|
@@ -29,9 +29,10 @@ var (
|
|
|
PtType = "projectset"
|
|
|
FieldsDetail = `"purchasing","projectname.pname"`
|
|
|
Fields = `"projectname.pname"`
|
|
|
+ BWCount = Top1000
|
|
|
)
|
|
|
|
|
|
-func MAInit(limit, timeOut, projectNumLimit, keyWordsCount, pCount, minKCount, maxPCount int, ptIndex, ptType string, fields []string) {
|
|
|
+func MAInit(limit, timeOut, projectNumLimit, keyWordsCount, pCount, minKCount, maxPCount, bwc int, ptIndex, ptType string, fields []string) {
|
|
|
if limit == 0 {
|
|
|
limit = 5
|
|
|
}
|
|
@@ -72,6 +73,10 @@ func MAInit(limit, timeOut, projectNumLimit, keyWordsCount, pCount, minKCount, m
|
|
|
Fields = fmt.Sprintf(`"%s"`, fields[0])
|
|
|
FieldsDetail = fmt.Sprintf(`"%s"`, strings.Join(fields, `","`))
|
|
|
}
|
|
|
+ //
|
|
|
+ if bwc > 0 {
|
|
|
+ BWCount = bwc
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// AnalysisRequestParam 接口原请求参数
|
|
@@ -1261,11 +1266,23 @@ func (a *AnalysisEntity) AllData() (rMap map[string]interface{}, err error) {
|
|
|
buyclass := a.FormatParam.BuyerClass
|
|
|
aggs = append(aggs, aggsAllCM, fmt.Sprintf(queryAggsSortprice, sortpriceStr), aggsArea)
|
|
|
if (len(area) + len(city)) != 1 {
|
|
|
- aggs = append(aggs, aggsAreaAmounttop3, aggsAreaCounttop3)
|
|
|
+ aaat3 := fmt.Sprintf(aggsAreaAmounttop3, Top30)
|
|
|
+ aact3 := fmt.Sprintf(aggsAreaCounttop3, Top30)
|
|
|
+ if a.Offline == ValueOffline {
|
|
|
+ aaat3 = fmt.Sprintf(aggsAreaAmounttop3, Top30)
|
|
|
+ aact3 = fmt.Sprintf(aggsAreaCounttop3, Top30)
|
|
|
+ }
|
|
|
+ aggs = append(aggs, aaat3, aact3)
|
|
|
}
|
|
|
if len(buyclass) != 1 {
|
|
|
+ abat3 := fmt.Sprintf(aggsBuyerclassAmounttop3, Top30)
|
|
|
+ abct3 := fmt.Sprintf(aggsBuyerclassCounttop3, Top30)
|
|
|
+ if a.Offline == ValueOffline {
|
|
|
+ abat3 = fmt.Sprintf(aggsBuyerclassAmounttop3, Top30)
|
|
|
+ abct3 = fmt.Sprintf(aggsBuyerclassCounttop3, Top30)
|
|
|
+ }
|
|
|
//aggs = append(aggs, aggs_buyerclass, aggs_buyerclass_other, aggs_buyerclass_amounttop3, aggs_buyerclass_counttop3)
|
|
|
- aggs = append(aggs, aggsBuyerclass, aggsBuyerclassAmounttop3, aggsBuyerclassCounttop3)
|
|
|
+ aggs = append(aggs, aggsBuyerclass, abat3, abct3)
|
|
|
}
|
|
|
finalSql := fmt.Sprintf(a.GetCommonQuerySqlWithAggs(), strings.Join(aggs, ","))
|
|
|
log.Println("allData sql:", finalSql)
|
|
@@ -1356,11 +1373,13 @@ func (a *AnalysisEntity) AllData() (rMap map[string]interface{}, err error) {
|
|
|
rMap["area_infos"] = area_data
|
|
|
rMap["customer_scale"] = customerData
|
|
|
rMap["customer_scale_other"] = customerOther //客户分布(其它)
|
|
|
- rMap["scaleAreaAmountTop"] = AmountCompute(thisRow, "area", eid)
|
|
|
- rMap["scaleBuyclassAmountTop"] = AmountCompute(thisRow, "buyclass", eid)
|
|
|
- rMap["scaleAreaCountTop"] = CountCompute(thisRow, "area", eid)
|
|
|
- rMap["scaleBuyclassCountTop"] = CountCompute(thisRow, "buyclass", eid)
|
|
|
- rMap["count_not_0"] = thisRow.CountNot0.Count
|
|
|
+ rMap["scaleAreaAmountTop"] = AmountCompute(thisRow, "area", eid, a.Offline == ValueOffline)
|
|
|
+ rMap["scaleBuyclassAmountTop"] = AmountCompute(thisRow, "buyclass", eid, a.Offline == ValueOffline)
|
|
|
+ rMap["scaleAreaCountTop"] = CountCompute(thisRow, "area", eid, a.Offline == ValueOffline)
|
|
|
+ rMap["scaleBuyclassCountTop"] = CountCompute(thisRow, "buyclass", eid, a.Offline == ValueOffline)
|
|
|
+ if a.Offline == ValueOffline {
|
|
|
+ rMap["count_not_0"] = thisRow.CountNot0.Count
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -1380,7 +1399,14 @@ func (a *AnalysisEntity) MarketScaleRefineQuery() (rMap map[string]interface{},
|
|
|
}
|
|
|
}
|
|
|
if len(bools) > 0 {
|
|
|
- aggsGroup = append(aggsGroup, fmt.Sprintf(`"%s":{"filter":{"bool":{"should":[%s],"minimum_should_match": 1}},"aggs":{"project_count":{"filter":{"match_all":{}}},"project_amount":{"sum":{"field":"sortprice"}},"winner_total_top":{"terms":{"field":"entidlist","exclude":["-"],"order":[{"refine_winner_total":"desc"}],"size":%d},"aggs":{"refine_winner_total":{"filter":{"match_all":{}}}}},"winner_amount_top":{"terms":{"field":"entidlist","exclude":["-"],"order":[{"refine_winner_amount":"desc"}],"size":%d},"aggs":{"refine_winner_amount":{"sum":{"field":"sortprice"}}}}}}`, group.ItemName, strings.Join(bools, ","), topWinnerLimit, topWinnerLimit))
|
|
|
+ //临时调整 进行数据验证 Top3
|
|
|
+ rwt := Top30
|
|
|
+ rwa := Top30
|
|
|
+ if a.Offline == ValueOffline { //离线
|
|
|
+ rwt = Top30
|
|
|
+ rwa = Top30
|
|
|
+ }
|
|
|
+ aggsGroup = append(aggsGroup, fmt.Sprintf(`"%s":{"filter":{"bool":{"should":[%s],"minimum_should_match": 1}},"aggs":{"project_count":{"filter":{"match_all":{}}},"project_amount":{"sum":{"field":"sortprice"}},"winner_total_top":{"terms":{"field":"entidlist","exclude":["-"],"order":[{"refine_winner_total":"desc"}],"size":%d},"aggs":{"refine_winner_total":{"filter":{"match_all":{}}}}},"winner_amount_top":{"terms":{"field":"entidlist","exclude":["-"],"order":[{"refine_winner_amount":"desc"}],"size":%d},"aggs":{"refine_winner_amount":{"sum":{"field":"sortprice"}}}}}}`, group.ItemName, strings.Join(bools, ","), rwt, rwa))
|
|
|
}
|
|
|
itemDataMap[group.ItemName] = group.UpdateTime
|
|
|
}
|
|
@@ -1391,7 +1417,7 @@ func (a *AnalysisEntity) MarketScaleRefineQuery() (rMap map[string]interface{},
|
|
|
if res == nil || len(res) == 0 {
|
|
|
return
|
|
|
}
|
|
|
- scale := scaleRefineData{IdSwitch: map[string]string{}}
|
|
|
+ scale := scaleRefineData{IdSwitch: map[string]string{}, IsOffline: a.Offline == ValueOffline}
|
|
|
for name, object := range res {
|
|
|
bArr, err := object.MarshalJSON()
|
|
|
if len(bArr) == 0 || err != nil {
|
|
@@ -1434,12 +1460,24 @@ func (a *AnalysisEntity) BuyerWinnerAnalysis() map[string]interface{} {
|
|
|
//buyer_scalefmt := fmt.Sprintf(buyer_procurement_scale, sortprice_str)
|
|
|
|
|
|
//采购单位-项目数量 采购单位-项目金额
|
|
|
- datas = append(datas, buyerProcurementScale, buyerCount, buyerSortprice)
|
|
|
+ bc := fmt.Sprintf(buyerCount, Top30, Top30)
|
|
|
+ bs := fmt.Sprintf(buyerSortprice, Top30, Top30)
|
|
|
+ if a.Offline == ValueOffline {
|
|
|
+ bc = fmt.Sprintf(buyerCount, BWCount, Top30)
|
|
|
+ bs = fmt.Sprintf(buyerSortprice, BWCount, Top30)
|
|
|
+ }
|
|
|
+ datas = append(datas, buyerProcurementScale, bc, bs)
|
|
|
//中标单位-规模分布
|
|
|
//winner_scalefmt := fmt.Sprintf(winner_procurement_scale, sortprice_str)
|
|
|
|
|
|
//中标单位-项目数量 中标单位-项目金额
|
|
|
- datas = append(datas, winnerProcurementScale, winnerCount, winnerSortprice)
|
|
|
+ wc := fmt.Sprintf(winnerCount, Top30, Top30)
|
|
|
+ ws := fmt.Sprintf(winnerSortprice, Top30, Top30)
|
|
|
+ if a.Offline == ValueOffline {
|
|
|
+ bc = fmt.Sprintf(winnerCount, BWCount, Top30)
|
|
|
+ bs = fmt.Sprintf(winnerSortprice, BWCount, Top30)
|
|
|
+ }
|
|
|
+ datas = append(datas, winnerProcurementScale, wc, ws)
|
|
|
finalSql := fmt.Sprintf(a.GetCommonQuerySqlWithAggs(), strings.Join(datas, ","))
|
|
|
log.Printf("final PurchasingAnalysiseQuery sql: %s", finalSql)
|
|
|
t := time.Now()
|