Эх сурвалжийг харах

Merge branch 'dev/v1.1.36_fuwencai' of https://jygit.jydev.jianyu360.cn/BaseService/jyMicroservices into dev/v1.1.36_fuwencai

wangshan 1 жил өмнө
parent
commit
da9f5ebd91

+ 19 - 0
jyBXCore/api/bxcore.api

@@ -185,6 +185,23 @@ type (
 		EntAccountId int64  `header:"entAccountId,optional"` //企业账户id
 		EntUserId    int64  `header:"newUserId,optional"`
 	}
+	ProjectDetailReq {
+		PositionId      int64    `header:"positionId,optional"`   //职位id
+		PositionType    int64    `header:"positionType,optional"` //职位类型 0个人 1企业
+		EntId           int64    `header:"entId,optional"`
+		EntUserId       int64    `header:"entUserId,optional"`
+		DeptId          int64    `header:"deptId,optional"`
+		EntUserIdArr    []string `json:"entUserIdArr,optional"`
+		StartTime       int64    `json:"startTime,optional"`
+		EndTime         int64    `json:"endTime,optional"`
+		Source          []int64  `json:"source,optional"`          // 标讯项目来源 -1:全部  1:个人订阅 2:企业自动分发 3:企业手动分发
+		BidWay          int64    `json:"bidWay,optional"`          // 投标类型 -1:全部 1:直接投标 2:渠道投标
+		Isparticipate   int64    `json:"isparticipate,optional"`   // 参标状态;-1:全部 0:未参标 1:是
+		UpdateStartTime string   `json:"updateStartTime,optional"` //
+		UpdateEndTime   string   `json:"updateEndTime,optional"`   //
+		PageSize        int64    `json:"pageSize,optional"`        //
+		PageNum         int64    `json:"pageNum,optional"`         //
+	}
 )
 service bxcore-api {
 	@handler searchList
@@ -215,5 +232,7 @@ service bxcore-api {
 	post /jybx/core/statistics/projectStatistics(ptatisticsListReq) returns (commonResp)
 	@handler polymerizeSearch//参标项目统计
 	post /jybx/core/polymerizeSearch(polymerizeSearchReq) returns (commonResp)
+	@handler statisticsProjectDetails//参标项目明细
+	post /jybx/core/statistics/projectDetails(ProjectDetailReq) returns (commonResp)
 	
 }

+ 5 - 0
jyBXCore/api/internal/handler/routes.go

@@ -82,6 +82,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/jybx/core/polymerizeSearch",
 				Handler: polymerizeSearchHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/jybx/core/statistics/projectDetails",
+				Handler: statisticsProjectDetailsHandler(serverCtx),
+			},
 		},
 	)
 }

+ 28 - 0
jyBXCore/api/internal/handler/statisticsProjectDetailsHandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+	"jyBXCore/api/internal/logic"
+	"jyBXCore/api/internal/svc"
+	"jyBXCore/api/internal/types"
+)
+
+func statisticsProjectDetailsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.ProjectDetailReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewStatisticsProjectDetailsLogic(r.Context(), svcCtx)
+		resp, err := l.StatisticsProjectDetails(&req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 1 - 0
jyBXCore/api/internal/logic/projectStatisticsLogic.go

@@ -38,6 +38,7 @@ func (l *ProjectStatisticsLogic) ProjectStatistics(req *types.PtatisticsListReq)
 		DeptId:       req.DeptId,
 		StartTime:    req.StartTime,
 		EndTime:      req.EndTime,
+		BidWay:       req.BidWay,
 	})
 	if err != nil {
 		return nil, err

+ 57 - 0
jyBXCore/api/internal/logic/statisticsProjectDetailsLogic.go

@@ -0,0 +1,57 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"context"
+	"jyBXCore/rpc/type/bxcore"
+
+	"jyBXCore/api/internal/svc"
+	"jyBXCore/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type StatisticsProjectDetailsLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewStatisticsProjectDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StatisticsProjectDetailsLogic {
+	return &StatisticsProjectDetailsLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *StatisticsProjectDetailsLogic) StatisticsProjectDetails(req *types.ProjectDetailReq) (resp *types.CommonResp, err error) {
+	// todo: add your logic here and delete this line
+	for k, v := range req.EntUserIdArr {
+		req.EntUserIdArr[k] = encrypt.SE.Decode4Hex(v)
+	}
+	res, err := l.svcCtx.BxCore.ProjectDetails(l.ctx, &bxcore.ProjectDetailsReq{
+		EntId:              req.EntId,
+		EntUserId:          req.EntUserId,
+		PositionId:         req.PositionId,
+		EntUserIdArr:       req.EntUserIdArr,
+		DeptId:             req.DeptId,
+		StartTime:          req.StartTime,
+		EndTime:            req.EndTime,
+		BidWay:             req.BidWay,
+		Source:             req.Source,
+		IsParticipate:      req.Isparticipate,
+		BidUpdateEndTime:   req.UpdateEndTime,
+		BidUpdateStartTime: req.UpdateStartTime,
+		PageNum:            req.PageNum,
+		PageSize:           req.PageSize,
+		PositionType:       req.PositionType,
+	})
+	if err != nil {
+		return nil, err
+	}
+	return &types.CommonResp{
+		Data: res.Data,
+	}, nil
+	return
+}

