consts.go 7.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package marketanalysis
  2. const (
  3. MarketQueryItem = iota //回显查询条件
  4. MarketScaleMain //市场规模
  5. MarketTopProject //项目规模TOP10
  6. MarketProjectAllData //项目规模 地区分布 客户分布 地区客户top3
  7. MarketScaleRefine //细化市场
  8. MarketBuyerAndWinner //市场-采购单位&&中标企业
  9. queryBoolMustAnd = `{"bool": {"must": [%s]%s}}`
  10. pSearchDecMust = `"bidstatus": ["中标","成交","合同","单一"]`
  11. queryBoolMust = `{"terms": {%s}}`
  12. //市场分析聚合查询
  13. 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","precision_threshold": 40000}},"winner_count":{"cardinality":{"field":"s_winner","precision_threshold": 40000}}}}`
  14. //时间分布统计
  15. projectTimeDistribution = `"%s": {"range": { "field": "jgtime","ranges": [%s]},"aggs":{ "scale_amount": {"sum": {"field": "sortprice"}}, "scale_total": {"filter": {"match_all":{}}}}}`
  16. //采购单位聚合查询
  17. buyerProcurementScale = `"buyer_amount_distribution": {"terms": {"field": "buyer","order": [{"amount": "desc"}],"size":%d},"aggs": {"amount": {"sum": {"field": "sortprice"}}}}`
  18. //采购单位top3(价格)buyer_sortprice
  19. buyerSortprice = `"buyer_amount_top3": {"terms": {"field": "buyer","order": [{"buyer_amount": "desc"}],"size": %d},"aggs": {"buyer_amount": {"sum": {"field": "sortprice"}},"s_winner_top": {"terms": {"field": "entidlist","exclude":["-"],"order": [{"buyer_winner_amount": "desc"}],"size": %d},"aggs": {"buyer_winner_amount": {"sum": {"field": "sortprice"}}}}}}`
  20. //采购单位top3(数量)
  21. buyerCount = `"buyer_count_top3": {"terms": {"field": "buyer","order": [{"buyer_count": "desc"}],"size": %d},"aggs": {"buyer_count": {"filter":{"match_all":{}}},"s_winner_top": {"terms": {"field": "entidlist","exclude":["-"],"order": [{"buyer_winner_count": "desc"}],"size": %d},"aggs": { "buyer_winner_count": {"filter":{"match_all":{}}}}}}}`
  22. //中标单位
  23. winnerProcurementScale = `"winner_amount_distribution": {"filter": {"script": {"script": "doc['entidlist'].length == 1"}},"aggs": {"entidlist_terms": {"terms": {"field": "entidlist","order": {"amount": "desc"},"size": %d},"aggs": {"amount": {"sum": {"field": "sortprice"}}}}}}`
  24. //中标单位top3(价格)
  25. winnerSortprice = `"winner_amount_top3": {"terms": {"field": "entidlist","exclude":["-"],"order": [{"s_winner_amount": "desc"}],"size": %d},"aggs": {"s_winner_amount": {"sum": {"field": "sortprice"}},"buyer_top": {"terms": {"field": "buyer","order": [{"buyer_winner_amount": "desc"}],"size": %d},"aggs": {"buyer_winner_amount": {"sum": {"field": "sortprice"}}}}}}`
  26. //中标单位(数量)
  27. winnerCount = `"winner_count_top3": {"terms": {"field": "entidlist","exclude":["-"],"order": [{"s_winner_count": "desc"}],"size": %d},"aggs": {"s_winner_count": {"filter":{"match_all":{}}},"buyer_top": {"terms": {"field": "buyer","order": [{"buyer_winner_count": "desc"}],"size": %d},"aggs": {"buyer_winner_count": {"filter":{"match_all":{}}}}}}}`
  28. queryAggsSortprice = `"sortprice_ranges": {"range":{"field":"sortprice","ranges":[%s]},"aggs":{"sum_sortprice":{"sum":{"field":"sortprice"}}}}`
  29. 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"}}}}}}`
  30. queryTop10 = `,"sort": [{"sortprice": "desc"}],"from": 0,"size": 10`
  31. 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":%d},"aggs":{"area_winner_amount":{"sum":{"field":"sortprice"}}}}}}`
  32. 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":%d},"aggs":{"area_winner_count":{"filter":{"match_all":{}}}}}}}`
  33. aggsBuyerclass = `"buyerclass_scale":{"terms":{"field":"buyerclass","size":2000,"exclude":["其它",""]},"aggs":{"buyerclass_amount":{"sum":{"field":"sortprice"}},"buyerclass_total":{"filter":{"match_all":{}}}}}`
  34. 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":%d},"aggs":{"buyer_winner_count":{"filter":{"match_all":{}}}}}}}`
  35. 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":%d},"aggs":{"buyer_winner_amount":{"sum":{"field":"sortprice"}}}}}}`
  36. 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}`
  37. aggsAllCM = `"project_count": {"filter": {"match_all":{}}},"project_count_not0": {"filter": {"range": {"sortprice": {"gt": 0}}}},"project_amount": {"sum": {"field": "sortprice"}}`
  38. queryIdto = `{"query": {"bool": {"must": [{"terms": {"id": ["%s"]}}]}},"_source":["_id","company_name"],"size": %d}`
  39. ReportHistoryTable = "marketAnalysisReport"
  40. ReportCacheDB = "other"
  41. ReportCacheKey = "marketAnalysis_%s_%d"
  42. ReportCacheTime = 60 * 5
  43. ReportCanceledKey = "marketAnalysisCanceled_%s" // 取消的报告id
  44. ReportCanceledTime = 60 * 60 * 24
  45. ReportStateGenerating = 0 // 报告生成状态 生成中
  46. ReportStateGenerated = 1 // 生成 成功
  47. ReportStateCanceled = 2 // 已取消
  48. ReportStateFailed = -1 // 生成失败
  49. CollMarketScaleMain = "marketanalysisreport_scal" //市场规模 报告模块对应的mongo 集合名称
  50. CollMarketTopProject = "marketanalysisreport_top" //项目规模TOP10
  51. CollMarketProjectAllData = "marketanalysisreport_all" //项目规模 地区分布 客户分布 地区客户top3
  52. CollMarketScaleRefine = "marketanalysisreport_refine" //细化市场
  53. CollMarketBuyerAndWinner = "marketanalysisreport_bw" //市场-采购单位&&中标企业
  54. ValueError = -1 // 分析数据过大
  55. ValueOffline = 1 // 离线
  56. ValueRealTime = 2 // 实时
  57. TablejianyuMarUserAccount = "jianyu.mar_user_account" // 离线市场报告分析关键词标准信息表
  58. Top3 = 3
  59. Top5 = 5
  60. Top10 = 10
  61. Top20 = 20
  62. Top30 = 30
  63. Top50 = 50
  64. Top1000 = 1000
  65. BWDistribution = 100000
  66. )
  67. var (
  68. 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}
  69. Analysis = []string{"<10万", "10万~50万", "50万~100万", "100万~500万", "500万~1000万", "1000万~1亿", "≥1亿"}
  70. )