wangshan 1 жил өмнө
parent
commit
893336cc93

+ 4 - 1
internal/dao/internal/offline.go

@@ -5,6 +5,7 @@ import (
 	"analyze/internal/model/do"
 	"analyze/internal/model/entity"
 	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/mongodb"
 	"fmt"
 	"github.com/gogf/gf/v2/frame/g"
 )
@@ -30,7 +31,9 @@ func (o *OfflineInfo) OfflineData() ([]*AnalyzeTask, error) {
 	var analyze = &AnalyzeTask{}
 	for _, row := range *res {
 		ui := NewUserInfo()
-		ui.Id = common.ObjToString(row["s_userId"])
+		ui.MgoUserId = common.ObjToString(row["s_userId"])   //MgoUserId
+		ui.PositionId = common.Int64All(row["i_positionId"]) //职位id
+		ui.RId = mongodb.BsonIdToSId(row["_id"])
 		ui.AnalysisParam = entity.AnalyzeParameters{
 			KeysItemsStr: common.ObjToString(row["s_keysItems"]),
 			RangeTime:    common.ObjToString(row["s_rangeTime"]),

+ 63 - 41
internal/dao/internal/userTask.go

@@ -21,13 +21,16 @@ import (
 
 // user 信息
 type UserTask struct {
-	Id                   string                       //用户id
+	MgoUserId            string //用户id
+	PositionId           int64
 	StartTime            int64                        //开始时间
 	EndTime              int64                        //结束时间
 	IsEnd                bool                         //是否结束
-	IsCancel             bool                         //是否已取消
+	IsCancel             bool                         //是否已取消-----------------待处理
+	IsFalse              bool                         //是否离线分析成功
 	IsRatio              bool                         //是否需要进行环比
 	PInfo                chan *entity.ProjectInfo     //项目信息
+	RId                  string                       //市场分析报告id
 	AnalysisParam        entity.AnalyzeParameters     //市场分析报告参数
 	FormatParam          entity.AnalysisRequestFormat //格式化
 	MatchingMode         string                       //匹配方式 title:标题 content:项目名称/标的物
@@ -56,6 +59,7 @@ func NewUserInfo() *UserTask {
 		Result:        &CalculateResult{},
 		JudgmentMap:   make(map[string]bool),
 		CalculateWG:   sync.WaitGroup{},
+		Started:       0, //重置
 	}
 }
 
@@ -67,7 +71,7 @@ func (ut *UserTask) Push(info *entity.ProjectInfo) {
 // 开始用户任务
 func (ut *UserTask) Start() {
 	if atomic.CompareAndSwapInt32(&ut.Started, 0, 1) {
-		g.Log().Info(gctx.New(), ut.Id, "----", ut.AnalysisParam)
+		g.Log().Info(gctx.New(), ut.MgoUserId, "----", ut.AnalysisParam)
 		go ut.Run()
 	}
 }
@@ -88,6 +92,7 @@ func (ut *UserTask) Run() {
 			}
 		case <-ut.Ticker.C:
 			ut.ResultSave()
+			ut.SendMsg()
 			ut.IsEnd = true
 			break
 		}
@@ -490,9 +495,9 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
 				}
 				//TOP3
 				//-------------redis----sorted---- 中标企业--score---项目数量TOP3客户类型的重点中标单位
-				utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev3, "sbct", ut.Id, bc), pt, 1)
+				utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev3, "sbct", ut.MgoUserId, bc), pt, 1)
 				//-------------redis----sorted---- 中标企业--score---项目金额TOP3客户类型的重点中标单位
-				utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev3, "sbat", ut.Id, bc), pt, pt.Sortprice)
+				utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev3, "sbat", ut.MgoUserId, bc), pt, pt.Sortprice)
 				top3Key := utility.GetJudgmentPrevKey(consts.JudgmentPrev3, fmt.Sprintf("%s_top3", bc))
 				if !ut.JudgmentMap[top3Key] {
 					ut.JudgmentMap[top3Key] = true
@@ -557,9 +562,9 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
 		//项目金额TOP3地区的重点中标单位
 		var scaleAreaAmountAndCountTopFunc = func() {
 			//-------------redis----sorted---- 中标企业--score---项目金额---TOP3地区的重点中标单位
-			utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev5, "saat", ut.Id, pt.Area), pt, pt.Sortprice)
+			utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev5, "saat", ut.MgoUserId, pt.Area), pt, pt.Sortprice)
 			//-------------redis----sorted---- 中标企业--score---项目数量---TOP3地区的重点中标单位