+ 18 - 0
jyBXCore/api/internal/types/types.go

@@ -180,3 +180,21 @@ type PolymerizeSearchReq struct {
 	EntAccountId int64  `header:"entAccountId,optional"` //企业账户id
 	EntUserId    int64  `header:"newUserId,optional"`
 }
+
+type ProjectDetailReq struct {
+	PositionId      int64    `header:"positionId,optional"`   //职位id
+	PositionType    int64    `header:"positionType,optional"` //职位类型 0个人 1企业
+	EntId           int64    `header:"entId,optional"`
+	EntUserId       int64    `header:"entUserId,optional"`
+	DeptId          int64    `header:"deptId,optional"`
+	EntUserIdArr    []string `json:"entUserIdArr,optional"`
+	StartTime       int64    `json:"startTime,optional"`
+	EndTime         int64    `json:"endTime,optional"`
+	Source          []int64  `json:"source,optional"`          // 标讯项目来源 -1:全部  1:个人订阅 2:企业自动分发 3:企业手动分发
+	BidWay          int64    `json:"bidWay,optional"`          // 投标类型 -1:全部 1:直接投标 2:渠道投标
+	Isparticipate   int64    `json:"isparticipate,optional"`   // 参标状态;-1:全部 0:未参标 1:是
+	UpdateStartTime string   `json:"updateStartTime,optional"` //
+	UpdateEndTime   string   `json:"updateEndTime,optional"`   //
+	PageSize        int64    `json:"pageSize,optional"`        //
+	PageNum         int64    `json:"pageNum,optional"`         //
+}

+ 42 - 0
jyBXCore/rpc/bxcore.proto

@@ -454,6 +454,24 @@ message StatisticsListReq{
   int64 bidWay = 9; //   -1:全部 1:直接投标 2:渠道投标
 
 }
