wangshan преди 1 година
родител
ревизия
4a89be9137
променени са 4 файла, в които са добавени 25 реда и са изтрити 105 реда
  1. 1 0
      internal/consts/consts.go
  2. 3 2
      internal/dao/internal/offline.go
  3. 14 14
      internal/dao/internal/userTask.go
  4. 7 89
      utility/userTask.go

+ 1 - 0
internal/consts/consts.go

@@ -24,6 +24,7 @@ const (
 )
 
 var (
+	ReportCanceledKey = "marketAnalysisCanceled_%s"
 	//项目规模分布
 	ProjectScale = []struct {
 		Key  string

+ 3 - 2
internal/dao/internal/offline.go

@@ -21,8 +21,9 @@ func NewOfflineDao() *OfflineInfo {
 // 查看是否有需要处理的离线数据
 func (o *OfflineInfo) OfflineData() ([]*AnalyzeTask, error) {
 	queryMap := map[string]interface{}{
-		"i_state": 0,
-		"i_del":   map[string]interface{}{"$ne": 1},
+		"i_state":   0,                                //未生成
+		"i_offline": 1,                                //离线生成
+		"i_del":     map[string]interface{}{"$ne": 1}, //未删除
 	}
 	res, _ := do.Mgo.Find(o.Table, queryMap, `{"l_createTime":-1}`, nil, false, -1, -1)
 	if res == nil || len(*res) == 0 {

+ 14 - 14
internal/dao/internal/userTask.go

@@ -850,7 +850,7 @@ func (ut *UserTask) DataCollation() {
 					//del cache
 					go utility.DelRedisInfo(redisKey)
 				} else {
-					g.Log().Info(model.Ctx, "项目数量TOP3客户类型的重点中标单位 err:", err.Error(), v.Name)
+					g.Log().Info(model.Ctx, "项目数量TOP3客户类型的重点中标单位 err:", err, v.Name)
 				}
 			}
 		}
@@ -879,7 +879,7 @@ func (ut *UserTask) DataCollation() {
 					//del cache
 					go utility.DelRedisInfo(redisKey)
 				} else {
-					g.Log().Info(model.Ctx, "项目金额TOP3客户类型的重点中标单位 err:", err.Error(), v.Name)
+					g.Log().Info(model.Ctx, "项目金额TOP3客户类型的重点中标单位 err:", err, v.Name)
 				}
 			}
 		}
@@ -908,7 +908,7 @@ func (ut *UserTask) DataCollation() {
 					//del cache
 					go utility.DelRedisInfo(redisKey)
 				} else {
-					g.Log().Info(model.Ctx, "项目金额TOP3地区的重点中标单位 err:", err.Error(), v.Name)
+					g.Log().Info(model.Ctx, "项目金额TOP3地区的重点中标单位 err:", err, v.Name)
 				}
 			}
 		}
@@ -936,7 +936,7 @@ func (ut *UserTask) DataCollation() {
 					//del cache
 					go utility.DelRedisInfo(redisKey)
 				} else {
-					g.Log().Info(model.Ctx, "项目数量TOP3地区的重点中标单位 err:", err.Error(), v.Name)
+					g.Log().Info(model.Ctx, "项目数量TOP3地区的重点中标单位 err:", err, v.Name)
 				}
 			}
 		}
@@ -970,7 +970,7 @@ func (ut *UserTask) DataCollation() {
 				//del cache
 				go utility.DelRedisInfo(redisKey)
 			} else {
-				g.Log().Info(model.Ctx, "细分市场的重点中标单位-项目数量占比 err:", err.Error(), v.Name)
+				g.Log().Info(model.Ctx, "细分市场的重点中标单位-项目数量占比 err:", err, v.Name)
 			}
 		}
 		//细分市场的重点中标单位-分类金额百分比
@@ -990,7 +990,7 @@ func (ut *UserTask) DataCollation() {
 				//del cache
 				go utility.DelRedisInfo(redisKey)
 			} else {
-				g.Log().Info(model.Ctx, "细分市场的重点中标单位-分类金额百分比 err:", err.Error(), v.Name)
+				g.Log().Info(model.Ctx, "细分市场的重点中标单位-分类金额百分比 err:", err, v.Name)
 			}
 		}
 	}
