瀏覽代碼

feat:更换表名

wangchuanjin 9 月之前
父節點
當前提交
6c8b209082

+ 1 - 1
api/internal/logic/prpnameasslogic.go

@@ -33,7 +33,7 @@ func (l *PrPnameAssLogic) PrPnameAss(req *types.PnameAssReq) (resp *types.Reply,
 	resp = &types.Reply{}
 	if req.ProjectName != "" {
 		esq := `{"query": {"bool": {"must": [{"match": {"project_name.pname": "` + req.ProjectName + `" }}]}}}`
-		binfo := GetAllByNgram("transaction_info", "transaction_info", esq, "", "", findfields, 0, 10, 0, false)
+		binfo := GetAllByNgram("transaction_info_all", "transaction_info_all", esq, "", "", findfields, 0, 10, 0, false)
 		if binfo != nil && len(*binfo) > 0 {
 			resp.Error_code = 0
 			resp.Data = *binfo

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

@@ -18,11 +18,11 @@ import (
 )
 
 var (
-	INDEX_1   = "transaction_info"
-	sql_2_0   = `SELECT buyer, buyer_id, agency, agency_id, property_form FROM information.transaction_info WHERE project_id = ?`
-	sql_2_2   = `SELECT buyer, buyer_id, agency, agency_id, property_form FROM information.transaction_info WHERE has(info_ids, ?)`
-	sql_2_1   = `SELECT project_id, project_name, zbtime FROM information.transaction_info WHERE buyer_id = ? AND has(winner, ?) ORDER BY zbtime DESC`
-	sql_2_1_1 = `SELECT project_id, project_name, zbtime FROM information.transaction_info WHERE buyer_id = ? AND agency = ? ORDER BY zbtime DESC`
+	INDEX_1   = "transaction_info_all"
+	sql_2_0   = `SELECT buyer, buyer_id, agency, agency_id, property_form FROM information.transaction_info_all WHERE project_id = ?`
+	sql_2_2   = `SELECT buyer, buyer_id, agency, agency_id, property_form FROM information.transaction_info_all WHERE has(info_ids, ?)`
+	sql_2_1   = `SELECT project_id, project_name, zbtime FROM information.transaction_info_all WHERE buyer_id = ? AND has(winner, ?) ORDER BY zbtime DESC`
+	sql_2_1_1 = `SELECT project_id, project_name, zbtime FROM information.transaction_info_all WHERE buyer_id = ? AND agency = ? ORDER BY zbtime DESC`
 	//sql_2_2    = `select DISTINCT  b.company_id,b.company_name,a.relate_id,a.relate_name,b.contact_person   from  connection_introduce a  INNER JOIN connection b on  a.position_id= ? and a.connection_id=b.id  and   a.relate_Id = ? and  a.itype =1  and  b.itype=4 and  b.status=1 `
 	//sql_2_3    = `select a.a_id as a_id, a.b_id as b_id, a.a_name as a_name, a.b_name as b_name, a.code as code, c.legal_person as c_person, d.legal_person d_person from crm.ent_map_code a left join ent_info c on (a.a_id = ? or a.b_id = ? ) and a.code in('0101', '0201') and a.a_id = c.id left join ent_info d on (a.a_id = ? or a.b_id = ? ) and a.code in('0101', '0201') and a.b_id = d.id where (a.a_id = ? or a.b_id = ? ) and a.code in('0101', '0201')`
 	es_query  = `{"query": {"bool": {"must": [{"terms": {"buyer_id": ["%s"]}},{"exists": {"field": "winner_id"}}],"must_not": {"terms": {"topscopeclass": ["%s"]}}}},"aggs": {"winner_count": {"terms": {"field": "winner","size": 1000,"order": {"_count": "desc"}},"aggs": {"amount_all": {"sum": {"field": "project_money"}},"ent_id": {"terms": {"field": "winner_id"}},"buyer_id": {"terms": {"field": "buyer_id"}}}}},"size": 1}`
@@ -355,10 +355,10 @@ func LastTimeCoop(buyerId, ent, stype string) (bool, int64) {
 	zbtime := int64(0)
 	near := false
 	if stype == "adiffb" {
-		sql := `SELECT zbtime FROM information.transaction_info WHERE buyer_id = ? AND has(winner, ?) ORDER BY zbtime DESC LIMIT 1`
+		sql := `SELECT zbtime FROM information.transaction_info_all WHERE buyer_id = ? AND has(winner, ?) ORDER BY zbtime DESC LIMIT 1`
 		_ = T.ClickhouseConn.QueryRow(context.TODO(), sql, buyerId, ent).Scan(&zbtime)
 	} else if stype == "agency" {
-		sql := `SELECT zbtime FROM information.transaction_info WHERE buyer_id = ? AND agency = ? ORDER BY zbtime DESC LIMIT 1`
+		sql := `SELECT zbtime FROM information.transaction_info_all WHERE buyer_id = ? AND agency = ? ORDER BY zbtime DESC LIMIT 1`
 		_ = T.ClickhouseConn.QueryRow(context.TODO(), sql, buyerId, ent).Scan(&zbtime)
 	}
 	timestamp := time.Now().AddDate(-3, 0, 0).Unix()
@@ -418,7 +418,7 @@ func LastTimeCoopBath(positionId int64, buyerId string, winners, agencys []strin
 		if err == nil {
 			json.Unmarshal(*wb, &adiffb)
 		} else {
-			sql := `SELECT winner_one,max(zbtime) FROM information.transaction_info ARRAY JOIN winner AS winner_one WHERE buyer_id=? AND hasAny(winner,[%s])) group by winner_one`
+			sql := `SELECT winner_one,max(zbtime) FROM information.transaction_info_all ARRAY JOIN winner AS winner_one WHERE buyer_id=? AND hasAny(winner,[%s])) group by winner_one`
 			wns := []string{}
 			for _, v := range winners {
 				wns = append(wns, v)
@@ -439,7 +439,7 @@ func LastTimeCoopBath(positionId int64, buyerId string, winners, agencys []strin
 		if err == nil {
 			json.Unmarshal(*wb, &agency)
 		} else {
-			sql := `SELECT agency,max(zbtime) FROM information.transaction_info WHERE buyer_id=? AND agency in (%s) group by agency`
+			sql := `SELECT agency,max(zbtime) FROM information.transaction_info_all WHERE buyer_id=? AND agency in (%s) group by agency`
 			acs := []string{}
 			for _, v := range agencys {
 				acs = append(acs, v)

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

@@ -37,7 +37,7 @@ func (i *InitNetwork) Init() {
 	ids := []string{}
 	//①业主人脉:当前企业曾经合作过物业项目的采购单位的联系人作为业主人脉
 	func() {
-		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT buyer,buyer_id from information.transaction_info where has(winner,?)`, i.EntName)
+		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT buyer,buyer_id from information.transaction_info_all where has(winner,?)`, i.EntName)
 		if err != nil {
 			logx.Error(err)
 			return
@@ -72,7 +72,7 @@ func (i *InitNetwork) Init() {
 		args := []interface{}{i.EntName}
 		wh, newArgs := util.WhArgs(strings.Split(i.BusinessType, ","))
 		args = append(args, newArgs...)
-		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT winner_id,winner from information.transaction_info WHERE buyer_id IN (SELECT buyer_id from information.transaction_info WHERE has(winner,?) and buyer_id<>'') AND hasAny(topscopeclass,[`+wh+`])`, args...)
+		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT winner_id,winner from information.transaction_info_all WHERE buyer_id IN (SELECT buyer_id from information.transaction_info_all WHERE has(winner,?) and buyer_id<>'') AND hasAny(topscopeclass,[`+wh+`])`, args...)
 		if err != nil {
 			logx.Error(err)
 			return
@@ -105,7 +105,7 @@ func (i *InitNetwork) Init() {
 	}()
 	//③招标代理机构(人脉):当前企业曾经合作过的招标代理机构联系人信息
 	func() {
-		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT agency,agency_id from information.transaction_info where buyer=? or has(winner,?)`, i.EntName, i.EntName)
+		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT agency,agency_id from information.transaction_info_all where buyer=? or has(winner,?)`, i.EntName, i.EntName)
 		if err != nil {
 			logx.Error(err)
 			return

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

@@ -244,7 +244,7 @@ func (n *network) Associate(in *types.AssociateReq) (reply *types.Reply) {
 			args := []interface{}{in.EntName}
 			wh, newArgs := NetworkCom.WhArgs(businessType)
 			args = append(args, newArgs...)
-			q := `select DISTINCT winner_id,winner from information.transaction_info where buyer_id in (select buyer_id from information.transaction_info where has(winner, ?) and buyer_id<>'') and hasAny(topscopeclass,[` + wh + `])=0 ORDER BY project_id`
+			q := `select DISTINCT winner_id,winner from information.transaction_info_all where buyer_id in (select buyer_id from information.transaction_info_all where has(winner, ?) and buyer_id<>'') and hasAny(topscopeclass,[` + wh + `])=0 ORDER BY project_id`
 			rows, err := ClickhouseConn.Query(context.Background(), q, args...)
 			if err != nil {
 				logx.Error(err)
@@ -896,7 +896,7 @@ func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork, entM
 		return result
 	}
 	wh, args := NetworkCom.WhArgs(values)
-	q := `select buyer_id,count(project_id) AS project_count,sum(project_money) AS project_amount,groupUniqArray(project_id) from information.transaction_info where buyer_id in (` + wh + `)`
+	q := `select buyer_id,count(project_id) AS project_count,sum(project_money) AS project_amount,groupUniqArray(project_id) from information.transaction_info_all where buyer_id in (` + wh + `)`
 	if len(businessType) > 0 {
 		newWh, newArgs := NetworkCom.WhArgs(businessType)
 		q += ` and hasAny(topscopeclass,[` + newWh + `])`
@@ -961,7 +961,7 @@ func (n *network) Introduce_Supplier(values []string, entMonitor map[string]bool
 	repeat := map[string]bool{}
 	whRepeat := map[string]map[string]bool{}
 	buyers := []string{}
-	q := `select winner_id,buyer_id,buyer from information.transaction_info where hasAny(winner_id,[` + wh + `]) and project_bidstatus>1`
+	q := `select winner_id,buyer_id,buyer from information.transaction_info_all where hasAny(winner_id,[` + wh + `]) and project_bidstatus>1`
 	rows, err := ClickhouseConn.Query(context.Background(), q, args...)
 	if err != nil {
 		logx.Error(err)
@@ -1011,7 +1011,7 @@ func (n *network) Introduce_Agency(values []string, entMonitor map[string]bool,
 		return map[string]*projectInfo{}
 	}
 	wh, args := NetworkCom.WhArgs(values)
-	q := `select DISTINCT agency_id,buyer_id,buyer from information.transaction_info where agency_id in (` + wh + `) and project_bidstatus>1`
+	q := `select DISTINCT agency_id,buyer_id,buyer from information.transaction_info_all where agency_id in (` + wh + `) and project_bidstatus>1`
 	rows, err := ClickhouseConn.Query(context.Background(), q, args...)
 	if err != nil {
 		logx.Error(err)
@@ -1056,7 +1056,7 @@ func (n *network) Introduce_Middleman(values []string, entMonitor map[string]boo
 		return result
 	}
 	wh, args := NetworkCom.WhArgs(values)
-	q := `select DISTINCT project_id,project_money from information.transaction_info where project_id in (` + wh + `) and project_bidstatus>1`
+	q := `select DISTINCT project_id,project_money from information.transaction_info_all where project_id in (` + wh + `) and project_bidstatus>1`
 	if len(businessType) > 0 {
 		newWh, newArgs := NetworkCom.WhArgs(businessType)
 		q += ` and hasAny(topscopeclass,[` + newWh + `])`
@@ -1162,7 +1162,7 @@ func (n *network) BuyerProjectInfo(ids []string, businessType []string) map[stri
 		return vm
 	}
 	wh, args := NetworkCom.WhArgs(ids)
-	q := `select buyer_id,count(DISTINCT project_id) AS project_count,sum(project_money) AS project_amount,groupUniqArray(project_id) from information.transaction_info where buyer_id in (` + wh + `) and project_bidstatus>1`
+	q := `select buyer_id,count(DISTINCT project_id) AS project_count,sum(project_money) AS project_amount,groupUniqArray(project_id) from information.transaction_info_all where buyer_id in (` + wh + `) and project_bidstatus>1`
 	if len(businessType) > 0 {
 		newWh, newArgs := NetworkCom.WhArgs(businessType)
 		q += ` and hasAny(topscopeclass,[` + newWh + `])`

+ 7 - 7
api/internal/service/owner.go

@@ -294,7 +294,7 @@ func Findwinner(buyerArr []string) []map[string]interface{} {
 			entId,
 			'supplier' as entType
 from
-			transaction_info ARRAY
+			transaction_info_all ARRAY
 JOIN winner_id as entId
 where
 		buyer_id in (%s)
@@ -308,7 +308,7 @@ UNION ALL
 			agency_id as entId,
 			'agent' as  entType
 from
-			transaction_info
+			transaction_info_all
 where
 		buyer_id in (%s) and  agency_id!='') order by  zbtime DESC,project_id DESC   `, strings.Join(buyerArr, ","), strings.Join(buyerArr, ","))
 	winnerArr := SupplierFindConnectionsHandle(winnerSql)
@@ -740,7 +740,7 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
 		}
 	}
 	if len(findInSetArr) > 0 {
-		sqlStr := fmt.Sprintf(`SELECT buyer_id,buyer FROM transaction_info where  hasAny(winner_id,[%s])    `, strings.Join(findInSetArr, ","))
+		sqlStr := fmt.Sprintf(`SELECT buyer_id,buyer FROM transaction_info_all where  hasAny(winner_id,[%s])    `, strings.Join(findInSetArr, ","))
 		FindHandle(sqlStr, dataMap, "supplier")
 	}
 	//同甲异业
@@ -753,7 +753,7 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
 		}
 	}
 	if len(findheterotophyArr) > 0 {
-		sqlStr := fmt.Sprintf(`SELECT buyer_id,buyer FROM transaction_info where  hasAny(winner_id,[%s])    `, strings.Join(findheterotophyArr, ","))
+		sqlStr := fmt.Sprintf(`SELECT buyer_id,buyer FROM transaction_info_all where  hasAny(winner_id,[%s])    `, strings.Join(findheterotophyArr, ","))
 		FindHandle(sqlStr, dataMap, "adiffb")
 	}
 	//中间人
@@ -779,7 +779,7 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
 		for _, s := range strings.Split(agency, ",") {
 			agencyArr = append(agencyArr, fmt.Sprintf("'%s'", s))
 		}
-		sqlStr := fmt.Sprintf(`SELECT  buyer_id,buyer FROM transaction_info  where agency_id in (%s) `, strings.Join(agencyArr, ","))
+		sqlStr := fmt.Sprintf(`SELECT  buyer_id,buyer FROM transaction_info_all  where agency_id in (%s) `, strings.Join(agencyArr, ","))
 		FindHandle(sqlStr, dataMap, "agency")
 	}
 	return dataMap
@@ -1065,14 +1065,14 @@ func (t *OwnerService) OwnerCooperate() []map[string]interface{} {
 			project_name
 			
 		FROM
-			transaction_info     
+			transaction_info_all     
 		ARRAY 
 		JOIN winner_id  as  winnerId  
 		where  buyer_id= '%s' and  winnerId='%s' order by  zbtime DESC,project_id DESC `, t.BuyerId, t.WinnerId)
 		dataArr = TimeFindConnectionsHandle(supplierSql)
 	} else if t.CooperateType == "agency" {
 		//代理机构
-		agentSql := fmt.Sprintf(`select  zbtime,project_id,project_name  from   transaction_info  where  buyer_id ='%s' and  agency_id ='%s' order by  zbtime DESC,project_id DESC   `, t.BuyerId, t.WinnerId)
+		agentSql := fmt.Sprintf(`select  zbtime,project_id,project_name  from   transaction_info_all  where  buyer_id ='%s' and  agency_id ='%s' order by  zbtime DESC,project_id DESC   `, t.BuyerId, t.WinnerId)
 		dataArr = TimeFindConnectionsHandle(agentSql)
 	}
 	if dataArr != nil && len(dataArr) > 0 {

+ 5 - 5
api/internal/service/plistService.go

@@ -18,7 +18,7 @@ import (
 )
 
 const (
-	sql_1 = `SELECT buyer_id, count(1) as count FROM information.transaction_info WHERE buyer_id in (%s) GROUP BY buyer_id`
+	sql_1 = `SELECT buyer_id, count(1) as count FROM information.transaction_info_all WHERE buyer_id in (%s) GROUP BY buyer_id`
 	sql_2 = `SELECT relate_id, is_handle, is_ignore, is_create FROM crm.connection_status WHERE position_id = ? AND itype = 2`
 	sql_3 = `SELECT * FROM crm.connection WHERE company_id in (%s) AND status = 1`
 	sql_4 = `SELECT id, s_id FROM base_service.follow_project_monitor WHERE s_userid = ?`
@@ -269,11 +269,11 @@ func getQuerySql(req *types.ProjectListReq, isPage bool, buyerArr, plist []strin
 	querys = append(querys, fmt.Sprintf(" a.project_bidstatus in (%s) ", "2,3,4"))
 	findSql = "select a.project_id, a.project_name, a.business_type, a.buyer, a.buyer_id, a.area, a.city, a.district, a.zbtime, a.endtime, a.project_money, a.info_id, a.information_id, a.info_ids "
 	if len(querys) > 0 {
-		countSql = fmt.Sprintf("select count(1) from %s a where %s ", "information.transaction_info", strings.Join(querys, " and "))
-		findSql = fmt.Sprintf("%s from %s  a  where  %s order by zbtime desc", findSql, "information.transaction_info", strings.Join(querys, " and "))
+		countSql = fmt.Sprintf("select count(1) from %s a where %s ", "information.transaction_info_all", strings.Join(querys, " and "))
+		findSql = fmt.Sprintf("%s from %s  a  where  %s order by zbtime desc", findSql, "information.transaction_info_all", strings.Join(querys, " and "))
 	} else {
-		countSql = fmt.Sprintf("select count(1) from %s a ", "information.transaction_info")
-		findSql = fmt.Sprintf("%s from %s a order by zbtime", findSql, "information.transaction_info")
+		countSql = fmt.Sprintf("select count(1) from %s a ", "information.transaction_info_all")
+		findSql = fmt.Sprintf("%s from %s a order by zbtime", findSql, "information.transaction_info_all")
 	}
 	if isPage {
 		findSql += fmt.Sprintf(" limit %d,%d", (req.PageNum-1)*req.PageSize, req.PageSize)