fuwencai 1 жил өмнө
parent
commit
784c3a64db

+ 29 - 21
jyBXCore/rpc/service/participateStatistics.go

@@ -53,8 +53,7 @@ func (in *ParticipateStatistics) ProjectStatistics(entUserIdArr []string, startT
 	query := QueryHandle(isAdmin, startTime, endTime, personArrStr, []int64{}, bidWay)
 	//订阅推送数处理
 	//推送数据查询
-	// 调整为时间倒序  处理投标阶段的时候  只取最新的一条的数据
-	dataList := IC.BaseMysql.SelectBySql(fmt.Sprintf("select  * from  participate_project_statistics where %s order  by ymd desc ", strings.Join(query, "and ")))
+	dataList := IC.BaseMysql.SelectBySql(fmt.Sprintf("select  * from  participate_project_statistics where %s order  by ymd  ", strings.Join(query, "and ")))
 	if users != nil && len(*users) > 0 {
 		result = ProjectHandle(dataList, users, isAdmin, bidWay)
 	}
@@ -206,6 +205,7 @@ type ProjectData struct {
 	EndNumb                map[string]interface{} //终止数量
 	participateProjectNumb map[string]interface{} // 参标数量
 	Stage                  map[string]map[string]interface{}
+	StageStr               map[string]string // 字符串处理
 }
 
 func PushHandle(data *[]map[string]interface{}, users *[]map[string]interface{}, isAdmin bool, isManager bool) []*bxcore.PushStatisticsData {
@@ -345,7 +345,22 @@ func ProjectHandle(data *[]map[string]interface{}, users *[]map[string]interface
 		}
 	}
 	if data != nil && len(*data) > 0 {
-		// existProject 已经存在的项目 项目id_用户id
+		for _, v := range *data {
+			userId := int64(0)
+			if isAdmin {
+				userId = common.Int64All(v["ent_user_id"])
+			} else {
+				userId = common.Int64All(v["position_id"])
+			}
+			project_id := common.InterfaceToStr(common.InterfaceToStr(v["project_id"]))
+			if (*result)[userId] != nil {
+				stage := common.ObjToString(v["bid_stage"])
+				if _, ok := (*result)[userId].StageStr[project_id]; !ok {
+					(*result)[userId].StageStr = map[string]string{}
+				}
+				(*result)[userId].StageStr[project_id] = stage
+			}
+		}
 		existProject := map[string]struct{}{}
 		for _, v := range *data {
 			userId := int64(0)
@@ -362,23 +377,6 @@ func ProjectHandle(data *[]map[string]interface{}, users *[]map[string]interface
 				if common.Int64All(v["isbid"]) > 0 {
 					(*result)[userId].BidNumb = DataHanle((*result)[userId].BidNumb, project_id)
 				}
-				//终止参保统计
-				if common.Int64All(v["isend"]) != 0 {
-					(*result)[userId].EndNumb = DataHanle((*result)[userId].EndNumb, project_id)
-				}
-				/* p408 调整:
-				这里是因为participate_project_statistics 表的数据是多条的
-				统计各阶段数据的时候和中标总数的时候只以最新的为准
-				但是统计各阶段勾选数量时 重复统计后续删除不好处理 所以这里调整为
-				查询的时候根据时间倒序,同一个项目只统计第一条就可以了 每个项目第一条就是当前阶段内最新的
-				其他的直接跳过 不用重复统计后续再删除
-				*/
-				existKey := fmt.Sprintf("%d_%s", userId, project_id)
-				if _, ok := existProject[existKey]; !ok {
-					existProject[existKey] = struct{}{}
-				} else {
-					continue
-				}
 				//直接投标数
 				if common.Int64All(v["bid_way"]) > 0 {
 					if common.Int64All(v["bid_way"]) == 2 {
@@ -413,11 +411,21 @@ func ProjectHandle(data *[]map[string]interface{}, users *[]map[string]interface
 						delete((*result)[userId].DirectWinNumb, project_id)
 					}
 				}
+				//终止参保统计
+				if common.Int64All(v["isend"]) != 0 {
+					(*result)[userId].EndNumb = DataHanle((*result)[userId].EndNumb, project_id)
+				}
 				if bidWay == 0 {
 					// 投标类型为全部时不需要统计勾选的数量
 					continue
 				}
-				// 阶段勾选数量统计 只统计第一条
+				existKey := fmt.Sprintf("%d_%s", userId, project_id)
+				if _, ok := existProject[existKey]; !ok {
+					existProject[existKey] = struct{}{}
+				} else {
+					continue
+				}
+				// 阶段勾选数量统计
 				stage := common.ObjToString(v["bid_stage"])
 				if stage != "" {
 					stageSplit := strings.Split(stage, ",")