|
@@ -1533,7 +1533,7 @@ func (this *StatisticCompanyMergerController) CompanyContractPercentageListV2()
|
|
|
contractDataType := this.GetString("ContractDataType")
|
|
|
startDate := this.GetString("StartDate")
|
|
|
endDate := this.GetString("EndDate")
|
|
|
- initendDate := this.GetString("EndDate")
|
|
|
+ //initendDate := this.GetString("EndDate")
|
|
|
if startDate == "" || endDate == "" {
|
|
|
br.Msg = "开始时间或结束时间不能为空"
|
|
|
return
|
|
@@ -1563,24 +1563,6 @@ func (this *StatisticCompanyMergerController) CompanyContractPercentageListV2()
|
|
|
}
|
|
|
startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
|
|
|
- var conditionConfirm string
|
|
|
- var parsConfirm []interface{}
|
|
|
- conditionConfirm = ` AND company_ascribe_id != 9 `
|
|
|
- companyConfirmList, err := company.GetCompanyContractNoRenewedAscribeList(conditionConfirm, parsConfirm, 0, 0)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,GetCompanyNoRenewedAscribeList Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- var noRenewedcompanyContractIds []int //已经确定未续约的公司ID
|
|
|
- if len(companyConfirmList) == 0 {
|
|
|
- noRenewedcompanyContractIds = append(noRenewedcompanyContractIds, 0) // 给一个不存在的ID
|
|
|
- } else {
|
|
|
- for _, v := range companyConfirmList {
|
|
|
- noRenewedcompanyContractIds = append(noRenewedcompanyContractIds, v.CompanyContractId)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
|
|
@@ -1606,114 +1588,103 @@ func (this *StatisticCompanyMergerController) CompanyContractPercentageListV2()
|
|
|
var expireRenewalContractMoney int //到期合同数量
|
|
|
var dataTotal int //分页数据
|
|
|
|
|
|
- conditionRenewal := condition // 续约合同查询条件查询条件
|
|
|
- parsRenewal := pars
|
|
|
+ //conditionRenewal := condition // 续约合同查询条件查询条件
|
|
|
+ //parsRenewal := pars
|
|
|
//conditionRenewal += ` AND a.start_date >= ? AND a.start_date <= ? `
|
|
|
- conditionRenewal += ` AND a.end_date >= ? AND a.end_date <= ? `
|
|
|
- parsRenewal = append(parsRenewal, startDate, endDate)
|
|
|
- //conditionRenewal += ` AND a.rai_contract_type = ? `
|
|
|
- //parsRenewal = append(parsRenewal, "续约合同")
|
|
|
+ //conditionRenewal += ` AND a.end_date >= ? AND a.end_date <= ? `
|
|
|
+ //parsRenewal = append(parsRenewal, startDate, endDate)
|
|
|
+ ////conditionRenewal += ` AND a.rai_contract_type = ? `
|
|
|
+ ////parsRenewal = append(parsRenewal, "续约合同")
|
|
|
+ //
|
|
|
+ //conditionRenewal += ` AND a.company_ascribe_id > 0 AND a.company_ascribe_id !=9 ` // 已确认未续约
|
|
|
|
|
|
- conditionRenewal += ` AND a.company_contract_id IN (` + utils.GetOrmInReplace(len(noRenewedcompanyContractIds)) + `) ` // 已确认未续约
|
|
|
- parsRenewal = append(parsRenewal, noRenewedcompanyContractIds)
|
|
|
+ //totalRenewal, err := company.GetIncrementalRenewalCompanyProductMergeCount(conditionRenewal, parsRenewal)
|
|
|
+ //if err != nil {
|
|
|
+ // br.Msg = "获取失败"
|
|
|
+ // br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //
|
|
|
+ //totalMoneyRenewal, err := company.GetIncrementalRenewalCompanyProductMergeSumMoney(conditionRenewal, parsRenewal)
|
|
|
+ //if err != nil {
|
|
|
+ // br.Msg = "获取失败"
|
|
|
+ // br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //续约合同查询条件查询条件 end
|
|
|
|
|
|
- totalRenewal, err := company.GetIncrementalRenewalCompanyProductMergeCount(conditionRenewal, parsRenewal)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
+ //conditionRenewalEnd := condition // 今年结束的续约合同查询条件
|
|
|
+ //parsRenewalEnd := pars
|
|
|
+ //
|
|
|
+ ////startDateTime, _ := time.Parse(utils.FormatDate, endDate)
|
|
|
+ ////startDateTime = startDateTime.AddDate(-1, 0, 2) //合同开始时间,与查询的结束时间,之间相差的天数大于 365天。
|
|
|
+ ////fmt.Println("startDateTime", startDateTime)
|
|
|
+ //conditionRenewalEnd += ` AND a.end_date >= ? AND a.end_date <= ? `
|
|
|
+ //parsRenewalEnd = append(parsRenewalEnd, startDate, endDate)
|
|
|
+ //conditionRenewalEnd += ` AND a.rai_contract_type = ? `
|
|
|
+ //parsRenewalEnd = append(parsRenewalEnd, "续约合同")
|
|
|
+ //
|
|
|
+ //totalRenewalEnd, err := company.GetIncrementalRenewalCompanyProductMergeCount(conditionRenewalEnd, parsRenewalEnd)
|
|
|
+ //if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ // br.Msg = "获取失败"
|
|
|
+ // br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ ////return
|
|
|
+ //totalMoneyRenewalEnd, err := company.GetIncrementalRenewalCompanyProductMergeSumMoney(conditionRenewalEnd, parsRenewalEnd)
|
|
|
+ //if err != nil {
|
|
|
+ // br.Msg = "获取失败"
|
|
|
+ // br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ // return
|
|
|
+ //} // 今年结束的续约合同查询条件end
|
|
|
+ //
|
|
|
+ //conditionNew := condition // 新签合同查询条件
|
|
|
+ //parsNew := pars
|
|
|
+ //conditionNew += ` AND a.end_date >= ? AND a.end_date <= ? `
|
|
|
+ //parsNew = append(parsNew, startDate, endDate)
|
|
|
+ //conditionNew += ` AND a.rai_contract_type = ? `
|
|
|
+ //parsNew = append(parsNew, "新签合同")
|
|
|
+ //totalNew, err := company.GetIncrementalRenewalCompanyProductMergeCount(conditionNew, parsNew)
|
|
|
+ //if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ // br.Msg = "获取失败"
|
|
|
+ // br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //totalMoneyNew, err := company.GetIncrementalRenewalCompanyProductMergeSumMoney(conditionNew, parsNew)
|
|
|
+ //if err != nil {
|
|
|
+ // br.Msg = "获取失败"
|
|
|
+ // br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ // return
|
|
|
+ //} // 新签合同查询条件 end
|
|
|
|
|
|
- totalMoneyRenewal, err := company.GetIncrementalRenewalCompanyProductMergeSumMoney(conditionRenewal, parsRenewal)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- //续约合同查询条件查询条件 end
|
|
|
+ //fmt.Println("totalNew", totalNew)
|
|
|
+ //fmt.Println("totalRenewalEnd", totalRenewalEnd)
|
|
|
|
|
|
- conditionRenewalEnd := condition // 今年结束的续约合同查询条件
|
|
|
- parsRenewalEnd := pars
|
|
|
+ condition1 := condition
|
|
|
+ pars1 := pars
|
|
|
+ //condition1 += ` AND a.start_date >= ? AND a.start_date <= ? `
|
|
|
+ condition1 += ` AND a.end_date >= ? AND a.end_date <= ? `
|
|
|
+ pars1 = append(pars1, startDate, endDate)
|
|
|
+ //condition1 += ` AND a.rai_contract_type = ? `
|
|
|
+ //pars1 = append(pars1, "续约合同")
|
|
|
+ condition1 += ` AND a.company_ascribe_id > 0 AND a.company_ascribe_id !=9 ` // 已确认未续约
|
|
|
|
|
|
- startDateTime, _ := time.Parse(utils.FormatDate, endDate)
|
|
|
- startDateTime = startDateTime.AddDate(-1, 0, 2) //合同开始时间,与查询的结束时间,之间相差的天数大于 365天。
|
|
|
- //fmt.Println("startDateTime", startDateTime)
|
|
|
- conditionRenewalEnd += ` AND a.end_date >= ? AND a.end_date <= ? AND a.start_date < ? `
|
|
|
- parsRenewalEnd = append(parsRenewalEnd, startDate, endDate, startDateTime)
|
|
|
- conditionRenewalEnd += ` AND a.rai_contract_type = ? `
|
|
|
- parsRenewalEnd = append(parsRenewalEnd, "续约合同")
|
|
|
- totalRenewalEnd, err := company.GetIncrementalRenewalCompanyProductMergeCount(conditionRenewalEnd, parsRenewalEnd)
|
|
|
+ totalNo, err := company.GetIncrementalRenewalCompanyProductMergeCount(condition1, pars1)
|
|
|
if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- //return
|
|
|
- totalMoneyRenewalEnd, err := company.GetIncrementalRenewalCompanyProductMergeSumMoney(conditionRenewalEnd, parsRenewalEnd)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- } // 今年结束的续约合同查询条件end
|
|
|
-
|
|
|
- conditionNew := condition // 新签合同查询条件
|
|
|
- parsNew := pars
|
|
|
- conditionNew += ` AND a.end_date >= ? AND a.end_date <= ? AND a.start_date < ? `
|
|
|
- parsNew = append(parsNew, startDate, endDate, startDateTime)
|
|
|
- conditionNew += ` AND a.rai_contract_type = ? `
|
|
|
- parsNew = append(parsNew, "新签合同")
|
|
|
- totalNew, err := company.GetIncrementalRenewalCompanyProductMergeCount(conditionNew, parsNew)
|
|
|
+ totalMoney, err := company.GetIncrementalRenewalCompanyProductMergeSumMoney(condition1, pars1)
|
|
|
if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- totalMoneyNew, err := company.GetIncrementalRenewalCompanyProductMergeSumMoney(conditionNew, parsNew)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- } // 新签合同查询条件 end
|
|
|
-
|
|
|
- //分子或者分母为零的时候,不做计算
|
|
|
- if totalRenewal == 0 || totalNew+totalRenewalEnd == 0 {
|
|
|
- renewalRateMoney = "0%"
|
|
|
- renewalRateTotal = "0%"
|
|
|
- } else {
|
|
|
- renewalRateMoney = fmt.Sprint(utils.SubFloatToString(float64(totalMoneyRenewal)/float64(totalMoneyNew+totalMoneyRenewalEnd)*100, 2), "%")
|
|
|
- renewalRateTotal = fmt.Sprint(utils.SubFloatToString(float64(totalRenewal)/float64(totalNew+totalRenewalEnd)*100, 2), "%")
|
|
|
- }
|
|
|
- renewalRateTotalContent = fmt.Sprint(int(totalMoneyRenewal), "/", int(totalMoneyNew+totalMoneyRenewalEnd))
|
|
|
- renewalRateMoneyContent = fmt.Sprint(totalRenewal, "份/", totalNew+totalRenewalEnd, "份")
|
|
|
-
|
|
|
- if contractDataType == "续约合同" {
|
|
|
- condition1 := condition
|
|
|
- pars1 := pars
|
|
|
- //condition1 += ` AND a.start_date >= ? AND a.start_date <= ? `
|
|
|
- condition1 += ` AND a.end_date >= ? AND a.end_date <= ? `
|
|
|
- pars1 = append(pars1, startDate, endDate)
|
|
|
- //condition1 += ` AND a.rai_contract_type = ? `
|
|
|
- //pars1 = append(pars1, "续约合同")
|
|
|
-
|
|
|
- condition1 += ` AND a.company_contract_id IN (` + utils.GetOrmInReplace(len(noRenewedcompanyContractIds)) + `) ` // 已确认未续约
|
|
|
- pars1 = append(pars1, noRenewedcompanyContractIds)
|
|
|
-
|
|
|
- total, err := company.GetIncrementalRenewalCompanyProductMergeCount(condition1, pars1)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- totalMoney, err := company.GetIncrementalRenewalCompanyProductMergeSumMoney(condition1, pars1)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- renewalContractTotal = total
|
|
|
- renewalContractMoney = int(totalMoney)
|
|
|
|
|
|
+ renewalContractTotal = totalNo
|
|
|
+ renewalContractMoney = int(totalMoney)
|
|
|
+ if contractDataType == "续约合同" || contractDataType == "确认不续约合同" {
|
|
|
//列表页数据
|
|
|
tmpList, err := models.GetIncrementalCompanyMergeListEnd(condition1, pars1, startSize, pageSize)
|
|
|
if err != nil {
|
|
@@ -1722,53 +1693,63 @@ func (this *StatisticCompanyMergerController) CompanyContractPercentageListV2()
|
|
|
return
|
|
|
}
|
|
|
list = tmpList
|
|
|
- dataTotal = total
|
|
|
+ dataTotal = totalNo
|
|
|
}
|
|
|
|
|
|
- if contractDataType == "到期合同" {
|
|
|
- condition1 := condition
|
|
|
- pars1 := pars
|
|
|
+ conditionEnd1 := condition
|
|
|
+ parsEnd1 := pars
|
|
|
|
|
|
- //判断结束时间是否晚于当前时间,如果晚于当前时间,那么就把当前时间作为截止时间。并且当前这天的到期的合同,不查询
|
|
|
- endDateTime, _ := time.Parse(utils.FormatDate, initendDate)
|
|
|
- if endDateTime.After(time.Now()) {
|
|
|
- endDate = time.Now().Format(utils.FormatDate)
|
|
|
- condition1 += ` AND a.end_date >= ? AND a.end_date < ? `
|
|
|
- } else {
|
|
|
- condition1 += ` AND a.end_date >= ? AND a.end_date <= ? `
|
|
|
- }
|
|
|
+ //判断结束时间是否晚于当前时间,如果晚于当前时间,那么就把当前时间作为截止时间。并且当前这天的到期的合同,不查询
|
|
|
+ //endDateTime, _ := time.Parse(utils.FormatDate, initendDate)
|
|
|
+ //if endDateTime.After(time.Now()) {
|
|
|
+ // endDate = time.Now().Format(utils.FormatDate)
|
|
|
+ // condition1 += ` AND a.end_date >= ? AND a.end_date < ? `
|
|
|
+ //} else {
|
|
|
+ // condition1 += ` AND a.end_date >= ? AND a.end_date <= ? `
|
|
|
+ //}
|
|
|
|
|
|
- //condition1 += ` AND a.end_date >= ? AND a.end_date <= ? `
|
|
|
- pars1 = append(pars1, startDate, endDate)
|
|
|
+ conditionEnd1 += ` AND a.end_date >= ? AND a.end_date <= ? AND a.company_ascribe_id !=9 `
|
|
|
+ parsEnd1 = append(parsEnd1, startDate, endDate)
|
|
|
|
|
|
- condition1 += ` AND a.start_date < ? `
|
|
|
- pars1 = append(pars1, startDateTime)
|
|
|
-
|
|
|
- total, err := company.GetIncrementalRenewalCompanyProductMergeCount(condition1, pars1)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- totalMoney, err := company.GetIncrementalRenewalCompanyProductMergeSumMoney(condition1, pars1)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- expireRenewalContractTotal = total
|
|
|
- expireRenewalContractMoney = int(totalMoney)
|
|
|
+ //condition1 += ` AND a.start_date < ? `
|
|
|
+ //pars1 = append(pars1, startDateTime)
|
|
|
|
|
|
+ totalEnd, err := company.GetIncrementalRenewalCompanyProductMergeCount(conditionEnd1, parsEnd1)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ totalMoneyEnd, err := company.GetIncrementalRenewalCompanyProductMergeSumMoney(conditionEnd1, parsEnd1)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ expireRenewalContractTotal = totalEnd
|
|
|
+ expireRenewalContractMoney = int(totalMoney)
|
|
|
+ if contractDataType == "到期合同" {
|
|
|
//列表页数据
|
|
|
- tmpList, err := models.GetIncrementalCompanyMergeListEnd(condition1, pars1, startSize, pageSize)
|
|
|
+ tmpList, err := models.GetIncrementalCompanyMergeListEnd(conditionEnd1, parsEnd1, startSize, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
list = tmpList
|
|
|
- dataTotal = total
|
|
|
+ dataTotal = totalEnd
|
|
|
+ }
|
|
|
+
|
|
|
+ //分子或者分母为零的时候,不做计算
|
|
|
+ if totalNo == 0 || totalEnd == 0 {
|
|
|
+ renewalRateMoney = "0%"
|
|
|
+ renewalRateTotal = "0%"
|
|
|
+ } else {
|
|
|
+ renewalRateMoney = fmt.Sprint(utils.SubFloatToString(float64(totalMoney)/float64(totalMoneyEnd)*100, 2), "%")
|
|
|
+ renewalRateTotal = fmt.Sprint(utils.SubFloatToString(float64(totalNo)/float64(totalEnd)*100, 2), "%")
|
|
|
}
|
|
|
+ renewalRateTotalContent = fmt.Sprint(int(totalMoney), "/", int(totalMoneyEnd))
|
|
|
+ renewalRateMoneyContent = fmt.Sprint(totalNo, "份/", totalEnd, "份")
|
|
|
|
|
|
listLen := len(list)
|
|
|
if listLen == 0 {
|
|
@@ -1841,3 +1822,22 @@ func init213() {
|
|
|
fmt.Println(err)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+func init323() {
|
|
|
+ var conditionConfirm string
|
|
|
+ var parsConfirm []interface{}
|
|
|
+
|
|
|
+ companyConfirmList, err := company.GetCompanyContractNoRenewedAscribeList(conditionConfirm, parsConfirm, 0, 0)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range companyConfirmList {
|
|
|
+ err = company.UpdateCompanyContractCompanyAscribeId(v.CompanyAscribeId, v.CompanyContractId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|