xingzai 10 месяцев назад
Родитель
Сommit
90d3fbf37a
2 измененных файлов с 153 добавлено и 73 удалено
  1. 143 73
      controllers/cygx/enter_score.go
  2. 10 0
      models/cygx/enter_score.go

+ 143 - 73
controllers/cygx/enter_score.go

@@ -802,6 +802,67 @@ func (this *EnterScoreController) EnterScoreScoreOverview() {
 		return
 	}
 
+	var companyCondition string
+	var companypars []interface{}
+	companyCondition += ` AND b.product_name = ? `
+	companypars = append(companypars, "权益")
+	companyCondition += ` AND b.status = ? `
+	companypars = append(companypars, "永续")
+
+	if city != "" {
+		//传过来多个城市的时候的筛选
+		citySlice := strings.Split(city, ",")
+		city = strings.Join(citySlice, "','")
+		city = "'" + city + "'"
+		companyCondition += ` AND a.city  IN  (` + city + `) `
+	}
+
+	//权益申请销售只能看到自己名下的客户的申请
+	companyIds, err := cygxService.GetAdminLookUserCompanyIdsBySelf(AdminUser)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,GetAdminLookUserCompanyIds Err:" + err.Error()
+		return
+	}
+
+	var newcompanyIds []int
+	var searchcompanyIds []int
+	//如果机构搜索做了限制 ,那么公司列表的纵向展示也做限制
+	if keyWord != "" {
+		listSearchCompany, err := cygx.GetCygxEnterScoreListBySecuritiesFirmsName(keyWord)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		if len(listSearchCompany) > 0 {
+			for _, v := range listSearchCompany {
+				searchcompanyIds = append(searchcompanyIds, v.CompanyId)
+			}
+		}
+		if len(companyIds) > 0 {
+			newcompanyIds = utils.IntersectInt(searchcompanyIds, companyIds) //获取销售可见权限,与搜索权限的交集
+		} else {
+			newcompanyIds = searchcompanyIds
+		}
+	} else {
+		newcompanyIds = companyIds
+	}
+
+	newlencompanyIds := len(newcompanyIds)
+
+	if newlencompanyIds > 0 {
+		companyCondition += ` AND a.company_id IN (` + utils.GetOrmInReplace(newlencompanyIds) + `)`
+		companypars = append(companypars, newcompanyIds)
+	}
+
+	companyList, err := company.GetCompanyIdListByproductName(companyCondition, companypars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
 	var condition string
 	var pars []interface{}
 	if endDate != "" {
@@ -842,58 +903,7 @@ func (this *EnterScoreController) EnterScoreScoreOverview() {
 				mapenterScoreTypeCompanyIds[v.CompanyId] = true //记录按照百分比录入的公司
 			}
 		}
-		var companyCondition string
-		var companypars []interface{}
-		companyCondition += ` AND b.product_name = ? `
-		companypars = append(companypars, "权益")
-		companyCondition += ` AND b.status = ? `
-		companypars = append(companypars, "永续")
-
-		//权益申请销售只能看到自己名下的客户的申请
-		companyIds, err := cygxService.GetAdminLookUserCompanyIdsBySelf(AdminUser)
-		if err != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取失败,GetAdminLookUserCompanyIds Err:" + err.Error()
-			return
-		}
-		var newcompanyIds []int
-		lencompanyIds := len(companyIds)
-		var searchcompanyIds []int
-		//如果机构搜索做了限制 ,那么公司列表的纵向展示也做限制
-		if keyWord != "" {
-			for _, v := range list {
-				searchcompanyIds = append(searchcompanyIds, v.CompanyId)
-			}
-			if lencompanyIds > 0 {
-				newcompanyIds = utils.IntersectInt(searchcompanyIds, companyIds) //获取销售可见权限,与搜索权限的交集
-			} else {
-				newcompanyIds = searchcompanyIds
-			}
-		} else {
-			newcompanyIds = companyIds
-		}
-
-		newlencompanyIds := len(newcompanyIds)
-
-		if newlencompanyIds > 0 {
-			companyCondition += ` AND a.company_id IN (` + utils.GetOrmInReplace(newlencompanyIds) + `)`
-			companypars = append(companypars, newcompanyIds)
-		}
 
