wangchuanjin 9 mesi fa
parent
commit
c19aa2bf40
1 ha cambiato i file con 27 aggiunte e 3 eliminazioni
  1. 27 3
      api/internal/service/initNetwork.go

+ 27 - 3
api/internal/service/initNetwork.go

@@ -12,6 +12,10 @@ import (
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
+const (
+	InitNetworkMaxSize = 100
+)
+
 type ContactInfo struct {
 	Name  string
 	Phone string
@@ -37,9 +41,11 @@ func (i *InitNetwork) Init() {
 	array := []*Connection{}
 	ids := []string{}
 	idMap := map[string]bool{}
+	yearLimit := NetworkCom.ProjectYearLimit()
 	//①业主人脉:当前企业曾经合作过物业项目的采购单位的联系人作为业主人脉
+	index1 := 0
 	func() {
-		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT buyer,buyer_id from information.transaction_info_all prewhere has(winner,?)`, i.EntName)
+		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT buyer,buyer_id from information.transaction_info_all prewhere has(winner,?) and zbtime>?`, i.EntName, yearLimit)
 		if err != nil {
 			logx.Error(err)
 			return
@@ -65,9 +71,15 @@ func (i *InitNetwork) Init() {
 				Company_name: buyer,
 				Itype:        1,
 			})
+			index1++
+			if index1 == InitNetworkMaxSize {
+				break
+			}
 		}
 	}()
+	logx.Info("初始化设置业主人脉over。。。", index1)
 	//②甲异业渠道(人脉):“当前企业曾经合作过物业项目的采购单位的中标物业企业中”与当前企业不一样业态的企业的联系人列表
+	index2 := 0
 	func() {
 		if i.BusinessType == "" {
 			return
@@ -75,7 +87,7 @@ func (i *InitNetwork) Init() {
 		args := []interface{}{i.EntName, i.EntName}
 		wh, newArgs := util.WhArgs(strings.Split(i.BusinessType, ","))
 		args = append(args, newArgs...)
-		args = append(args, NetworkCom.ProjectYearLimit())
+		args = append(args, yearLimit)
 		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 prewhere has(winner,?) and buyer_id<>'') and wr<>? and LENGTH(winner)=LENGTH(winner_id) and hasAny(topscopeclass,[`+wh+`])=0 AND zbtime>?`, args...)
 		if err != nil {
 			logx.Error(err)
@@ -102,11 +114,17 @@ func (i *InitNetwork) Init() {
 				Company_name: winner,
 				Itype:        3,
 			})
+			index2++
+			if index2 == InitNetworkMaxSize {
+				break
+			}
 		}
 	}()
+	logx.Info("初始化设置甲异业渠道人脉over。。。", index2)
 	//③招标代理机构(人脉):当前企业曾经合作过的招标代理机构联系人信息
+	index3 := 0
 	func() {
-		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT agency,agency_id from information.transaction_info_all prewhere buyer=? or has(winner,?)`, i.EntName, i.EntName)
+		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT agency,agency_id from information.transaction_info_all prewhere (buyer=? or has(winner,?)) and zbtime>?`, i.EntName, i.EntName, yearLimit)
 		if err != nil {
 			logx.Error(err)
 			return
@@ -132,11 +150,17 @@ func (i *InitNetwork) Init() {
 				Company_name: agency,
 				Itype:        5,
 			})
+			index3++
+			if index3 == InitNetworkMaxSize {
+				break
+			}
 		}
 	}()
+	logx.Info("初始化设置招标代理机构人脉over。。。", index2)
 	newIds := []string{}
 	cis := map[string]*ContactInfo{}
 	cids := map[string]string{}
+	logx.Info("初始化设置总共企业数量", len(ids))
 	for _, v := range ids {
 		newIds = append(newIds, v)
 		if len(newIds) == C.BuyerBatch {