ソースを参照

wip:查询条件调整

fuwencai 1 年間 前
コミット
7edb516761

+ 1 - 0
jyBXCore/rpc/bxcore.proto

@@ -508,6 +508,7 @@ message ProjectDetailData {
   string   IsDistribute = 3 [json_name = "isDistribute"];// 手动分发状态  1已分发
   string  DisDate =4 [json_name = "disDate"]; // 分发时间
   string  ViewDate = 5 [json_name = "visitDate"];//最早浏览时间
+  string  id =7 [json_name = "id"];// 项目id
   map<string, StageValue> stage =6 [json_name = "stage"];// 阶段相关信息  <阶段名称,勾选时间>
 }
 message DetailData{

+ 46 - 20
jyBXCore/rpc/service/participateStatistics.go

@@ -353,7 +353,8 @@ func ProjectHandle(data *[]map[string]interface{}, users *[]map[string]interface
 		k := common.Int64All(strings.Split(v.PersonName, "_")[1])
 		tmpStage := map[string]int64{}
 		for stageK, stageV := range v.Stage {
-			tmpStage[stageK] = int64(len(stageV))
+			stage_ := fmt.Sprintf("%s(阶段)", stageK)
+			tmpStage[stage_] = int64(len(stageV))
 		}
 		projectStatisticsList[k] = &bxcore.ProjectStatisticsData{
 			PersonName:             personName,
@@ -517,12 +518,11 @@ func QueryHandle(isAdmin bool, startTime, endTime int64, personArrStr string, so
 		query = append(query, fmt.Sprintf(" ymd <= %d ", endTime))
 	}
 	if len(source) > 0 {
-		sourceValue := ""
+		sourceArr := []string{}
 		for i := 0; i < len(source); i++ {
-			sourceValue += fmt.Sprint(source[i]) + ","
+			sourceArr = append(sourceArr, fmt.Sprintf(" FIND_IN_SET('%s', a.source)", source[i]))
 		}
-		sourceValue = sourceValue[:len(sourceValue)-1]
-		query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', a.source)", sourceValue))
+		query = append(query, fmt.Sprintf(" (%s) ", strings.Join(sourceArr, " or ")))
 	}
 	if bidWay != 0 {
 		query = append(query, fmt.Sprintf("bid_way = %d", bidWay))
@@ -571,13 +571,29 @@ func GetDetailQuery(isAdmin bool, personArrStr string, req *bxcore.ProjectDetail
 		if isAdmin {
 			//是管理员
 			query1 = append(query1, fmt.Sprintf(" a.ent_user_id in (%s) ", personArrStr))
-			query2 = append(query2, fmt.Sprintf(" FIND_IN_SET('%s', b.ent_user_ids) ", personArrStr))
-			query3 = append(query3, fmt.Sprintf(" FIND_IN_SET('%s', b.ent_user_ids) ", personArrStr))
+			personArr := []string{}
+			personArrStrSplit := strings.Split(personArrStr, ",")
+			for i := 0; i < len(personArrStrSplit); i++ {
+				personArr = append(personArr, fmt.Sprintf(" FIND_IN_SET('%s', b.ent_user_ids)", personArrStrSplit[i]))
+			}
+			if len(personArr) > 0 {
+				personStr := strings.Join(personArr, " or ")
+				query2 = append(query2, fmt.Sprintf(" (%s)"))
+				query3 = append(query3, fmt.Sprintf("  (%s)", personStr))
+			}
 		} else {
 			//不是管理员
 			query1 = append(query1, fmt.Sprintf(" a.position_id = %s ", personArrStr))
-			query2 = append(query2, fmt.Sprintf(" FIND_IN_SET('%s', b.position_ids) ", personArrStr))
-			query3 = append(query3, fmt.Sprintf(" FIND_IN_SET('%s', b.position_ids) ", personArrStr))
+			personArr := []string{}
+			personArrStrSplit := strings.Split(personArrStr, ",")
+			for i := 0; i < len(personArrStrSplit); i++ {
+				personArr = append(personArr, fmt.Sprintf(" FIND_IN_SET('%s', b.position_ids)", personArrStrSplit[i]))
+			}
+			if len(personArr) > 0 {
+				personStr := strings.Join(personArr, " or ")
+				query2 = append(query2, fmt.Sprintf(" (%s)"))
+				query3 = append(query3, fmt.Sprintf("  (%s)", personStr))
+			}
 		}
 		q := `SELECT A.project_id, B.stage
 				FROM
@@ -629,16 +645,16 @@ func GetDetailQuery(isAdmin bool, personArrStr string, req *bxcore.ProjectDetail
 		}
 		// 标讯/项目来源
 		if len(req.Source) > 0 {
-			sourceValue := ""
+			sourceArr := []string{}
 			for i := 0; i < len(req.Source); i++ {
 				if req.Source[i] == 0 {
-					sourceValue += "1,2,"
+					sourceArr = append(sourceArr, fmt.Sprintf(" FIND_IN_SET('%d', a.source)", 1))
+					sourceArr = append(sourceArr, fmt.Sprintf(" FIND_IN_SET('%d', a.source)", 2))
 				} else {
-					sourceValue += fmt.Sprint(req.Source[i]) + ","
+					sourceArr = append(sourceArr, fmt.Sprintf(" FIND_IN_SET('%s', a.source)", sourceArr[i]))
 				}
 			}
-			sourceValue = sourceValue[:len(sourceValue)-1]
-			query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', a.source)", sourceValue))
+			query = append(query, fmt.Sprintf(" (%s) ", strings.Join(sourceArr, " or ")))
 		}
 		// 投标类型 投标方式;1:直接投标 2:渠道投标',
 		if req.BidWay != 0 {
@@ -653,7 +669,16 @@ func GetDetailQuery(isAdmin bool, personArrStr string, req *bxcore.ProjectDetail
 	} else if queryType == 2 {
 		if isAdmin {
 			//是管理员
-			query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', b.ent_user_ids) ", personArrStr))
+			personArr := []string{}
+			personArrStrSplit := strings.Split(personArrStr, ",")
+			for i := 0; i < len(personArrStrSplit); i++ {
+				personArr = append(personArr, fmt.Sprintf(" FIND_IN_SET('%s', b.ent_user_ids)", personArrStrSplit[i]))
+			}
+			if len(personArr) > 0 {
+				personStr := strings.Join(personArr, " or ")
+				query = append(query, personStr)
+
+			}
 		} else {
 			//不是管理员
 			query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', b.position_ids)", personArrStr))
@@ -697,16 +722,16 @@ func GetDetailQuery(isAdmin bool, personArrStr string, req *bxcore.ProjectDetail
 			query = append(query, fmt.Sprintf(" a.ymd <= %d ", req.EndTime))
 		}
 		if len(req.Source) > 0 {
-			sourceValue := ""
+			sourceArr := []string{}
 			for i := 0; i < len(req.Source); i++ {
 				if req.Source[i] == 0 {
-					sourceValue += "1,2," // 选择未分发时  相当于选择个人订阅和企业自动分发
+					sourceArr = append(sourceArr, fmt.Sprintf(" FIND_IN_SET('%d', a.source)", 1))
+					sourceArr = append(sourceArr, fmt.Sprintf(" FIND_IN_SET('%d', a.source)", 2))
 				} else {
-					sourceValue += fmt.Sprint(req.Source[i]) + ","
+					sourceArr = append(sourceArr, fmt.Sprintf(" FIND_IN_SET('%s', a.source)", sourceArr[i]))
 				}
 			}
-			sourceValue = sourceValue[:len(sourceValue)-1]
-			query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', a.source)", sourceValue))
+			query = append(query, fmt.Sprintf(" (%s) ", strings.Join(sourceArr, " or ")))
 		}
 		//参标状态:-1全部,0未参标、1已参标
 		if req.IsParticipate != -1 {
@@ -816,6 +841,7 @@ func ProjectDetailHandle(dataList []map[string]interface{}, entId int64, positio
 				}
 			}
 		}
+		tmp.Id = encrypt.EncodeArticleId2ByCheck(projectId)
 		results = append(results, &tmp)
 	}
 	return results

+ 11 - 2
jyBXCore/rpc/type/bxcore/bxcore.pb.go

@@ -4715,6 +4715,7 @@ type ProjectDetailData struct {
 	IsDistribute string                 `protobuf:"bytes,3,opt,name=IsDistribute,json=isDistribute,proto3" json:"IsDistribute,omitempty"`                                                         // 手动分发状态  1已分发
 	DisDate      string                 `protobuf:"bytes,4,opt,name=DisDate,json=disDate,proto3" json:"DisDate,omitempty"`                                                                        // 分发时间
 	ViewDate     string                 `protobuf:"bytes,5,opt,name=ViewDate,json=visitDate,proto3" json:"ViewDate,omitempty"`                                                                    //最早浏览时间
+	Id           string                 `protobuf:"bytes,7,opt,name=id,proto3" json:"id,omitempty"`                                                                                               // 项目id
 	Stage        map[string]*StageValue `protobuf:"bytes,6,rep,name=stage,proto3" json:"stage,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // 阶段相关信息  <阶段名称,勾选时间>
 }
 
@@ -4785,6 +4786,13 @@ func (x *ProjectDetailData) GetViewDate() string {
 	return ""
 }
 
+func (x *ProjectDetailData) GetId() string {
+	if x != nil {
+		return x.Id
+	}
+	return ""
+}
+
 func (x *ProjectDetailData) GetStage() map[string]*StageValue {
 	if x != nil {
 		return x.Stage
@@ -6386,7 +6394,7 @@ var file_bxcore_proto_rawDesc = []byte{
 	0x53, 0x74, 0x61, 0x67, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x74,
 	0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x53, 0x74, 0x61, 0x74,
 	0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
-	0x52, 0x04, 0x44, 0x61, 0x74, 0x65, 0x22, 0xb2, 0x02, 0x0a, 0x11, 0x50, 0x72, 0x6f, 0x6a, 0x65,
+	0x52, 0x04, 0x44, 0x61, 0x74, 0x65, 0x22, 0xc2, 0x02, 0x0a, 0x11, 0x50, 0x72, 0x6f, 0x6a, 0x65,
 	0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x12, 0x20, 0x0a, 0x0b,
 	0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
 	0x09, 0x52, 0x0b, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16,
@@ -6397,7 +6405,8 @@ var file_bxcore_proto_rawDesc = []byte{
 	0x73, 0x44, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x69, 0x73,
 	0x44, 0x61, 0x74, 0x65, 0x12, 0x1b, 0x0a, 0x08, 0x56, 0x69, 0x65, 0x77, 0x44, 0x61, 0x74, 0x65,
 	0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x76, 0x69, 0x73, 0x69, 0x74, 0x44, 0x61, 0x74,
-	0x65, 0x12, 0x3a, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b,
+	0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69,
+	0x64, 0x12, 0x3a, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b,
 	0x32, 0x24, 0x2e, 0x62, 0x78, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63,
 	0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x74, 0x61, 0x67,
 	0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x73, 0x74, 0x61, 0x67, 0x65, 0x1a, 0x4c, 0x0a,