-		if city != "" {
-			//传过来多个城市的时候的筛选
-			citySlice := strings.Split(city, ",")
-			city = strings.Join(citySlice, "','")
-			city = "'" + city + "'"
-			companyCondition += ` AND a.city  IN  (` + city + `) `
-		}
-
-		companyList, err := company.GetCompanyIdListByproductName(companyCondition, companypars)
-		if err != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取失败,Err:" + err.Error()
-			return
-		}
 		//fmt.Println(enterScoreIds)
 		listResearcher, err := cygx.GeCygxEnterScoreResearcherListByIds(enterScoreIds, newcompanyIds) //获取所有的研究员
 		if err != nil {
@@ -927,15 +937,21 @@ func (this *EnterScoreController) EnterScoreScoreOverview() {
 		mapResearcherProportionText := make(map[string][]string)
 		for _, vC := range companyList {
 			for _, vR := range researcherArr {
-
 				var proportionText string
 				if mapResearcherProportion[fmt.Sprint(vR, "_", vC.CompanyId)] != "" {
 					proportionText = mapResearcherProportion[fmt.Sprint(vR, "_", vC.CompanyId)]
 				} else {
-					proportionText = "0"
+					if mapenterScoreProportionTotal[vC.CompanyId] > 0 {
+						proportionText = "0"
+					} else {
+						proportionText = ""
+					}
 				}
+				//0与空的展示逻辑处理
 				if mapenterScoreTypeCompanyIds[vC.CompanyId] || enterScoreType == 2 { //按照百分比展示的拼接 %
-					proportionText += "%"
+					if proportionText != "" {
+						proportionText += "%"
+					}
 				}
 				mapResearcherProportionText[vR] = append(mapResearcherProportionText[vR], proportionText)
 			}
@@ -994,11 +1010,19 @@ func (this *EnterScoreController) EnterScoreScoreOverview() {
 				if mapPermissionProportion[fmt.Sprint(vP, "_", vC.CompanyId)] != "" {
 					proportionText = mapPermissionProportion[fmt.Sprint(vP, "_", vC.CompanyId)]
 				} else {
-					proportionText = "0"
+					if mapenterScoreProportionTotal[vC.CompanyId] > 0 {
+						proportionText = "0"
+					} else {
+						proportionText = ""
+					}
 				}
+
 				if mapenterScoreTypeCompanyIds[vC.CompanyId] || enterScoreType == 2 { //按照百分比展示的拼接 %
-					proportionText += "%"
+					if proportionText != "" {
+						proportionText += "%"
+					}
 				}
+
 				mapPermissionProportionText[vP] = append(mapPermissionProportionText[vP], proportionText)
 			}
 		}
@@ -1043,10 +1067,16 @@ func (this *EnterScoreController) EnterScoreScoreOverview() {
 				if mapGroupProportion[fmt.Sprint(vP, "_", vC.CompanyId)] != "" {
 					proportionText = mapGroupProportion[fmt.Sprint(vP, "_", vC.CompanyId)]
 				} else {
-					proportionText = "0"
+					if mapenterScoreProportionTotal[vC.CompanyId] > 0 {
+						proportionText = "0"
+					} else {
+						proportionText = ""
+					}
 				}
 				if mapenterScoreTypeCompanyIds[vC.CompanyId] || enterScoreType == 2 { //按照百分比展示的拼接 %
-					proportionText += "%"
+					if proportionText != "" {
+						proportionText += "%"
+					}
 				}
 				mapGroupProportionText[vP] = append(mapGroupProportionText[vP], proportionText)
 			}
@@ -1060,26 +1090,34 @@ func (this *EnterScoreController) EnterScoreScoreOverview() {
 			itemsG = append(itemsG, itemG)
 		}
 
-		var rankingText []string             //排名
-		var securitiesFirmsNameText []string //券商名称
-		var proportionTotalText []string     //占比
+		var proportionTotalText []string      //总计
+		var rankingText []string              //排名
+		var securitiesFirmsNameText []string  //券商名称
+		var mergeProportionTotalText []string //占比
 
 		for _, vC := range companyList {
-			var ranking, securitiesFirmsName, proportionTotal string
+			var ranking, securitiesFirmsName, proportionTotal, mergeProportionTotal string
 			item := mapenterScore[vC.CompanyId]
 			if item != nil {
 				ranking = item.Ranking
 				securitiesFirmsName = item.SecuritiesFirmsName
-				proportionTotal = fmt.Sprint(item.MergeProportion)
-			}
-			if mapenterScoreTypeCompanyIds[vC.CompanyId] { //按照百分比展示的拼接 %
-				proportionTotal += "%"
+				proportionTotal = fmt.Sprint(item.ProportionTotal)
+				mergeProportionTotal = fmt.Sprint(item.MergeProportion)
 			}
+			//if mapenterScoreTypeCompanyIds[vC.CompanyId] { //按照百分比展示的拼接 %
+			mergeProportionTotal += "%"
+			//}
 			rankingText = append(rankingText, ranking)
 			securitiesFirmsNameText = append(securitiesFirmsNameText, securitiesFirmsName)
 			proportionTotalText = append(proportionTotalText, proportionTotal)
+			mergeProportionTotalText = append(mergeProportionTotalText, mergeProportionTotal)
 		}
 
+		itemproportionTotal := new(cygx.EnterScoreGroupListResp) //券商名称结构体
+		itemproportionTotal.GroupName = "合计"
+		itemproportionTotal.ProportionListText = proportionTotalText
+		itemsG = append(itemsG, itemproportionTotal)
+
 		itemranking := new(cygx.EnterScoreGroupListResp) //排名结构体
 		itemranking.GroupName = "排名"
 		itemranking.ProportionListText = rankingText
@@ -1090,18 +1128,50 @@ func (this *EnterScoreController) EnterScoreScoreOverview() {
 		itemsecuritiesFirmsName.ProportionListText = securitiesFirmsNameText
 		itemsG = append(itemsG, itemsecuritiesFirmsName)
 
-		itemproportionTotal := new(cygx.EnterScoreGroupListResp) //券商名称结构体
-		itemproportionTotal.GroupName = "占比"
-		itemproportionTotal.ProportionListText = proportionTotalText
-		itemsG = append(itemsG, itemproportionTotal)
+		itemmergeProportionTotal := new(cygx.EnterScoreGroupListResp) //券商名称结构体
+		itemmergeProportionTotal.GroupName = "占比"
+		itemmergeProportionTotal.ProportionListText = mergeProportionTotalText
+		itemsG = append(itemsG, itemmergeProportionTotal)
 
 		resp.ListPermission = itemsP
 		resp.ListGroup = itemsG
-		resp.ListCompany = companyList
+
 	} else {
-		resp.ListPermission = make([]*cygx.EnterScorePermissionListResp, 0)
-		resp.ListGroup = make([]*cygx.EnterScoreGroupListResp, 0)
+
+		listPermission, err := cygx.GetChartPermissionAll()
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+			return
+		}
+
+		permissionNameArr := []string{"医药", "消费", "科技", "智造", "策略", "固收", "宏观组", "建材组", "有色组", "能化组"}
+		for _, v := range listPermission {
+			if !utils.InArrayByStr(permissionNameArr, v.PermissionName) {
+				continue
+			}
+			item := new(cygx.EnterScorePermissionListResp)
+			item.ChartPermissionName = v.PermissionName
+			item.ProportionListText = make([]string, 0)
+			item.List = make([]*cygx.EnterScoreRealNameListResp, 0)
+			resp.ListPermission = append(resp.ListPermission, item)
+		}
+
+		groupNameArr := []string{"销售分", "专题分", "专家分", "云图大拓", "艾摩宏观", "合计", "排名", "券商名称", "占比"}
+		for _, v := range groupNameArr {
+			item := new(cygx.EnterScoreGroupListResp)
+			item.GroupName = v
+			item.ProportionListText = make([]string, 0)
+			resp.ListGroup = append(resp.ListGroup, item)
+		}
+		//resp.ListPermission = make([]*cygx.EnterScorePermissionListResp, 0)
+		//resp.ListGroup = make([]*cygx.EnterScoreGroupListResp, 0)
+	}
+
+	if len(companyList) == 0 {
 		resp.ListCompany = make([]*company.CompanyNameAndId, 0)
+	} else {
+		resp.ListCompany = companyList
 	}
 	//导出excel
 	if isExport {

+ 10 - 0
models/cygx/enter_score.go

@@ -370,6 +370,16 @@ func GetCygxEnterScoreList(condition string, pars []interface{}, startSize, page
 	return
 }
 
+// 根据券商名称获取列表
+func GetCygxEnterScoreListBySecuritiesFirmsName(keyWord string) (items []*CygxEnterScore, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT company_id  FROM cygx_enter_score  WHERE 1 = 1  `
+	sql += ` AND securities_firms_name LIKE '%` + keyWord + `%' `
+	sql += ` GROUP  BY company_id `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 // 获取数量
 func GetCygxEnterScoreCount(condition string, pars []interface{}) (count int, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")