Browse Source

feat:xiugai

wangchuanjin 9 months ago
parent
commit
87e13ea9cf

+ 2 - 2
api/internal/service/CoopHistoryService.go

@@ -196,8 +196,8 @@ func GetWinnerData(scopeClass string, bid string) []AggStruct {
 	args := []interface{}{bid, bid}
 	args := []interface{}{bid, bid}
 	wh, newArgs := common.WhArgs(strings.Split(scopeClass, ","))
 	wh, newArgs := common.WhArgs(strings.Split(scopeClass, ","))
 	args = append(args, newArgs...)
 	args = append(args, newArgs...)
-	rows, err1 := T.ClickhouseConn.Query(context.TODO(), `select distinct winner as name,winner_id as id from information.transaction_info_all ARRAY JOIN winner_id,winner
-			WHERE buyer_id IN (SELECT buyer_id from information.transaction_info_all WHERE has(winner_id,?) and buyer_id<>'') and winner_id<>? AND hasAny(topscopeclass,[`+wh+`])=0`, args...)
+	rows, err1 := T.ClickhouseConn.Query(context.TODO(), `select distinct wr as name,wr_id as id from information.transaction_info_all ARRAY JOIN winner_id as wr_id,winner as wr
+			WHERE buyer_id IN (SELECT buyer_id from information.transaction_info_all WHERE has(winner_id,?) and buyer_id<>'') and wr_id<>? and LENGTH(winner)=LENGTH(winner_id) AND hasAny(topscopeclass,[`+wh+`])=0`, args...)
 	if err1 != nil {
 	if err1 != nil {
 		logx.Error(err1)
 		logx.Error(err1)
 		return ass
 		return ass

+ 1 - 1
api/internal/service/initNetwork.go

@@ -72,7 +72,7 @@ func (i *InitNetwork) Init() {
 		wh, newArgs := util.WhArgs(strings.Split(i.BusinessType, ","))
 		wh, newArgs := util.WhArgs(strings.Split(i.BusinessType, ","))
 		args = append(args, newArgs...)
 		args = append(args, newArgs...)
 		args = append(args, NetworkCom.ProjectYearLimit())
 		args = append(args, NetworkCom.ProjectYearLimit())
-		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT winner,winner_id from information.transaction_info_all ARRAY JOIN winner_id,winner WHERE buyer_id IN (SELECT buyer_id from information.transaction_info_all WHERE has(winner,?) and buyer_id<>'') and winner<>? and hasAny(topscopeclass,[`+wh+`])=0 AND zbtime>?`, args...)
+		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT wr,wr_id from information.transaction_info_all ARRAY JOIN winner_id as wr_id,winner as wr WHERE buyer_id IN (SELECT buyer_id from information.transaction_info_all WHERE has(winner,?) and buyer_id<>'') and wr<>? and LENGTH(winner)=LENGTH(winner_id) and hasAny(topscopeclass,[`+wh+`])=0 AND zbtime>?`, args...)
 		if err != nil {
 		if err != nil {
 			logx.Error(err)
 			logx.Error(err)
 			return
 			return

+ 10 - 3
api/internal/service/network.go

@@ -374,7 +374,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 		if rbt, rerr := redis.GetNewBytes("newother", key); rerr == nil && rbt != nil {
 		if rbt, rerr := redis.GetNewBytes("newother", key); rerr == nil && rbt != nil {
 			json.Unmarshal(*rbt, &aio)
 			json.Unmarshal(*rbt, &aio)
 		} else {
 		} else {
-			aio = n.AllIntroduceOwner(sqlAppend1, "", args, true, businessType)
+			aio = n.AllIntroduceOwner(in.PositionId, sqlAppend1, "", args, true, businessType)
 			redis.Put("newother", key, aio, NetworkCom.CacheTimeout())
 			redis.Put("newother", key, aio, NetworkCom.CacheTimeout())
 		}
 		}
 		firstparty = aio.Firstparty
 		firstparty = aio.Firstparty
@@ -763,7 +763,7 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 	if aioErr == nil && aioByte != nil {
 	if aioErr == nil && aioByte != nil {
 		json.Unmarshal(*aioByte, &aio)
 		json.Unmarshal(*aioByte, &aio)
 	} else {
 	} else {
-		aio = n.AllIntroduceOwner(sqlAppend1, sqlAppend2, args, isTjProject, businessType)
+		aio = n.AllIntroduceOwner(in.PositionId, sqlAppend1, sqlAppend2, args, isTjProject, businessType)
 		redis.Put("newother", redisKey, aio, timeOut)
 		redis.Put("newother", redisKey, aio, timeOut)
 	}
 	}
 	entMonitor := NetworkCom.EntMonitor(in.UserId)
 	entMonitor := NetworkCom.EntMonitor(in.UserId)
@@ -1449,7 +1449,8 @@ func (n *network) MakeProjectInfo(agencyIds, winnerIds []string, vbs map[string]
 	return vm
 	return vm
 }
 }
 
 
-func (n *network) AllIntroduceOwner(sqlAppend1, sqlAppend2 string, args []interface{}, isTjProject bool, businessType []string) *introduceOwnerProject {
+func (n *network) AllIntroduceOwner(positionId int64, sqlAppend1, sqlAppend2 string, args []interface{}, isTjProject bool, businessType []string) *introduceOwnerProject {
+	logx.Info(positionId, " AllIntroduceOwner start 。。。")
 	q := `select a.id,a.company_id,a.company_name,a.qyxy_id,a.itype,a.contact_person as person,a.contact_phone as phone,count(DISTINCT if(b.itype=1,b.relate_id,null)) as buyer_count,count(DISTINCT if(b.itype=2,b.relate_id,null)) as project_count,GROUP_CONCAT(IF(b.itype=1,b.relate_id,NULL)) AS relate_buyer_id,GROUP_CONCAT(IF(b.itype=1,b.relate_name,NULL)) AS relate_buyer_name,GROUP_CONCAT(IF(b.itype=2,b.relate_id,NULL)) AS relate_project_id,a.create_time from crm.connection a 
 	q := `select a.id,a.company_id,a.company_name,a.qyxy_id,a.itype,a.contact_person as person,a.contact_phone as phone,count(DISTINCT if(b.itype=1,b.relate_id,null)) as buyer_count,count(DISTINCT if(b.itype=2,b.relate_id,null)) as project_count,GROUP_CONCAT(IF(b.itype=1,b.relate_id,NULL)) AS relate_buyer_id,GROUP_CONCAT(IF(b.itype=1,b.relate_name,NULL)) AS relate_buyer_name,GROUP_CONCAT(IF(b.itype=2,b.relate_id,NULL)) AS relate_project_id,a.create_time from crm.connection a 
 		left join crm.connection_introduce b on (a.position_id=? and b.position_id=? and a.id=b.connection_id) where a.position_id=?` + sqlAppend1 + ` GROUP BY a.id order by a.create_time desc` + sqlAppend2
 		left join crm.connection_introduce b on (a.position_id=? and b.position_id=? and a.id=b.connection_id) where a.position_id=?` + sqlAppend1 + ` GROUP BY a.id order by a.create_time desc` + sqlAppend2
 	listTemp := CrmMysql.SelectBySql(q, args...)
 	listTemp := CrmMysql.SelectBySql(q, args...)
@@ -1501,11 +1502,17 @@ func (n *network) AllIntroduceOwner(sqlAppend1, sqlAppend2 string, args []interf
 	}
 	}
 	if isTjProject {
 	if isTjProject {
 		iop.FirstpartyNetwork = n.FirstpartyNetwork("", firstparty_array)
 		iop.FirstpartyNetwork = n.FirstpartyNetwork("", firstparty_array)
+		logx.Info(positionId, " FirstpartyNetwork over 。。。")
 		iop.Firstparty = n.Introduce_Firstparty(iop.FirstpartyNetwork, businessType)
 		iop.Firstparty = n.Introduce_Firstparty(iop.FirstpartyNetwork, businessType)
+		logx.Info(positionId, " Introduce_Firstparty over 。。。")
 		iop.Supplier = n.Introduce_Supplier(supplier_array, businessType)
 		iop.Supplier = n.Introduce_Supplier(supplier_array, businessType)
+		logx.Info(positionId, " Introduce_Supplier over 。。。")
 		iop.Adiffb = n.Introduce_Supplier(adiffb_array, businessType)
 		iop.Adiffb = n.Introduce_Supplier(adiffb_array, businessType)
+		logx.Info(positionId, " Introduce_Supplier over 。。。")
 		iop.Agency = n.Introduce_Agency(agency_array, businessType)
 		iop.Agency = n.Introduce_Agency(agency_array, businessType)
+		logx.Info(positionId, " Introduce_Agency over 。。。")
 		iop.Middleman = n.Introduce_Middleman_Buyer(middleman_buyer_array, businessType)
 		iop.Middleman = n.Introduce_Middleman_Buyer(middleman_buyer_array, businessType)
+		logx.Info(positionId, " Introduce_Middleman_Buyer over 。。。")
 	}
 	}
 	return iop
 	return iop
 }
 }

+ 13 - 8
api/internal/service/owner.go

@@ -85,7 +85,6 @@ type OwnerlListRes struct {
 // OwnerlList 执行主要的业务逻辑
 // OwnerlList 执行主要的业务逻辑
 func (t *OwnerService) OwnerlList() *OwnerlListRes {
 func (t *OwnerService) OwnerlList() *OwnerlListRes {
 	// 先查询采购单位列表
 	// 先查询采购单位列表
-	startTime := time.Now().Unix()
 	businessStr := FindBusiness(t.EntId, t.UserId)
 	businessStr := FindBusiness(t.EntId, t.UserId)
 	// 初始化分页参数
 	// 初始化分页参数
 	if t.PageSize == 0 {
 	if t.PageSize == 0 {
@@ -101,6 +100,7 @@ func (t *OwnerService) OwnerlList() *OwnerlListRes {
 	if businessStr == "" {
 	if businessStr == "" {
 		return olr
 		return olr
 	}
 	}
+	logx.Info(t.PositionId, " OwnerlList start 。。。")
 	//监控状态处理
 	//监控状态处理
 	monitorMap := NetworkCom.EntMonitor(gconv.String(t.PositionId))
 	monitorMap := NetworkCom.EntMonitor(gconv.String(t.PositionId))
 	comKey := common.GetMd5String(fmt.Sprintf("%+v business:%s", t, businessStr))
 	comKey := common.GetMd5String(fmt.Sprintf("%+v business:%s", t, businessStr))
@@ -125,12 +125,13 @@ func (t *OwnerService) OwnerlList() *OwnerlListRes {
 		if len(*dataMap) == 0 && t.Supplier == "" && t.Heterotophy == "" && t.Agency == "" {
 		if len(*dataMap) == 0 && t.Supplier == "" && t.Heterotophy == "" && t.Agency == "" {
 			return olr
 			return olr
 		}
 		}
+		logx.Info(t.PositionId, " BuyerList over 。。。")
 		// 项目数量查询
 		// 项目数量查询
 		buyerArr := getBuyerArr(dataMap)
 		buyerArr := getBuyerArr(dataMap)
 		// 项目数量处理
 		// 项目数量处理
+		logx.Info(t.PositionId, " ProjectHandle start 。。。")
 		projectMap, connectionsNumber := t.ProjectHandle(buyerArr, businessStr, monitorBuyers)
 		projectMap, connectionsNumber := t.ProjectHandle(buyerArr, businessStr, monitorBuyers)
-		endTime := time.Now().Unix()
-		fmt.Println("用时时间:", endTime-startTime)
+		logx.Info(t.PositionId, " ProjectHandle over 。。。")
 		if len(*projectMap) == 0 {
 		if len(*projectMap) == 0 {
 			return olr
 			return olr
 		}
 		}
@@ -155,10 +156,9 @@ func (t *OwnerService) OwnerlList() *OwnerlListRes {
 			}
 			}
 		}
 		}
 		// 可介绍业主人脉处理
 		// 可介绍业主人脉处理
-		a3 := time.Now().Unix()
+		logx.Info(t.PositionId, " ConnectionsHandle start 。。。")
 		routeList := ConnectionsHandle(buyerIdArr, t.PositionId, false)
 		routeList := ConnectionsHandle(buyerIdArr, t.PositionId, false)
-		a4 := time.Now().Unix()
-		fmt.Println("组合数1111据", a4-a3)
+		logx.Info(t.PositionId, " ConnectionsHandle over 。。。")
 		updateReturnDataWithRoutes(olr.ReturnData, routeList)
 		updateReturnDataWithRoutes(olr.ReturnData, routeList)
 	}
 	}
 	if len(olr.ReturnData) > 0 {
 	if len(olr.ReturnData) > 0 {
@@ -235,6 +235,7 @@ func Findwinner(buyerArr []string) []map[string]interface{} {
 	args1 = append(args1, args1...)
 	args1 = append(args1, args1...)
 	//供应商  采购单位 供应商     招标代理机构  采购单位  招标代理机构  需要计算合作次数
 	//供应商  采购单位 供应商     招标代理机构  采购单位  招标代理机构  需要计算合作次数
 	winnerSql := `select zbtime,project_id,project_name,buyer_id,buyer,wr_id,wr,agency_id,agency from transaction_info_all ARRAY JOIN winner_id as wr_id,winner as wr where buyer_id in (` + wh1 + `) and LENGTH(winner)=LENGTH(winner_id) order by zbtime DESC,project_id DESC`
 	winnerSql := `select zbtime,project_id,project_name,buyer_id,buyer,wr_id,wr,agency_id,agency from transaction_info_all ARRAY JOIN winner_id as wr_id,winner as wr where buyer_id in (` + wh1 + `) and LENGTH(winner)=LENGTH(winner_id) order by zbtime DESC,project_id DESC`
+	logx.Info("Findwinner 合作 sql ", winnerSql, args1)
 	winnerArr := SupplierFindConnectionsHandle(winnerSql, args1...)
 	winnerArr := SupplierFindConnectionsHandle(winnerSql, args1...)
 	if winnerArr != nil && len(winnerArr) > 0 {
 	if winnerArr != nil && len(winnerArr) > 0 {
 		//企业联系人处理
 		//企业联系人处理
@@ -258,6 +259,7 @@ func Findwinner(buyerArr []string) []map[string]interface{} {
 		if len(entIdArr) > 0 {
 		if len(entIdArr) > 0 {
 			wh2, args2 := common.WhArgs(entIdArr)
 			wh2, args2 := common.WhArgs(entIdArr)
 			personSql := `select id,name as personName from ent_contact where id in (` + wh2 + `) ORDER by name`
 			personSql := `select id,name as personName from ent_contact where id in (` + wh2 + `) ORDER by name`
+			logx.Info("Findwinner 联系人 sql ", personSql, args2)
 			personArr := PersonFindConnectionsHandle(personSql, args2...)
 			personArr := PersonFindConnectionsHandle(personSql, args2...)
 			//联系人处理
 			//联系人处理
 			for _, v := range personArr {
 			for _, v := range personArr {
@@ -726,7 +728,7 @@ func (t *OwnerService) ProjectHandle(buyerArr []string, businessStr string, moni
 	}
 	}
 	countSql := fmt.Sprintf("select count(1) as count from (%s) b ", sqlStr)
 	countSql := fmt.Sprintf("select count(1) as count from (%s) b ", sqlStr)
 	sqlStr += fmt.Sprintf(" order by maxzbtime desc limit %d,%d", startIndex, t.PageSize)
 	sqlStr += fmt.Sprintf(" order by maxzbtime desc limit %d,%d", startIndex, t.PageSize)
-	logx.Info("查询列表sql", sqlStr, allArgs)
+	logx.Info(t.PositionId, " ProjectHandle sql ", sqlStr, allArgs)
 	//总数查询
 	//总数查询
 	ass := []BuyerAggStruct{}
 	ass := []BuyerAggStruct{}
 	rows, err1 := ClickhouseConn.Query(context.TODO(), sqlStr, allArgs...)
 	rows, err1 := ClickhouseConn.Query(context.TODO(), sqlStr, allArgs...)
@@ -756,7 +758,10 @@ func (t *OwnerService) ProjectHandle(buyerArr []string, businessStr string, moni
 			"buyerName": buyerName,
 			"buyerName": buyerName,
 		}
 		}
 	}
 	}
-	return projectMap, T.NetworkCom.Count(countSql, allArgs...)
+	logx.Info(t.PositionId, " ProjectHandle sql over 。。。", sqlStr, allArgs)
+	count := T.NetworkCom.Count(countSql, allArgs...)
+	logx.Info(t.PositionId, " ProjectHandle count over 。。。", sqlStr, allArgs)
+	return projectMap, count
 }
 }
 
 
 type BuyerAggStruct struct {
 type BuyerAggStruct struct {

+ 7 - 2
api/internal/service/plistService.go

@@ -80,10 +80,12 @@ func GetProjectList(req *types.ProjectListReq) *ProjectData {
 	if businessStr == "" {
 	if businessStr == "" {
 		return projectData
 		return projectData
 	}
 	}
+	logx.Info(req.PositionId, " GetProjectList start 。。。")
 	dataMap := BuyerList(req.PartyA, req.Intermediary, req.PositionId)
 	dataMap := BuyerList(req.PartyA, req.Intermediary, req.PositionId)
 	if len(*dataMap) == 0 && req.Supplier == "" && req.Heterotophy == "" && req.Agency == "" {
 	if len(*dataMap) == 0 && req.Supplier == "" && req.Heterotophy == "" && req.Agency == "" {
 		return projectData
 		return projectData
 	}
 	}
+	logx.Info(req.PositionId, " GetProjectList BuyerList over 。。。")
 	// 项目数量查询
 	// 项目数量查询
 	buyerArr := getBuyerArr(dataMap)
 	buyerArr := getBuyerArr(dataMap)
 	//preSales := preSalesStatus(req.PositionId)
 	//preSales := preSalesStatus(req.PositionId)
@@ -97,8 +99,8 @@ func GetProjectList(req *types.ProjectListReq) *ProjectData {
 	if ret, err := redis.GetNewBytes("newother", rkey); err == nil && ret != nil {
 	if ret, err := redis.GetNewBytes("newother", rkey); err == nil && ret != nil {
 		err = json.Unmarshal(*ret, &projectData)
 		err = json.Unmarshal(*ret, &projectData)
 	} else {
 	} else {
-		logx.Info("findSql: ", findSql, args)
-		logx.Info("countSql: ", countSql, args)
+		logx.Info(req.PositionId, " GetProjectList findSql ", findSql, args)
+		logx.Info(req.PositionId, " GetProjectList countSql ", countSql, args)
 		rows, err := T.ClickhouseConn.Query(context.TODO(), findSql, args...)
 		rows, err := T.ClickhouseConn.Query(context.TODO(), findSql, args...)
 		if err != nil {
 		if err != nil {
 			return projectData
 			return projectData
@@ -115,12 +117,15 @@ func GetProjectList(req *types.ProjectListReq) *ProjectData {
 			resultList = append(resultList, &project)
 			resultList = append(resultList, &project)
 		}
 		}
 		projectData.PList = resultList
 		projectData.PList = resultList
+		logx.Info(req.PositionId, " GetProjectList list over 。。。")
 		projectData.Count = T.NetworkCom.Count(countSql, args...)
 		projectData.Count = T.NetworkCom.Count(countSql, args...)
+		logx.Info(req.PositionId, " GetProjectList count over 。。。")
 		moreInfo(req, getIyProList(req.Intermediary, req.PositionId), projectData.PList) //  补充信息
 		moreInfo(req, getIyProList(req.Intermediary, req.PositionId), projectData.PList) //  补充信息
 		redis.Put("newother", rkey, projectData, T.NetworkCom.CacheTimeout())
 		redis.Put("newother", rkey, projectData, T.NetworkCom.CacheTimeout())
 	}
 	}
 	mmp := MonitorStatus(req.UserId) // 项目监控
 	mmp := MonitorStatus(req.UserId) // 项目监控
 	projectData.PList = filterData(req, projectData.PList, nil, mmp, true)
 	projectData.PList = filterData(req, projectData.PList, nil, mmp, true)
+	logx.Info(req.PositionId, " GetProjectList over 。。。")
 	totalPage := int(math.Ceil(float64(projectData.Count) / float64(req.PageSize)))
 	totalPage := int(math.Ceil(float64(projectData.Count) / float64(req.PageSize)))
 	if totalPage > req.PageNum {
 	if totalPage > req.PageNum {
 		projectData.HasNextPage = true
 		projectData.HasNextPage = true