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