+// 企业项目参标明细
+message ProjectDetailsReq{
+  int64  entId = 1; //企业id
+  int64  entUserId = 2; // 企业下用户id
+  int64  positionId = 3; // 职位id
+  int64  positionType = 15; // 职位类型
+  repeated string  entUserIdArr = 4; //人员选择
+  int64  deptId = 5; //部门id
+  int64 startTime = 6;
+  int64 endTime = 7;
+  repeated int64 source = 8; // source  0:全部  1:个人订阅 2:企业自动分发 3:企业手动分发
+  int64 bidWay = 9; //   -1:全部 1:直接投标 2:渠道投标
+  string bidUpdateStartTime =10;// 参标状态跟新时间开始
+  string bidUpdateEndTime =11;// 参标状态跟新时间结束
+  int64 isParticipate = 12;// -1全部 1-已参标是 0-未参标否
+  int64 PageNum = 13;// 页码 从1开始
+  int64 PageSize =14;// 每页条数 默认50
+}
 // 筛选项
 message sourceItem{
  string Name =1;
@@ -480,6 +498,28 @@ message ProjectStatisticsDataRes{
   string err_msg = 2;
   repeated ProjectStatisticsData data = 3;
 }
+message StageValue{
+  string Status =1;
+  string Date =2;
+}
+message ProjectDetailData {
+  string  ProjectName =1 [json_name = "projectName"];// 项目名称
+  string  Source = 2 [json_name = "source"]; // 标讯/项目来源 '来源;1:个人订阅 2:企业自动分发 3:企业手动分发
+  string   IsDistribute = 3 [json_name = "isDistribute"];// 手动分发状态  1已分发
+  string  DisDate =4 [json_name = "disDate"]; // 分发时间
+  string  ViewDate = 5 [json_name = "visitDate"];//最早浏览时间
+  map<string, StageValue> stage =6 [json_name = "stage"];// 阶段相关信息  <阶段名称,勾选时间>
+}
+message DetailData{
+  repeated ProjectDetailData list = 1;
+  int64    total  = 2;
+}
+message DetailDataRes{
+  int64 err_code = 1;
+  string err_msg = 2;
+  DetailData data =3;
+  }
+
 message ProjectStatisticsData{
   string  personName = 1;
   string  departmentName = 2;
@@ -580,4 +620,6 @@ service BxCore {
   rpc ProjectStatistics(StatisticsListReq) returns (ProjectStatisticsDataRes);
   //聚合搜索
   rpc PolymerizeSearch(PolymerizeSearchReq) returns (PolymerizeSearchResp);
+  rpc ProjectDetails(ProjectDetailsReq) returns (DetailDataRes);
+
 }

+ 11 - 0
jyBXCore/rpc/bxcore/bxcore.go

@@ -14,6 +14,8 @@ import (
 
 type (
 	BidTypeReq               = bxcore.BidTypeReq
+	DetailData               = bxcore.DetailData
+	DetailDataRes            = bxcore.DetailDataRes
 	MenuList                 = bxcore.MenuList
 	PInfo                    = bxcore.PInfo
 	ParticipateActionReq     = bxcore.ParticipateActionReq
@@ -42,6 +44,8 @@ type (
 	ParticipateShowRes       = bxcore.ParticipateShowRes
 	PolymerizeSearchReq      = bxcore.PolymerizeSearchReq
 	PolymerizeSearchResp     = bxcore.PolymerizeSearchResp
+	ProjectDetailData        = bxcore.ProjectDetailData
+	ProjectDetailsReq        = bxcore.ProjectDetailsReq
 	ProjectStatisticsData    = bxcore.ProjectStatisticsData
 	ProjectStatisticsDataRes = bxcore.ProjectStatisticsDataRes
 	PushStatisticsData       = bxcore.PushStatisticsData
@@ -58,6 +62,7 @@ type (
 	SearchReturn             = bxcore.SearchReturn
 	ShowInfo                 = bxcore.ShowInfo
 	SourceItem               = bxcore.SourceItem
+	StageValue               = bxcore.StageValue
 	StatisticsListReq        = bxcore.StatisticsListReq
 	TipInfo                  = bxcore.TipInfo
 	UpdateBidStatusReq       = bxcore.UpdateBidStatusReq
@@ -93,6 +98,7 @@ type (
 		ProjectStatistics(ctx context.Context, in *StatisticsListReq, opts ...grpc.CallOption) (*ProjectStatisticsDataRes, error)
 		// 聚合搜索
 		PolymerizeSearch(ctx context.Context, in *PolymerizeSearchReq, opts ...grpc.CallOption) (*PolymerizeSearchResp, error)
+		ProjectDetails(ctx context.Context, in *ProjectDetailsReq, opts ...grpc.CallOption) (*DetailDataRes, error)
 	}
 
 	defaultBxCore struct {
@@ -189,3 +195,8 @@ func (m *defaultBxCore) PolymerizeSearch(ctx context.Context, in *PolymerizeSear
 	client := bxcore.NewBxCoreClient(m.cli.Conn())
 	return client.PolymerizeSearch(ctx, in, opts...)
 }
+
+func (m *defaultBxCore) ProjectDetails(ctx context.Context, in *ProjectDetailsReq, opts ...grpc.CallOption) (*DetailDataRes, error) {
+	client := bxcore.NewBxCoreClient(m.cli.Conn())
+	return client.ProjectDetails(ctx, in, opts...)
+}

+ 40 - 0
jyBXCore/rpc/internal/logic/projectdetailslogic.go

@@ -0,0 +1,40 @@
+package logic
+
+import (
+	"context"
+	"jyBXCore/rpc/internal/svc"
+	"jyBXCore/rpc/service"
+	"jyBXCore/rpc/type/bxcore"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ProjectDetailsLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewProjectDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ProjectDetailsLogic {
+	return &ProjectDetailsLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *ProjectDetailsLogic) ProjectDetails(in *bxcore.ProjectDetailsReq) (*bxcore.DetailDataRes, error) {
+	participateService := service.ParticipateStatistics{
+		PositionId: in.PositionId,
+		EntId:      in.EntId,
+		DeptId:     in.EntId,
+		EntUserId:  in.EntUserId,
+	}
+
+	data := participateService.ProjectDetails(in.EntUserIdArr, in)
+	return &bxcore.DetailDataRes{
+		ErrCode: 1,
+		ErrMsg:  "",
+		Data:    &data,
+	}, nil
+}

+ 5 - 0
jyBXCore/rpc/internal/server/bxcoreserver.go

@@ -105,3 +105,8 @@ func (s *BxCoreServer) PolymerizeSearch(ctx context.Context, in *bxcore.Polymeri
 	l := logic.NewPolymerizeSearchLogic(ctx, s.svcCtx)
 	return l.PolymerizeSearch(in)
 }
+
+func (s *BxCoreServer) ProjectDetails(ctx context.Context, in *bxcore.ProjectDetailsReq) (*bxcore.DetailDataRes, error) {
+	l := logic.NewProjectDetailsLogic(ctx, s.svcCtx)
+	return l.ProjectDetails(in)
+}

+ 26 - 0
jyBXCore/rpc/model/es/project.go

@@ -100,3 +100,29 @@ func GetBidInfoByPId(infoId string) *[]map[string]interface{} {
 	return projectResult
 
 }
+
+func GetProjectNameByProjectId(projectId []string) *[]map[string]interface{} {
+	projectQuery := `{
+  "query": {
+    "bool": {
+      "must": [
+        {
+          "terms": {
+            "_id": [
+              "` + strings.Join(projectId, "\",\"") + `"
+            ]
+          }
+        }
+      ]
+    }
+  },
+  "_source": [
+    "_id",
+    "projectname"
+  ],"size":%d
+}`
+	projectQuery = fmt.Sprintf(projectQuery, len(projectId))
+	projectResult := elastic.Get(IndexProjectSet, TypeProjectSet, projectQuery)
+	return projectResult
+
+}

+ 361 - 8
jyBXCore/rpc/service/participateStatistics.go

@@ -8,7 +8,9 @@ import (
 	"fmt"
 	"jyBXCore/rpc/bxcore"
 	IC "jyBXCore/rpc/init"
+	"jyBXCore/rpc/model/es"
 	"log"
+	"strconv"
 	"strings"
 	"time"
 )
@@ -30,7 +32,7 @@ func (in *ParticipateStatistics) PushStatistics(entUserIdArr []string, startTime
 	//判断是企业、部门还是个人
 	isAdmin, personArrStr, users := in.PersonHandle(entUserIdArr)
 	//时间处理
-	query := QueryHandle(isAdmin, startTime, endTime, personArrStr, source, -1)
+	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 ")))
 	if users != nil && len(*users) > 0 {
@@ -59,6 +61,11 @@ var (
 		2: "企业自动分发",
 		3: "企业手动分发",
 	}
+	SourceMap = map[string]string{
+		"1": "个人订阅",
+		"2": "企业自动分发",
+		"3": "企业手动分发",
+	}
 )
 
 // GetSourceItem 获取标讯项目来源筛选项
@@ -89,12 +96,23 @@ func (in *ParticipateStatistics) GetSourceItem(entId, positionId int) (result []
 		return
 	}
 	for i := 0; i < len(*rs); i++ {
-		value := common.IntAll((*rs)[i][""])
-		if name, ok := SelectItemMap[value]; ok {
-			result = append(result, &bxcore.SourceItem{
-				Name:  name,
-				Value: int64(value),
-			})
+		value := common.ObjToString((*rs)[i]["source"])
+		if value == "" {
+			continue
+		}
+		splitSource := strings.Split(value, ",")
+		for j := 0; j < len(splitSource); j++ {
+			sourceValue, err := strconv.Atoi(splitSource[j])
+			if err != nil {
+				log.Println("类型转换错误:", err, splitSource[j])
+				continue
+			}
+			if name, ok := SelectItemMap[sourceValue]; ok {
+				result = append(result, &bxcore.SourceItem{
+					Name:  name,
+					Value: int64(sourceValue),
+				})
+			}
 		}
 	}
 	if len(result) > 0 {
@@ -504,10 +522,345 @@ func QueryHandle(isAdmin bool, startTime, endTime int64, personArrStr string, so
 			sourceValue += fmt.Sprint(source[i]) + ","
 		}
 		sourceValue = sourceValue[:len(sourceValue)-1]
-		query = append(query, fmt.Sprintf("source in ( %s )", sourceValue))
+		query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', a.source)", sourceValue))
 	}
 	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) {
+	//判断是企业、部门还是个人
+	isAdmin, personArrStr, _ := in.PersonHandle(entUserIdArr)
+	queryType := GetQueryType(detailReq)
+	query, countQuery := GetDetailQuery(isAdmin, 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
+}
+
+//	todo 查询条件待验证
+//
+// 这个查询只用查出符合筛选条件的项目id 以及该项目对应的stage
+// 查询类型  0空搜索 全连接 1查左边 连右表查stage 2只查右表 3内连接
+func GetDetailQuery(isAdmin bool, personArrStr string, req *bxcore.ProjectDetailsReq, queryType int) (string, string) {
+
+	// 这是因为数据库中 0是未参标 1是已参标, 接收参数时和其他默认参数保持一致 0-全部 1 是未参标 2 是已参标
+	req.IsParticipate -= 1
+	if queryType == 0 {
+		// 空搜索调整
+		query1, query2, query3 := []string{}, []string{}, []string{}
+		//没有传时间,默认时间处理
+		var start = time.Now().AddDate(0, 0, -30)
+		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_ids) ", personArrStr))
+			query3 = append(query3, fmt.Sprintf(" FIND_IN_SET('%s', b.ent_user_ids) ", personArrStr))
+		} 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))
+		}
+		q := `SELECT A.project_id, B.stage
+				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{}
+	joinStr := ""
+	if queryType == 1 {
+		if isAdmin {
+			//是管理员
+			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))
+			//不是管理员
+			// 个人版
+			if req.PositionType == 0 {
+				joinStr = "and a.position_id = b.position_ids"
+			} else {
+				// 企业版  个人 因为是查项目的最新状态信息 所以 用ent_id 和项目id连表
+				joinStr = "and a.ent_id = b.ent_id"
+			}
+		}
+		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++ {
+				if req.Source[i] == 0 {
+					sourceValue += "1,2,"
+				} else {
+					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,a.id,b.id as  bid  from participate_push_statistics a left join participate_stage_statistics b on(a.project_id=b.project_id %s ) where %s order by a.id desc,b.id 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 isAdmin {
+			//是管理员
+			query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', b.ent_user_ids) ", personArrStr))
+		} else {
+			//不是管理员
+			query = append(query, fmt.Sprintf(" FIND_IN_SET('%s', b.position_ids)", 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,a.id,b.id   from  participate_stage_statistics b where %s %s order by b.id desc"
+		qCount = "select count(b.project_id)   from  participate_stage_statistics b where %s %s"
+	} else {
+		if isAdmin {
+			//是管理员
+			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))
+			//不是管理员
+			// 个人版
+			if req.PositionType == 0 {
+				joinStr = "and a.position_id = b.position_ids"
+			} else {
+				// 企业版  个人 因为是查项目的最新状态信息 所以 用ent_id 和项目id连表
+				joinStr = "and a.ent_id = b.ent_id"
+			}
+		}
+		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++ {
+				if req.Source[i] == 0 {
+					sourceValue += "1,2," // 选择未分发时  相当于选择个人订阅和企业自动分发
+				} else {
+					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,a.id,b.id   from participate_push_statistics a inner join  participate_stage_statistics b on(b.project_id=a.project_id %s) where %s order by a.id desc,b.id 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 "))
+	}
+	// 处理分页
+	if req.PageNum == 0 && req.PageSize == 0 {
+		req.PageNum = 1
+		req.PageSize = 50
+	}
+	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 {
+			if stage_, err := json.Marshal(dataList[i]["stage"]); err == nil {
+				err := json.Unmarshal(stage_, &tmp.Stage)
+				if err != nil {
+					log.Println("stage 反序列失败", err)
+				}
+			}
+		}
+		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, A.visit_date, A.dis_date, A.is_distribute,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) where 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 {
+	// 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.IsParticipate == 1 {
+		// 未参标只筛选推送表 右表条件无效
+		return 1
+	}
+	if (in.StartTime != 0 || in.EndTime != 0 || len(in.Source) > 0) && (in.BidUpdateStartTime == "" && in.BidUpdateEndTime == "" && in.IsParticipate != 2) {
+		return 1
+	}
+	if (in.StartTime == 0 && in.EndTime == 0 && len(in.Source) == 0) && (in.BidUpdateStartTime != "" || in.BidUpdateEndTime == "" || in.IsParticipate == 2 || in.BidWay != 0) {
+		return 2
+	}
+	return 3
+}

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 748 - 258
jyBXCore/rpc/type/bxcore/bxcore.pb.go


+ 36 - 0
jyBXCore/rpc/type/bxcore/bxcore_grpc.pb.go

@@ -50,6 +50,7 @@ type BxCoreClient interface {
 	ProjectStatistics(ctx context.Context, in *StatisticsListReq, opts ...grpc.CallOption) (*ProjectStatisticsDataRes, error)
 	//聚合搜索
 	PolymerizeSearch(ctx context.Context, in *PolymerizeSearchReq, opts ...grpc.CallOption) (*PolymerizeSearchResp, error)
+	ProjectDetails(ctx context.Context, in *ProjectDetailsReq, opts ...grpc.CallOption) (*DetailDataRes, error)
 }
 
 type bxCoreClient struct {
@@ -186,6 +187,15 @@ func (c *bxCoreClient) PolymerizeSearch(ctx context.Context, in *PolymerizeSearc
 	return out, nil
 }
 
+func (c *bxCoreClient) ProjectDetails(ctx context.Context, in *ProjectDetailsReq, opts ...grpc.CallOption) (*DetailDataRes, error) {
+	out := new(DetailDataRes)
+	err := c.cc.Invoke(ctx, "/bxcore.BxCore/ProjectDetails", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // BxCoreServer is the server API for BxCore service.
 // All implementations must embed UnimplementedBxCoreServer
 // for forward compatibility
@@ -218,6 +228,7 @@ type BxCoreServer interface {
 	ProjectStatistics(context.Context, *StatisticsListReq) (*ProjectStatisticsDataRes, error)
 	//聚合搜索
 	PolymerizeSearch(context.Context, *PolymerizeSearchReq) (*PolymerizeSearchResp, error)
+	ProjectDetails(context.Context, *ProjectDetailsReq) (*DetailDataRes, error)
 	mustEmbedUnimplementedBxCoreServer()
 }
 
@@ -267,6 +278,9 @@ func (UnimplementedBxCoreServer) ProjectStatistics(context.Context, *StatisticsL
 func (UnimplementedBxCoreServer) PolymerizeSearch(context.Context, *PolymerizeSearchReq) (*PolymerizeSearchResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method PolymerizeSearch not implemented")
 }
+func (UnimplementedBxCoreServer) ProjectDetails(context.Context, *ProjectDetailsReq) (*DetailDataRes, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ProjectDetails not implemented")
+}
 func (UnimplementedBxCoreServer) mustEmbedUnimplementedBxCoreServer() {}
 
 // UnsafeBxCoreServer may be embedded to opt out of forward compatibility for this service.
@@ -532,6 +546,24 @@ func _BxCore_PolymerizeSearch_Handler(srv interface{}, ctx context.Context, dec
 	return interceptor(ctx, in, info, handler)
 }
 
+func _BxCore_ProjectDetails_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ProjectDetailsReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(BxCoreServer).ProjectDetails(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/bxcore.BxCore/ProjectDetails",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(BxCoreServer).ProjectDetails(ctx, req.(*ProjectDetailsReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // BxCore_ServiceDesc is the grpc.ServiceDesc for BxCore service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -595,6 +627,10 @@ var BxCore_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "PolymerizeSearch",
 			Handler:    _BxCore_PolymerizeSearch_Handler,
 		},
+		{
+			MethodName: "ProjectDetails",
+			Handler:    _BxCore_ProjectDetails_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "bxcore.proto",

+ 14 - 0
jyBXCore/test.http

@@ -244,3 +244,17 @@ GRPC http://127.0.0.1:8003/bxcore.BxCore/ParticipateSetUpInfo
   "newUserId": 486050,
   "accountId": 360058
 }
+###
+GRPC http://127.0.0.1:8003/bxcore.BxCore/ParticipateSetUpInfo
+
+{
+"entId": 0,
+"entUserId": 0,
+"positionId": 1204781659,
+"positionType": 0,
+"mgoUserId": "641aa7bcac1c8e639bc15cdb",
+"appId": 10000,
+"userId": "641aa7bcac1c8e639bc15cdb",
+"newUserId": 486050,
+"accountId": 360058
+}

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно