|
@@ -217,27 +217,27 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
//项目信息结果时间在原始查询条件范围内
|
|
|
if utility.DateIsIn(ut.StartTime, ut.EndTime, pt.JgTime, 0) {
|
|
|
if pt.Buyer != "" {
|
|
|
- scale.MarketProfile.Buyercount += 1
|
|
|
+ scale.MarketProfile.Buyercount++
|
|
|
}
|
|
|
- scale.MarketProfile.ProjectCount += 1
|
|
|
+ scale.MarketProfile.ProjectCount++
|
|
|
if pt.Winners != "" {
|
|
|
scale.MarketProfile.Winnercount += len(strings.Split(pt.Winners, ","))
|
|
|
}
|
|
|
scale.MarketProfile.Projctamout += pt.Sortprice
|
|
|
- scale.MarketProfile.Projectavgmoney = utility.Sequential(scale.MarketProfile.Projctamout, float64(scale.MarketProfile.ProjectCount)) //项目平均金额(万)
|
|
|
+ scale.MarketProfile.Projectavgmoney = utility.Formula(scale.MarketProfile.Projctamout, float64(scale.MarketProfile.ProjectCount)) //项目平均金额(万)
|
|
|
}
|
|
|
//是否需要进行环比
|
|
|
if ut.IsRatio {
|
|
|
- scale.ProjectInfoAll.ProjectCount += 1
|
|
|
+ scale.ProjectInfoAll.ProjectCount++
|
|
|
scale.ProjectInfoAll.Projctamout += pt.Sortprice
|
|
|
if pt.Buyer != "" {
|
|
|
- scale.ProjectInfoAll.Buyercount += 1
|
|
|
+ scale.ProjectInfoAll.Buyercount++
|
|
|
}
|
|
|
if pt.Winners != "" {
|
|
|
scale.ProjectInfoAll.Winnercount += len(strings.Split(pt.Winners, ","))
|
|
|
}
|
|
|
//项目平均金额(万)
|
|
|
- scale.ProjectInfoAll.Projectavgmoney = utility.Sequential(scale.ProjectInfoAll.Projctamout, float64(scale.ProjectInfoAll.ProjectCount))
|
|
|
+ scale.ProjectInfoAll.Projectavgmoney = utility.Formula(scale.ProjectInfoAll.Projctamout, float64(scale.ProjectInfoAll.ProjectCount))
|
|
|
//采购单位项目数量环比
|
|
|
scale.MarketProfile.BuyercountRatio = utility.Sequential(float64(scale.MarketProfile.Buyercount), float64(scale.ProjectInfoAll.Buyercount))
|
|
|
//项目金额环比
|
|
@@ -258,7 +258,7 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
eDCount.Minth = mdv.Key
|
|
|
if utility.DateIsIn(mdv.From, mdv.To, pt.JgTime, 0) {
|
|
|
eDAmount.Value += pt.Sortprice
|
|
|
- eDCount.Value += 1
|
|
|
+ eDCount.Value++
|
|
|
if ut.IsRatio && mdk > 0 {
|
|
|
//计算环比
|
|
|
eDAmount.Ratio = utility.Sequential(eDAmount.Value, scale.MonthDistribution.ProjectAmount[mdk-1].Value)
|
|
@@ -278,7 +278,7 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
eDCount.Minth = ydv.Key
|
|
|
if utility.DateIsIn(ydv.From, ydv.To, pt.JgTime, 0) {
|
|
|
eDAmount.Value += pt.Sortprice
|
|
|
- eDCount.Value += 1
|
|
|
+ eDCount.Value++
|
|
|
if ut.IsRatio && ydk > 0 {
|
|
|
//计算环比
|
|
|
eDAmount.Ratio = utility.Sequential(eDAmount.Value, scale.YearDistribution.ProjectAmount[ydk-1].Value)
|
|
@@ -301,6 +301,7 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
entIdList = pt.Entidlist
|
|
|
)
|
|
|
if len(pt.Entidlist) > 0 {
|
|
|
+ //加密
|
|
|
for _, entId := range pt.Entidlist {
|
|
|
entIdList = append(entIdList, utility.EncodeId(entId))
|
|
|
}
|
|
@@ -334,7 +335,7 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
}()
|
|
|
//地区分布
|
|
|
var areaInfoFunc = func() {
|
|
|
- areaInfoKey := utility.GetJudgmentPrevKey(consts.JudgmentPrev1, pt.Area)
|
|
|
+ areaInfoKey := utility.GetJudgmentPrevKey(consts.JudgmentPrev0, pt.Area)
|
|
|
cityInfoKey := utility.GetJudgmentPrevKey(consts.JudgmentPrev1, fmt.Sprintf("%s_%s", pt.Area, pt.City))
|
|
|
if !ut.JudgmentMap[areaInfoKey] {
|
|
|
ut.JudgmentMap[areaInfoKey] = true
|
|
@@ -352,27 +353,45 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
Total: 1,
|
|
|
})
|
|
|
} else {
|
|
|
+ var (
|
|
|
+ wc = make(chan bool, common.If(len(pad.AreaInfos) > 10, consts.JudgmentPrev3, 1).(int))
|
|
|
+ wg = &sync.WaitGroup{}
|
|
|
+ stopLoop = false
|
|
|
+ )
|
|
|
for _, ai := range pad.AreaInfos {
|
|
|
- if ai.Area == pt.Area {
|
|
|
- if !ut.JudgmentMap[cityInfoKey] {
|
|
|
- ut.JudgmentMap[cityInfoKey] = true
|
|
|
- ai.AreaDetails = append(ai.AreaDetails, &entity.AreaDetailsS{
|
|
|
- Amount: pt.Sortprice,
|
|
|
- City: pt.City,
|
|
|
- Total: 1,
|
|
|
- })
|
|
|
- } else {
|
|
|
- for _, ci := range ai.AreaDetails {
|
|
|
- if ci.City == pt.City {
|
|
|
- ci.Amount += pt.Sortprice
|
|
|
- ci.Total += 1
|
|
|
- break
|
|
|
+ if stopLoop {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ wc <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(ai *entity.AreaInfosS) {
|
|
|
+ defer func() {
|
|
|
+ wg.Done()
|
|
|
+ <-wc
|
|
|
+ }()
|
|
|
+ if ai.Area == pt.Area {
|
|
|
+ stopLoop = true
|
|
|
+ if !ut.JudgmentMap[cityInfoKey] {
|
|
|
+ ut.JudgmentMap[cityInfoKey] = true
|
|
|
+ ai.AreaDetails = append(ai.AreaDetails, &entity.AreaDetailsS{
|
|
|
+ Amount: pt.Sortprice,
|
|
|
+ City: pt.City,
|
|
|
+ Total: 1,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ for _, ci := range ai.AreaDetails {
|
|
|
+ if ci.City == pt.City {
|
|
|
+ ci.Amount += pt.Sortprice
|
|
|
+ ci.Total++
|
|
|
+ break
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ return
|
|
|
}
|
|
|
- break
|
|
|
- }
|
|
|
+ }(ai)
|
|
|
}
|
|
|
+ wg.Wait()
|
|
|
}
|
|
|
}
|
|
|
areaInfoFunc()
|
|
@@ -394,7 +413,7 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
}
|
|
|
} else {
|
|
|
pad.CustomerScaleOther.Amount += pt.Sortprice
|
|
|
- pad.CustomerScaleOther.Total += 1
|
|
|
+ pad.CustomerScaleOther.Total++
|
|
|
}
|
|
|
} else {
|
|
|
//客户分布
|
|
@@ -406,13 +425,31 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
Total: 1,
|
|
|
})
|
|
|
} else {
|
|
|
+ var (
|
|
|
+ wc = make(chan bool, common.If(len(pad.CustomerScale) > 10, consts.JudgmentPrev3, 1).(int))
|
|
|
+ wg = &sync.WaitGroup{}
|
|
|
+ stopLoop = false
|
|
|
+ )
|
|
|
for _, csm := range pad.CustomerScale {
|
|
|
- if csm.Buyclass == bc {
|
|
|
- csm.Amount += pt.Sortprice
|
|
|
- csm.Total += 1
|
|
|
+ if stopLoop {
|
|
|
break
|
|
|
}
|
|
|
+ wc <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(csm *entity.CustomerScaleS) {
|
|
|
+ defer func() {
|
|
|
+ wg.Done()
|
|
|
+ <-wc
|
|
|
+ }()
|
|
|
+ if csm.Buyclass == bc {
|
|
|
+ stopLoop = true
|
|
|
+ csm.Amount += pt.Sortprice
|
|
|
+ csm.Total++
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }(csm)
|
|
|
}
|
|
|
+ wg.Wait()
|
|
|
}
|
|
|
}
|
|
|
top3Key := utility.GetJudgmentPrevKey(consts.JudgmentPrev3, fmt.Sprintf("%s_top3", bc))
|
|
@@ -436,28 +473,45 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
//项目数量TOP3客户类型的重点中标单位
|
|
|
for _, sbct := range pad.ScaleBuyclassCountTop {
|
|
|
if sbct.Name == bc {
|
|
|
- sbct.BuyclassCount += 1
|
|
|
+ sbct.BuyclassCount++
|
|
|
sbct.BuyclassScale = utility.Formula(float64(sbct.BuyclassCount), float64(scale.MarketProfile.ProjectCount))
|
|
|
if len(sbct.Winner) > 0 {
|
|
|
var (
|
|
|
wnMap = map[string]int{}
|
|
|
winners = strings.Split(pt.Winners, ",")
|
|
|
winnerNum int
|
|
|
+
|
|
|
+ wc = make(chan bool, common.If(len(sbct.Winner) > 10, consts.JudgmentPrev3, 1).(int))
|
|
|
+ wg = &sync.WaitGroup{}
|
|
|
+ stopLoop = false
|
|
|
)
|
|
|
for wi, wn := range sbct.Winner {
|
|
|
- if strings.Contains(pt.Winners, wn.Winner) {
|
|
|
- winnerNum++
|
|
|
- wnMap[wn.Winner] = wi + 1
|
|
|
- }
|
|
|
- if winnerNum == len(winners) {
|
|
|
+ if stopLoop {
|
|
|
break
|
|
|
}
|
|
|
+ wc <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(wn *entity.WinnerTotalS, wi int) {
|
|
|
+ defer func() {
|
|
|
+ wg.Done()
|
|
|
+ <-wc
|
|
|
+ }()
|
|
|
+ if strings.Contains(pt.Winners, wn.Winner) {
|
|
|
+ winnerNum++
|
|
|
+ wnMap[wn.Winner] = wi + 1
|
|
|
+ }
|
|
|
+ if winnerNum == len(winners) {
|
|
|
+ stopLoop = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }(wn, wi)
|
|
|
}
|
|
|
+ wg.Wait()
|
|
|
for wk, wd := range winners {
|
|
|
if wnMap[wd] > 0 {
|
|
|
- sbct.Winner[wnMap[wd]-1].WinnerTotal += 1
|
|
|
+ sbct.Winner[wnMap[wd]-1].WinnerTotal++
|
|
|
} else {
|
|
|
- sbct.Winner = append(sbct.Winner, &entity.WinnerTotal{
|
|
|
+ sbct.Winner = append(sbct.Winner, &entity.WinnerTotalS{
|
|
|
Id: common.If(len(pt.Entidlist) > wk, encrypt.EncodeArticleId2ByCheck(pt.Entidlist[wk]), "").(string),
|
|
|
Winner: wd,
|
|
|
WinnerTotal: 1,
|
|
@@ -476,6 +530,7 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
sbct.Winner = sbct.Winner[:consts.Top3]
|
|
|
}
|
|
|
}
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
/*-------------排序----------------*/
|
|
@@ -497,21 +552,37 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
wnMap = map[string]int{}
|
|
|
winners = strings.Split(pt.Winners, ",")
|
|
|
winnerNum int
|
|
|
+ wc = make(chan bool, common.If(len(sbat.Winner) > 10, consts.JudgmentPrev3, 1).(int))
|
|
|
+ wg = &sync.WaitGroup{}
|
|
|
+ stopLoop = false
|
|
|
)
|
|
|
for wi, wn := range sbat.Winner {
|
|
|
- if strings.Contains(pt.Winners, wn.Winner) {
|
|
|
- winnerNum++
|
|
|
- wnMap[wn.Winner] = wi + 1
|
|
|
- }
|
|
|
- if winnerNum == len(winners) {
|
|
|
+ if stopLoop {
|
|
|
break
|
|
|
}
|
|
|
+ wc <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(wn *entity.WinnerAmountS, wi int) {
|
|
|
+ defer func() {
|
|
|
+ wg.Done()
|
|
|
+ <-wc
|
|
|
+ }()
|
|
|
+ if strings.Contains(pt.Winners, wn.Winner) {
|
|
|
+ winnerNum++
|
|
|
+ wnMap[wn.Winner] = wi + 1
|
|
|
+ }
|
|
|
+ if winnerNum == len(winners) {
|
|
|
+ stopLoop = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }(wn, wi)
|
|
|
}
|
|
|
+ wg.Wait()
|
|
|
for wk, wd := range winners {
|
|
|
if wnMap[wd] > 0 {
|
|
|
sbat.Winner[wnMap[wd]-1].WinnerAmount += pt.Sortprice
|
|
|
} else {
|
|
|
- sbat.Winner = append(sbat.Winner, &entity.WinnerAmount{
|
|
|
+ sbat.Winner = append(sbat.Winner, &entity.WinnerAmountS{
|
|
|
Id: common.If(len(pt.Entidlist) > wk, encrypt.EncodeArticleId2ByCheck(pt.Entidlist[wk]), "").(string),
|
|
|
Winner: wd,
|
|
|
WinnerAmount: pt.Sortprice,
|
|
@@ -566,7 +637,7 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
} else {
|
|
|
for _, ps := range pad.ProjectScale {
|
|
|
if ps.Name == psk {
|
|
|
- ps.Count += 1
|
|
|
+ ps.Count++
|
|
|
ps.Amount += pt.Sortprice
|
|
|
ps.PersentC = utility.Formula(ps.Amount, scale.MarketProfile.Projctamout)
|
|
|
ps.PersentA = utility.Formula(float64(ps.Count), float64(scale.MarketProfile.ProjectCount))
|
|
@@ -608,21 +679,37 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
wnMap = map[string]int{}
|
|
|
winners = strings.Split(pt.Winners, ",")
|
|
|
winnerNum int
|
|
|
+ wc = make(chan bool, common.If(len(saat.Winner) > 10, consts.JudgmentPrev3, 1).(int))
|
|
|
+ wg = &sync.WaitGroup{}
|
|
|
+ stopLoop = false
|
|
|
)
|
|
|
for wi, wn := range saat.Winner {
|
|
|
- if strings.Contains(pt.Winners, wn.Winner) {
|
|
|
- winnerNum++
|
|
|
- wnMap[wn.Winner] = wi + 1
|
|
|
- }
|
|
|
- if winnerNum == len(winners) {
|
|
|
+ if stopLoop {
|
|
|
break
|
|
|
}
|
|
|
+ wc <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(wn *entity.WinnerAmountS, wi int) {
|
|
|
+ defer func() {
|
|
|
+ wg.Done()
|
|
|
+ <-wc
|
|
|
+ }()
|
|
|
+ if strings.Contains(pt.Winners, wn.Winner) {
|
|
|
+ winnerNum++
|
|
|
+ wnMap[wn.Winner] = wi + 1
|
|
|
+ }
|
|
|
+ if winnerNum == len(winners) {
|
|
|
+ stopLoop = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }(wn, wi)
|
|
|
}
|
|
|
+ wg.Wait()
|
|
|
for wk, wd := range winners {
|
|
|
if wnMap[wd] > 0 {
|
|
|
saat.Winner[wnMap[wd]-1].WinnerAmount += pt.Sortprice
|
|
|
} else {
|
|
|
- saat.Winner = append(saat.Winner, &entity.WinnerAmount{
|
|
|
+ saat.Winner = append(saat.Winner, &entity.WinnerAmountS{
|
|
|
Id: common.If(len(pt.Entidlist) > wk, encrypt.EncodeArticleId2ByCheck(pt.Entidlist[wk]), "").(string),
|
|
|
Winner: wd,
|
|
|
WinnerAmount: pt.Sortprice,
|
|
@@ -655,28 +742,44 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
//项目数量---TOP3地区的重点中标单位
|
|
|
for _, sact := range pad.ScaleAreaCountTop {
|
|
|
if sact.Name == pt.Area {
|
|
|
- sact.AreaCount += 1
|
|
|
+ sact.AreaCount++
|
|
|
sact.AreaScale = utility.Formula(float64(sact.AreaCount), scale.MarketProfile.Projctamout)
|
|
|
if len(sact.Winner) > 0 {
|
|
|
var (
|
|
|
wnMap = map[string]int{}
|
|
|
winners = strings.Split(pt.Winners, ",")
|
|
|
winnerNum int
|
|
|
+ wc = make(chan bool, common.If(len(sact.Winner) > 10, consts.JudgmentPrev3, 1).(int))
|
|
|
+ wg = &sync.WaitGroup{}
|
|
|
+ stopLoop = false
|
|
|
)
|
|
|
for wi, wn := range sact.Winner {
|
|
|
- if strings.Contains(pt.Winners, wn.Winner) {
|
|
|
- winnerNum++
|
|
|
- wnMap[wn.Winner] = wi + 1
|
|
|
- }
|
|
|
- if winnerNum == len(winners) {
|
|
|
+ if stopLoop {
|
|
|
break
|
|
|
}
|
|
|
+ wc <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(wn *entity.WinnerTotalS, wi int) {
|
|
|
+ defer func() {
|
|
|
+ wg.Done()
|
|
|
+ <-wc
|
|
|
+ }()
|
|
|
+ if strings.Contains(pt.Winners, wn.Winner) {
|
|
|
+ winnerNum++
|
|
|
+ wnMap[wn.Winner] = wi + 1
|
|
|
+ }
|
|
|
+ if winnerNum == len(winners) {
|
|
|
+ stopLoop = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }(wn, wi)
|
|
|
}
|
|
|
+ wg.Wait()
|
|
|
for wk, wd := range winners {
|
|
|
if wnMap[wd] > 0 {
|
|
|
- sact.Winner[wnMap[wd]-1].WinnerTotal += 1
|
|
|
+ sact.Winner[wnMap[wd]-1].WinnerTotal++
|
|
|
} else {
|
|
|
- sact.Winner = append(sact.Winner, &entity.WinnerTotal{
|
|
|
+ sact.Winner = append(sact.Winner, &entity.WinnerTotalS{
|
|
|
Id: common.If(len(pt.Entidlist) > wk, encrypt.EncodeArticleId2ByCheck(pt.Entidlist[wk]), "").(string),
|
|
|
Winner: wd,
|
|
|
WinnerTotal: 1,
|
|
@@ -746,10 +849,10 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
TopList: utility.GetWinnerInfoTopList(pt, pt.Sortprice, scale.MarketProfile.Projctamout),
|
|
|
})
|
|
|
} else {
|
|
|
- //订阅分类
|
|
|
+ //订阅分类 300+
|
|
|
for _, sra := range sr.ScaleRefineAll {
|
|
|
if sra.Name == itemName {
|
|
|
- sra.Total += 1
|
|
|
+ sra.Total++
|
|
|
sra.Amount += pt.Sortprice
|
|
|
break
|
|
|
}
|
|
@@ -757,26 +860,43 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
//重点中标单位-项目数量
|
|
|
for _, srtt := range sr.ScaleRefineTotalTop {
|
|
|
if srtt.Name == itemName {
|
|
|
- srtt.Value += 1
|
|
|
+ srtt.Value++
|
|
|
srtt.Prop = utility.Formula(float64(srtt.Value), float64(scale.MarketProfile.ProjectCount))
|
|
|
if len(srtt.TopList) > 0 {
|
|
|
var (
|
|
|
wnMap = map[string]int{}
|
|
|
winners = strings.Split(pt.Winners, ",")
|
|
|
winnerNum int
|
|
|
+ wc = make(chan bool, common.If(len(srtt.TopList) > 10, consts.JudgmentPrev3, 1).(int))
|
|
|
+ wg = &sync.WaitGroup{}
|
|
|
+ stopLoop = false
|
|
|
)
|
|
|
for wi, wn := range srtt.TopList {
|
|
|
- if strings.Contains(pt.Winners, wn.Name) {
|
|
|
- winnerNum++
|
|
|
- wnMap[wn.Name] = wi + 1
|
|
|
- }
|
|
|
- if winnerNum == len(winners) {
|
|
|
+ if stopLoop {
|
|
|
break
|
|
|
}
|
|
|
+ wc <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(wn *entity.TopListS, wi int) {
|
|
|
+ defer func() {
|
|
|
+ wg.Done()
|
|
|
+ <-wc
|
|
|
+ }()
|
|
|
+
|
|
|
+ if strings.Contains(pt.Winners, wn.Name) {
|
|
|
+ winnerNum++
|
|
|
+ wnMap[wn.Name] = wi + 1
|
|
|
+ }
|
|
|
+ if winnerNum == len(winners) {
|
|
|
+ stopLoop = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }(wn, wi)
|
|
|
}
|
|
|
+ wg.Wait()
|
|
|
for wk, wd := range winners {
|
|
|
if wnMap[wd] > 0 {
|
|
|
- srtt.TopList[wnMap[wd]-1].Value += 1
|
|
|
+ srtt.TopList[wnMap[wd]-1].Value++
|
|
|
srtt.TopList[wnMap[wd]-1].Prop = utility.Formula(srtt.TopList[wnMap[wd]-1].Value, float64(scale.MarketProfile.ProjectCount))
|
|
|
} else {
|
|
|
srtt.TopList = append(srtt.TopList, &entity.TopListS{
|
|
@@ -811,16 +931,32 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
wnMap = map[string]int{}
|
|
|
winners = strings.Split(pt.Winners, ",")
|
|
|
winnerNum int
|
|
|
+ wc = make(chan bool, common.If(len(srat.TopList) > 10, consts.JudgmentPrev3, 1).(int))
|
|
|
+ wg = &sync.WaitGroup{}
|
|
|
+ stopLoop = false
|
|
|
)
|
|
|
for wi, wn := range srat.TopList {
|
|
|
- if strings.Contains(pt.Winners, wn.Name) {
|
|
|
- winnerNum++
|
|
|
- wnMap[wn.Name] = wi + 1
|
|
|
- }
|
|
|
- if winnerNum == len(winners) {
|
|
|
+ if stopLoop {
|
|
|
break
|
|
|
}
|
|
|
+ wc <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(wn *entity.TopListS, wi int) {
|
|
|
+ defer func() {
|
|
|
+ wg.Done()
|
|
|
+ <-wc
|
|
|
+ }()
|
|
|
+ if strings.Contains(pt.Winners, wn.Name) {
|
|
|
+ winnerNum++
|
|
|
+ wnMap[wn.Name] = wi + 1
|
|
|
+ }
|
|
|
+ if winnerNum == len(winners) {
|
|
|
+ stopLoop = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }(wn, wi)
|
|
|
}
|
|
|
+ wg.Wait()
|
|
|
for wk, wd := range winners {
|
|
|
if wnMap[wd] > 0 {
|
|
|
srat.TopList[wnMap[wd]-1].Value += pt.Sortprice
|
|
@@ -882,7 +1018,7 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
//项目数量TOP30采购单位及其重点合作中标单位
|
|
|
for _, bct := range baw.BuyerCountTop3 {
|
|
|
if bct.Name == pt.Buyer {
|
|
|
- bct.Number += 1
|
|
|
+ bct.Number++
|
|
|
if len(bct.Winnertop3) == 0 {
|
|
|
bct.Winnertop3 = utility.GetWinnerInfoOfBuyerCount(pt)
|
|
|
} else {
|
|
@@ -890,19 +1026,35 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
wnMap = map[string]int{}
|
|
|
winners = strings.Split(pt.Winners, ",")
|
|
|
winnerNum int
|
|
|
+ wc = make(chan bool, common.If(len(bct.Winnertop3) > 10, consts.JudgmentPrev3, 1).(int))
|
|
|
+ wg = &sync.WaitGroup{}
|
|
|
+ stopLoop = false
|
|
|
)
|
|
|
for wi, wn := range bct.Winnertop3 {
|
|
|
- if strings.Contains(pt.Winners, wn.Name) {
|
|
|
- winnerNum++
|
|
|
- wnMap[wn.Name] = wi + 1
|
|
|
- }
|
|
|
- if winnerNum == len(winners) {
|
|
|
+ if stopLoop {
|
|
|
break
|
|
|
}
|
|
|
+ wc <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(wn *entity.Winnertop3Number, wi int) {
|
|
|
+ defer func() {
|
|
|
+ wg.Done()
|
|
|
+ <-wc
|
|
|
+ }()
|
|
|
+ if strings.Contains(pt.Winners, wn.Name) {
|
|
|
+ winnerNum++
|
|
|
+ wnMap[wn.Name] = wi + 1
|
|
|
+ }
|
|
|
+ if winnerNum == len(winners) {
|
|
|
+ stopLoop = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }(wn, wi)
|
|
|
}
|
|
|
+ wg.Wait()
|
|
|
for wk, wd := range winners {
|
|
|
if wnMap[wd] > 0 {
|
|
|
- bct.Winnertop3[wnMap[wd]-1].Number += 1
|
|
|
+ bct.Winnertop3[wnMap[wd]-1].Number++
|
|
|
} else {
|
|
|
bct.Winnertop3 = append(bct.Winnertop3, &entity.Winnertop3Number{
|
|
|
Id: common.If(len(pt.Entidlist) > wk, encrypt.EncodeArticleId2ByCheck(pt.Entidlist[wk]), "").(string),
|
|
@@ -926,16 +1078,32 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
wnMap = map[string]int{}
|
|
|
winners = strings.Split(pt.Winners, ",")
|
|
|
winnerNum int
|
|
|
+ wc = make(chan bool, common.If(len(bat.Winnertop3) > 10, consts.JudgmentPrev3, 1).(int))
|
|
|
+ wg = &sync.WaitGroup{}
|
|
|
+ stopLoop = false
|
|
|
)
|
|
|
for wi, wn := range bat.Winnertop3 {
|
|
|
- if strings.Contains(pt.Winners, wn.Name) {
|
|
|
- winnerNum++
|
|
|
- wnMap[wn.Name] = wi + 1
|
|
|
- }
|
|
|
- if winnerNum == len(winners) {
|
|
|
+ if stopLoop {
|
|
|
break
|
|
|
}
|
|
|
+ wc <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(wn *entity.Winnertop3Amount, wi int) {
|
|
|
+ defer func() {
|
|
|
+ wg.Done()
|
|
|
+ <-wc
|
|
|
+ }()
|
|
|
+ if strings.Contains(pt.Winners, wn.Name) {
|
|
|
+ winnerNum++
|
|
|
+ wnMap[wn.Name] = wi + 1
|
|
|
+ }
|
|
|
+ if winnerNum == len(winners) {
|
|
|
+ stopLoop = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }(wn, wi)
|
|
|
}
|
|
|
+ wg.Wait()
|
|
|
for wk, wd := range winners {
|
|
|
if wnMap[wd] > 0 {
|
|
|
bat.Winnertop3[wnMap[wd]-1].Amount += pt.Sortprice
|
|
@@ -952,7 +1120,7 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //采购规模分布
|
|
|
+ //采购规模分布 --7
|
|
|
var psk = ""
|
|
|
for _, cp := range consts.ProjectScale {
|
|
|
if cp.From < pt.Sortprice && common.If(cp.To > 0, cp.To > pt.Sortprice, true).(bool) {
|
|
@@ -972,7 +1140,7 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
} else {
|
|
|
for _, ps := range baw.BuyerTimeDistribution {
|
|
|
if ps.Key == psk {
|
|
|
- ps.Number += 1
|
|
|
+ ps.Number++
|
|
|
ps.Amount += pt.Sortprice
|
|
|
ps.TotalAmount = utility.Formula(ps.Amount, scale.MarketProfile.Projctamout)
|
|
|
ps.TotalNumber = utility.Formula(ps.Number, float64(scale.MarketProfile.ProjectCount))
|
|
@@ -1006,19 +1174,37 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
//项目数量TOP30中标单位及其重点合作采购单位
|
|
|
for _, wct := range baw.WinnerCountTop3 {
|
|
|
if wct.Name == winner {
|
|
|
- wct.Number += 1
|
|
|
+ wct.Number++
|
|
|
if len(wct.Buyertop3) == 0 {
|
|
|
wct.Buyertop3 = utility.GetWinnerInfoOfWinnerCount(pt)
|
|
|
} else {
|
|
|
- var wnMap = map[string]int{}
|
|
|
+ var (
|
|
|
+ wnMap = map[string]int{}
|
|
|
+ wc = make(chan bool, common.If(len(wct.Buyertop3) > 10, consts.JudgmentPrev3, 1).(int))
|
|
|
+ wg = &sync.WaitGroup{}
|
|
|
+ stopLoop = false
|
|
|
+ )
|
|
|
for wi, wn := range wct.Buyertop3 {
|
|
|
- if wn.Name == pt.Buyer {
|
|
|
- wnMap[wn.Name] = wi + 1
|
|
|
+ if stopLoop {
|
|
|
break
|
|
|
}
|
|
|
+ wc <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(wn *entity.Buyertop3Number, wi int) {
|
|
|
+ defer func() {
|
|
|
+ wg.Done()
|
|
|
+ <-wc
|
|
|
+ }()
|
|
|
+ if wn.Name == pt.Buyer {
|
|
|
+ wnMap[wn.Name] = wi + 1
|
|
|
+ stopLoop = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }(wn, wi)
|
|
|
}
|
|
|
+ wg.Wait()
|
|
|
if wnMap[pt.Buyer] > 0 {
|
|
|
- wct.Buyertop3[wnMap[pt.Buyer]-1].Number += 1
|
|
|
+ wct.Buyertop3[wnMap[pt.Buyer]-1].Number++
|
|
|
} else {
|
|
|
wct.Buyertop3 = append(wct.Buyertop3, &entity.Buyertop3Number{
|
|
|
Name: pt.Buyer,
|
|
@@ -1036,12 +1222,31 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
if len(wat.Buyertop3) == 0 {
|
|
|
wat.Buyertop3 = utility.GetWinnerInfoOfWinnerAmount(pt)
|
|
|
} else {
|
|
|
- var wnMap = map[string]int{}
|
|
|
+ var (
|
|
|
+ wnMap = map[string]int{}
|
|
|
+ wc = make(chan bool, common.If(len(wat.Buyertop3) > 10, consts.JudgmentPrev3, 1).(int))
|
|
|
+ wg = &sync.WaitGroup{}
|
|
|
+ stopLoop = false
|
|
|
+ )
|
|
|
for wi, wn := range wat.Buyertop3 {
|
|
|
- if wn.Name == pt.Buyer {
|
|
|
- wnMap[wn.Name] = wi + 1
|
|
|
+ if stopLoop {
|
|
|
+ break
|
|
|
}
|
|
|
+ wc <- true
|
|
|
+ wg.Add(1)
|
|
|
+ go func(wn *entity.Buyertop3Amount, wi int) {
|
|
|
+ defer func() {
|
|
|
+ wg.Done()
|
|
|
+ <-wc
|
|
|
+ }()
|
|
|
+ if wn.Name == pt.Buyer {
|
|
|
+ wnMap[wn.Name] = wi + 1
|
|
|
+ stopLoop = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }(wn, wi)
|
|
|
}
|
|
|
+ wg.Wait()
|
|
|
if wnMap[pt.Buyer] > 0 {
|
|
|
wat.Buyertop3[wnMap[pt.Buyer]-1].Amount += pt.Sortprice
|
|
|
} else {
|
|
@@ -1076,7 +1281,7 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
} else {
|
|
|
for _, ps := range baw.WinnerTimeDistribution {
|
|
|
if ps.Key == psk {
|
|
|
- ps.Number += 1
|
|
|
+ ps.Number++
|
|
|
ps.Amount += pt.Sortprice
|
|
|
ps.TotalAmount = utility.Formula(ps.Amount, scale.MarketProfile.Projctamout)
|
|
|
ps.TotalNumber = utility.Formula(ps.Number, float64(scale.MarketProfile.ProjectCount))
|
|
@@ -1100,7 +1305,6 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
}
|
|
|
scaleFunc()
|
|
|
nextFunc()
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// ResultSave 结果保存
|