|
@@ -10,6 +10,7 @@ import (
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
|
"app.yhyue.com/moapp/jybase/encrypt"
|
|
|
elastic "app.yhyue.com/moapp/jybase/es"
|
|
|
+ "app.yhyue.com/moapp/jybase/redis"
|
|
|
T "bp.jydev.jianyu360.cn/CRM/networkManage/api/common"
|
|
|
"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/types"
|
|
|
"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
|
|
@@ -75,6 +76,28 @@ type Cooperate struct {
|
|
|
ZbTime int64
|
|
|
}
|
|
|
|
|
|
+type AggStruct struct {
|
|
|
+ Buckets []struct {
|
|
|
+ Key string `json:"key,omitempty"`
|
|
|
+ Doc_count int64 `json:"doc_count,omitempty"`
|
|
|
+ Amount_all struct {
|
|
|
+ Value float64 `json:"value,omitempty"`
|
|
|
+ } `json:"amount_all"`
|
|
|
+ EntId struct {
|
|
|
+ Buckets []struct {
|
|
|
+ Key string `json:"key,omitempty"`
|
|
|
+ Doc_count int64 `json:"doc_count,omitempty"`
|
|
|
+ } `json:"buckets"`
|
|
|
+ } `json:"ent_id"`
|
|
|
+ BuyerId struct {
|
|
|
+ Buckets []struct {
|
|
|
+ Key string `json:"key,omitempty"`
|
|
|
+ Doc_count int64 `json:"doc_count,omitempty"`
|
|
|
+ } `json:"buckets"`
|
|
|
+ } `json:"buyer_id"`
|
|
|
+ } `json:"buckets"`
|
|
|
+}
|
|
|
+
|
|
|
func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2, size_3, size_4 int64) {
|
|
|
pTmp := ProjectTmp{}
|
|
|
var err error
|
|
@@ -132,9 +155,8 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- rs1, rs2 := GetData(strings.Split(scopeClass, ","), pTmp.BuyerId)
|
|
|
- r1 := rs1[pTmp.BuyerId]
|
|
|
- r2 := rs2[pTmp.BuyerId]
|
|
|
+ r1 := GetWinnerData(strings.Split(scopeClass, ","), pTmp.BuyerId)
|
|
|
+ r2 := GetAgencyData(pTmp.BuyerId)
|
|
|
winners, agency := []string{}, []string{}
|
|
|
for _, m := range r1 {
|
|
|
winners = append(winners, common.ObjToString(m["name"]))
|
|
@@ -186,32 +208,15 @@ func GetPrList(req *types.CoopHistoryReq) (result []*ResultData, size_1, size_2,
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
-func GetData(scopeClass []string, bid string) (result1, result2 map[string][]map[string]interface{}) {
|
|
|
- result1, result2 = map[string][]map[string]interface{}{}, map[string][]map[string]interface{}{}
|
|
|
- type AggStruct struct {
|
|
|
- Buckets []struct {
|
|
|
- Key string `json:"key,omitempty"`
|
|
|
- Doc_count int64 `json:"doc_count,omitempty"`
|
|
|
- Amount_all struct {
|
|
|
- Value float64 `json:"value,omitempty"`
|
|
|
- } `json:"amount_all"`
|
|
|
- EntId struct {
|
|
|
- Buckets []struct {
|
|
|
- Key string `json:"key,omitempty"`
|
|
|
- Doc_count int64 `json:"doc_count,omitempty"`
|
|
|
- } `json:"buckets"`
|
|
|
- } `json:"ent_id"`
|
|
|
- BuyerId struct {
|
|
|
- Buckets []struct {
|
|
|
- Key string `json:"key,omitempty"`
|
|
|
- Doc_count int64 `json:"doc_count,omitempty"`
|
|
|
- } `json:"buckets"`
|
|
|
- } `json:"buyer_id"`
|
|
|
- } `json:"buckets"`
|
|
|
+func GetWinnerData(scopeClass []string, bid string) (result1 []map[string]interface{}) {
|
|
|
+ result1 = []map[string]interface{}{}
|
|
|
+ winnerKey := fmt.Sprintf("networkManage_coopHistory_winner_%s", common.GetMd5String(strings.Join(scopeClass, ",")+"_"+bid))
|
|
|
+ wb, err := redis.GetBytes("newother", winnerKey)
|
|
|
+ if err == nil {
|
|
|
+ json.Unmarshal(*wb, &result1)
|
|
|
+ return
|
|
|
}
|
|
|
m1 := make(map[string]interface{}) //采购单位-中标单位
|
|
|
- m2 := make(map[string]interface{}) //采购单位-代理机构
|
|
|
noIds := []string{}
|
|
|
if len(scopeClass) > 0 {
|
|
|
//同甲异态 中标企业
|
|
@@ -245,6 +250,34 @@ func GetData(scopeClass []string, bid string) (result1, result2 map[string][]map
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ idName := T.NetworkCom.GetEntIdByName(noIds)
|
|
|
+ for k, v := range m1 {
|
|
|
+ v1 := v.(map[string]interface{})
|
|
|
+ tmp := make(map[string]interface{})
|
|
|
+ tmp["name"] = k
|
|
|
+ nameId, _ := v1["nameId"].(string)
|
|
|
+ if nameId == "" {
|
|
|
+ nameId = idName[k]
|
|
|
+ }
|
|
|
+ tmp["nameId"] = nameId
|
|
|
+ tmp["coop_size"] = v1["count"]
|
|
|
+ tmp["coop_amount"] = v1["amount"]
|
|
|
+ result1 = append(result1, tmp)
|
|
|
+ }
|
|
|
+ redis.Put("newother", winnerKey, result1, T.C.CacheTimeOut)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func GetAgencyData(bid string) (result2 []map[string]interface{}) {
|
|
|
+ result2 = []map[string]interface{}{}
|
|
|
+ agencyKey := fmt.Sprintf("networkManage_coopHistory_agency_%s", bid)
|
|
|
+ wb, err := redis.GetBytes("newother", agencyKey)
|
|
|
+ if err == nil {
|
|
|
+ json.Unmarshal(*wb, &result2)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ m2 := make(map[string]interface{}) //采购单位-代理机构
|
|
|
+ noIds := []string{}
|
|
|
//代理机构
|
|
|
aggs1, _, _ := elastic.GetAggs(INDEX_1, INDEX_1, fmt.Sprintf(es_query1, strings.ReplaceAll(bid, ",", `","`)))
|
|
|
var m2Buckets = AggStruct{}
|
|
@@ -272,20 +305,6 @@ func GetData(scopeClass []string, bid string) (result1, result2 map[string][]map
|
|
|
}
|
|
|
}
|
|
|
idName := T.NetworkCom.GetEntIdByName(noIds)
|
|
|
- for k, v := range m1 {
|
|
|
- v1 := v.(map[string]interface{})
|
|
|
- tmp := make(map[string]interface{})
|
|
|
- tmp["name"] = k
|
|
|
- nameId, _ := v1["nameId"].(string)
|
|
|
- if nameId == "" {
|
|
|
- nameId = idName[k]
|
|
|
- }
|
|
|
- tmp["nameId"] = nameId
|
|
|
- tmp["coop_size"] = v1["count"]
|
|
|
- tmp["coop_amount"] = v1["amount"]
|
|
|
- buyerId, _ := v1["buyerId"].(string)
|
|
|
- result1[buyerId] = append(result1[buyerId], tmp)
|
|
|
- }
|
|
|
for k, v := range m2 {
|
|
|
v1 := v.(map[string]interface{})
|
|
|
tmp := make(map[string]interface{})
|
|
@@ -297,9 +316,9 @@ func GetData(scopeClass []string, bid string) (result1, result2 map[string][]map
|
|
|
tmp["nameId"] = nameId
|
|
|
tmp["coop_size"] = v1["count"]
|
|
|
tmp["coop_amount"] = v1["amount"]
|
|
|
- buyerId, _ := v1["buyerId"].(string)
|
|
|
- result2[buyerId] = append(result2[buyerId], tmp)
|
|
|
+ result2 = append(result2, tmp)
|
|
|
}
|
|
|
+ redis.Put("newother", agencyKey, result2, T.C.CacheTimeOut)
|
|
|
return
|
|
|
}
|
|
|
|