@@ -1019,7 +1019,7 @@ func (ut *UserTask) DataCollation() {
 					//del cache
 					go utility.DelRedisInfo(redisKey_winner)
 				} else {
-					g.Log().Info(model.Ctx, "b--项目数量TOP30采购单位> winner err:", err.Error(), buyerInfo.Member)
+					g.Log().Info(model.Ctx, "b--项目数量TOP30采购单位> winner err:", err, buyerInfo.Member)
 				}
 				baw.BuyerCountTop3 = append(baw.BuyerCountTop3, &entity.BuyerCountTop3S{
 					Name:       buyerInfo.Member,
@@ -1030,7 +1030,7 @@ func (ut *UserTask) DataCollation() {
 			//del cache
 			go utility.DelRedisInfo(redisKey)
 		} else {
-			g.Log().Info(model.Ctx, "b--项目数量TOP30采购单位 err:", err.Error())
+			g.Log().Info(model.Ctx, "b--项目数量TOP30采购单位 err:", err)
 		}
 		//-------------redis----sorted---- 采购单位--score---采购金额TOP30采购单位-金额
 		redisKey = utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bat", ut.MgoUserId, "top30")
@@ -1052,7 +1052,7 @@ func (ut *UserTask) DataCollation() {
 					//del cache
 					go utility.DelRedisInfo(redisKey_winner)
 				} else {
-					g.Log().Info(model.Ctx, "b--采购金额TOP30采购单位> winner err:", err.Error(), buyerInfo.Member)
+					g.Log().Info(model.Ctx, "b--采购金额TOP30采购单位> winner err:", err, buyerInfo.Member)
 				}
 				baw.BuyerAmountTop3 = append(baw.BuyerAmountTop3, &entity.BuyerAmountTop3S{
 					Name:       buyerInfo.Member,
@@ -1063,7 +1063,7 @@ func (ut *UserTask) DataCollation() {
 			//del cache
 			go utility.DelRedisInfo(redisKey)
 		} else {
-			g.Log().Info(model.Ctx, "b--采购金额TOP30采购单位 err:", err.Error())
+			g.Log().Info(model.Ctx, "b--采购金额TOP30采购单位 err:", err)
 		}
 		//采购规模分布
 		for _, v := range baw.BuyerTimeDistribution {
@@ -1091,7 +1091,7 @@ func (ut *UserTask) DataCollation() {
 					//del cache
 					go utility.DelRedisInfo(redisKey_buyer)
 				} else {
-					g.Log().Info(model.Ctx, "w--项目数量TOP30采购单位 --buyer err:", err.Error())
+					g.Log().Info(model.Ctx, "w--项目数量TOP30采购单位 --buyer err:", err)
 				}
 				baw.WinnerCountTop3 = append(baw.WinnerCountTop3, &entity.WinnerCountTop3S{
 					Id:        winnerInfo.Id,
@@ -1103,7 +1103,7 @@ func (ut *UserTask) DataCollation() {
 			//del cache
 			go utility.DelRedisInfo(redisKey)
 		} else {
-			g.Log().Info(model.Ctx, "w--项目数量TOP30采购单位 err:", err.Error())
+			g.Log().Info(model.Ctx, "w--项目数量TOP30采购单位 err:", err)
 		}
 		//-------------redis----sorted---- 中标企业--score---采购金额TOP30采购单位-金额
 		redisKey = utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wat", ut.MgoUserId, "top30")
@@ -1124,7 +1124,7 @@ func (ut *UserTask) DataCollation() {
 					//del cache
 					go utility.DelRedisInfo(redisKey_buyer)
 				} else {
-					g.Log().Info(model.Ctx, "w--采购金额TOP30采购单位 buyer err:", err.Error())
+					g.Log().Info(model.Ctx, "w--采购金额TOP30采购单位 buyer err:", err)
 				}
 				baw.WinnerAmountTop3 = append(baw.WinnerAmountTop3, &entity.WinnerAmountTop3S{
 					Id:        winnerInfo.Id,
@@ -1136,7 +1136,7 @@ func (ut *UserTask) DataCollation() {
 			//del cache
 			go utility.DelRedisInfo(redisKey)
 		} else {
-			g.Log().Info(model.Ctx, "w--采购金额TOP30采购单位 err:", err.Error())
+			g.Log().Info(model.Ctx, "w--采购金额TOP30采购单位 err:", err)
 		}
 		//中标规模分布
 		for _, v := range baw.WinnerTimeDistribution {

+ 7 - 89
utility/userTask.go

@@ -207,95 +207,7 @@ func UpdateBuyerInfoOfScore(key string, pt *entity.ProjectInfo, score float64) {
 	}
 }
 
-// 项目金额---TOP3地区的重点中标单位
-func SetWinnerInfoOfAmount(key string, pt *entity.ProjectInfo) {
-	if pt.Winners != "" {
-		for k, w := range strings.Split(pt.Winners, ",") {
-			id := common.If(len(pt.Entidlist) > k, encrypt.EncodeArticleId2ByCheck(pt.Entidlist[k]), "").(string)
-			UpdateIncrementRedis(key, fmt.Sprintf("%s##%s", w, id), pt.Sortprice)
-		}
-	}
-}
-
-// 项目数量---TOP3地区的重点中标单位
-func SetWinnerInfoOfCount(key string, pt *entity.ProjectInfo) {
-	if pt.Winners != "" {
-		for k, w := range strings.Split(pt.Winners, ",") {
-			id := common.If(len(pt.Entidlist) > k, encrypt.EncodeArticleId2ByCheck(pt.Entidlist[k]), "").(string)
-			UpdateIncrementRedis(key, fmt.Sprintf("%s##%s", w, id), 1)
-		}
-	}
-}
-
-// 细化市场重点中标单位-项目数量|金额
-func GetWinnerInfoTopList(pt *entity.ProjectInfo, value, total float64) []*entity.TopListS {
-	var winnerTotal []*entity.TopListS
-	if pt.Winners != "" {
-		for k, w := range strings.Split(pt.Winners, ",") {
-			winnerTotal = append(winnerTotal, &entity.TopListS{
-				Id:    common.If(len(pt.Entidlist) > k, encrypt.EncodeArticleId2ByCheck(pt.Entidlist[k]), "").(string),
-				Name:  w,
-				Value: value,
-				Prop:  Formula(value, total),
-			})
-		}
-	}
-	return winnerTotal
-}
-
-// 市场-采购单位&&中标企业---采购金额TOP30采购单位及其重点合作中标单位
-func GetWinnerInfoOfBuyerCount(pt *entity.ProjectInfo) []*entity.Winnertop3Number {
-	var winnertop3Number []*entity.Winnertop3Number
-	if pt.Winners != "" {
-		for k, w := range strings.Split(pt.Winners, ",") {
-			winnertop3Number = append(winnertop3Number, &entity.Winnertop3Number{
-				Id:     common.If(len(pt.Entidlist) > k, encrypt.EncodeArticleId2ByCheck(pt.Entidlist[k]), "").(string),
-				Name:   w,
-				Number: 1,
-			})
-		}
-	}
-	return winnertop3Number
-}
-
-// 市场-采购单位&&中标企业---采购金额TOP30采购单位及其重点合作中标单位
-func GetWinnerInfoOfBuyerAmount(pt *entity.ProjectInfo) []*entity.Winnertop3Amount {
-	var winnertop3Amount []*entity.Winnertop3Amount
-	if pt.Winners != "" {
-		for k, w := range strings.Split(pt.Winners, ",") {
-			winnertop3Amount = append(winnertop3Amount, &entity.Winnertop3Amount{
-				Id:     common.If(len(pt.Entidlist) > k, encrypt.EncodeArticleId2ByCheck(pt.Entidlist[k]), "").(string),
-				Name:   w,
-				Amount: pt.Sortprice,
-			})
-		}
-	}
-	return winnertop3Amount
-}
-
-// 市场-采购单位&&中标企业---采购金额TOP30采购单位及其重点合作中标单位
-func GetWinnerInfoOfWinnerCount(pt *entity.ProjectInfo) []*entity.Buyertop3Number {
-	var buyertop3Number []*entity.Buyertop3Number
-	if pt.Buyer != "" {
-		buyertop3Number = append(buyertop3Number, &entity.Buyertop3Number{
-			Name:   pt.Buyer,
-			Number: 1,
-		})
-	}
-	return buyertop3Number
-}
-
-// 市场-采购单位&&中标企业---采购金额TOP30采购单位及其重点合作中标单位
-func GetWinnerInfoOfWinnerAmount(pt *entity.ProjectInfo) []*entity.Buyertop3Amount {
-	var buyertop3Amount []*entity.Buyertop3Amount
-	if pt.Buyer != "" {
-		buyertop3Amount = append(buyertop3Amount, &entity.Buyertop3Amount{
-			Name:   pt.Buyer,
-			Amount: pt.Sortprice,
-		})
-	}
-	return buyertop3Amount
-}
+// prev
 func GetJudgmentPrevKey(first int, next string) (key string) {
 	return fmt.Sprintf("mk_%d_%s", first, next)
 }
@@ -346,3 +258,9 @@ func DelRedisInfo(key string) {
 func GetSortedKeyOfRedis(prev int, key, id, suffix string) string {
 	return fmt.Sprintf("sorted_%d_%s_%s_%s", prev, key, id, suffix)
 }
+
+// --
+func IsAnalyzeCancel(key string) bool {
+	n, _ := g.Redis().Exists(model.Ctx, key)
+	return n > 0
+}