123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package marketanalysis
- const (
- MarketQueryItem = iota //回显查询条件
- MarketScaleMain //市场规模
- MarketTopProject //项目规模TOP10
- MarketProjectAllData //项目规模 地区分布 客户分布 地区客户top3
- MarketScaleRefine //细化市场
- MarketBuyerAndWinner //市场-采购单位&&中标企业
- queryBoolMustAnd = `{"bool": {"must": [%s]%s}}`
- pSearchDecMust = `"bidstatus": ["中标","成交","合同","单一"]`
- queryBoolMust = `{"terms": {%s}}`
- //市场分析聚合查询
- aggsMarketAnalysis = `"%s": {"range": {"field": "jgtime","ranges": [%s]},"aggs":{"project_count": {"filter": {"match_all":{}}},"project_amount":{"sum":{"field":"sortprice"}},"project_avgMoney": { "avg": {"field": "sortprice","missing": 0}} ,"buyer_count":{"cardinality":{"field":"buyer"}},"winner_count":{"cardinality":{"field":"s_winner"}}}}`
- //时间分布统计
- projectTimeDistribution = `"%s": {"range": { "field": "jgtime","ranges": [%s]},"aggs":{ "scale_amount": {"sum": {"field": "sortprice"}}, "scale_total": {"filter": {"match_all":{}}}}}`
- //采购单位聚合查询
- buyerProcurementScale = `"buyer_amount_distribution": {"terms": {"field": "buyer","order": [{"amount": "desc"}],"size":100000},"aggs": {"amount": {"sum": {"field": "sortprice"}}}}`
- //采购单位top3(价格)buyer_sortprice
- buyerSortprice = `"buyer_amount_top3": {"terms": {"field": "buyer","order": [{"buyer_amount": "desc"}],"size": 30},"aggs": {"buyer_amount": {"sum": {"field": "sortprice"}},"s_winner_top": {"terms": {"field": "entidlist","exclude":["-"],"order": [{"buyer_winner_amount": "desc"}],"size": 3},"aggs": {"buyer_winner_amount": {"sum": {"field": "sortprice"}}}}}}`
- //采购单位top3(数量)
- buyerCount = `"buyer_count_top3": {"terms": {"field": "buyer","order": [{"buyer_count": "desc"}],"size": 30},"aggs": {"buyer_count": {"filter":{"match_all":{}}},"s_winner_top": {"terms": {"field": "entidlist","exclude":["-"],"order": [{"buyer_winner_count": "desc"}],"size": 3},"aggs": { "buyer_winner_count": {"filter":{"match_all":{}}}}}}}`
- //中标单位
- winnerProcurementScale = `"winner_amount_distribution": {"filter": {"script": {"script": "doc['entidlist'].length == 1"}},"aggs": {"entidlist_terms": {"terms": {"field": "entidlist","order": {"amount": "desc"},"size": 100000},"aggs": {"amount": {"sum": {"field": "sortprice"}}}}}}`
- //中标单位top3(价格)
- winnerSortprice = `"winner_amount_top3": {"terms": {"field": "entidlist","exclude":["-"],"order": [{"s_winner_amount": "desc"}],"size": 30},"aggs": {"s_winner_amount": {"sum": {"field": "sortprice"}},"buyer_top": {"terms": {"field": "buyer","order": [{"buyer_winner_amount": "desc"}],"size": 3},"aggs": {"buyer_winner_amount": {"sum": {"field": "sortprice"}}}}}}`
- //中标单位(数量)
- winnerCount = `"winner_count_top3": {"terms": {"field": "entidlist","exclude":["-"],"order": [{"s_winner_count": "desc"}],"size": 30},"aggs": {"s_winner_count": {"filter":{"match_all":{}}},"buyer_top": {"terms": {"field": "buyer","order": [{"buyer_winner_count": "desc"}],"size": 3},"aggs": {"buyer_winner_count": {"filter":{"match_all":{}}}}}}}`
- queryAggsSortprice = `"sortprice_ranges": {"range":{"field":"sortprice","ranges":[%s]},"aggs":{"sum_sortprice":{"sum":{"field":"sortprice"}}}}`
- aggsArea = `"area_distribution": {"terms": {"field": "area","size": 40},"aggs": {"area_amount": {"sum": {"field": "sortprice"}},"area_total": {"filter": {"match_all":{}}},"city_group": {"terms": {"field": "city","size": 40},"aggs": {"city_amount": {"sum": {"field": "sortprice"}}}}}}`
- queryTop10 = `,"sort": [{"sortprice": "desc"}],"from": 0,"size": 10`
- aggsAreaAmounttop3 = `"area_amount_top3":{"terms":{"field":"area","exclude":["全国"],"order":[{"area_amount":"desc"}],"size":34},"aggs":{"area_amount":{"sum":{"field":"sortprice"}},"winner_top":{"terms":{"field":"entidlist","exclude": ["-"],"order":[{"area_winner_amount":"desc"}],"size":3},"aggs":{"area_winner_amount":{"sum":{"field":"sortprice"}}}}}}`
- aggsAreaCounttop3 = `"area_count_top3":{"terms":{"field":"area","exclude":["全国"],"order":[{"area_count":"desc"}],"size":40},"aggs":{"area_count":{"filter":{"match_all":{}}},"winner_top":{"terms":{"field":"entidlist","exclude": ["-"],"order":[{"area_winner_count":"desc"}],"size":3},"aggs":{"area_winner_count":{"filter":{"match_all":{}}}}}}}`
- aggsBuyerclass = `"buyerclass_scale":{"terms":{"field":"buyerclass","size":2000,"exclude":["其它",""]},"aggs":{"buyerclass_amount":{"sum":{"field":"sortprice"}},"buyerclass_total":{"filter":{"match_all":{}}}}}`
- aggsBuyerclassCounttop3 = `"buyerclass_count_top3":{"terms":{"field":"buyerclass","exclude":["其它",""],"order":[{"buyerclass_count":"desc"}],"size":70},"aggs":{"buyerclass_count":{"filter":{"match_all":{}}},"bidcount_top":{"terms":{"field":"entidlist","exclude": ["-"],"order":[{"buyer_winner_count":"desc"}],"size":3},"aggs":{"buyer_winner_count":{"filter":{"match_all":{}}}}}}}`
- aggsBuyerclassAmounttop3 = `"buyerclass_amount_top3":{"terms":{"field":"buyerclass","exclude":["其它",""],"order":[{"buyerclass_amount":"desc"}],"size":70},"aggs":{"buyerclass_amount":{"sum":{"field":"sortprice"}},"winner_top":{"terms":{"field":"entidlist","exclude": ["-"],"order":[{"buyer_winner_amount":"desc"}],"size":3},"aggs":{"buyer_winner_amount":{"sum":{"field":"sortprice"}}}}}}`
- sortpriceStr = `{"key":"<10万","from":0.0000000000001,"to":100000},{"key":"10万-50万","from":100000,"to":500000},{"key":"50万-100万","from":500000,"to":1000000},{"key":"100万-500万","from":1000000,"to":5000000},{"key":"500万-1000万","from":5000000,"to":10000000},{"key":"1000万-1亿","from":10000000,"to":100000000},{"key":"≥1亿","from":100000000}`
- aggsAllCM = `"project_count": {"filter": {"match_all":{}}},"project_count_not0": {"filter": {"range": {"sortprice": {"gt": 0}}}},"project_amount": {"sum": {"field": "sortprice"}}`
- queryIdto = `{"query": {"bool": {"must": [{"terms": {"id": ["%s"]}}]}},"_source":["_id","company_name"],"size": %d}`
- ReportHistoryTable = "marketAnalysisReport"
- ReportCacheDB = "other"
- ReportCacheKey = "marketAnalysis_%s_%d"
- ReportCacheTime = 60 * 5
- ReportCanceledKey = "marketAnalysisCanceled_%s" // 取消的报告id
- ReportCanceledTime = 60 * 60 * 24
- ReportStateGenerating = 0 // 报告生成状态 生成中
- ReportStateGenerated = 1 // 生成 成功
- ReportStateCanceled = 2 // 已取消
- ReportStateFailed = -1 // 生成失败
- CollMarketScaleMain = "marketanalysisreport_scal" //市场规模 报告模块对应的mongo 集合名称
- CollMarketTopProject = "marketanalysisreport_top" //项目规模TOP10
- CollMarketProjectAllData = "marketanalysisreport_all" //项目规模 地区分布 客户分布 地区客户top3
- CollMarketScaleRefine = "marketanalysisreport_refine" //细化市场
- CollMarketBuyerAndWinner = "marketanalysisreport_bw" //市场-采购单位&&中标企业
- ValueError = -1 // 分析数据过大
- ValueOffline = 1 // 离线
- ValueRealTime = 2 // 实时
- TablejianyuMarUserAccount = "jianyu.mar_user_account" // 离线市场报告分析关键词标准信息表
- )
- var (
- yMDay = map[int]int{1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
- Analysis = []string{"<10万", "10万~50万", "50万~100万", "100万~500万", "500万~1000万", "1000万~1亿", "≥1亿"}
- )
|