|
@@ -2,11 +2,16 @@ package service
|
|
|
|
|
|
import (
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
|
+ "app.yhyue.com/moapp/jybase/date"
|
|
|
"app.yhyue.com/moapp/jybase/encrypt"
|
|
|
+ "app.yhyue.com/moapp/jybase/redis"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"jyBXCore/rpc/bxcore"
|
|
|
IC "jyBXCore/rpc/init"
|
|
|
+ "jyBXCore/rpc/model/es"
|
|
|
+ "log"
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
@@ -24,34 +29,102 @@ type ParticipateStatistics struct {
|
|
|
EntUserId int64
|
|
|
}
|
|
|
|
|
|
-func (in *ParticipateStatistics) PushStatistics(entUserIdArr []string, startTime, endTime int64) (result []*bxcore.PushStatisticsData) {
|
|
|
+func (in *ParticipateStatistics) PushStatistics(entUserIdArr []string, startTime, endTime int64, source []int64) (result []*bxcore.PushStatisticsData) {
|
|
|
//判断是企业、部门还是个人
|
|
|
- isAdmin, personArrStr, users := in.PersonHandle(entUserIdArr)
|
|
|
+ isAdmin, personArrStr, users, userInfo := in.PersonHandle(entUserIdArr)
|
|
|
//时间处理
|
|
|
- query := QueryHandle(isAdmin, startTime, endTime, personArrStr)
|
|
|
+ query := QueryHandle(isAdmin, startTime, endTime, personArrStr, source, 0)
|
|
|
//推送数据查询
|
|
|
dataList := IC.BaseMysql.SelectBySql(fmt.Sprintf("select * from participate_push_statistics where %s order by ymd", strings.Join(query, " and ")))
|
|
|
+ isManage := false
|
|
|
if users != nil && len(*users) > 0 {
|
|
|
- result = PushHandle(dataList, users, isAdmin)
|
|
|
+ if userInfo != nil {
|
|
|
+ isManage = userInfo.Role_admin_department || userInfo.Role_admin_system
|
|
|
+ }
|
|
|
+
|
|
|
+ result = PushHandle(dataList, users, isAdmin, isManage)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func (in *ParticipateStatistics) ProjectStatistics(entUserIdArr []string, startTime, endTime int64) (result []*bxcore.ProjectStatisticsData) {
|
|
|
+func (in *ParticipateStatistics) ProjectStatistics(entUserIdArr []string, startTime, endTime, bidWay int64) (result []*bxcore.ProjectStatisticsData) {
|
|
|
//判断是企业、部门还是个人
|
|
|
- isAdmin, personArrStr, users := in.PersonHandle(entUserIdArr)
|
|
|
- query := QueryHandle(isAdmin, startTime, endTime, personArrStr)
|
|
|
+ isAdmin, personArrStr, users, _ := in.PersonHandle(entUserIdArr)
|
|
|
+ query := QueryHandle(isAdmin, startTime, endTime, personArrStr, []int64{}, bidWay)
|
|
|
//订阅推送数处理
|
|
|
//推送数据查询
|
|
|
- dataList := IC.BaseMysql.SelectBySql(fmt.Sprintf("select * from participate_project_statistics where %s order by ymd", strings.Join(query, "and ")))
|
|
|
+ // 调整为时间倒序 处理投标阶段的时候 只取最新的一条的数据
|
|
|
+ dataList := IC.BaseMysql.SelectBySql(fmt.Sprintf("select * from participate_project_statistics where %s order by ymd desc ", strings.Join(query, "and ")))
|
|
|
if users != nil && len(*users) > 0 {
|
|
|
- result = ProjectHandle(dataList, users, isAdmin)
|
|
|
+ result = ProjectHandle(dataList, users, isAdmin, bidWay)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func (in *ParticipateStatistics) PersonHandle(entUserIdArr []string) (isAdmin bool, idStr string, users *[]map[string]interface{}) {
|
|
|
- userEnt := EntInfo(common.IntAll(in.EntId), common.IntAll(in.EntUserId))
|
|
|
+var (
|
|
|
+ SourceMap = map[string]string{
|
|
|
+ "1": "个人订阅",
|
|
|
+ "2": "企业自动分发",
|
|
|
+ "3": "企业手动分发",
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
+// GetSourceItem 获取标讯项目来源筛选项
|
|
|
+func (in *ParticipateStatistics) GetSourceItem(entId, positionId int) (result []*bxcore.SourceItem) {
|
|
|
+ redisKey := "sourceItem%s_%d"
|
|
|
+ query := "select distinct substring_index(source,',',-1) as `source` from participate_push_statistics where "
|
|
|
+ // 个人用户
|
|
|
+ if entId == 0 {
|
|
|
+ // 查职位id
|
|
|
+ query += fmt.Sprintf(" position_id =%d", positionId)
|
|
|
+ redisKey = fmt.Sprintf(redisKey, "personal", positionId)
|
|
|
+ } else {
|
|
|
+ // 企业用户 用企业id查
|
|
|
+ query += fmt.Sprintf(" ent_id =%d", entId)
|
|
|
+ redisKey = fmt.Sprintf(redisKey, "ent", entId)
|
|
|
+ }
|
|
|
+ if data, err := redis.GetBytes("other", redisKey); err == nil && data != nil {
|
|
|
+ err := json.Unmarshal(*data, &result)
|
|
|
+ if err == nil {
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ log.Println("序列化失败", redisKey, err)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rs := IC.BaseMysql.SelectBySql(query)
|
|
|
+ if rs == nil || len(*rs) == 0 {
|
|
|
+ //emtpy := make([]*bxcore.SourceItem, 0)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for i := 0; i < len(*rs); i++ {
|
|
|
+ value := common.ObjToString((*rs)[i]["source"])
|
|
|
+ if value == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if name, ok := SourceMap[value]; ok {
|
|
|
+ value_, err := strconv.Atoi(value)
|
|
|
+ if err == nil {
|
|
|
+ result = append(result, &bxcore.SourceItem{
|
|
|
+ Name: name,
|
|
|
+ Value: int64(value_),
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ log.Println("转换失败:", err, value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if len(result) > 0 {
|
|
|
+ // 存缓存
|
|
|
+ rsByte, _ := json.Marshal(result)
|
|
|
+ redis.PutBytes("other", redisKey, &rsByte, 60*60*2)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 注意:该方法返回值中第一个虽然名字叫IsAdmin 但是实际是指是否是企业版 用于区分企业和个人版 不能用于是否是管理员
|
|
|
+func (in *ParticipateStatistics) PersonHandle(entUserIdArr []string) (isAdmin bool, idStr string, users *[]map[string]interface{}, userEnt *CurrentUser) {
|
|
|
+ userEnt = EntInfo(common.IntAll(in.EntId), common.IntAll(in.EntUserId))
|
|
|
if len(entUserIdArr) > 0 {
|
|
|
//查询所选人的部门以及人员信息
|
|
|
users = GetUser(entUserIdArr)
|
|
@@ -102,22 +175,32 @@ type PushData struct {
|
|
|
BidNumb map[string]interface{}
|
|
|
WinNumb map[string]interface{}
|
|
|
BrowseNumb map[string]interface{}
|
|
|
+ SourceMap map[string]sourceStruct
|
|
|
+}
|
|
|
+type sourceStruct struct {
|
|
|
+ PushNumb map[string]interface{}
|
|
|
+ ParticipateNumb map[string]interface{}
|
|
|
+ BidNumb map[string]interface{}
|
|
|
+ WinNumb map[string]interface{}
|
|
|
+ BrowseNumb map[string]interface{}
|
|
|
}
|
|
|
type ProjectData struct {
|
|
|
- PersonName string
|
|
|
- DepartmentName string
|
|
|
- entUserId string
|
|
|
- BidNumb map[string]interface{} //投标数量
|
|
|
- DirectBidNumb map[string]interface{} //直接投标数
|
|
|
- ChannelBidNumb map[string]interface{} //渠道投标数
|
|
|
- WinNumb map[string]interface{}
|
|
|
- DirectWinNumb map[string]interface{} //直接中标数
|
|
|
- ChannelWinNumb map[string]interface{} //渠道中标数
|
|
|
- NotBidNumber map[string]interface{} //未中标数量
|
|
|
- EndNumb map[string]interface{} //终止数量
|
|
|
+ PersonName string
|
|
|
+ DepartmentName string
|
|
|
+ entUserId string
|
|
|
+ BidNumb map[string]interface{} //投标数量
|
|
|
+ DirectBidNumb map[string]interface{} //直接投标数
|
|
|
+ ChannelBidNumb map[string]interface{} //渠道投标数
|
|
|
+ WinNumb map[string]interface{}
|
|
|
+ DirectWinNumb map[string]interface{} //直接中标数
|
|
|
+ ChannelWinNumb map[string]interface{} //渠道中标数
|
|
|
+ NotBidNumber map[string]interface{} //未中标数量
|
|
|
+ EndNumb map[string]interface{} //终止数量
|
|
|
+ participateProjectNumb map[string]interface{} // 参标数量
|
|
|
+ Stage map[string]map[string]interface{}
|
|
|
}
|
|
|
|
|
|
-func PushHandle(data *[]map[string]interface{}, users *[]map[string]interface{}, isAdmin bool) []*bxcore.PushStatisticsData {
|
|
|
+func PushHandle(data *[]map[string]interface{}, users *[]map[string]interface{}, isAdmin bool, isManager bool) []*bxcore.PushStatisticsData {
|
|
|
result := &map[int64]*PushData{}
|
|
|
for k, v := range *users {
|
|
|
(*result)[common.Int64All(v["id"])] = &PushData{
|
|
@@ -159,27 +242,92 @@ func PushHandle(data *[]map[string]interface{}, users *[]map[string]interface{},
|
|
|
delete((*result)[userId].WinNumb, project_id)
|
|
|
}
|
|
|
}
|
|
|
+ // 如果是个人处理 按照source分开统计
|
|
|
+ if !isManager && common.InterfaceToStr(common.InterfaceToStr(v["source"])) != "" {
|
|
|
+ splitSource := strings.Split(common.InterfaceToStr(common.InterfaceToStr(v["source"])), ",")
|
|
|
+ for i := 0; i < len(splitSource); i++ {
|
|
|
+ //
|
|
|
+ if (*result)[userId].SourceMap == nil {
|
|
|
+ (*result)[userId].SourceMap = map[string]sourceStruct{}
|
|
|
+ }
|
|
|
+ if _, ok := (*result)[userId].SourceMap[splitSource[i]]; !ok {
|
|
|
+ (*result)[userId].SourceMap[splitSource[i]] = sourceStruct{}
|
|
|
+ }
|
|
|
+ tmp := (*result)[userId].SourceMap[splitSource[i]]
|
|
|
+ //浏览总数处理处理
|
|
|
+ if common.Int64All(v["isvisit"]) > 0 {
|
|
|
+ tmp.BrowseNumb = DataHanle(tmp.BrowseNumb, project_id)
|
|
|
+ }
|
|
|
+ //推送总数处理
|
|
|
+ tmp.PushNumb = DataHanle(tmp.PushNumb, project_id)
|
|
|
+ //参标总数处理
|
|
|
+ if common.Int64All(v["isparticipate"]) > 0 {
|
|
|
+ tmp.ParticipateNumb = DataHanle(tmp.ParticipateNumb, project_id)
|
|
|
+ }
|
|
|
+ //投标总数处理
|
|
|
+ if common.Int64All(v["isbid"]) > 0 {
|
|
|
+ tmp.BidNumb = DataHanle(tmp.BidNumb, project_id)
|
|
|
+ }
|
|
|
+ //中标总数处理
|
|
|
+ if common.Int64All(v["win_status"]) != 0 {
|
|
|
+ win_status := common.Int64All(v["win_status"])
|
|
|
+ if win_status == 1 {
|
|
|
+ tmp.WinNumb = DataHanle(tmp.WinNumb, project_id)
|
|
|
+ } else {
|
|
|
+ delete(tmp.WinNumb, project_id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ (*result)[userId].SourceMap[splitSource[i]] = tmp
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- pushStatisticsList := make([]*bxcore.PushStatisticsData, len(*result))
|
|
|
- for _, v := range *result {
|
|
|
- personName := strings.Split(v.PersonName, "_")[0]
|
|
|
- k := common.Int64All(strings.Split(v.PersonName, "_")[1])
|
|
|
- pushStatisticsList[k] = &bxcore.PushStatisticsData{
|
|
|
- PersonName: personName,
|
|
|
- DepartmentName: v.DepartmentName,
|
|
|
- EntUserId: encrypt.SE.Encode2Hex(v.entUserId),
|
|
|
- PushNumb: common.Int64All(len(v.PushNumb)),
|
|
|
- ParticipateNumb: common.Int64All(len(v.ParticipateNumb)),
|
|
|
- BidNumb: common.Int64All(len(v.BidNumb)),
|
|
|
- WinNumb: common.Int64All(len(v.WinNumb)),
|
|
|
- BrowseNumb: common.Int64All(len(v.BrowseNumb)),
|
|
|
+ pushStatisticsList := []*bxcore.PushStatisticsData{}
|
|
|
+ if !isManager {
|
|
|
+ for _, v := range *result {
|
|
|
+ for sourceK, sourceV := range v.SourceMap {
|
|
|
+ personName := strings.Split(v.PersonName, "_")[0]
|
|
|
+ pushStatisticsList = append(pushStatisticsList, &bxcore.PushStatisticsData{
|
|
|
+ PersonName: personName,
|
|
|
+ DepartmentName: v.DepartmentName,
|
|
|
+ EntUserId: encrypt.SE.Encode2Hex(v.entUserId),
|
|
|
+ ParticipateNumb: int64(len(sourceV.ParticipateNumb)),
|
|
|
+ BrowseNumb: int64(len(sourceV.BrowseNumb)),
|
|
|
+ BidNumb: int64(len(sourceV.BidNumb)),
|
|
|
+ WinNumb: int64(len(sourceV.WinNumb)),
|
|
|
+ PushNumb: int64(len(sourceV.PushNumb)),
|
|
|
+ Source: common.InterfaceToStr(SourceMap[sourceK]),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ pushStatisticsList = make([]*bxcore.PushStatisticsData, len(*result))
|
|
|
+ for _, v := range *result {
|
|
|
+ personName := strings.Split(v.PersonName, "_")[0]
|
|
|
+ k := common.Int64All(strings.Split(v.PersonName, "_")[1])
|
|
|
+ pushStatisticsList[k] = &bxcore.PushStatisticsData{
|
|
|
+ PersonName: personName,
|
|
|
+ DepartmentName: v.DepartmentName,
|
|
|
+ EntUserId: encrypt.SE.Encode2Hex(v.entUserId),
|
|
|
+ PushNumb: common.Int64All(len(v.PushNumb)),
|
|
|
+ ParticipateNumb: common.Int64All(len(v.ParticipateNumb)),
|
|
|
+ BidNumb: common.Int64All(len(v.BidNumb)),
|
|
|
+ WinNumb: common.Int64All(len(v.WinNumb)),
|
|
|
+ BrowseNumb: common.Int64All(len(v.BrowseNumb)),
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return pushStatisticsList
|
|
|
}
|
|
|
-func ProjectHandle(data *[]map[string]interface{}, users *[]map[string]interface{}, isAdmin bool) []*bxcore.ProjectStatisticsData {
|
|
|
+
|
|
|
+var stageNameArr = map[int64][]string{
|
|
|
+ 1: []string{"已报名", "投标决策", "编织投标文件", "递交投标文件", "中标公示", "签合同", "已结束"},
|
|
|
+ 2: []string{"已报名", "中标公示", "签合同", "已结束"},
|
|
|
+}
|
|
|
+
|
|
|
+func ProjectHandle(data *[]map[string]interface{}, users *[]map[string]interface{}, isAdmin bool, bidWay int64) []*bxcore.ProjectStatisticsData {
|
|
|
result := &map[int64]*ProjectData{}
|
|
|
for k, v := range *users {
|
|
|
(*result)[common.Int64All(v["id"])] = &ProjectData{
|
|
@@ -189,6 +337,8 @@ func ProjectHandle(data *[]map[string]interface{}, users *[]map[string]interface
|
|
|
}
|
|
|
}
|
|
|
if data != nil && len(*data) > 0 {
|
|
|
+ // existProject 已经存在的项目 项目id_用户id
|
|
|
+ existProject := map[string]struct{}{}
|
|
|
for _, v := range *data {
|
|
|
userId := int64(0)
|
|
|
if isAdmin {
|
|
@@ -198,10 +348,29 @@ func ProjectHandle(data *[]map[string]interface{}, users *[]map[string]interface
|
|
|
}
|
|
|
project_id := common.InterfaceToStr(common.InterfaceToStr(v["project_id"]))
|
|
|
if (*result)[userId] != nil {
|
|
|
+ // 参标数量
|
|
|
+ (*result)[userId].participateProjectNumb = DataHanle((*result)[userId].participateProjectNumb, project_id)
|
|
|
//投标数量
|
|
|
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 {
|
|
@@ -236,29 +405,65 @@ 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
|
|
|
+ }
|
|
|
+ // 阶段勾选数量统计 只统计第一条
|
|
|
+ stage := common.ObjToString(v["bid_stage"])
|
|
|
+ if stage != "" {
|
|
|
+ stageSplit := strings.Split(stage, ",")
|
|
|
+ if (*result)[userId].Stage == nil {
|
|
|
+ (*result)[userId].Stage = map[string]map[string]interface{}{}
|
|
|
+ }
|
|
|
+ for i := 0; i < len(stageSplit); i++ {
|
|
|
+ stageK := stageSplit[i]
|
|
|
+ (*result)[userId].Stage[stageK] = DataHanle((*result)[userId].Stage[stageSplit[i]], project_id)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
projectStatisticsList := make([]*bxcore.ProjectStatisticsData, len(*result))
|
|
|
+
|
|
|
+ stageName := []string{}
|
|
|
+ if bidWay != 0 {
|
|
|
+ stageName = stageNameArr[bidWay]
|
|
|
+ }
|
|
|
for _, v := range *result {
|
|
|
personName := strings.Split(v.PersonName, "_")[0]
|
|
|
k := common.Int64All(strings.Split(v.PersonName, "_")[1])
|
|
|
+ tmpStage := []*bxcore.StageValue{}
|
|
|
+ if bidWay != 0 && len(stageName) > 0 {
|
|
|
+ for i := 0; i < len(stageName); i++ {
|
|
|
+ name_ := fmt.Sprintf("%s(阶段)", stageName[i])
|
|
|
+ if stageV, ok := v.Stage[stageName[i]]; ok {
|
|
|
+ tmpStage = append(tmpStage, &bxcore.StageValue{
|
|
|
+ Name: name_,
|
|
|
+ Value: fmt.Sprintf("%d", len(stageV)),
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ tmpStage = append(tmpStage, &bxcore.StageValue{
|
|
|
+ Name: name_,
|
|
|
+ Value: "-",
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
projectStatisticsList[k] = &bxcore.ProjectStatisticsData{
|
|
|
- PersonName: personName,
|
|
|
- DepartmentName: v.DepartmentName,
|
|
|
- EntUserId: encrypt.SE.Encode2Hex(v.entUserId),
|
|
|
- BidNumb: common.Int64All(len(v.BidNumb)),
|
|
|
- DirectBidNumb: common.Int64All(len(v.DirectBidNumb)),
|
|
|
- ChannelBidNumb: common.Int64All(len(v.ChannelBidNumb)),
|
|
|
- WinNumb: common.Int64All(len(v.WinNumb)),
|
|
|
- DirectWinNumb: common.Int64All(len(v.DirectWinNumb)),
|
|
|
- ChannelWinNumb: common.Int64All(len(v.ChannelWinNumb)),
|
|
|
- NotBidNumber: common.Int64All(len(v.NotBidNumber)),
|
|
|
- EndNumb: common.Int64All(len(v.EndNumb)),
|
|
|
+ PersonName: personName,
|
|
|
+ DepartmentName: v.DepartmentName,
|
|
|
+ EntUserId: encrypt.SE.Encode2Hex(v.entUserId),
|
|
|
+ BidNumb: common.Int64All(len(v.BidNumb)),
|
|
|
+ DirectBidNumb: common.Int64All(len(v.DirectBidNumb)),
|
|
|
+ ChannelBidNumb: common.Int64All(len(v.ChannelBidNumb)),
|
|
|
+ WinNumb: common.Int64All(len(v.WinNumb)),
|
|
|
+ DirectWinNumb: common.Int64All(len(v.DirectWinNumb)),
|
|
|
+ ChannelWinNumb: common.Int64All(len(v.ChannelWinNumb)),
|
|
|
+ NotBidNumber: common.Int64All(len(v.NotBidNumber)),
|
|
|
+ EndNumb: common.Int64All(len(v.EndNumb)),
|
|
|
+ ParticipateProjectNumb: common.Int64All(len(v.participateProjectNumb)),
|
|
|
+ Stage: tmpStage,
|
|
|
}
|
|
|
}
|
|
|
return projectStatisticsList
|
|
@@ -385,7 +590,7 @@ func DataHanle(data map[string]interface{}, project_id string) map[string]interf
|
|
|
}
|
|
|
return data
|
|
|
}
|
|
|
-func QueryHandle(isAdmin bool, startTime, endTime int64, personArrStr string) []string {
|
|
|
+func QueryHandle(isAdmin bool, startTime, endTime int64, personArrStr string, source []int64, bidWay int64) []string {
|
|
|
//时间处理
|
|
|
query := []string{}
|
|
|
if isAdmin {
|
|
@@ -406,5 +611,398 @@ func QueryHandle(isAdmin bool, startTime, endTime int64, personArrStr string) []
|
|
|
if endTime != 0 {
|
|
|
query = append(query, fmt.Sprintf(" ymd <= %d ", endTime))
|
|
|
}
|
|
|
+ if len(source) > 0 {
|
|
|
+ sourceArr := []string{}
|
|
|
+ for i := 0; i < len(source); i++ {
|
|
|
+ sourceArr = append(sourceArr, fmt.Sprintf(" FIND_IN_SET('%d', source)", source[i]))
|
|
|
+ }
|
|
|
+ query = append(query, fmt.Sprintf(" (%s) ", strings.Join(sourceArr, " or ")))
|
|
|
+ }
|
|
|
+ if bidWay != 0 {
|
|
|
+ query = append(query, fmt.Sprintf("bid_way = %d", bidWay))
|
|
|
+ }
|
|
|
return query
|
|
|
}
|
|
|
+func (in *ParticipateStatistics) ProjectDetails(entUserIdArr []string, detailReq *bxcore.ProjectDetailsReq) (result bxcore.DetailData) {
|
|
|
+ //判断是企业、还是个人
|
|
|
+ isEnt, personArrStr, _, _ := in.PersonHandle(entUserIdArr)
|
|
|
+ queryType := GetQueryType(detailReq)
|
|
|
+ query, countQuery := GetDetailQuery(isEnt, personArrStr, detailReq, queryType)
|
|
|
+ totalCount := IC.BaseMysql.CountBySql(countQuery)
|
|
|
+ if totalCount <= 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 处理数据 这里只是筛选出项目id和阶段信息
|
|
|
+ dataList := IC.BaseMysql.SelectBySql(query)
|
|
|
+ if dataList == nil || len(*dataList) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 处理数据 补充项目名称、推送表字段 、格式化数据
|
|
|
+ rs := ProjectDetailHandle(*dataList, in.EntId, int(detailReq.PositionId), int(detailReq.PositionType))
|
|
|
+ result = bxcore.DetailData{
|
|
|
+ List: rs,
|
|
|
+ Total: totalCount,
|
|
|
+ }
|
|
|
+ // 处理数据
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 这个查询只用查出符合筛选条件的项目id 以及该项目对应的stage
|
|
|
+// 查询类型 0空搜索 全连接 1查左边 连右表查stage 2只查右表 3内连接
|
|
|
+func GetDetailQuery(isEnt bool, personArrStr string, req *bxcore.ProjectDetailsReq, queryType int) (string, string) {
|
|
|
+ // 处理分页
|
|
|
+ if req.PageNum == 0 || req.PageSize == 0 {
|
|
|
+ req.PageNum = 1
|
|
|
+ req.PageSize = 50
|
|
|
+ }
|
|
|
+ // 这是因为数据库中 0是未参标 1是已参标, 接收参数时和其他默认参数保持一致 0-全部 1 是未参标 2 是已参标
|
|
|
+ req.IsParticipate -= 1
|
|
|
+ if queryType == 0 {
|
|
|
+ // 空搜索调整
|
|
|
+ query1, query2 := []string{}, []string{}
|
|
|
+ query3 := ""
|
|
|
+ //没有传时间,默认时间处理
|
|
|
+ var start = time.Now().AddDate(0, 0, -10)
|
|
|
+ query1 = append(query1, fmt.Sprintf(" a.ymd >= %s ", start.Local().Format("20060102")))
|
|
|
+ query2 = append(query2, fmt.Sprintf(" b.update_date >= '%s' ", start.Local().Format(date.Date_Full_Layout)))
|
|
|
+ if isEnt {
|
|
|
+ //是企业版
|
|
|
+ query1 = append(query1, fmt.Sprintf(" a.ent_user_id in (%s) ", 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)", personStr))
|
|
|
+ }
|
|
|
+ query3 = fmt.Sprintf("b.ent_id='%d'", req.EntId) // 连接时右表的条件
|
|
|
+ } else {
|
|
|
+ //不是企业版
|
|
|
+ query1 = append(query1, fmt.Sprintf(" a.position_id = %s ", 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)", personStr))
|
|
|
+ }
|
|
|
+ query3 = fmt.Sprintf("b.position_ids='%d'", req.PositionId) // 连接时右表的条件
|
|
|
+ }
|
|
|
+ q := `SELECT A.project_id, B.stage
|
|
|
+ FROM
|
|
|
+ (SELECT DISTINCT(project_id)
|
|
|
+ FROM
|
|
|
+ (SELECT project_id FROM participate_push_statistics a
|
|
|
+ WHERE %s UNION
|
|
|
+ SELECT project_id
|
|
|
+ FROM participate_stage_statistics b
|
|
|
+ WHERE %s) order by project_id
|
|
|
+ LIMIT %d , %d) A
|
|
|
+ LEFT JOIN
|
|
|
+ participate_stage_statistics B ON A.project_id = B.project_id and %s` // and 连接前对右表过滤
|
|
|
+ q2 := "select count(project_id) from (select distinct(project_id) from participate_push_statistics a where %s union select project_id from participate_stage_statistics b where %s )"
|
|
|
+ q1Str := strings.Join(query1, " and ")
|
|
|
+ q2Str := strings.Join(query2, " and ")
|
|
|
+ return fmt.Sprintf(q, q1Str, q2Str, (req.PageNum-1)*req.PageSize, req.PageSize, query3), fmt.Sprintf(q2, q1Str, q2Str)
|
|
|
+ }
|
|
|
+ var q, qCount string
|
|
|
+ query := []string{}
|
|
|
+ joinStr := ""
|
|
|
+ if queryType == 1 {
|
|
|
+ if isEnt {
|
|
|
+ //是企业版
|
|
|
+ query = append(query, fmt.Sprintf(" a.ent_user_id in (%s) ", personArrStr))
|
|
|
+ joinStr = "and a.ent_id = b.ent_id"
|
|
|
+ } else {
|
|
|
+ query = append(query, fmt.Sprintf(" a.position_id = %s ", personArrStr))
|
|
|
+ //不是企业版
|
|
|
+ joinStr = "and a.position_id = b.position_ids"
|
|
|
+ }
|
|
|
+ if req.StartTime == 0 && req.EndTime == 0 {
|
|
|
+ //没有传时间,默认时间处理
|
|
|
+ var start = time.Now().AddDate(0, 0, -30)
|
|
|
+ query = append(query, fmt.Sprintf(" a.ymd >= %s ", start.Local().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 {
|
|
|
+ sourceArr := []string{}
|
|
|
+ for i := 0; i < len(req.Source); i++ {
|
|
|
+ if req.Source[i] == 0 {
|
|
|
+ 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 {
|
|
|
+ sourceArr = append(sourceArr, fmt.Sprintf(" FIND_IN_SET('%d', a.source)", req.Source[i]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ query = append(query, fmt.Sprintf(" (%s) ", strings.Join(sourceArr, " or ")))
|
|
|
+ }
|
|
|
+ // 投标类型 投标方式;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,a.ymd,b.update_date from participate_push_statistics a left join participate_stage_statistics b on(a.project_id=b.project_id %s ) where %s order by a.ymd desc,b.update_date desc"
|
|
|
+ qCount = "select count(distinct(a.project_id)) from participate_push_statistics a left join participate_stage_statistics b on(a.project_id=b.project_id %s) where %s"
|
|
|
+ } else if queryType == 2 {
|
|
|
+ if isEnt {
|
|
|
+ //是企业版
|
|
|
+ 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, fmt.Sprintf("(%s)", personStr))
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //不是企业版
|
|
|
+ query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', b.position_ids)", personArrStr))
|
|
|
+ }
|
|
|
+ //// 无默认时间时
|
|
|
+ if req.BidUpdateStartTime == 0 && req.BidUpdateEndTime == 0 {
|
|
|
+ var start = time.Now().AddDate(0, 0, -30)
|
|
|
+ query = append(query, fmt.Sprintf(" b.update_date >= '%s' ", start.Local().Format(date.Date_Full_Layout)))
|
|
|
+ }
|
|
|
+ // 参标状态更新时间
|
|
|
+ if req.BidUpdateStartTime != 0 {
|
|
|
+ bidStart_, err := time.ParseInLocation(date.Date_yyyyMMdd, fmt.Sprintf("%d", req.BidUpdateStartTime), time.Local)
|
|
|
+ if err != nil {
|
|
|
+ bidStart_ = time.Now().AddDate(0, 0, -30)
|
|
|
+ log.Println("时间转换失败,使用默认值:", err)
|
|
|
+ }
|
|
|
+ bidStart := date.FormatDate(&bidStart_, date.Date_Full_Layout)
|
|
|
+ query = append(query, fmt.Sprintf("b.update_date >= '%s'", bidStart))
|
|
|
+ }
|
|
|
+ if req.BidUpdateEndTime != 0 {
|
|
|
+ bidEnd_, err := time.ParseInLocation("20060102 15:04:05", fmt.Sprintf("%d 23:59:59", req.BidUpdateEndTime), time.Local)
|
|
|
+ if err != nil {
|
|
|
+ bidEnd_ = time.Now().AddDate(0, 0, -30)
|
|
|
+ log.Println("时间转换失败,使用默认值:", err)
|
|
|
+ }
|
|
|
+ bidEnd := date.FormatDate(&bidEnd_, date.Date_Full_Layout)
|
|
|
+ query = append(query, fmt.Sprintf("b.update_date <= '%s'", bidEnd))
|
|
|
+ }
|
|
|
+ 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 b.project_id,b.stage from participate_stage_statistics b where %s %s order by b.update_date desc"
|
|
|
+ qCount = "select count(b.project_id) from participate_stage_statistics b where %s %s"
|
|
|
+ } else {
|
|
|
+ if isEnt {
|
|
|
+ //是企业版
|
|
|
+ query = append(query, fmt.Sprintf(" a.ent_user_id in (%s) ", personArrStr))
|
|
|
+ joinStr = "and a.ent_id = b.ent_id"
|
|
|
+ } else {
|
|
|
+ query = append(query, fmt.Sprintf(" a.position_id = %s ", personArrStr))
|
|
|
+ //不是企业版
|
|
|
+ // 个人版
|
|
|
+ joinStr = "and a.position_id = b.position_ids"
|
|
|
+ }
|
|
|
+ if req.StartTime != 0 && req.EndTime == 0 && req.BidUpdateStartTime == 0 && req.BidUpdateEndTime == 0 {
|
|
|
+ var start = time.Now().AddDate(0, 0, -30)
|
|
|
+ query = append(query, fmt.Sprintf(" a.ymd >= %s ", start.Local().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 {
|
|
|
+ sourceArr := []string{}
|
|
|
+ for i := 0; i < len(req.Source); i++ {
|
|
|
+ if req.Source[i] == 0 {
|
|
|
+ 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 {
|
|
|
+ sourceArr = append(sourceArr, fmt.Sprintf(" FIND_IN_SET('%d', a.source)", req.Source[i]))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ query = append(query, fmt.Sprintf(" (%s) ", strings.Join(sourceArr, " or ")))
|
|
|
+ }
|
|
|
+ //参标状态:-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 != 0 {
|
|
|
+ bidStart_, err := time.ParseInLocation(date.Date_yyyyMMdd, fmt.Sprintf("%d", req.BidUpdateStartTime), time.Local)
|
|
|
+ if err != nil {
|
|
|
+ bidStart_ = time.Now().AddDate(0, 0, -30)
|
|
|
+ log.Println("时间转换失败,使用默认值:", err)
|
|
|
+ }
|
|
|
+ bidStart := date.FormatDate(&bidStart_, date.Date_Full_Layout)
|
|
|
+ query = append(query, fmt.Sprintf("b.update_date >= '%s'", bidStart))
|
|
|
+ }
|
|
|
+ if req.BidUpdateEndTime != 0 {
|
|
|
+ bidEnd_, err := time.ParseInLocation("20060102 15:04:05", fmt.Sprintf("%d 23:59:59", req.BidUpdateEndTime), time.Local)
|
|
|
+ if err != nil {
|
|
|
+ bidEnd_ = time.Now().AddDate(0, 0, -30)
|
|
|
+ log.Println("时间转换失败,使用默认值:", err)
|
|
|
+ }
|
|
|
+ bidEnd := date.FormatDate(&bidEnd_, date.Date_Full_Layout)
|
|
|
+ query = append(query, fmt.Sprintf("b.update_date <= '%s'", bidEnd))
|
|
|
+ }
|
|
|
+ q = "select distinct(a.project_id),b.stage,a.ymd,b.update_date from participate_push_statistics a inner join participate_stage_statistics b on(b.project_id=a.project_id %s) where %s order by a.ymd desc,b.update_date desc"
|
|
|
+ qCount = "select count(distinct(a.project_id)) from participate_push_statistics a inner join participate_stage_statistics b on(b.project_id=a.project_id %s) where %s"
|
|
|
+ }
|
|
|
+ if len(query) > 0 {
|
|
|
+ q = fmt.Sprintf(q, joinStr, strings.Join(query, " and "))
|
|
|
+ qCount = fmt.Sprintf(qCount, joinStr, strings.Join(query, " and "))
|
|
|
+ }
|
|
|
+ q = fmt.Sprintf("%s limit %d,%d", q, (req.PageNum-1)*req.PageSize, req.PageSize)
|
|
|
+ return q, qCount
|
|
|
+}
|
|
|
+
|
|
|
+type PushInfoStruct struct {
|
|
|
+ Source string
|
|
|
+ VisitDate string
|
|
|
+ DisDate string
|
|
|
+ IsDistribute int
|
|
|
+}
|
|
|
+
|
|
|
+func ProjectDetailHandle(dataList []map[string]interface{}, entId int64, positionId, positionType int) []*bxcore.ProjectDetailData {
|
|
|
+ //dataList 里面包含 项目id、各阶段信息
|
|
|
+ // 处理项目名称
|
|
|
+ projectIdList := []string{}
|
|
|
+ for i := 0; i < len(dataList); i++ {
|
|
|
+ projectIdList = append(projectIdList, common.ObjToString(dataList[i]["project_id"]))
|
|
|
+ }
|
|
|
+ // 项目名称处理成map用于后续使用
|
|
|
+ projectNameMap := map[string]string{}
|
|
|
+ projectNameRs := es.GetProjectNameByProjectId(projectIdList)
|
|
|
+ if projectNameRs != nil && len(*projectNameRs) > 0 {
|
|
|
+ for i := 0; i < len(*projectNameRs); i++ {
|
|
|
+ projectId_ := common.ObjToString((*projectNameRs)[i]["_id"])
|
|
|
+ projectName_ := (*projectNameRs)[i]["projectname"]
|
|
|
+ projectNameMap[projectId_] = common.ObjToString(projectName_)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 获取推送最新状态
|
|
|
+ newPushInfo := getNewPushInfo(projectIdList, int(entId), positionId, positionType)
|
|
|
+ newPushInfoMap := map[string]PushInfoStruct{}
|
|
|
+ // 处理推送最新状态
|
|
|
+ if newPushInfo != nil && len(*newPushInfo) > 0 {
|
|
|
+ for i := 0; i < len(*newPushInfo); i++ {
|
|
|
+ project_ := common.ObjToString((*newPushInfo)[i]["project_id"])
|
|
|
+ info := PushInfoStruct{
|
|
|
+ Source: common.ObjToString((*newPushInfo)[i]["source"]),
|
|
|
+ VisitDate: common.ObjToString((*newPushInfo)[i]["visit_date"]),
|
|
|
+ DisDate: common.ObjToString((*newPushInfo)[i]["dis_date"]),
|
|
|
+ }
|
|
|
+ newPushInfoMap[project_] = info
|
|
|
+ }
|
|
|
+ }
|
|
|
+ results := []*bxcore.ProjectDetailData{}
|
|
|
+ // 处理成最后的数据
|
|
|
+ for i := 0; i < len(dataList); i++ {
|
|
|
+ projectId := common.ObjToString(dataList[i]["project_id"])
|
|
|
+ tmp := bxcore.ProjectDetailData{
|
|
|
+ ProjectName: projectNameMap[projectId],
|
|
|
+ }
|
|
|
+ isDistribute_ := ""
|
|
|
+ // 处理推送表相关字段
|
|
|
+ if pushInfo_, ok := newPushInfoMap[projectId]; ok {
|
|
|
+ sourceStr := []string{}
|
|
|
+ if pushInfo_.Source != "" {
|
|
|
+ isDistribute_ = "未分发"
|
|
|
+ sourceSplit := strings.Split(pushInfo_.Source, ",")
|
|
|
+ for j := 0; j < len(sourceSplit); j++ {
|
|
|
+ if sourceSplit[j] == "3" {
|
|
|
+ isDistribute_ = "已分发"
|
|
|
+ }
|
|
|
+
|
|
|
+ if sourceName, ok := SourceMap[sourceSplit[j]]; ok {
|
|
|
+ sourceStr = append(sourceStr, sourceName)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tmp.Source = strings.Join(sourceStr, ",") // 处理成中文
|
|
|
+ tmp.ViewDate = pushInfo_.VisitDate
|
|
|
+ tmp.IsDistribute = isDistribute_
|
|
|
+ tmp.DisDate = pushInfo_.DisDate
|
|
|
+ } //
|
|
|
+ // 处理阶段勾选信息和参标、终止参标信息
|
|
|
+
|
|
|
+ if dataList[i]["stage"] != nil {
|
|
|
+ s := common.ObjToString(dataList[i]["stage"])
|
|
|
+ err := json.Unmarshal([]byte(strings.Replace(s, "'", "\"", -1)), &tmp.Stage)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("stage 反序列失败", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ tmp.Id = encrypt.EncodeArticleId2ByCheck(projectId)
|
|
|
+ results = append(results, &tmp)
|
|
|
+ }
|
|
|
+ return results
|
|
|
+}
|
|
|
+
|
|
|
+// 获取项目的最新推送状态信息
|
|
|
+func getNewPushInfo(projectIds []string, entId int, positionId int, positionType int) *[]map[string]interface{} {
|
|
|
+ s := ""
|
|
|
+ if positionType == 0 {
|
|
|
+ s = fmt.Sprintf("position_id=%d", positionId)
|
|
|
+ } else {
|
|
|
+ s = fmt.Sprintf("ent_id=%d", entId)
|
|
|
+ }
|
|
|
+ sql := `
|
|
|
+SELECT
|
|
|
+ A.project_id, A.source,DATE_FORMAT(A.visit_date,'%%Y-%%m-%%d') as visit_date, DATE_FORMAT(A.dis_date,'%%Y-%%m-%%d') as dis_date,A.id,A.ymd,B.ymd
|
|
|
+FROM participate_push_statistics A inner join (SELECT
|
|
|
+ project_id,MAX(ymd) as ymd
|
|
|
+ FROM
|
|
|
+ participate_push_statistics
|
|
|
+ WHERE
|
|
|
+ %s
|
|
|
+ AND project_id IN ( "` + strings.Join(projectIds, "\",\"") + `" )
|
|
|
+ GROUP BY project_id) B on (A.project_id=B.project_id and A.ymd=b.ymd) and A.%s
|
|
|
+`
|
|
|
+ query := fmt.Sprintf(sql, s, s)
|
|
|
+ return IC.BaseMysql.SelectBySql(query)
|
|
|
+}
|
|
|
+
|
|
|
+// GetQueryType 查询类型 0空搜索 1查左边 连右表查stage 2只查右表 3内连接
|
|
|
+// IsParticipate 接收参数时 0 全部 1 未参标 2已参标 数据库中 未参标是0
|
|
|
+func GetQueryType(in *bxcore.ProjectDetailsReq) int {
|
|
|
+ //
|
|
|
+ if in.BidUpdateStartTime == 0 && in.BidUpdateEndTime == 0 && in.StartTime == 0 && in.EndTime == 0 && in.IsParticipate == 0 && in.BidWay == 0 && len(in.Source) == 0 {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ if in.IsParticipate == 1 {
|
|
|
+ // 未参标只筛选推送表 右表条件无效
|
|
|
+ in.BidWay = 0
|
|
|
+ in.BidUpdateStartTime = 0
|
|
|
+ in.BidUpdateEndTime = 0
|
|
|
+ return 1
|
|
|
+ }
|
|
|
+ if (in.StartTime != 0 || in.EndTime != 0 || len(in.Source) > 0) && (in.BidUpdateStartTime == 0 && in.BidUpdateEndTime == 0 && in.IsParticipate != 2) {
|
|
|
+ return 1
|
|
|
+ }
|
|
|
+ if (in.StartTime == 0 && in.EndTime == 0 && len(in.Source) == 0) && (in.BidUpdateStartTime != 0 || in.BidUpdateEndTime == 0 || in.IsParticipate == 2 || in.BidWay != 0) {
|
|
|
+ return 2
|
|
|
+ }
|
|
|
+ return 3
|
|
|
+}
|