-			utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev5, "sact", ut.Id, pt.Area), pt, 1)
+			utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev5, "sact", ut.MgoUserId, pt.Area), pt, 1)
 			saaactKey := utility.GetJudgmentPrevKey(consts.JudgmentPrev5, pt.Area)
 			if !ut.JudgmentMap[saaactKey] {
 				ut.JudgmentMap[saaactKey] = true
@@ -606,9 +611,9 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
 					itemName := keysItems.ItemName
 					itemNameKey := utility.GetJudgmentPrevKey(consts.JudgmentPrev6, itemName)
 					//-------------redis----sorted---- 中标企业--score---重点中标单位-项目数量
-					utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev6, "srtt", ut.Id, itemName), pt, 1)
+					utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev6, "srtt", ut.MgoUserId, itemName), pt, 1)
 					//-------------redis----sorted---- 中标企业--score---重点中标单位-金额
-					utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev6, "srat", ut.Id, itemName), pt, pt.Sortprice)
+					utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev6, "srat", ut.MgoUserId, itemName), pt, pt.Sortprice)
 					if !ut.JudgmentMap[itemNameKey] {
 						ut.JudgmentMap[itemNameKey] = true
 						//订阅分类
@@ -665,13 +670,13 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
 		//采购单位
 		var buyerAmountAndTotalTop30 = func() {
 			//-------------redis----sorted---- 采购单位--score---项目数量TOP30采购单位-项目数量
-			utility.UpdateBuyerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bct", ut.Id, "top30"), pt, 1)
+			utility.UpdateBuyerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bct", ut.MgoUserId, "top30"), pt, 1)
 			//-------------redis----sorted---- 采购单位--score---采购金额TOP30采购单位-金额
-			utility.UpdateBuyerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bat", ut.Id, "top30"), pt, pt.Sortprice)
+			utility.UpdateBuyerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bat", ut.MgoUserId, "top30"), pt, pt.Sortprice)
 			//-------------redis----sorted---- 采购单位--score---项目数量TOP30采购单位-下的前三个中标企业信息-项目数量
-			utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bct_winner", ut.Id, pt.Buyer), pt, 1)
+			utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bct_winner", ut.MgoUserId, pt.Buyer), pt, 1)
 			//-------------redis----sorted---- 采购单位--score---采购金额TOP30采购单位-下的前三个中标企业信息-金额
-			utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bat_winner", ut.Id, pt.Buyer), pt, pt.Sortprice)
+			utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bat_winner", ut.MgoUserId, pt.Buyer), pt, pt.Sortprice)
 			//采购规模分布 --7
 			var psk = ""
 			for _, cp := range consts.ProjectScale {
@@ -704,13 +709,13 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
 		var winnerAmountAndTotalTop30 = func() {
 			for _, winner := range strings.Split(pt.Winners, ",") {
 				//-------------redis----sorted---- 中标企业--score---项目数量TOP30采购单位-项目数量
-				utility.UpdateBuyerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wct", ut.Id, "top30"), pt, 1)
+				utility.UpdateBuyerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wct", ut.MgoUserId, "top30"), pt, 1)
 				//-------------redis----sorted---- 中标企业--score---采购金额TOP30采购单位-金额
-				utility.UpdateBuyerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wat", ut.Id, "top30"), pt, pt.Sortprice)
+				utility.UpdateBuyerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wat", ut.MgoUserId, "top30"), pt, pt.Sortprice)
 				//-------------redis----sorted---- 中标企业--score---项目数量TOP30采购单位-下的前三个中标企业信息-项目数量
-				utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wct_buyer", ut.Id, winner), pt, 1)
+				utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wct_buyer", ut.MgoUserId, winner), pt, 1)
 				//-------------redis----sorted---- 中标企业--score---采购金额TOP30采购单位-下的前三个中标企业信息-金额
-				utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wat_buyer", ut.Id, winner), pt, pt.Sortprice)
+				utility.UpdateWinnerInfoOfScore(utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wat_buyer", ut.MgoUserId, winner), pt, pt.Sortprice)
 			}
 			//中标规模分布
 			var psk = ""
@@ -831,7 +836,7 @@ func (ut *UserTask) DataCollation() {
 			//采购单位数量环比
 			for _, v := range pad.ScaleBuyclassCountTop {
 				v.BuyclassScale = utility.Formula(float64(v.BuyclassCount), float64(scale.MarketProfile.ProjectCount))
-				redisKey := utility.GetSortedKeyOfRedis(consts.JudgmentPrev3, "sbct", ut.Id, v.Name)
+				redisKey := utility.GetSortedKeyOfRedis(consts.JudgmentPrev3, "sbct", ut.MgoUserId, v.Name)
 				winnerInfos, err := utility.GetZrevRangeByScore(redisKey, consts.JudgmentPrev2, 0)
 				if err == nil && len(winnerInfos) > 0 {
 					for _, winnerInfo := range winnerInfos {
@@ -860,7 +865,7 @@ func (ut *UserTask) DataCollation() {
 			//采购单位类型金额占比
 			for _, v := range pad.ScaleBuyclassAmountTop {
 				v.BuyclassScale = utility.Formula(v.BuyclassAmount, float64(scale.MarketProfile.ProjectCount))
-				redisKey := utility.GetSortedKeyOfRedis(consts.JudgmentPrev3, "sbat", ut.Id, v.Name)
+				redisKey := utility.GetSortedKeyOfRedis(consts.JudgmentPrev3, "sbat", ut.MgoUserId, v.Name)
 				winnerInfos, err := utility.GetZrevRangeByScore(redisKey, consts.JudgmentPrev2, 0)
 				if err == nil && len(winnerInfos) > 0 {
 					for _, winnerInfo := range winnerInfos {
@@ -889,7 +894,7 @@ func (ut *UserTask) DataCollation() {
 			//地区环比
 			for _, v := range pad.ScaleAreaAmountTop {
 				v.AreaScale = utility.Formula(v.AreaAmount, scale.MarketProfile.Projctamout)
-				redisKey := utility.GetSortedKeyOfRedis(consts.JudgmentPrev5, "saat", ut.Id, v.Name)
+				redisKey := utility.GetSortedKeyOfRedis(consts.JudgmentPrev5, "saat", ut.MgoUserId, v.Name)
 				winnerInfos, err := utility.GetZrevRangeByScore(redisKey, consts.JudgmentPrev2, 0)
 				if err == nil && len(winnerInfos) > 0 {
 					for _, winnerInfo := range winnerInfos {
@@ -917,7 +922,7 @@ func (ut *UserTask) DataCollation() {
 			}
 			for _, v := range pad.ScaleAreaCountTop {
 				v.AreaScale = utility.Formula(float64(v.AreaCount), scale.MarketProfile.Projctamout)
-				redisKey := utility.GetSortedKeyOfRedis(consts.JudgmentPrev3, "sact", ut.Id, v.Name)
+				redisKey := utility.GetSortedKeyOfRedis(consts.JudgmentPrev3, "sact", ut.MgoUserId, v.Name)
 				winnerInfos, err := utility.GetZrevRangeByScore(redisKey, consts.JudgmentPrev2, 0)
 				if err == nil && len(winnerInfos) > 0 {
 					for _, winnerInfo := range winnerInfos {
@@ -950,7 +955,7 @@ func (ut *UserTask) DataCollation() {
 		//细分市场的重点中标单位-项目数量占比
 		for _, v := range sr.ScaleRefineTotalTop {
 			v.Prop = utility.Formula(float64(v.Value), float64(scale.MarketProfile.ProjectCount))
-			redisKey := utility.GetSortedKeyOfRedis(consts.JudgmentPrev6, "srtt", ut.Id, v.Name)
+			redisKey := utility.GetSortedKeyOfRedis(consts.JudgmentPrev6, "srtt", ut.MgoUserId, v.Name)
 			winnerInfos, err := utility.GetZrevRangeByScore(redisKey, consts.JudgmentPrev2, 0)
 			if err == nil && len(winnerInfos) > 0 {
 				for _, winnerInfo := range winnerInfos {
@@ -970,7 +975,7 @@ func (ut *UserTask) DataCollation() {
 		//细分市场的重点中标单位-分类金额百分比
 		for _, v := range sr.ScaleRefineAmountTop {
 			v.Prop = utility.Formula(v.Value, scale.MarketProfile.Projctamout)
-			redisKey := utility.GetSortedKeyOfRedis(consts.JudgmentPrev6, "srat", ut.Id, v.Name)
+			redisKey := utility.GetSortedKeyOfRedis(consts.JudgmentPrev6, "srat", ut.MgoUserId, v.Name)
 			winnerInfos, err := utility.GetZrevRangeByScore(redisKey, consts.JudgmentPrev2, 0)
 			if err == nil && len(winnerInfos) > 0 {
 				for _, winnerInfo := range winnerInfos {
@@ -994,13 +999,13 @@ func (ut *UserTask) DataCollation() {
 	var buyerAndWinnerFunc = func() {
 		baw := ut.Result.BuyerAndWinner
 		//-------------redis----sorted---- 采购单位--score---项目数量TOP30采购单位-项目数量
-		redisKey := utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bct", ut.Id, "top30")
+		redisKey := utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bct", ut.MgoUserId, "top30")
 		buyerInfos, err := utility.GetZrevRangeByScore(redisKey, consts.Top30-1, 0)
 		if err == nil && len(buyerInfos) > 0 {
 			for _, buyerInfo := range buyerInfos {
 				var winnertop3Number []*entity.Winnertop3Number
 				//-------------redis----sorted---- 采购单位--score---项目数量TOP30采购单位-下的前三个中标企业信息-项目数量
-				redisKey_winner := utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bct_winner", ut.Id, buyerInfo.Member)
+				redisKey_winner := utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bct_winner", ut.MgoUserId, buyerInfo.Member)
 				winnerInfos, err := utility.GetZrevRangeByScore(redisKey_winner, consts.JudgmentPrev2, 0)
 				if err == nil && len(winnerInfos) > 0 {
 					for _, winnerInfo := range winnerInfos {
@@ -1027,13 +1032,13 @@ func (ut *UserTask) DataCollation() {
 			g.Log().Info(model.Ctx, "b--项目数量TOP30采购单位 err:", err.Error())
 		}
 		//-------------redis----sorted---- 采购单位--score---采购金额TOP30采购单位-金额
-		redisKey = utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bat", ut.Id, "top30")
+		redisKey = utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bat", ut.MgoUserId, "top30")
 		buyerInfos, err = utility.GetZrevRangeByScore(redisKey, consts.Top30-1, 0)
 		if err == nil && len(buyerInfos) > 0 {
 			for _, buyerInfo := range buyerInfos {
 				var winnertop3Amount []*entity.Winnertop3Amount
 				//-------------redis----sorted---- 中标企业--score---采购金额TOP30采购单位-下的前三个中标企业信息-金额
-				redisKey_winner := utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bat_winner", ut.Id, buyerInfo.Member)
+				redisKey_winner := utility.GetSortedKeyOfRedis(consts.JudgmentPrev7, "bat_winner", ut.MgoUserId, buyerInfo.Member)
 				winnerInfos, err := utility.GetZrevRangeByScore(redisKey_winner, consts.JudgmentPrev2, 0)
 				if err == nil && len(winnerInfos) > 0 {
 					for _, winnerInfo := range winnerInfos {
@@ -1067,13 +1072,13 @@ func (ut *UserTask) DataCollation() {
 			v.TotalNumber = utility.Formula(v.Number, float64(scale.MarketProfile.ProjectCount))
 		}
 		//-------------redis----sorted---- 中标企业--score---项目数量TOP30采购单位-项目数量
-		redisKey = utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wct", ut.Id, "top30")
+		redisKey = utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wct", ut.MgoUserId, "top30")
 		winnerInfos, err := utility.GetZrevRangeByScore(redisKey, consts.Top30-1, 0)
 		if err == nil && len(winnerInfos) > 0 {
 			for _, winnerInfo := range winnerInfos {
 				var buyertop3 []*entity.Buyertop3Number
 				//-------------redis----sorted---- 中标企业--score---项目数量TOP30采购单位-下的前三个中标企业信息-项目数量
-				redisKey_buyer := utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wct_buyer", ut.Id, winnerInfo.Member)
+				redisKey_buyer := utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wct_buyer", ut.MgoUserId, winnerInfo.Member)
 				buyerInfos, err := utility.GetZrevRangeByScore(redisKey_buyer, consts.JudgmentPrev2, 0)
 				if err == nil && len(buyerInfos) > 0 {
 					for _, buyerInfo := range buyerInfos {
@@ -1100,13 +1105,13 @@ func (ut *UserTask) DataCollation() {
 			g.Log().Info(model.Ctx, "w--项目数量TOP30采购单位 err:", err.Error())
 		}
 		//-------------redis----sorted---- 中标企业--score---采购金额TOP30采购单位-金额
-		redisKey = utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wat", ut.Id, "top30")
+		redisKey = utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wat", ut.MgoUserId, "top30")
 		winnerInfos, err = utility.GetZrevRangeByScore(redisKey, consts.Top30-1, 0)
 		if err == nil && len(winnerInfos) > 0 {
 			for _, winnerInfo := range winnerInfos {
 				var buyertop3 []*entity.Buyertop3Amount
 				//-------------redis----sorted---- 中标企业--score---项目数量TOP30采购单位-下的前三个中标企业信息-项目数量
-				redisKey_buyer := utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wat_buyer", ut.Id, winnerInfo.Member)
+				redisKey_buyer := utility.GetSortedKeyOfRedis(consts.JudgmentPrev9, "wat_buyer", ut.MgoUserId, winnerInfo.Member)
 				buyerInfos, err := utility.GetZrevRangeByScore(redisKey_buyer, consts.JudgmentPrev2, 0)
 				if err == nil && len(buyerInfos) > 0 {
 					for _, buyerInfo := range buyerInfos {
@@ -1150,50 +1155,66 @@ func (ut *UserTask) ResultSave() {
 	scale := ut.Result.Scale
 	if scale.MarketProfile.ProjectCount > 0 {
 		var scaleMap = common.StructToMapMore(scale)
-		scaleMap["s_m_id"] = ut.Id
+		scaleMap["s_m_id"] = ut.MgoUserId
 		delete(scaleMap, "project_info_all")
 		if id := do.Mgo.Save(consts.MarketScaleMain, scaleMap); id == "" {
-			g.Log().Info(model.Ctx, fmt.Sprintf("marketanalysisreport -- 保存失败-:%s , %s", consts.MarketScaleMain, ut.Id))
+			ut.IsFalse = true
+			g.Log().Info(model.Ctx, fmt.Sprintf("marketanalysisreport -- 保存失败-:%s , %s", consts.MarketScaleMain, ut.MgoUserId))
 		}
 	}
 	//项目规模TOP10 集合
 	topProject := ut.Result.TopProject
 	if len(topProject.ProjectTop10) > 0 {
 		var topProject10 = common.StructToMapMore(topProject.ProjectTop10)
-		topProject10["s_m_id"] = ut.Id
+		topProject10["s_m_id"] = ut.MgoUserId
 		if id := do.Mgo.Save(consts.MarketTopProject, topProject10); id == "" {
-			g.Log().Info(model.Ctx, fmt.Sprintf("marketanalysisreport -- 保存失败-:%s , %s", consts.MarketTopProject, ut.Id))
+			ut.IsFalse = true
+			g.Log().Info(model.Ctx, fmt.Sprintf("marketanalysisreport -- 保存失败-:%s , %s", consts.MarketTopProject, ut.MgoUserId))
 		}
 	}
 	///* 项目规模 地区分布 客户分布 地区客户top3*/
 	pad := ut.Result.ProjectAllData
 	if len(pad.ProjectScale) > 0 {
 		var padMap = common.StructToMapMore(pad)
-		padMap["s_m_id"] = ut.Id
+		padMap["s_m_id"] = ut.MgoUserId
 		if id := do.Mgo.Save(consts.MarketProjectAllData, padMap); id == "" {
-			g.Log().Info(model.Ctx, fmt.Sprintf("marketanalysisreport -- 保存失败-:%s , %s", consts.MarketProjectAllData, ut.Id))
+			ut.IsFalse = true
+			g.Log().Info(model.Ctx, fmt.Sprintf("marketanalysisreport -- 保存失败-:%s , %s", consts.MarketProjectAllData, ut.MgoUserId))
 		}
 	}
 	//细化市场
 	sr := ut.Result.ScaleRefine
 	if len(sr.ScaleRefineAll) > 0 || len(sr.ScaleRefineTotalTop) > 0 {
 		var srMap = common.StructToMapMore(sr)
-		srMap["s_m_id"] = ut.Id
+		srMap["s_m_id"] = ut.MgoUserId
 		if id := do.Mgo.Save(consts.MarketScaleRefine, srMap); id == "" {
-			g.Log().Info(model.Ctx, fmt.Sprintf("marketanalysisreport -- 保存失败-:%s , %s", consts.MarketScaleRefine, ut.Id))
+			ut.IsFalse = true
+			g.Log().Info(model.Ctx, fmt.Sprintf("marketanalysisreport -- 保存失败-:%s , %s", consts.MarketScaleRefine, ut.MgoUserId))
 		}
 	}
 	///* 市场-采购单位&&中标企业*/
 	baw := ut.Result.BuyerAndWinner
 	if len(baw.WinnerCountTop3) > 0 || len(baw.BuyerCountTop3) > 0 {
 		var bawMap = common.StructToMapMore(baw)
-		bawMap["s_m_id"] = ut.Id
+		bawMap["s_m_id"] = ut.MgoUserId
 		if id := do.Mgo.Save(consts.MarketBuyerAndWinner, bawMap); id == "" {
-			g.Log().Info(model.Ctx, fmt.Sprintf("marketanalysisreport -- 保存失败-:%s , %s", consts.MarketBuyerAndWinner, ut.Id))
+			ut.IsFalse = true
+			g.Log().Info(model.Ctx, fmt.Sprintf("marketanalysisreport -- 保存失败-:%s , %s", consts.MarketBuyerAndWinner, ut.MgoUserId))
 		}
 	}
 }
 
+// 消息通知
+func (ut *UserTask) SendMsg() {
+	//分析报告离线分析异常
+	if ut.IsFalse {
+		content := fmt.Sprintf(g.Cfg("task.yaml").MustGet(model.Ctx, "falseMsg").String(), ut.RId, ut.MgoUserId, ut.PositionId, ut.AnalysisParam.KeysItemsStr, ut.AnalysisParam.Area, ut.AnalysisParam.Industry, ut.AnalysisParam.BuyerClass, ut.MatchingMode)
+		SendAlarmMail(model.Ctx, content)
+	} else {
+		SendReportMsg(model.Ctx, ut.MgoUserId, ut.PositionId, ut.RId)
+	}
+}
+
 // Reset RESET
 func (ut *UserTask) Reset() {
 	ut.JudgmentMap = map[string]bool{}
@@ -1201,6 +1222,7 @@ func (ut *UserTask) Reset() {
 	ut.AnalysisParam = entity.AnalyzeParameters{}
 	close(ut.PInfo)
 	ut.IsEnd = false
+	ut.Started = 0
 	ut.Ticker.Stop()
 }
 

+ 2 - 2
internal/dao/internal/warn.go

@@ -28,14 +28,14 @@ func SendAlarmMail(ctx context.Context, content string) {
 var Sewx encrypt.SimpleEncrypt //微信的加密方法
 
 // SendReportMsg 报告生成后发送消息
-func SendReportMsg(ctx context.Context, mgoId string, positionId int, rId string) {
+func SendReportMsg(ctx context.Context, mgoId string, positionId int64, rId string) {
 	reportId := utility.EncodeId(mongodb.BsonIdToSId(rId))
 	msgInfo := do.TaskConfig.MessageInfo
 	pcUrl := fmt.Sprintf(msgInfo.Link.PcUrl, reportId)
 	androidUrl := fmt.Sprintf(msgInfo.Link.AndroidUrl, reportId)
 	iosUrl := fmt.Sprintf(msgInfo.Link.IosUrl, reportId)
 	now := strconv.Itoa(int(time.Now().Unix()))
-	sessData := fmt.Sprintf("%s,positionId,%s,weChatUrl", strconv.FormatInt(int64(positionId), 10), now)
+	sessData := fmt.Sprintf("%s,positionId,%s,weChatUrl", strconv.FormatInt(positionId, 10), now)
 	weChatUrl := fmt.Sprintf(msgInfo.Link.WeChatUrl, Sewx.EncodeString(sessData))
 	parm := utility.MessageParam{
 		UserIds: mgoId, Title: msgInfo.Title, Content: msgInfo.Content, Link: pcUrl, AndroidUrl: androidUrl, IosUrl: iosUrl, WeChatUrl: weChatUrl, MsgType: msgInfo.MsgType,

+ 4 - 0
internal/model/entity/result.go

@@ -283,3 +283,7 @@ type MemberScore struct {
 	Id     string
 	Score  float64
 }
+
+//err
+type ErrorInfo struct {
+}

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
manifest/config/task.yaml


Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно