wangchuanjin 9 hónapja
szülő
commit
dba8627367

+ 6 - 0
api/common/network.go

@@ -125,3 +125,9 @@ func (n *networkCom) EntMonitor(userId string) map[string]bool {
 func (n *networkCom) ProjectYearLimit() int64 {
 	return time.Now().AddDate(-C.ProjectYearLimit, 0, 0).Unix()
 }
+
+//最近三年
+func (n *networkCom) CacheTimeout() int {
+	now := time.Now()
+	return int(time.Date(now.Year(), now.Month(), now.Day(), IntAll(strings.Split(C.CacheTimeOut, ":")[0]), IntAll(strings.Split(C.CacheTimeOut, ":")[1]), 0, 0, time.Local).AddDate(0, 1, 0).Unix() - now.Unix())
+}

+ 2 - 1
api/etc/networkmanage.yaml

@@ -6,8 +6,9 @@ Gateway:
   ServerCode: networkManage
   Etcd:
     - 127.0.0.1:2379
-CacheTimeOut: 600
+CacheTimeOut: "01:00"
 BuyerBatch: 500
+ExportIdCachaPoolSize: 3
 ProjectYearLimit: 3
 EntNameList: ["思特威(上海)电子科技股份有限公司","浙江宇视科技有限公司","广州敏视数码科技有限公司","安徽创世科技股份有限公司","深圳市同为数码科技股份有限公司",
               "上海为旌科技有限公司","天地伟业技术有限公司","华为技术有限公司","安徽清新互联信息科技有限公司","杭州数尔安防科技股份有限公司","天津中安视通科技有限公司",

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

@@ -185,7 +185,7 @@ func GetPrList(req *types.CoopHistoryReq) *PrListRes {
 			prListRes.Result = append(prListRes.Result, &tmp)
 		}
 	}
-	redis.Put("newother", redisKey, prListRes, T.C.CacheTimeOut)
+	redis.Put("newother", redisKey, prListRes, T.NetworkCom.CacheTimeout())
 	return prListRes
 }
 func GetWinnerData(scopeClass string, bid string) []AggStruct {
@@ -389,7 +389,7 @@ func LastTimeCoopBath(positionId int64, buyerId string, winners, agencys []strin
 			if len(wns) > 0 {
 				toSearch(1, sql, wns)
 			}
-			redis.Put("newother", key, adiffb, T.C.CacheTimeOut)
+			redis.Put("newother", key, adiffb, T.NetworkCom.CacheTimeout())
 		}
 	}
 	if len(agencys) > 0 {
@@ -410,7 +410,7 @@ func LastTimeCoopBath(positionId int64, buyerId string, winners, agencys []strin
 			if len(acs) > 0 {
 				toSearch(2, sql, acs)
 			}
-			redis.Put("newother", key, agency, T.C.CacheTimeOut)
+			redis.Put("newother", key, agency, T.NetworkCom.CacheTimeout())
 		}
 	}
 	return adiffb, agency

+ 26 - 23
api/internal/service/network.go

@@ -8,6 +8,7 @@ import (
 	"math"
 	"sort"
 	"strings"
+	"sync"
 	"time"
 
 	. "app.yhyue.com/moapp/jybase/common"
@@ -374,7 +375,7 @@ func (n *network) AllProject(in *types.AllprojectReq) (reply *types.Reply) {
 			json.Unmarshal(*rbt, &aio)
 		} else {
 			aio = n.AllIntroduceOwner(sqlAppend1, "", args, true, businessType)
-			redis.Put("newother", key, aio, C.CacheTimeOut)
+			redis.Put("newother", key, aio, NetworkCom.CacheTimeout())
 		}
 		firstparty = aio.Firstparty
 		firstpartyChild = aio.FirstpartyNetwork
@@ -758,13 +759,12 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 	redisKey := fmt.Sprintf(NetworkManageList, in.PositionId, GetMd5String(fmt.Sprintf("%+v", in)))
 	aio := &introduceOwnerProject{}
 	aioByte, aioErr := redis.GetNewBytes("newother", redisKey)
+	timeOut := NetworkCom.CacheTimeout()
 	if aioErr == nil && aioByte != nil {
-		logx.Info("-----3333---")
 		json.Unmarshal(*aioByte, &aio)
 	} else {
-		logx.Info("--------")
 		aio = n.AllIntroduceOwner(sqlAppend1, sqlAppend2, args, isTjProject, businessType)
-		redis.Put("newother", redisKey, aio, C.CacheTimeOut)
+		redis.Put("newother", redisKey, aio, timeOut)
 	}
 	entMonitor := NetworkCom.EntMonitor(in.UserId)
 	for _, v := range aio.Networks {
@@ -891,24 +891,6 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 				continue
 			}
 		}
-		export_url := ""
-		if len(export_id) > 0 {
-			exportIdRepeat := map[string]bool{}
-			exportId := ""
-			for _, v := range export_id {
-				if exportIdRepeat[v] {
-					continue
-				}
-				exportIdRepeat[v] = true
-				if exportId != "" {
-					exportId += ","
-				}
-				exportId += v
-			}
-			md5Id := GetMd5String(exportId)
-			redis.Put("newother", fmt.Sprintf("network_export_%s", md5Id), exportId, 259200)
-			export_url = "/subscribepay/network/projectExport?version=1&export_id=" + md5Id
-		}
 		url := ""
 		if v.Qyxy_id != "" && (jump_type == "supplier" || jump_type == "adiffb") {
 			url = "/swordfish/page_big_pc/ent_portrait/" + encrypt.EncodeArticleId2ByCheck(v.Qyxy_id)
@@ -928,9 +910,9 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 			"expect_amount": RetainDecimal(expect_amount/10000, 2),
 			"project_count": project_count,
 			"create_time":   v.Create_time,
-			"export_url":    export_url,
 			"url":           url,
 			"id":            v.Id,
+			"export_id":     strings.Join(export_id, ","),
 		})
 	}
 	csList := &ComSortList{
@@ -962,6 +944,27 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 	} else {
 		finalList = csList.List
 	}
+	pool := make(chan bool, C.ExportIdCachaPoolSize)
+	wait := &sync.WaitGroup{}
+	for _, v := range finalList {
+		exportId := ObjToString((*v)["export_id"])
+		md5Id := GetMd5String(exportId)
+		(*v)["export_url"] = "/subscribepay/network/projectExport?version=1&export_id=" + md5Id
+		delete(*v, "export_id")
+		pool <- true
+		wait.Add(1)
+		go func(md5IdNew, exportIdNew string) {
+			defer func() {
+				<-pool
+				wait.Done()
+			}()
+			key := fmt.Sprintf("network_export_%s", md5IdNew)
+			if ok, _ := redis.Exists("newother", key); !ok {
+				redis.Put("newother", key, exportIdNew, timeOut)
+			}
+		}(md5Id, exportId)
+	}
+	wait.Wait()
 	total_page := int64(math.Ceil(float64(count) / float64(in.Page_size)))
 	return &types.Reply{
 		Data: map[string]interface{}{

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

@@ -169,7 +169,7 @@ func (t *OwnerService) OwnerlList() *OwnerlListRes {
 				olr.ReturnData[k].IsMonitor = false
 			}
 		}
-		redis.Put("newother", listKey, olr, C.CacheTimeOut)
+		redis.Put("newother", listKey, olr, NetworkCom.CacheTimeout())
 	}
 	// 返回数据组装
 	return olr

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

@@ -117,7 +117,7 @@ func GetProjectList(req *types.ProjectListReq) *ProjectData {
 		projectData.PList = resultList
 		projectData.Count = T.NetworkCom.Count(countSql, args...)
 		moreInfo(req, getIyProList(req.Intermediary, req.PositionId), projectData.PList) //  补充信息
-		redis.Put("newother", rkey, projectData, T.C.CacheTimeOut)
+		redis.Put("newother", rkey, projectData, T.NetworkCom.CacheTimeout())
 	}
 	mmp := MonitorStatus(req.UserId) // 项目监控
 	projectData.PList = filterData(req, projectData.PList, nil, mmp, true)