|
@@ -119,8 +119,12 @@ func (ut *UserTask) MatchConditions(p *entity.ProjectInfo) (b bool) {
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
-// 采购单位类型
|
|
|
+// BuyClassMatch 采购单位类型
|
|
|
func (ut *UserTask) BuyClassMatch(buyerclass string) (b bool) {
|
|
|
+ if len(ut.FormatParam.BuyerClass) == 0 {
|
|
|
+ b = true
|
|
|
+ return
|
|
|
+ }
|
|
|
if buyerclass == "" {
|
|
|
return
|
|
|
}
|
|
@@ -130,8 +134,14 @@ func (ut *UserTask) BuyClassMatch(buyerclass string) (b bool) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// 省份和城市
|
|
|
+// AreaMatch 省份和城市
|
|
|
func (ut *UserTask) AreaMatch(area, city string) (b bool) {
|
|
|
+ //没有地区分析条件
|
|
|
+ if len(ut.FormatParam.Area) == 0 && len(ut.FormatParam.City) == 0 {
|
|
|
+ b = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //项目信息没有地区字段
|
|
|
if area == "" && city == "" {
|
|
|
return
|
|
|
}
|
|
@@ -142,8 +152,12 @@ func (ut *UserTask) AreaMatch(area, city string) (b bool) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// 行业
|
|
|
+// IndustryMatch 行业
|
|
|
func (ut *UserTask) IndustryMatch(industry string) (b bool) {
|
|
|
+ if len(ut.FormatParam.Industry) == 0 {
|
|
|
+ b = true
|
|
|
+ return
|
|
|
+ }
|
|
|
if industry == "" {
|
|
|
return
|
|
|
}
|
|
@@ -181,8 +195,12 @@ func (ut *UserTask) KeysMatchByKeysItems(matchObject string, keysItems entity.Ke
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// 关键词
|
|
|
+// KeysMatch 关键词
|
|
|
func (ut *UserTask) KeysMatch(matchObject string) (b bool) {
|
|
|
+ if len(ut.FormatParam.KeysItems) == 0 {
|
|
|
+ b = true
|
|
|
+ return
|
|
|
+ }
|
|
|
var (
|
|
|
dfaKey = dfa.DFA{}
|
|
|
dfaExclude = dfa.DFA{}
|
|
@@ -223,12 +241,77 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
if pt.Buyer != "" {
|
|
|
scale.MarketProfile.Buyercount++
|
|
|
}
|
|
|
- scale.MarketProfile.ProjectCount++
|
|
|
if pt.Winners != "" {
|
|
|
scale.MarketProfile.Winnercount += len(strings.Split(pt.Winners, ","))
|
|
|
}
|
|
|
+ scale.MarketProfile.ProjectCount++
|
|
|
scale.MarketProfile.Projctamout += pt.Sortprice
|
|
|
- scale.MarketProfile.Projectavgmoney = utility.Formula(scale.MarketProfile.Projctamout, float64(scale.MarketProfile.ProjectCount)) //项目平均金额(万)
|
|
|
+ //月度分配
|
|
|
+ if len(ut.MonthDistributionKey) > 0 {
|
|
|
+ if monthKey := ut.GetMonthDistributionKey(pt.JgTime); monthKey != "" {
|
|
|
+ monthKeyPrev := utility.GetJudgmentPrevKey(consts.JudgmentPrev11, monthKey)
|
|
|
+ if !ut.JudgmentMap[monthKeyPrev] {
|
|
|
+ ut.JudgmentMap[monthKeyPrev] = true
|
|
|
+ //金额
|
|
|
+ scale.MonthDistribution.ProjectAmount = append(scale.MonthDistribution.ProjectAmount, &entity.Distribution{
|
|
|
+ Minth: monthKey,
|
|
|
+ Value: pt.Sortprice,
|
|
|
+ })
|
|
|
+ //项目数量
|
|
|
+ scale.MonthDistribution.ProjectCount = append(scale.MonthDistribution.ProjectCount, &entity.Distribution{
|
|
|
+ Minth: monthKey,
|
|
|
+ Value: 1,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ //金额
|
|
|
+ for _, mdpa := range scale.MonthDistribution.ProjectAmount {
|
|
|
+ if mdpa.Minth == monthKey {
|
|
|
+ mdpa.Value += pt.Sortprice
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //项目数量
|
|
|
+ for _, mdpc := range scale.MonthDistribution.ProjectCount {
|
|
|
+ if mdpc.Minth == monthKey {
|
|
|
+ mdpc.Value++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //年度分配
|
|
|
+ if len(ut.YearDistributionKey) > 0 {
|
|
|
+ if yearKey := ut.GetYearDistributionKey(pt.JgTime); yearKey != "" {
|
|
|
+ yearKeyPrev := utility.GetJudgmentPrevKey(consts.JudgmentPrev11, yearKey)
|
|
|
+ if !ut.JudgmentMap[yearKeyPrev] {
|
|
|
+ ut.JudgmentMap[yearKeyPrev] = true
|
|
|
+ //金额
|
|
|
+ scale.YearDistribution.ProjectAmount = append(scale.YearDistribution.ProjectAmount, &entity.Distribution{
|
|
|
+ Minth: yearKey,
|
|
|
+ Value: pt.Sortprice,
|
|
|
+ })
|
|
|
+ //项目数量
|
|
|
+ scale.YearDistribution.ProjectCount = append(scale.YearDistribution.ProjectCount, &entity.Distribution{
|
|
|
+ Minth: yearKey,
|
|
|
+ Value: 1,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ //金额
|
|
|
+ for _, mdpa := range scale.YearDistribution.ProjectAmount {
|
|
|
+ if mdpa.Minth == yearKey {
|
|
|
+ mdpa.Value += pt.Sortprice
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //项目数量
|
|
|
+ for _, mdpc := range scale.YearDistribution.ProjectCount {
|
|
|
+ if mdpc.Minth == yearKey {
|
|
|
+ mdpc.Value++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
//是否需要进行环比
|
|
|
if ut.IsRatio {
|
|
@@ -240,58 +323,6 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
if pt.Winners != "" {
|
|
|
scale.ProjectInfoAll.Winnercount += len(strings.Split(pt.Winners, ","))
|
|
|
}
|
|
|
- //项目平均金额(万)
|
|
|
- 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))
|
|
|
- //项目金额环比
|
|
|
- scale.MarketProfile.ProjctamountRatio = utility.Sequential(scale.MarketProfile.Projctamout, scale.ProjectInfoAll.Projctamout)
|
|
|
- //项目数量环比
|
|
|
- scale.MarketProfile.ProjectCountRatio = utility.Sequential(float64(scale.MarketProfile.ProjectCount), float64(scale.ProjectInfoAll.ProjectCount))
|
|
|
- //项目平均金额环比
|
|
|
- scale.MarketProfile.ProjectavgmoneyRatio = utility.Sequential(scale.MarketProfile.Projectavgmoney, float64(scale.ProjectInfoAll.Projectavgmoney))
|
|
|
- //采购单位环比
|
|
|
- scale.MarketProfile.BuyercountRatio = utility.Sequential(float64(scale.MarketProfile.Buyercount), float64(scale.ProjectInfoAll.Buyercount))
|
|
|
- }
|
|
|
- //月度分配
|
|
|
- if len(ut.MonthDistributionKey) > 0 {
|
|
|
- for mdk, mdv := range ut.MonthDistributionKey {
|
|
|
- eDAmount := entity.Distribution{} //金额
|
|
|
- eDCount := entity.Distribution{} //项目数量
|
|
|
- eDAmount.Minth = mdv.Key
|
|
|
- eDCount.Minth = mdv.Key
|
|
|
- if utility.DateIsIn(mdv.From, mdv.To, pt.JgTime, 0) {
|
|
|
- eDAmount.Value += pt.Sortprice
|
|
|
- eDCount.Value++
|
|
|
- if ut.IsRatio && mdk > 0 {
|
|
|
- //计算环比
|
|
|
- eDAmount.Ratio = utility.Sequential(eDAmount.Value, scale.MonthDistribution.ProjectAmount[mdk-1].Value)
|
|
|
- eDCount.Ratio = utility.Sequential(eDCount.Value, scale.MonthDistribution.ProjectCount[mdk-1].Value)
|
|
|
- }
|
|
|
- }
|
|
|
- scale.MonthDistribution.ProjectAmount = append(scale.MonthDistribution.ProjectAmount, eDAmount)
|
|
|
- scale.MonthDistribution.ProjectCount = append(scale.MonthDistribution.ProjectCount, eDCount)
|
|
|
- }
|
|
|
- }
|
|
|
- //年度分配
|
|
|
- if len(ut.YearDistributionKey) > 0 {
|
|
|
- for ydk, ydv := range ut.YearDistributionKey {
|
|
|
- eDAmount := entity.Distribution{} //金额
|
|
|
- eDCount := entity.Distribution{} //项目数量
|
|
|
- eDAmount.Minth = ydv.Key
|
|
|
- eDCount.Minth = ydv.Key
|
|
|
- if utility.DateIsIn(ydv.From, ydv.To, pt.JgTime, 0) {
|
|
|
- eDAmount.Value += pt.Sortprice
|
|
|
- eDCount.Value++
|
|
|
- if ut.IsRatio && ydk > 0 {
|
|
|
- //计算环比
|
|
|
- eDAmount.Ratio = utility.Sequential(eDAmount.Value, scale.YearDistribution.ProjectAmount[ydk-1].Value)
|
|
|
- eDCount.Ratio = utility.Sequential(eDCount.Value, scale.YearDistribution.ProjectCount[ydk-1].Value)
|
|
|
- }
|
|
|
- }
|
|
|
- scale.YearDistribution.ProjectAmount = append(scale.YearDistribution.ProjectAmount, eDAmount)
|
|
|
- scale.YearDistribution.ProjectCount = append(scale.YearDistribution.ProjectCount, eDCount)
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
//项目规模TOP10 集合
|
|
@@ -309,7 +340,7 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
entIdList = append(entIdList, utility.EncodeId(entId))
|
|
|
}
|
|
|
}
|
|
|
- topProject.ProjectTop10 = append(topProject.ProjectTop10, entity.ProjectTop{
|
|
|
+ topProject.ProjectTop10 = append(topProject.ProjectTop10, &entity.ProjectTop{
|
|
|
Id: common.If(pt.SourceInfoId != "", utility.EncodeId(pt.SourceInfoId), "").(string),
|
|
|
Area: pt.Area,
|
|
|
City: pt.City,
|
|
@@ -460,14 +491,12 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
//项目数量TOP3客户类型的重点中标单位
|
|
|
pad.ScaleBuyclassCountTop = append(pad.ScaleBuyclassCountTop, &entity.ScaleBuyclassCountTopS{
|
|
|
BuyclassCount: 1,
|
|
|
- BuyclassScale: utility.Formula(1, float64(scale.MarketProfile.ProjectCount)),
|
|
|
Name: bc,
|
|
|
Winner: utility.GetWinnerInfoOfCount(pt),
|
|
|
})
|
|
|
//项目金额TOP3客户类型的重点中标单位
|
|
|
pad.ScaleBuyclassAmountTop = append(pad.ScaleBuyclassAmountTop, &entity.ScaleBuyclassAmountTopS{
|
|
|
BuyclassAmount: pt.Sortprice,
|
|
|
- BuyclassScale: utility.Formula(pt.Sortprice, float64(scale.MarketProfile.ProjectCount)),
|
|
|
Name: bc,
|
|
|
Winner: utility.GetWinnerInfoOfAmount(pt),
|
|
|
})
|
|
@@ -476,7 +505,6 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
for _, sbct := range pad.ScaleBuyclassCountTop {
|
|
|
if sbct.Name == bc {
|
|
|
sbct.BuyclassCount++
|
|
|
- sbct.BuyclassScale = utility.Formula(float64(sbct.BuyclassCount), float64(scale.MarketProfile.ProjectCount))
|
|
|
if len(sbct.Winner) > 0 {
|
|
|
var (
|
|
|
wnMap = map[string]int{}
|
|
@@ -535,20 +563,10 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
- /*-------------排序------BuyerclassCount----------*/
|
|
|
- //if len(pad.ScaleBuyclassCountTop) > 1 {
|
|
|
- // sort.Slice(pad.ScaleBuyclassCountTop, func(i, j int) bool {
|
|
|
- // return pad.ScaleBuyclassCountTop[i].BuyclassCount > pad.ScaleBuyclassCountTop[j].BuyclassCount
|
|
|
- // })
|
|
|
- // if len(pad.ScaleBuyclassCountTop) > consts.Top3 {
|
|
|
- // pad.ScaleBuyclassCountTop = pad.ScaleBuyclassCountTop[:consts.Top3]
|
|
|
- // }
|
|
|
- //}
|
|
|
//项目金额TOP3客户类型的重点中标单位
|
|
|
for _, sbat := range pad.ScaleBuyclassAmountTop {
|
|
|
if sbat.Name == bc {
|
|
|
sbat.BuyclassAmount += pt.Sortprice
|
|
|
- sbat.BuyclassScale = utility.Formula(sbat.BuyclassAmount, float64(scale.MarketProfile.ProjectCount))
|
|
|
if len(sbat.Winner) > 0 {
|
|
|
var (
|
|
|
wnMap = map[string]int{}
|
|
@@ -605,15 +623,6 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- /*-------------排序-----BuyerclassAmount-----------*/
|
|
|
- //if len(pad.ScaleBuyclassAmountTop) > 1 {
|
|
|
- // sort.Slice(pad.ScaleBuyclassAmountTop, func(i, j int) bool {
|
|
|
- // return pad.ScaleBuyclassAmountTop[i].BuyclassAmount > pad.ScaleBuyclassAmountTop[j].BuyclassAmount
|
|
|
- // })
|
|
|
- // if len(pad.ScaleBuyclassAmountTop) > consts.Top3 {
|
|
|
- // pad.ScaleBuyclassAmountTop = pad.ScaleBuyclassAmountTop[:consts.Top3]
|
|
|
- // }
|
|
|
- //}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -632,19 +641,15 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
if !ut.JudgmentMap[scaleKey] {
|
|
|
ut.JudgmentMap[scaleKey] = true
|
|
|
pad.ProjectScale = append(pad.ProjectScale, &entity.ProjectScaleS{
|
|
|
- Name: psk,
|
|
|
- Count: 1,
|
|
|
- Amount: pt.Sortprice,
|
|
|
- PersentA: utility.Formula(1, float64(scale.MarketProfile.ProjectCount)),
|
|
|
- PersentC: utility.Formula(pt.Sortprice, scale.MarketProfile.Projctamout),
|
|
|
+ Name: psk,
|
|
|
+ Count: 1,
|
|
|
+ Amount: pt.Sortprice,
|
|
|
})
|
|
|
} else {
|
|
|
for _, ps := range pad.ProjectScale {
|
|
|
if ps.Name == psk {
|
|
|
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))
|
|
|
break
|
|
|
}
|
|
|
}
|
|
@@ -661,14 +666,12 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
//项目金额---TOP3地区的重点中标单位
|
|
|
pad.ScaleAreaAmountTop = append(pad.ScaleAreaAmountTop, &entity.ScaleAreaAmountTopS{
|
|
|
AreaAmount: pt.Sortprice,
|
|
|
- AreaScale: utility.Formula(pt.Sortprice, scale.MarketProfile.Projctamout),
|
|
|
Name: pt.Area,
|
|
|
Winner: utility.GetWinnerInfoOfAmount(pt),
|
|
|
})
|
|
|
//项目数量---TOP3地区的重点中标单位
|
|
|
pad.ScaleAreaCountTop = append(pad.ScaleAreaCountTop, &entity.ScaleAreaCountTopS{
|
|
|
AreaCount: 1,
|
|
|
- AreaScale: utility.Formula(1, scale.MarketProfile.Projctamout),
|
|
|
Name: pt.Area,
|
|
|
Winner: utility.GetWinnerInfoOfCount(pt),
|
|
|
})
|
|
@@ -677,7 +680,6 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
for _, saat := range pad.ScaleAreaAmountTop {
|
|
|
if saat.Name == pt.Area {
|
|
|
saat.AreaAmount += pt.Sortprice
|
|
|
- saat.AreaScale = utility.Formula(saat.AreaAmount, scale.MarketProfile.Projctamout)
|
|
|
if len(saat.Winner) > 0 {
|
|
|
var (
|
|
|
wnMap = map[string]int{}
|
|
@@ -734,20 +736,10 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- /*-------------排序----------AreaAmount------*/
|
|
|
- //if len(pad.ScaleAreaAmountTop) > 1 {
|
|
|
- // sort.Slice(pad.ScaleAreaAmountTop, func(i, j int) bool {
|
|
|
- // return pad.ScaleAreaAmountTop[i].AreaAmount > pad.ScaleAreaAmountTop[j].AreaAmount
|
|
|
- // })
|
|
|
- // if len(pad.ScaleAreaAmountTop) > consts.Top3 {
|
|
|
- // pad.ScaleAreaAmountTop = pad.ScaleAreaAmountTop[:consts.Top3]
|
|
|
- // }
|
|
|
- //}
|
|
|
//项目数量---TOP3地区的重点中标单位
|
|
|
for _, sact := range pad.ScaleAreaCountTop {
|
|
|
if sact.Name == pt.Area {
|
|
|
sact.AreaCount++
|
|
|
- sact.AreaScale = utility.Formula(float64(sact.AreaCount), scale.MarketProfile.Projctamout)
|
|
|
if len(sact.Winner) > 0 {
|
|
|
var (
|
|
|
wnMap = map[string]int{}
|
|
@@ -804,15 +796,6 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- /*-------------排序-------AreaCount---------*/
|
|
|
- //if len(pad.ScaleAreaCountTop) > 1 {
|
|
|
- // sort.Slice(pad.ScaleAreaCountTop, func(i, j int) bool {
|
|
|
- // return pad.ScaleAreaCountTop[i].AreaCount > pad.ScaleAreaCountTop[j].AreaCount
|
|
|
- // })
|
|
|
- // if len(pad.ScaleAreaCountTop) > consts.Top3 {
|
|
|
- // pad.ScaleAreaCountTop = pad.ScaleAreaCountTop[:consts.Top3]
|
|
|
- // }
|
|
|
- //}
|
|
|
}
|
|
|
}
|
|
|
scaleAreaAmountAndCountTopFunc()
|
|
@@ -842,14 +825,12 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
sr.ScaleRefineTotalTop = append(sr.ScaleRefineTotalTop, &entity.ScaleRefineTotalTopS{
|
|
|
Name: itemName,
|
|
|
Value: 1,
|
|
|
- Prop: utility.Formula(1, float64(scale.MarketProfile.ProjectCount)),
|
|
|
TopList: utility.GetWinnerInfoTopList(pt, 1, float64(scale.MarketProfile.ProjectCount)),
|
|
|
})
|
|
|
//重点中标单位-金额
|
|
|
sr.ScaleRefineAmountTop = append(sr.ScaleRefineAmountTop, &entity.ScaleRefineAmountTopS{
|
|
|
Name: itemName,
|
|
|
Value: pt.Sortprice,
|
|
|
- Prop: utility.Formula(pt.Sortprice, scale.MarketProfile.Projctamout),
|
|
|
TopList: utility.GetWinnerInfoTopList(pt, pt.Sortprice, scale.MarketProfile.Projctamout),
|
|
|
})
|
|
|
} else {
|
|
@@ -865,7 +846,6 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
for _, srtt := range sr.ScaleRefineTotalTop {
|
|
|
if srtt.Name == itemName {
|
|
|
srtt.Value++
|
|
|
- srtt.Prop = utility.Formula(float64(srtt.Value), float64(scale.MarketProfile.ProjectCount))
|
|
|
if len(srtt.TopList) > 0 {
|
|
|
var (
|
|
|
wnMap = map[string]int{}
|
|
@@ -929,7 +909,6 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
for _, srat := range sr.ScaleRefineAmountTop {
|
|
|
if srat.Name == itemName {
|
|
|
srat.Value += pt.Sortprice
|
|
|
- srat.Prop = utility.Formula(srat.Value, float64(scale.MarketProfile.ProjectCount))
|
|
|
if len(srat.TopList) > 0 {
|
|
|
var (
|
|
|
wnMap = map[string]int{}
|
|
@@ -1153,19 +1132,15 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
if !ut.JudgmentMap[scaleKey] {
|
|
|
ut.JudgmentMap[scaleKey] = true
|
|
|
baw.BuyerTimeDistribution = append(baw.BuyerTimeDistribution, &entity.BuyerAndWinnerTimeDistributionS{
|
|
|
- Key: psk,
|
|
|
- Amount: pt.Sortprice,
|
|
|
- Number: 1,
|
|
|
- TotalAmount: utility.Formula(pt.Sortprice, scale.MarketProfile.Projctamout),
|
|
|
- TotalNumber: utility.Formula(1, float64(scale.MarketProfile.ProjectCount)),
|
|
|
+ Key: psk,
|
|
|
+ Amount: pt.Sortprice,
|
|
|
+ Number: 1,
|
|
|
})
|
|
|
} else {
|
|
|
for _, ps := range baw.BuyerTimeDistribution {
|
|
|
if ps.Key == psk {
|
|
|
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))
|
|
|
break
|
|
|
}
|
|
|
}
|
|
@@ -1312,19 +1287,15 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
if !ut.JudgmentMap[scaleKey] {
|
|
|
ut.JudgmentMap[scaleKey] = true
|
|
|
baw.WinnerTimeDistribution = append(baw.WinnerTimeDistribution, &entity.BuyerAndWinnerTimeDistributionS{
|
|
|
- Key: psk,
|
|
|
- Amount: pt.Sortprice,
|
|
|
- Number: 1,
|
|
|
- TotalAmount: utility.Formula(pt.Sortprice, scale.MarketProfile.Projctamout),
|
|
|
- TotalNumber: utility.Formula(1, float64(scale.MarketProfile.ProjectCount)),
|
|
|
+ Key: psk,
|
|
|
+ Amount: pt.Sortprice,
|
|
|
+ Number: 1,
|
|
|
})
|
|
|
} else {
|
|
|
for _, ps := range baw.WinnerTimeDistribution {
|
|
|
if ps.Key == psk {
|
|
|
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))
|
|
|
break
|
|
|
}
|
|
|
}
|
|
@@ -1351,7 +1322,66 @@ func (ut *UserTask) Calculate(pt *entity.ProjectInfo) {
|
|
|
|
|
|
// DataCollation 数据整理
|
|
|
func (ut *UserTask) DataCollation() {
|
|
|
- var projectAllData = func() {
|
|
|
+ //项目环比
|
|
|
+ scale := ut.Result.Scale
|
|
|
+ var ratioFunc = func() {
|
|
|
+ //项目平均金额(万)
|
|
|
+ scale.MarketProfile.Projectavgmoney = utility.Formula(scale.MarketProfile.Projctamout, float64(scale.MarketProfile.ProjectCount))
|
|
|
+ //环比
|
|
|
+ if ut.IsRatio {
|
|
|
+ //项目平均金额(万)
|
|
|
+ scale.ProjectInfoAll.Projectavgmoney = utility.Formula(scale.ProjectInfoAll.Projctamout, float64(scale.ProjectInfoAll.ProjectCount))
|
|
|
+ //项目平均金额环比
|
|
|
+ scale.MarketProfile.ProjectavgmoneyRatio = utility.Sequential(scale.MarketProfile.Projectavgmoney, scale.ProjectInfoAll.Projectavgmoney)
|
|
|
+ //项目金额环比
|
|
|
+ scale.MarketProfile.ProjctamountRatio = utility.Sequential(scale.MarketProfile.Projctamout, scale.ProjectInfoAll.Projctamout)
|
|
|
+ //项目数量环比
|
|
|
+ scale.MarketProfile.ProjectCountRatio = utility.Sequential(float64(scale.MarketProfile.ProjectCount), float64(scale.ProjectInfoAll.ProjectCount))
|
|
|
+ //采购单位项目数量环比
|
|
|
+ scale.MarketProfile.BuyercountRatio = utility.Sequential(float64(scale.MarketProfile.Buyercount), float64(scale.ProjectInfoAll.Buyercount))
|
|
|
+ //中标企业项目数量环比
|
|
|
+ scale.MarketProfile.WinnercountRatio = utility.Sequential(float64(scale.MarketProfile.Winnercount), float64(scale.ProjectInfoAll.Winnercount))
|
|
|
+ //月度分配
|
|
|
+ var monthRatioFunc = func() {
|
|
|
+ //金额
|
|
|
+ for k, v := range scale.MonthDistribution.ProjectAmount {
|
|
|
+ if k == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ v.Ratio = utility.Sequential(v.Value, scale.MonthDistribution.ProjectAmount[k-1].Value)
|
|
|
+ }
|
|
|
+ //项目数量
|
|
|
+ for k, v := range scale.MonthDistribution.ProjectCount {
|
|
|
+ if k == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ v.Ratio = utility.Sequential(v.Value, scale.MonthDistribution.ProjectCount[k-1].Value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ monthRatioFunc()
|
|
|
+ //年度分配
|
|
|
+ var yearRatioFunc = func() {
|
|
|
+ //金额
|
|
|
+ for k, v := range scale.YearDistribution.ProjectAmount {
|
|
|
+ if k == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ v.Ratio = utility.Sequential(v.Value, scale.YearDistribution.ProjectAmount[k-1].Value)
|
|
|
+ }
|
|
|
+ //项目数量
|
|
|
+ for k, v := range scale.YearDistribution.ProjectCount {
|
|
|
+ if k == 0 {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ v.Ratio = utility.Sequential(v.Value, scale.YearDistribution.ProjectCount[k-1].Value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ yearRatioFunc()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ratioFunc()
|
|
|
+ //项目规模----------0-0
|
|
|
+ var projectAllDataFunc = func() {
|
|
|
pad := ut.Result.ProjectAllData
|
|
|
//项目数量TOP3客户类型的重点中标单位
|
|
|
if len(pad.ScaleBuyclassCountTop) > 1 {
|
|
@@ -1362,6 +1392,10 @@ func (ut *UserTask) DataCollation() {
|
|
|
if len(pad.ScaleBuyclassCountTop) > consts.Top3 {
|
|
|
pad.ScaleBuyclassCountTop = pad.ScaleBuyclassCountTop[:consts.Top3]
|
|
|
}
|
|
|
+ //采购单位数量环比
|
|
|
+ for _, v := range pad.ScaleBuyclassCountTop {
|
|
|
+ v.BuyclassScale = utility.Formula(float64(v.BuyclassCount), float64(scale.MarketProfile.ProjectCount))
|
|
|
+ }
|
|
|
}
|
|
|
//项目金额TOP3客户类型的重点中标单位
|
|
|
if len(pad.ScaleBuyclassAmountTop) > 1 {
|
|
@@ -1372,6 +1406,10 @@ func (ut *UserTask) DataCollation() {
|
|
|
if len(pad.ScaleBuyclassAmountTop) > consts.Top3 {
|
|
|
pad.ScaleBuyclassAmountTop = pad.ScaleBuyclassAmountTop[:consts.Top3]
|
|
|
}
|
|
|
+ //采购单位类型金额占比
|
|
|
+ for _, v := range pad.ScaleBuyclassAmountTop {
|
|
|
+ v.BuyclassScale = utility.Formula(v.BuyclassAmount, float64(scale.MarketProfile.ProjectCount))
|
|
|
+ }
|
|
|
}
|
|
|
//项目金额TOP3地区的重点中标单位
|
|
|
if len(pad.ScaleAreaAmountTop) > 1 {
|
|
@@ -1382,6 +1420,10 @@ func (ut *UserTask) DataCollation() {
|
|
|
if len(pad.ScaleAreaAmountTop) > consts.Top3 {
|
|
|
pad.ScaleAreaAmountTop = pad.ScaleAreaAmountTop[:consts.Top3]
|
|
|
}
|
|
|
+ //地区环比
|
|
|
+ for _, v := range pad.ScaleAreaAmountTop {
|
|
|
+ v.AreaScale = utility.Formula(v.AreaAmount, scale.MarketProfile.Projctamout)
|
|
|
+ }
|
|
|
}
|
|
|
//项目数量TOP3地区的重点中标单位
|
|
|
/*-------------排序-------AreaCount---------*/
|
|
@@ -1392,10 +1434,53 @@ func (ut *UserTask) DataCollation() {
|
|
|
if len(pad.ScaleAreaCountTop) > consts.Top3 {
|
|
|
pad.ScaleAreaCountTop = pad.ScaleAreaCountTop[:consts.Top3]
|
|
|
}
|
|
|
+ for _, v := range pad.ScaleAreaCountTop {
|
|
|
+ v.AreaScale = utility.Formula(float64(v.AreaCount), scale.MarketProfile.Projctamout)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //项目规模分布
|
|
|
+ for _, v := range pad.ProjectScale {
|
|
|
+ //项目总金额占比
|
|
|
+ v.PersentC = utility.Formula(v.Amount, scale.MarketProfile.Projctamout)
|
|
|
+ //项目总数占比
|
|
|
+ v.PersentA = utility.Formula(float64(v.Count), float64(scale.MarketProfile.ProjectCount))
|
|
|
}
|
|
|
}
|
|
|
/* 项目规模 地区分布 客户分布 地区客户top3*/
|
|
|
- projectAllData()
|
|
|
+ projectAllDataFunc()
|
|
|
+ //细化市场
|
|
|
+ var scaleRefineFunc = func() {
|
|
|
+ sr := ut.Result.ScaleRefine
|
|
|
+ //细分市场的重点中标单位-项目数量占比
|
|
|
+ for _, v := range sr.ScaleRefineTotalTop {
|
|
|
+ v.Prop = utility.Formula(float64(v.Value), float64(scale.MarketProfile.ProjectCount))
|
|
|
+ }
|
|
|
+ //细分市场的重点中标单位-分类金额百分比
|
|
|
+ for _, v := range sr.ScaleRefineAmountTop {
|
|
|
+ v.Prop = utility.Formula(v.Value, float64(scale.MarketProfile.ProjectCount))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //细化市场
|
|
|
+ scaleRefineFunc()
|
|
|
+ ///* 市场-采购单位&&中标企业*/
|
|
|
+ var buyerAndWinnerFunc = func() {
|
|
|
+ baw := ut.Result.BuyerAndWinner
|
|
|
+ //采购规模分布
|
|
|
+ for _, v := range baw.BuyerTimeDistribution {
|
|
|
+ //总金额
|
|
|
+ v.TotalAmount = utility.Formula(v.Amount, scale.MarketProfile.Projctamout)
|
|
|
+ //总项目数量
|
|
|
+ v.TotalNumber = utility.Formula(v.Number, float64(scale.MarketProfile.ProjectCount))
|
|
|
+ }
|
|
|
+ //中标规模分布
|
|
|
+ for _, v := range baw.WinnerTimeDistribution {
|
|
|
+ //总金额
|
|
|
+ v.TotalAmount = utility.Formula(v.Amount, scale.MarketProfile.Projctamout)
|
|
|
+ //总项目数量
|
|
|
+ v.TotalNumber = utility.Formula(v.Number, float64(scale.MarketProfile.ProjectCount))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ buyerAndWinnerFunc()
|
|
|
/*---------------*/
|
|
|
//var buyerAndWinner = func() {
|
|
|
// ///* 市场-采购单位&&中标企业*/
|
|
@@ -1558,3 +1643,25 @@ func (ut *UserTask) ForMatData() error {
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+// GetMonthDistributionKey 获取月度key
|
|
|
+func (ut *UserTask) GetMonthDistributionKey(jgtime int64) (month string) {
|
|
|
+ for _, mdv := range ut.MonthDistributionKey {
|
|
|
+ if utility.DateIsIn(mdv.From, mdv.To, jgtime, 0) {
|
|
|
+ month = mdv.Key
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// GetYearDistributionKey 获取年度key
|
|
|
+func (ut *UserTask) GetYearDistributionKey(jgtime int64) (year string) {
|
|
|
+ for _, ydv := range ut.YearDistributionKey {
|
|
|
+ if utility.DateIsIn(ydv.From, ydv.To, jgtime, 0) {
|
|
|
+ year = ydv.Key
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|