소스 검색

feat:xiugai

wangchuanjin 9 달 전
부모
커밋
e7d8de1dc4
4개의 변경된 파일15개의 추가작업 그리고 16개의 파일을 삭제
  1. 3 2
      api/etc/networkmanage.yaml
  2. 2 1
      api/internal/config/config.go
  3. 9 12
      api/internal/service/initNetwork.go
  4. 1 1
      api/internal/service/network.go

+ 3 - 2
api/etc/networkmanage.yaml

@@ -7,9 +7,10 @@ Gateway:
   Etcd:
     - 127.0.0.1:2379
 CacheTimeOut: "01:00"
-BuyerBatch: 200
+SelectBatchSize: 200
 ExportIdCachaPoolSize: 3
-ProjectYearLimit: 3
+ProjectYearLimit: 13
+InitNetworkMaxSize: 50
 EntNameList: ["思特威(上海)电子科技股份有限公司","浙江宇视科技有限公司","广州敏视数码科技有限公司","安徽创世科技股份有限公司","深圳市同为数码科技股份有限公司",
               "上海为旌科技有限公司","天地伟业技术有限公司","华为技术有限公司","安徽清新互联信息科技有限公司","杭州数尔安防科技股份有限公司","天津中安视通科技有限公司",
               "深圳市高斯贝尔家居智能电子有限公司","广州派宝智能安防科技有限公司","厦门力鼎光电股份有限公司","深圳市江波龙电子股份有限公司","南京恩博科技有限公司",

+ 2 - 1
api/internal/config/config.go

@@ -12,10 +12,11 @@ type Config struct {
 		Etcd       []string
 	}
 	CacheTimeOut          string
-	BuyerBatch            int
+	SelectBatchSize       int
 	ExportIdCachaPoolSize int
 	ProjectYearLimit      int
 	EntNameList           []string
+	InitNetworkMaxSize    int
 }
 
 type Db struct {

+ 9 - 12
api/internal/service/initNetwork.go

@@ -12,10 +12,6 @@ import (
 	"github.com/zeromicro/go-zero/core/logx"
 )
 
-const (
-	InitNetworkMaxSize = 100
-)
-
 type ContactInfo struct {
 	Name  string
 	Phone string
@@ -45,7 +41,7 @@ func (i *InitNetwork) Init() {
 	//①业主人脉:当前企业曾经合作过物业项目的采购单位的联系人作为业主人脉
 	index1 := 0
 	func() {
-		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT buyer,buyer_id from information.transaction_info_all prewhere has(winner,?) and zbtime>?`, i.EntName, yearLimit)
+		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT buyer,buyer_id from information.transaction_info_all prewhere has(winner,?) and zbtime>? order by zbtime desc limit ?`, i.EntName, yearLimit, C.InitNetworkMaxSize)
 		if err != nil {
 			logx.Error(err)
 			return
@@ -72,7 +68,7 @@ func (i *InitNetwork) Init() {
 				Itype:        1,
 			})
 			index1++
-			if index1 == InitNetworkMaxSize {
+			if index1 == C.InitNetworkMaxSize {
 				break
 			}
 		}
@@ -88,7 +84,8 @@ func (i *InitNetwork) Init() {
 		wh, newArgs := util.WhArgs(strings.Split(i.BusinessType, ","))
 		args = append(args, newArgs...)
 		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...)
+		args = append(args, C.InitNetworkMaxSize)
+		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 wr_id<>'' AND zbtime>? order by zbtime desc limit ?`, args...)
 		if err != nil {
 			logx.Error(err)
 			return
@@ -115,7 +112,7 @@ func (i *InitNetwork) Init() {
 				Itype:        3,
 			})
 			index2++
-			if index2 == InitNetworkMaxSize {
+			if index2 == C.InitNetworkMaxSize {
 				break
 			}
 		}
@@ -124,7 +121,7 @@ func (i *InitNetwork) Init() {
 	//③招标代理机构(人脉):当前企业曾经合作过的招标代理机构联系人信息
 	index3 := 0
 	func() {
-		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)
+		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT agency,agency_id from information.transaction_info_all prewhere (buyer=? or has(winner,?)) and agency<>'' and agency_id<>'' and zbtime>? order by zbtime desc limit ?`, i.EntName, i.EntName, yearLimit, C.InitNetworkMaxSize)
 		if err != nil {
 			logx.Error(err)
 			return
@@ -151,19 +148,19 @@ func (i *InitNetwork) Init() {
 				Itype:        5,
 			})
 			index3++
-			if index3 == InitNetworkMaxSize {
+			if index3 == C.InitNetworkMaxSize {
 				break
 			}
 		}
 	}()
-	logx.Info("初始化设置招标代理机构人脉over。。。", index2)
+	logx.Info("初始化设置招标代理机构人脉over。。。", index3)
 	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 {
+		if len(newIds) == C.SelectBatchSize {
 			for kk, vv := range i.GetContactInfo(newIds) {
 				cis[kk] = vv
 			}

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

@@ -1299,7 +1299,7 @@ func (n *network) BuyerProjectInfo(ids []string, businessType []string) map[stri
 		}
 		m[v] = true
 		newIds = append(newIds, v)
-		if len(newIds) == C.BuyerBatch {
+		if len(newIds) == C.SelectBatchSize {
 			n.BuyerProjectInfoBatch(newIds, businessType, vm)
 			newIds = []string{}
 		}