|
@@ -548,83 +548,167 @@ func (in *ParticipateStatistics) ProjectDetails(entUserIdArr []string, detailReq
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// todo 查询条件待重新处理 现在不对
|
|
|
+// todo 查询条件待验证
|
|
|
+//
|
|
|
+// 这个查询只用查出符合筛选条件的项目id 以及该项目对应的stage
|
|
|
+// 查询类型 0空搜索 全连接 1查左边 连右表查stage 2只查右表 3内连接
|
|
|
func GetDetailQuery(isAdmin bool, personArrStr string, req *bxcore.ProjectDetailsReq, queryType int) (string, string) {
|
|
|
- joinStr := ""
|
|
|
- switch queryType {
|
|
|
- case 0:
|
|
|
- joinStr = " union "
|
|
|
- case 1:
|
|
|
- joinStr = " left join "
|
|
|
- case 2:
|
|
|
- joinStr = " right join "
|
|
|
- case 3:
|
|
|
- joinStr = " inner join "
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- query := []string{}
|
|
|
- if isAdmin {
|
|
|
- //是管理员
|
|
|
- query = append(query, fmt.Sprintf(" a.ent_user_id in (%s) ", personArrStr))
|
|
|
- } else {
|
|
|
- //不是管理员
|
|
|
- query = append(query, fmt.Sprintf(" a.position_id = %s ", personArrStr))
|
|
|
- }
|
|
|
- //// 标讯推送时间
|
|
|
- if req.StartTime == 0 && req.EndTime == 0 && req.BidUpdateStartTime == "" && req.BidUpdateEndTime == "" {
|
|
|
+ if queryType == 0 {
|
|
|
+ // 空搜索调整
|
|
|
+ query1, query2, query3 := []string{}, []string{}, []string{}
|
|
|
//没有传时间,默认时间处理
|
|
|
var start = time.Now().AddDate(0, 0, -30)
|
|
|
- query = append(query, fmt.Sprintf(" a.ymd >= %s ", start.Format("20060102")))
|
|
|
- }
|
|
|
- if req.StartTime != 0 {
|
|
|
- query = append(query, fmt.Sprintf(" a.ymd >= %d ", req.StartTime))
|
|
|
- }
|
|
|
- if req.EndTime != 0 {
|
|
|
- query = append(query, fmt.Sprintf(" a.ymd <= %d ", req.EndTime))
|
|
|
- }
|
|
|
- // 标讯/项目来源
|
|
|
- if len(req.Source) > 0 {
|
|
|
- sourceValue := ""
|
|
|
- for i := 0; i < len(req.Source); i++ {
|
|
|
- sourceValue += fmt.Sprint(req.Source[i]) + ","
|
|
|
+ query1 = append(query1, fmt.Sprintf(" a.ymd >= %s ", start.Format("20060102")))
|
|
|
+ query2 = append(query2, fmt.Sprintf(" b.update_date >= %s ", start.Format("20060102")))
|
|
|
+ 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_id) ", personArrStr))
|
|
|
+ query3 = append(query3, fmt.Sprintf(" FIND_IN_SET('%s', b.ent_user_id) ", personArrStr))
|
|
|
+ } else {
|
|
|
+ //不是管理员
|
|
|
+ query1 = append(query1, fmt.Sprintf(" a.position_id = %s ", personArrStr))
|
|
|
+ query2 = append(query2, fmt.Sprintf(" FIND_IN_SET('%s', b.position_id) ", personArrStr))
|
|
|
+ query3 = append(query3, fmt.Sprintf(" FIND_IN_SET('%s', b.position_id) ", personArrStr))
|
|
|
}
|
|
|
- sourceValue = sourceValue[:len(sourceValue)-1]
|
|
|
- query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', a.source)", sourceValue))
|
|
|
- }
|
|
|
- // 投标类型 投标方式;1:直接投标 2:渠道投标',
|
|
|
- if req.BidWay != 0 {
|
|
|
- query = append(query, fmt.Sprintf("a.bid_way = %d", req.BidWay))
|
|
|
- }
|
|
|
- //参标状态:-1全部,0未参标、1已参标
|
|
|
- if req.IsParticipate != -1 {
|
|
|
- query = append(query, fmt.Sprintf("a.isparticipate = %d", req.IsParticipate))
|
|
|
- }
|
|
|
- // 参标状态更新时间
|
|
|
- if req.BidUpdateStartTime != "" {
|
|
|
- query = append(query, fmt.Sprintf("b.update_date > %s", req.BidUpdateStartTime))
|
|
|
- }
|
|
|
- if req.BidUpdateEndTime != "" {
|
|
|
- query = append(query, fmt.Sprintf("b.update_date > %s", req.BidUpdateStartTime))
|
|
|
+ q := `SELECT A.project_id, B.stage,B.is_participate,B.bid_way
|
|
|
+ FROM
|
|
|
+ (SELECT DISTINCT(project_id)
|
|
|
+ FROM
|
|
|
+ (SELECT project_id FROM participate_push_statistics
|
|
|
+ WHERE %s UNION
|
|
|
+ SELECT project_id
|
|
|
+ FROM participate_stage_statistics
|
|
|
+ WHERE %s)
|
|
|
+ LIMIT %d , %d) A
|
|
|
+ LEFT JOIN
|
|
|
+ participate_stage_statistics B ON A.project_id = B.project_id where %s`
|
|
|
+ q2 := "select distinct(position_id) from participate_push_statistics where %s union select project_id from participate_stage_statistics where %s "
|
|
|
+ q1Str := strings.Join(query1, " and ")
|
|
|
+ q2Str := strings.Join(query2, " and ")
|
|
|
+ q3Str := strings.Join(query3, " and ")
|
|
|
+ return fmt.Sprintf(q, q1Str, q2Str, q3Str), fmt.Sprintf(q2, q1Str, q2Str)
|
|
|
+ }
|
|
|
+ var q, qCount string
|
|
|
+ query := []string{}
|
|
|
+ if queryType == 1 {
|
|
|
+ if isAdmin {
|
|
|
+ //是管理员
|
|
|
+ query = append(query, fmt.Sprintf(" a.ent_user_id in (%s) ", personArrStr))
|
|
|
+ query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', b.ent_user_id)", personArrStr))
|
|
|
+ } else {
|
|
|
+ //不是管理员
|
|
|
+ query = append(query, fmt.Sprintf(" a.position_id = %s ", personArrStr))
|
|
|
+ query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', b.position_id)", personArrStr))
|
|
|
+ }
|
|
|
+ if req.StartTime == 0 && req.EndTime == 0 {
|
|
|
+ //没有传时间,默认时间处理
|
|
|
+ var start = time.Now().AddDate(0, 0, -30)
|
|
|
+ query = append(query, fmt.Sprintf(" a.ymd >= %s ", start.Format("20060102")))
|
|
|
+ }
|
|
|
+ if req.StartTime != 0 {
|
|
|
+ query = append(query, fmt.Sprintf(" a.ymd >= %d ", req.StartTime))
|
|
|
+ }
|
|
|
+ if req.EndTime != 0 {
|
|
|
+ query = append(query, fmt.Sprintf(" a.ymd <= %d ", req.EndTime))
|
|
|
+ }
|
|
|
+ // 标讯/项目来源
|
|
|
+ if len(req.Source) > 0 {
|
|
|
+ sourceValue := ""
|
|
|
+ for i := 0; i < len(req.Source); i++ {
|
|
|
+ sourceValue += fmt.Sprint(req.Source[i]) + ","
|
|
|
+ }
|
|
|
+ sourceValue = sourceValue[:len(sourceValue)-1]
|
|
|
+ query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', a.source)", sourceValue))
|
|
|
+ }
|
|
|
+ // 投标类型 投标方式;1:直接投标 2:渠道投标',
|
|
|
+ if req.BidWay != 0 {
|
|
|
+ query = append(query, fmt.Sprintf("a.bid_way = %d", req.BidWay))
|
|
|
+ }
|
|
|
+ //参标状态:-1全部,0未参标、1已参标
|
|
|
+ if req.IsParticipate != -1 {
|
|
|
+ query = append(query, fmt.Sprintf("a.isparticipate = %d", req.IsParticipate))
|
|
|
+ }
|
|
|
+ q = "select distinct(a.project_id),b.stage,b.is_participate,b.bid_way from participate_push_statistics a left join participate_stage_statistics b on(b.project_id=a.project_id ) %s"
|
|
|
+ qCount = "select count(distinct(a.project_id),b.stage) from participate_push_statistics a left join participate_stage_statistics b on(b.project_id=a.project_id ) %s"
|
|
|
+ } else if queryType == 2 {
|
|
|
+ if isAdmin {
|
|
|
+ //是管理员
|
|
|
+ query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', b.ent_user_id) ", personArrStr))
|
|
|
+ } else {
|
|
|
+ //不是管理员
|
|
|
+ query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', b.position_id)", personArrStr))
|
|
|
+ }
|
|
|
+ // 参标状态更新时间
|
|
|
+ if req.BidUpdateStartTime != "" {
|
|
|
+ query = append(query, fmt.Sprintf("b.update_date > %s", req.BidUpdateStartTime))
|
|
|
+ }
|
|
|
+ if req.BidUpdateEndTime != "" {
|
|
|
+ query = append(query, fmt.Sprintf("b.update_date > %s", req.BidUpdateStartTime))
|
|
|
+ }
|
|
|
+ if req.BidWay != 0 {
|
|
|
+ query = append(query, fmt.Sprintf("b.bid_way = %d", req.BidWay))
|
|
|
+ }
|
|
|
+ //参标状态:-1全部,0未参标、1已参标
|
|
|
+ if req.IsParticipate == 1 {
|
|
|
+ query = append(query, fmt.Sprintf("b.isparticipate = %d", req.IsParticipate))
|
|
|
+ }
|
|
|
+ q = "select distinct(b.project_id),b.stage,b.is_participate,b.bid_way from participate_stage_statistics b %s"
|
|
|
+ qCount = "select count(distinct(b.project_id),b.stage) from participate_stage_statistics b %s"
|
|
|
+ } else {
|
|
|
+ if isAdmin {
|
|
|
+ //是管理员
|
|
|
+ query = append(query, fmt.Sprintf(" a.ent_user_id in (%s) ", personArrStr))
|
|
|
+ query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', b.ent_user_id) ", personArrStr))
|
|
|
+ } else {
|
|
|
+ //不是管理员
|
|
|
+ query = append(query, fmt.Sprintf(" a.position_id = %s ", personArrStr))
|
|
|
+ query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', b.position_id)", personArrStr))
|
|
|
+ }
|
|
|
+ if req.StartTime != 0 {
|
|
|
+ query = append(query, fmt.Sprintf(" a.ymd >= %d ", req.StartTime))
|
|
|
+ }
|
|
|
+ if req.EndTime != 0 {
|
|
|
+ query = append(query, fmt.Sprintf(" a.ymd <= %d ", req.EndTime))
|
|
|
+ }
|
|
|
+ // 标讯/项目来源
|
|
|
+ if len(req.Source) > 0 {
|
|
|
+ sourceValue := ""
|
|
|
+ for i := 0; i < len(req.Source); i++ {
|
|
|
+ sourceValue += fmt.Sprint(req.Source[i]) + ","
|
|
|
+ }
|
|
|
+ sourceValue = sourceValue[:len(sourceValue)-1]
|
|
|
+ query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', a.source)", sourceValue))
|
|
|
+ }
|
|
|
+ //参标状态:-1全部,0未参标、1已参标
|
|
|
+ if req.IsParticipate != -1 {
|
|
|
+ query = append(query, fmt.Sprintf("a.isparticipate = %d", req.IsParticipate))
|
|
|
+ }
|
|
|
+ // 投标类型 投标方式;1:直接投标 2:渠道投标',
|
|
|
+ if req.BidWay != 0 {
|
|
|
+ query = append(query, fmt.Sprintf("a.bid_way = %d", req.BidWay))
|
|
|
+ }
|
|
|
+ // 参标状态更新时间
|
|
|
+ if req.BidUpdateStartTime != "" {
|
|
|
+ query = append(query, fmt.Sprintf("b.update_date > %s", req.BidUpdateStartTime))
|
|
|
+ }
|
|
|
+ if req.BidUpdateEndTime != "" {
|
|
|
+ query = append(query, fmt.Sprintf("b.update_date > %s", req.BidUpdateStartTime))
|
|
|
+ }
|
|
|
+ q = "select distinct(a.project_id),b.stage,b.is_participate,b.bid_way from participate_push_statistics a inner join participate_stage_statistics b on(b.project_id=a.project_id ) %s"
|
|
|
+ qCount = "select count(distinct(a.project_id),b.stage) from participate_push_statistics a inner join participate_stage_statistics b on(b.project_id=a.project_id ) %s"
|
|
|
}
|
|
|
-
|
|
|
- q := "select distinct(a.project_id),b.stage from participate_push_statistics a ," + joinStr + " participate_stage_statistics b on(b.project_id=a.project_id and b.ent_id=a.ent_id) %s"
|
|
|
- q2 := "select count(distinct(a.project_id),b.stage) from participate_push_statistics a ," + joinStr + " participate_stage_statistics b on(b.project_id=a.project_id and b.ent_id=a.ent_id) %s"
|
|
|
if len(query) > 0 {
|
|
|
- q += " where "
|
|
|
- q2 += " where "
|
|
|
q = fmt.Sprintf(q, strings.Join(query, " and "))
|
|
|
- q2 = fmt.Sprintf(q2, strings.Join(query, " and "))
|
|
|
-
|
|
|
+ qCount = fmt.Sprintf(qCount, strings.Join(query, " and "))
|
|
|
}
|
|
|
-
|
|
|
// 处理分页
|
|
|
if req.PageNum == 0 && req.PageSize == 0 {
|
|
|
req.PageNum = 1
|
|
|
req.PageNum = 50
|
|
|
}
|
|
|
q = fmt.Sprintf("%s limit %d,%d", q, (req.PageNum-1)*req.PageSize, req.PageSize)
|
|
|
- return q, q2
|
|
|
+ return q, qCount
|
|
|
}
|
|
|
|
|
|
type PushInfoStruct struct {
|
|
@@ -682,9 +766,8 @@ func ProjectDetailHandle(dataList []map[string]interface{}, entId int64) []*bxco
|
|
|
tmp.ViewDate = pushInfo_.VisitDate
|
|
|
tmp.IsDistribute = int64(pushInfo_.IsDistribute)
|
|
|
tmp.DisDate = pushInfo_.DisDate
|
|
|
- }
|
|
|
- // todo 投标状态和投标类型需要加字段
|
|
|
- // 处理阶段勾选信息和参标、终止参标信息 todo 参标和终止参标不放在stage
|
|
|
+ } //
|
|
|
+ // 处理阶段勾选信息和参标、终止参标信息 todo
|
|
|
stageInfo := map[string]string{}
|
|
|
err := json.Unmarshal(dataList[i]["stage"].([]byte), &stageInfo)
|
|
|
if err != nil {
|
|
@@ -694,6 +777,8 @@ func ProjectDetailHandle(dataList []map[string]interface{}, entId int64) []*bxco
|
|
|
delete(stageInfo, "终止参标")
|
|
|
tmp.Stage = stageInfo
|
|
|
}
|
|
|
+ tmp.IsParticipate = common.Int64All(dataList[i]["is_participate"])
|
|
|
+ tmp.BidWay = common.Int64All(dataList[i]["bid_way"])
|
|
|
results = append(results, &tmp)
|
|
|
}
|
|
|
return results
|
|
@@ -706,17 +791,22 @@ func getNewPushInfo(projectIds []string, entId int) *[]map[string]interface{} {
|
|
|
return IC.BaseMysql.SelectBySql(query)
|
|
|
}
|
|
|
|
|
|
-// GetQueryType 查询类型 0空搜索 1左连接 2右连接 3内连接
|
|
|
+// GetQueryType 查询类型 0空搜索 全连接 1查左边 连右表查stage 2只查右表 3内连接
|
|
|
func GetQueryType(in *bxcore.ProjectDetailsReq) int {
|
|
|
// TODO 调整
|
|
|
if in.BidUpdateStartTime == "" && in.BidUpdateEndTime == "" && in.StartTime == 0 && in.EndTime == 0 && in.IsParticipate == -1 && in.BidWay == 0 && len(in.Source) == 0 {
|
|
|
return 0
|
|
|
}
|
|
|
- if (in.BidUpdateStartTime != "" || in.BidUpdateEndTime != "") && (in.StartTime != 0 || in.EndTime != 0 || in.IsParticipate != -1 || in.BidWay != 0 || len(in.Source) != 0) {
|
|
|
- return 3
|
|
|
+ if in.IsParticipate == 0 {
|
|
|
+ // 未参标只筛选推送表 右表条件无效
|
|
|
+ return 1
|
|
|
+ }
|
|
|
+ if (in.StartTime != 0 || in.EndTime != 0 || len(in.Source) > 0) && (in.BidUpdateStartTime == "" && in.BidUpdateEndTime == "" && in.IsParticipate != 1) {
|
|
|
+ return 1
|
|
|
}
|
|
|
- if (in.BidUpdateStartTime != "" || in.BidUpdateEndTime != "") && (in.StartTime == 0 && in.EndTime == 0 && in.IsParticipate == -1 && in.BidWay == 0 && len(in.Source) == 0) {
|
|
|
+ if (in.StartTime == 0 && in.EndTime == 0 && len(in.Source) == 0) && (in.BidUpdateStartTime != "" || in.BidUpdateEndTime == "" || in.IsParticipate == 1 || in.BidWay != 0) {
|
|
|
return 2
|
|
|
+
|
|
|
}
|
|
|
- return 1
|
|
|
+ return 3
|
|
|
}
|