|
@@ -1,34 +1,12 @@
|
|
|
-import com.dySweetFishPlugin.elasticsearch.ESClient
|
|
|
|
|
-import com.dySweetFishPlugin.tool.lang.DateUtil
|
|
|
|
|
import com.dderp.common.api.BusinessExecutor
|
|
import com.dderp.common.api.BusinessExecutor
|
|
|
-import com.dderp.common.api.erp.ProductService
|
|
|
|
|
import com.dderp.common.api.SupplierInitService
|
|
import com.dderp.common.api.SupplierInitService
|
|
|
import com.dderp.common.datas.ERPModule
|
|
import com.dderp.common.datas.ERPModule
|
|
|
-import com.dderp.common.datas.ESKeys
|
|
|
|
|
-import com.dderp.common.datas.TokenUserFrom
|
|
|
|
|
-import com.dderp.common.entity.base.EChartDoubleData
|
|
|
|
|
import com.dderp.common.entity.base.ProcessMapItem
|
|
import com.dderp.common.entity.base.ProcessMapItem
|
|
|
-import com.dderp.common.entity.product.ProductInfo
|
|
|
|
|
|
|
+import com.dySweetFishPlugin.elasticsearch.ESClient
|
|
|
import com.sweetfish.service.RetResult
|
|
import com.sweetfish.service.RetResult
|
|
|
-import org.elasticsearch.action.search.SearchRequestBuilder
|
|
|
|
|
-import org.elasticsearch.action.search.SearchResponse
|
|
|
|
|
-import org.elasticsearch.index.query.QueryBuilders
|
|
|
|
|
-import org.elasticsearch.search.aggregations.AggregationBuilders
|
|
|
|
|
-import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter
|
|
|
|
|
-import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval
|
|
|
|
|
-import org.elasticsearch.search.aggregations.bucket.histogram.ExtendedBounds
|
|
|
|
|
-import org.elasticsearch.search.aggregations.bucket.histogram.Histogram
|
|
|
|
|
-import org.elasticsearch.search.aggregations.bucket.histogram.InternalDateHistogram
|
|
|
|
|
-import org.elasticsearch.search.aggregations.bucket.terms.Terms
|
|
|
|
|
-import org.elasticsearch.search.aggregations.metrics.sum.InternalSum
|
|
|
|
|
-import org.elasticsearch.search.aggregations.metrics.valuecount.ValueCount
|
|
|
|
|
import org.rex.RMap
|
|
import org.rex.RMap
|
|
|
|
|
|
|
|
import javax.annotation.Resource
|
|
import javax.annotation.Resource
|
|
|
-import java.math.RoundingMode
|
|
|
|
|
-import java.time.LocalDate
|
|
|
|
|
-import java.time.LocalDateTime
|
|
|
|
|
-import java.time.temporal.TemporalAdjusters
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Created by jlutt on 2021-09-22
|
|
* Created by jlutt on 2021-09-22
|
|
@@ -44,9 +22,6 @@ class BE_IndexCardPanelData implements BusinessExecutor<ProcessMapItem, ProcessM
|
|
|
@Resource
|
|
@Resource
|
|
|
SupplierInitService supplierService
|
|
SupplierInitService supplierService
|
|
|
|
|
|
|
|
- @Resource
|
|
|
|
|
- ProductService productService
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
String scriptName() {
|
|
String scriptName() {
|
|
|
return "首页面板查询业务数据"
|
|
return "首页面板查询业务数据"
|
|
@@ -61,434 +36,7 @@ class BE_IndexCardPanelData implements BusinessExecutor<ProcessMapItem, ProcessM
|
|
|
RetResult<ProcessMapItem> execute(ProcessMapItem source) {
|
|
RetResult<ProcessMapItem> execute(ProcessMapItem source) {
|
|
|
RMap data = new RMap()
|
|
RMap data = new RMap()
|
|
|
|
|
|
|
|
- //region 生产数据查询
|
|
|
|
|
-
|
|
|
|
|
- //查询待组版订单数量
|
|
|
|
|
- SearchRequestBuilder childRequest1 = esClient.getClient().prepareSearch(supplierService.getDateYearESIndex(source.getSupplierCode(), ESKeys.ES_ERP_PRINT_ORDER_INDEX, 2021))
|
|
|
|
|
- .setQuery(QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_ERP_PRINT_ORDER_TYPE))
|
|
|
|
|
- .must(QueryBuilders.termQuery("voidFlag", 0)))
|
|
|
|
|
- childRequest1 = childRequest1.addAggregation(
|
|
|
|
|
- AggregationBuilders
|
|
|
|
|
- .filter("a3_count",
|
|
|
|
|
- OrderStatisticsQueryBuilder.valueOf("A3").apply(null, false, false)
|
|
|
|
|
- )
|
|
|
|
|
- .subAggregation(AggregationBuilders.count("subA3_Count").field("id"))
|
|
|
|
|
- )
|
|
|
|
|
- childRequest1 = childRequest1.addAggregation(
|
|
|
|
|
- AggregationBuilders
|
|
|
|
|
- .filter("a7_count",
|
|
|
|
|
- OrderStatisticsQueryBuilder.valueOf("A7").apply(null, false, false)
|
|
|
|
|
- )
|
|
|
|
|
- .subAggregation(AggregationBuilders.count("subA7_Count").field("id"))
|
|
|
|
|
- )
|
|
|
|
|
- childRequest1 = childRequest1.addAggregation(
|
|
|
|
|
- AggregationBuilders
|
|
|
|
|
- .filter("a12_count",
|
|
|
|
|
- OrderStatisticsQueryBuilder.valueOf("A12").apply(null, false, false)
|
|
|
|
|
- )
|
|
|
|
|
- .subAggregation(AggregationBuilders.count("subA12_Count").field("id"))
|
|
|
|
|
- )
|
|
|
|
|
- SearchResponse childRes1 = childRequest1.execute().actionGet()
|
|
|
|
|
-
|
|
|
|
|
- InternalFilter genderWaitBreedOrderCount = childRes1.getAggregations().get("a3_count")
|
|
|
|
|
- ValueCount valueWaitBreedOrderCount = genderWaitBreedOrderCount.getAggregations().get("subA3_Count")
|
|
|
|
|
- data.put("waitBreedOrderCount", valueWaitBreedOrderCount.getValue())
|
|
|
|
|
-
|
|
|
|
|
- InternalFilter genderWorkingOrderCount = childRes1.getAggregations().get("a7_count")
|
|
|
|
|
- ValueCount valueWorkingOrderCount = genderWorkingOrderCount.getAggregations().get("subA7_Count")
|
|
|
|
|
- data.put("workingOrderCount", valueWorkingOrderCount.getValue())
|
|
|
|
|
-
|
|
|
|
|
- InternalFilter genderWaitSendOrderCount = childRes1.getAggregations().get("a12_count")
|
|
|
|
|
- ValueCount valueWaitSendOrderCount = genderWaitSendOrderCount.getAggregations().get("subA12_Count")
|
|
|
|
|
- data.put("waitSendOrderCount", valueWaitSendOrderCount.getValue())
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- //查询待下机版数量
|
|
|
|
|
- SearchRequestBuilder childRequest11 = esClient.getClient().prepareSearch(supplierService.getDateYearESIndex(source.getSupplierCode(), ESKeys.ES_ERP_PRINTBILL_INDEX, 2021))
|
|
|
|
|
- .setQuery(QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_ERP_PRINTBILL_BREED_TYPE))
|
|
|
|
|
- .must(QueryBuilders.termQuery("voidFlag", 0)))
|
|
|
|
|
-
|
|
|
|
|
- childRequest11 = childRequest11.addAggregation(
|
|
|
|
|
- AggregationBuilders
|
|
|
|
|
- .filter("a3_count",
|
|
|
|
|
- BreedStatisticsQueryBuilder.valueOf("A3").apply(false)
|
|
|
|
|
- )
|
|
|
|
|
- .subAggregation(AggregationBuilders.count("subA3_Count").field("id"))
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
- SearchResponse childRes11 = childRequest11.execute().actionGet()
|
|
|
|
|
-
|
|
|
|
|
- InternalFilter genderScheduleBreedCount = childRes11.getAggregations().get("a3_count")
|
|
|
|
|
- ValueCount valueScheduleBreedCount = genderScheduleBreedCount.getAggregations().get("subA3_Count")
|
|
|
|
|
- data.put("scheduleBreedCount", valueScheduleBreedCount.getValue())
|
|
|
|
|
-
|
|
|
|
|
- //endregion
|
|
|
|
|
-
|
|
|
|
|
- if (source.getCurrentUser().getUserFrom() == TokenUserFrom.PC_ADMIN.value) {
|
|
|
|
|
-
|
|
|
|
|
- LocalDate nowDate = LocalDate.now()
|
|
|
|
|
- LocalDateTime nowTime = LocalDateTime.now()
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- //region 订单、施工单近7天的数量
|
|
|
|
|
-
|
|
|
|
|
- RMap day7WorkData = new RMap()
|
|
|
|
|
- RMap day7MoneyData = new RMap()
|
|
|
|
|
-
|
|
|
|
|
- List<String> day7Work_legendStrArray = new ArrayList<>()
|
|
|
|
|
- List<String> day7Money_legendStrArray = new ArrayList<>()
|
|
|
|
|
- day7Work_legendStrArray.add("订单数量")
|
|
|
|
|
- day7Work_legendStrArray.add("施工单版数量")
|
|
|
|
|
- day7Money_legendStrArray.add("订单金额")
|
|
|
|
|
- day7WorkData.put("legendStrArray", day7Work_legendStrArray)
|
|
|
|
|
- day7MoneyData.put("legendStrArray", day7Money_legendStrArray)
|
|
|
|
|
-
|
|
|
|
|
-// Date endDate2 = new Date();
|
|
|
|
|
-// endDate2 = DateUtil.getStartOfDay(endDate2);
|
|
|
|
|
-// Date beginDate2 = endDate2 - 6;
|
|
|
|
|
- Date endDate2 = nowDate.toDate()
|
|
|
|
|
- Date beginDate2 = (nowDate - 6).toDate()
|
|
|
|
|
-
|
|
|
|
|
- List<String> day7Work_xAxisArray = (nowDate - 6..nowDate).collect {
|
|
|
|
|
- String.valueOf(it.getMonthValue()) + "." + (it.dayOfMonth)
|
|
|
|
|
- }.toList()
|
|
|
|
|
-
|
|
|
|
|
-// List<String> day7Work_xAxisArray = (beginDate2..endDate2).collect {
|
|
|
|
|
-// (it[Calendar.MONTH] + 1) + "." + (it[Calendar.DAY_OF_MONTH])
|
|
|
|
|
-// }.toList();
|
|
|
|
|
- day7WorkData.put("xAxisArray", day7Work_xAxisArray)
|
|
|
|
|
- day7MoneyData.put("xAxisArray", day7Work_xAxisArray)
|
|
|
|
|
-
|
|
|
|
|
- List<EChartDoubleData> day7Work_seriesList = new ArrayList<>()
|
|
|
|
|
- List<EChartDoubleData> day7Money_seriesList = new ArrayList<>()
|
|
|
|
|
-
|
|
|
|
|
- SearchRequestBuilder childRequest2 = esClient.getClient().prepareSearch(supplierService.getDateYearESIndex(source.getSupplierCode(), ESKeys.ES_ERP_PRINT_ORDER_INDEX, 2021))
|
|
|
|
|
- .setQuery(
|
|
|
|
|
- QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_ERP_PRINT_ORDER_TYPE))
|
|
|
|
|
- .must(QueryBuilders.termQuery("voidFlag", 0))
|
|
|
|
|
- .must(QueryBuilders.rangeQuery("createTimeLong").gte(DateUtil.getStartOfDay(beginDate2).getTime()).lte(DateUtil.getEndOfDay(endDate2).getTime()))
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- childRequest2.addAggregation(
|
|
|
|
|
- AggregationBuilders.dateHistogram("orders")
|
|
|
|
|
- .field("createTimeLong")
|
|
|
|
|
- .dateHistogramInterval(DateHistogramInterval.DAY)
|
|
|
|
|
- .minDocCount(0l)
|
|
|
|
|
- .extendedBounds(new ExtendedBounds(DateUtil.getStartOfDay(beginDate2).getTime(), DateUtil.getEndOfDay(endDate2).getTime()))
|
|
|
|
|
- .order(Histogram.Order.KEY_ASC)
|
|
|
|
|
- .subAggregation(
|
|
|
|
|
- AggregationBuilders.sum("sub_orderMoney").field("orderMoneyTotal")
|
|
|
|
|
- )
|
|
|
|
|
- )
|
|
|
|
|
- SearchResponse childRes2 = childRequest2.execute().actionGet()
|
|
|
|
|
- InternalDateHistogram day7Work_Orders = childRes2.getAggregations().get("orders")
|
|
|
|
|
-
|
|
|
|
|
- EChartDoubleData day7Work_OrderCount_SeriesData = new EChartDoubleData()
|
|
|
|
|
- day7Work_OrderCount_SeriesData.setName("订单数量")
|
|
|
|
|
- day7Work_OrderCount_SeriesData.setType("line")
|
|
|
|
|
-
|
|
|
|
|
- EChartDoubleData day7Work_OrderMoney_SeriesData = new EChartDoubleData()
|
|
|
|
|
- day7Work_OrderMoney_SeriesData.setName("订单金额")
|
|
|
|
|
- day7Work_OrderMoney_SeriesData.setType("line")
|
|
|
|
|
-
|
|
|
|
|
- day7Work_Orders.buckets.each {
|
|
|
|
|
- day7Work_OrderCount_SeriesData.getData().add(BigDecimal.valueOf(it.docCount))
|
|
|
|
|
- InternalSum internalMoneySum = it.getAggregations().get("sub_orderMoney")
|
|
|
|
|
- day7Work_OrderMoney_SeriesData.getData().add(BigDecimal.valueOf(internalMoneySum.getValue()))
|
|
|
|
|
- }
|
|
|
|
|
- //extendedBounds必须添加,防止开始和结束的数据为0,但加上后,好像前面会多一天
|
|
|
|
|
- if (day7Work_OrderCount_SeriesData.getData().size() == 8) {
|
|
|
|
|
- day7Work_OrderCount_SeriesData.getData().remove(0)
|
|
|
|
|
- }
|
|
|
|
|
- if (day7Work_OrderMoney_SeriesData.getData().size() == 8) {
|
|
|
|
|
- day7Work_OrderMoney_SeriesData.getData().remove(0)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- day7Work_seriesList.add(day7Work_OrderCount_SeriesData)
|
|
|
|
|
- day7Money_seriesList.add(day7Work_OrderMoney_SeriesData)
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- //施工单
|
|
|
|
|
- SearchRequestBuilder childRequest12 = esClient.getClient().prepareSearch(supplierService.getDateYearESIndex(source.getSupplierCode(), ESKeys.ES_ERP_PRINTBILL_INDEX, 2021))
|
|
|
|
|
- .setQuery(
|
|
|
|
|
- QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_ERP_PRINTBILL_BREED_TYPE))
|
|
|
|
|
- .must(QueryBuilders.termQuery("voidFlag", 0))
|
|
|
|
|
- .must(QueryBuilders.rangeQuery("createTime").gte(DateUtil.getStartOfDay(beginDate2).getTime()).lte(DateUtil.getEndOfDay(endDate2).getTime()))
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- childRequest12.addAggregation(
|
|
|
|
|
- AggregationBuilders.dateHistogram("breeds")
|
|
|
|
|
- .field("createTime")
|
|
|
|
|
- .dateHistogramInterval(DateHistogramInterval.DAY)
|
|
|
|
|
- .minDocCount(0l)
|
|
|
|
|
- .extendedBounds(new ExtendedBounds(DateUtil.getStartOfDay(beginDate2).getTime(), DateUtil.getEndOfDay(endDate2).getTime()))
|
|
|
|
|
- .order(Histogram.Order.KEY_ASC)
|
|
|
|
|
- )
|
|
|
|
|
- SearchResponse childRes12 = childRequest12.execute().actionGet()
|
|
|
|
|
- InternalDateHistogram day7Work_Breeds = childRes12.getAggregations().get("breeds")
|
|
|
|
|
-
|
|
|
|
|
- EChartDoubleData day7Work_BreedCount_SeriesData = new EChartDoubleData()
|
|
|
|
|
- day7Work_BreedCount_SeriesData.setName("施工单版数量")
|
|
|
|
|
- day7Work_BreedCount_SeriesData.setType("line")
|
|
|
|
|
-
|
|
|
|
|
- day7Work_Breeds.buckets.each {
|
|
|
|
|
- day7Work_BreedCount_SeriesData.getData().add(BigDecimal.valueOf(it.docCount))
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //extendedBounds必须添加,防止开始和结束的数据为0,但加上后,好像前面会多一天
|
|
|
|
|
- if (day7Work_BreedCount_SeriesData.getData().size() == 8) {
|
|
|
|
|
- day7Work_BreedCount_SeriesData.getData().remove(0)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- day7Work_seriesList.add(day7Work_BreedCount_SeriesData)
|
|
|
|
|
-
|
|
|
|
|
- day7WorkData.put("seriesData", day7Work_seriesList)
|
|
|
|
|
- day7MoneyData.put("seriesData", day7Money_seriesList)
|
|
|
|
|
-// day7Work_Orders.
|
|
|
|
|
-
|
|
|
|
|
- data.put("day7Work", day7WorkData)
|
|
|
|
|
- data.put("day7Money", day7MoneyData)
|
|
|
|
|
-
|
|
|
|
|
- //endregion
|
|
|
|
|
-
|
|
|
|
|
- //region 订单产品近7天的印量
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- RMap day7ProductPrintCountData = new RMap()
|
|
|
|
|
-
|
|
|
|
|
- List<String> day7ProductPrintCount_legendStrArray = new ArrayList<>()
|
|
|
|
|
- List<ProductInfo> productInfoList = productService.getProductInfoAllLocal(source.getDataSourceId(), source.getSupplierCode())
|
|
|
|
|
- productInfoList.each {
|
|
|
|
|
- day7ProductPrintCount_legendStrArray.add(it.productName)
|
|
|
|
|
- }
|
|
|
|
|
- day7ProductPrintCount_legendStrArray.add("全部产品")
|
|
|
|
|
- day7ProductPrintCountData.put("legendStrArray", day7ProductPrintCount_legendStrArray)
|
|
|
|
|
-
|
|
|
|
|
-// Date endDate5 = new Date();
|
|
|
|
|
-// endDate5 = DateUtil.getStartOfDay(endDate5);
|
|
|
|
|
-// Date beginDate5 = endDate2 - 6;
|
|
|
|
|
- Date endDate5 = nowDate.toDate()
|
|
|
|
|
- Date beginDate5 = (nowDate - 6).toDate()
|
|
|
|
|
-
|
|
|
|
|
- List<String> day7ProductPrintCount_xAxisArray = (nowDate - 6..nowDate).collect {
|
|
|
|
|
- String.valueOf(it.getMonthValue()) + "." + String.valueOf(it.getDayOfMonth())
|
|
|
|
|
- }.toList()
|
|
|
|
|
-
|
|
|
|
|
-// List<String> day7ProductPrintCount_xAxisArray = (beginDate5..endDate5).collect {
|
|
|
|
|
-// (it[Calendar.MONTH] + 1) + "." + (it[Calendar.DAY_OF_MONTH])
|
|
|
|
|
-// }.toList();
|
|
|
|
|
- day7ProductPrintCountData.put("xAxisArray", day7ProductPrintCount_xAxisArray)
|
|
|
|
|
-
|
|
|
|
|
- List<EChartDoubleData> day7ProductPrintCount_seriesList = new ArrayList<>()
|
|
|
|
|
-
|
|
|
|
|
- SearchRequestBuilder childRequest5 = esClient.getClient().prepareSearch(supplierService.getDateYearESIndex(source.getSupplierCode(), ESKeys.ES_ERP_PRINT_ORDER_INDEX, 2021))
|
|
|
|
|
- .setQuery(
|
|
|
|
|
- QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_ERP_PRINT_ORDER_TYPE))
|
|
|
|
|
- .must(QueryBuilders.termQuery("voidFlag", 0))
|
|
|
|
|
- .must(QueryBuilders.rangeQuery("createTimeLong").gte(DateUtil.getStartOfDay(beginDate2).getTime()).lte(DateUtil.getEndOfDay(endDate2).getTime()))
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- childRequest5.addAggregation(
|
|
|
|
|
- AggregationBuilders.dateHistogram("orders")
|
|
|
|
|
- .field("createTimeLong")
|
|
|
|
|
- .dateHistogramInterval(DateHistogramInterval.DAY)
|
|
|
|
|
- .minDocCount(0l)
|
|
|
|
|
- .extendedBounds(new ExtendedBounds(DateUtil.getStartOfDay(beginDate5).getTime(), DateUtil.getEndOfDay(endDate5).getTime()))
|
|
|
|
|
- .order(Histogram.Order.KEY_ASC)
|
|
|
|
|
- .subAggregation(
|
|
|
|
|
- AggregationBuilders.terms("products")
|
|
|
|
|
- .field("idProduct")
|
|
|
|
|
- .size(100)
|
|
|
|
|
- .order(Terms.Order.count(false))
|
|
|
|
|
- .subAggregation(
|
|
|
|
|
- AggregationBuilders.sum("sub_orderPrintCount").field("orderQty")
|
|
|
|
|
- )
|
|
|
|
|
- )
|
|
|
|
|
- .subAggregation(
|
|
|
|
|
- AggregationBuilders.sum("sub_AllOrderPrintCount").field("orderQty")
|
|
|
|
|
- )
|
|
|
|
|
- )
|
|
|
|
|
- SearchResponse childRes5 = childRequest5.execute().actionGet()
|
|
|
|
|
-
|
|
|
|
|
- productInfoList.each {
|
|
|
|
|
- EChartDoubleData day7ProductPrintCount_SeriesData = new EChartDoubleData()
|
|
|
|
|
- day7ProductPrintCount_SeriesData.setType("line")
|
|
|
|
|
- day7ProductPrintCount_SeriesData.setName(it.productName)
|
|
|
|
|
- day7ProductPrintCount_SeriesData.setId(it.getId())
|
|
|
|
|
-
|
|
|
|
|
- day7ProductPrintCount_seriesList.add(day7ProductPrintCount_SeriesData)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- EChartDoubleData day7ProductPrintCount_SeriesData = new EChartDoubleData()
|
|
|
|
|
- day7ProductPrintCount_SeriesData.setType("line")
|
|
|
|
|
- day7ProductPrintCount_SeriesData.setName("全部产品")
|
|
|
|
|
- day7ProductPrintCount_SeriesData.setId(-1)
|
|
|
|
|
- day7ProductPrintCount_seriesList.add(day7ProductPrintCount_SeriesData)
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- InternalDateHistogram day7ProductPrintCount_Orders = childRes5.getAggregations().get("orders")
|
|
|
|
|
- List<Long> idProductList = new ArrayList<>()
|
|
|
|
|
- day7ProductPrintCount_Orders.buckets.each {
|
|
|
|
|
- idProductList.clear()
|
|
|
|
|
- Terms productsGenders = it.getAggregations().get("products")
|
|
|
|
|
- productsGenders.buckets.each { p ->
|
|
|
|
|
- Terms.Bucket productBucket = p
|
|
|
|
|
- long idProduct = Long.parseLong(productBucket.getKeyAsString())
|
|
|
|
|
- InternalSum internalOrderQtySum = productBucket.getAggregations().get("sub_orderPrintCount")
|
|
|
|
|
-
|
|
|
|
|
- idProductList.add(idProduct)
|
|
|
|
|
-
|
|
|
|
|
- EChartDoubleData chartData = day7ProductPrintCount_seriesList.find { x -> return x.getId() == idProduct }
|
|
|
|
|
- if (chartData != null) {
|
|
|
|
|
- chartData.getData().add(BigDecimal.valueOf(internalOrderQtySum.getValue()))
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- InternalSum internalAllOrderQtySum = it.getAggregations().get("sub_AllOrderPrintCount")
|
|
|
|
|
- EChartDoubleData chartAllData = day7ProductPrintCount_seriesList.find { x -> return x.getId() == -1 }
|
|
|
|
|
- if (chartAllData != null) {
|
|
|
|
|
- chartAllData.getData().add(BigDecimal.valueOf(internalAllOrderQtySum.getValue()))
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //找不到数据的得加0
|
|
|
|
|
- List<EChartDoubleData> remainDataList = day7ProductPrintCount_seriesList.findAll { x -> return ((x.getId() != -1) && (!idProductList.any { y -> y == x.getId() })) }
|
|
|
|
|
- remainDataList.each { d ->
|
|
|
|
|
- d.getData().add(BigDecimal.ZERO)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- day7ProductPrintCount_seriesList.each {
|
|
|
|
|
- //extendedBounds必须添加,防止开始和结束的数据为0,但加上后,好像前面会多一天
|
|
|
|
|
- if (it.getData().size() == 8) {
|
|
|
|
|
- it.getData().remove(0)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- day7ProductPrintCountData.put("seriesData", day7ProductPrintCount_seriesList)
|
|
|
|
|
-
|
|
|
|
|
- data.put("day7ProductPrintCount", day7ProductPrintCountData)
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- //endregion
|
|
|
|
|
-
|
|
|
|
|
- //region 订单月产品类型统计
|
|
|
|
|
-
|
|
|
|
|
- RMap monthOrderProductData = new RMap()
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- LocalDateTime beginDate3 = nowTime.withDayOfMonth(1)
|
|
|
|
|
- LocalDateTime endDate3 = nowTime.withDayOfMonth(nowTime.toLocalDate().lengthOfMonth())
|
|
|
|
|
-
|
|
|
|
|
- List<RMap> monthOrderProduct_seriesList = new ArrayList<>()
|
|
|
|
|
-
|
|
|
|
|
- SearchRequestBuilder childRequest3 = esClient.getClient().prepareSearch(supplierService.getDateYearESIndex(source.getSupplierCode(), ESKeys.ES_ERP_PRINT_ORDER_INDEX, 2021))
|
|
|
|
|
- .setQuery(
|
|
|
|
|
- QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_ERP_PRINT_ORDER_TYPE))
|
|
|
|
|
- .must(QueryBuilders.termQuery("voidFlag", 0))
|
|
|
|
|
- .must(QueryBuilders.rangeQuery("createTimeLong").gte(DateUtil.getStartOfDay(DateUtil.localDateTimeToDate(beginDate3)).getTime()).lte(DateUtil.getEndOfDay(DateUtil.localDateTimeToDate(endDate3)).getTime()))
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- childRequest3.addAggregation(
|
|
|
|
|
- AggregationBuilders.terms("orders")
|
|
|
|
|
- .field("idProduct")
|
|
|
|
|
- .size(100)
|
|
|
|
|
- .order(Terms.Order.count(false))
|
|
|
|
|
- .subAggregation(
|
|
|
|
|
- AggregationBuilders.sum("sub_orderMoney").field("orderMoneyTotal")
|
|
|
|
|
- )
|
|
|
|
|
- )
|
|
|
|
|
- SearchResponse childRes3 = childRequest3.execute().actionGet()
|
|
|
|
|
-
|
|
|
|
|
- Terms monthOrderProductGenders = childRes3.getAggregations().get("orders")
|
|
|
|
|
- for (Terms.Bucket monthOrderProductBucket : monthOrderProductGenders.getBuckets()) {
|
|
|
|
|
- long idProduct = Long.parseLong(monthOrderProductBucket.getKeyAsString())
|
|
|
|
|
- RMap bucketData = new RMap()
|
|
|
|
|
- InternalSum moneySum = monthOrderProductBucket.getAggregations().get("sub_orderMoney")
|
|
|
|
|
- bucketData.put("name", productService.getProductInfoName(idProduct, source.getSupplierCode()))
|
|
|
|
|
-// bucketData.put("value", monthOrderProductBucket.getDocCount());
|
|
|
|
|
- bucketData.put("value", BigDecimal.valueOf(moneySum.getValue()).setScale(2, RoundingMode.HALF_UP))
|
|
|
|
|
- monthOrderProduct_seriesList.add(bucketData)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- monthOrderProductData.put("seriesData", monthOrderProduct_seriesList)
|
|
|
|
|
- data.put("monthOrderProduct", monthOrderProductData)
|
|
|
|
|
-
|
|
|
|
|
- //endregion
|
|
|
|
|
-
|
|
|
|
|
- //region 订单月份数量统计
|
|
|
|
|
-
|
|
|
|
|
- RMap month12WorkData = new RMap()
|
|
|
|
|
- RMap month12MoneyData = new RMap()
|
|
|
|
|
-
|
|
|
|
|
- LocalDateTime beginDate4 = nowTime.with(TemporalAdjusters.firstDayOfYear())
|
|
|
|
|
- LocalDateTime endDate4 = nowTime.with(TemporalAdjusters.lastDayOfYear())
|
|
|
|
|
-
|
|
|
|
|
- List<EChartDoubleData> month12Work_seriesList = new ArrayList<>()
|
|
|
|
|
- List<EChartDoubleData> month12Money_seriesList = new ArrayList<>()
|
|
|
|
|
-
|
|
|
|
|
- SearchRequestBuilder childRequest4 = esClient.getClient().prepareSearch(supplierService.getDateYearESIndex(source.getSupplierCode(), ESKeys.ES_ERP_PRINT_ORDER_INDEX, 2021))
|
|
|
|
|
- .setQuery(
|
|
|
|
|
- QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_ERP_PRINT_ORDER_TYPE))
|
|
|
|
|
- .must(QueryBuilders.termQuery("voidFlag", 0))
|
|
|
|
|
- .must(QueryBuilders.rangeQuery("createTimeLong").gte(DateUtil.getStartOfDay(DateUtil.localDateTimeToDate(beginDate4)).getTime()).lte(DateUtil.getEndOfDay(DateUtil.localDateTimeToDate(endDate4)).getTime()))
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- childRequest4.addAggregation(
|
|
|
|
|
- AggregationBuilders.dateHistogram("orders")
|
|
|
|
|
- .field("createTimeLong")
|
|
|
|
|
- .dateHistogramInterval(DateHistogramInterval.MONTH)
|
|
|
|
|
- .minDocCount(0l)
|
|
|
|
|
- .extendedBounds(new ExtendedBounds(DateUtil.getStartOfDay(DateUtil.localDateTimeToDate(beginDate4)).getTime(), DateUtil.getEndOfDay(DateUtil.localDateTimeToDate(endDate4)).getTime()))
|
|
|
|
|
- .order(Histogram.Order.KEY_ASC)
|
|
|
|
|
- .subAggregation(
|
|
|
|
|
- AggregationBuilders.sum("sub_orderMoney").field("orderMoneyTotal")
|
|
|
|
|
- )
|
|
|
|
|
- )
|
|
|
|
|
- SearchResponse childRes4 = childRequest4.execute().actionGet()
|
|
|
|
|
- InternalDateHistogram month12Work_Orders = childRes4.getAggregations().get("orders")
|
|
|
|
|
-
|
|
|
|
|
- EChartDoubleData month12Work_OrderCount_SeriesData = new EChartDoubleData()
|
|
|
|
|
- month12Work_OrderCount_SeriesData.setName("订单数量")
|
|
|
|
|
- month12Work_OrderCount_SeriesData.setType("bar")
|
|
|
|
|
-
|
|
|
|
|
- EChartDoubleData month12Work_OrderMoney_SeriesData = new EChartDoubleData()
|
|
|
|
|
- month12Work_OrderMoney_SeriesData.setName("订单金额")
|
|
|
|
|
- month12Work_OrderMoney_SeriesData.setType("bar")
|
|
|
|
|
-
|
|
|
|
|
- month12Work_Orders.buckets.each {
|
|
|
|
|
- month12Work_OrderCount_SeriesData.getData().add(BigDecimal.valueOf(it.docCount))
|
|
|
|
|
- InternalSum internalMoneySum = it.getAggregations().get("sub_orderMoney")
|
|
|
|
|
- month12Work_OrderMoney_SeriesData.getData().add(BigDecimal.valueOf(internalMoneySum.getValue()).setScale(2, RoundingMode.HALF_UP))
|
|
|
|
|
- }
|
|
|
|
|
- //extendedBounds必须添加,防止开始和结束的数据为0,但加上后,好像前面会多一天
|
|
|
|
|
- if (month12Work_OrderCount_SeriesData.getData().size() == 13) {
|
|
|
|
|
- month12Work_OrderCount_SeriesData.getData().remove(0)
|
|
|
|
|
- }
|
|
|
|
|
- if (month12Work_OrderMoney_SeriesData.getData().size() == 13) {
|
|
|
|
|
- month12Work_OrderMoney_SeriesData.getData().remove(0)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- month12Work_seriesList.add(month12Work_OrderCount_SeriesData)
|
|
|
|
|
- month12Money_seriesList.add(month12Work_OrderMoney_SeriesData)
|
|
|
|
|
-
|
|
|
|
|
- month12WorkData.put("seriesData", month12Work_seriesList)
|
|
|
|
|
- month12MoneyData.put("seriesData", month12Money_seriesList)
|
|
|
|
|
-// day7Work_Orders.
|
|
|
|
|
-
|
|
|
|
|
- data.put("month12Work", month12WorkData)
|
|
|
|
|
- data.put("month12Money", month12MoneyData)
|
|
|
|
|
-
|
|
|
|
|
- //endregion
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- data.put("showData", true)
|
|
|
|
|
|
|
+ data.put("showData", false)
|
|
|
|
|
|
|
|
ProcessMapItem result = ProcessMapItem.newBuilder()
|
|
ProcessMapItem result = ProcessMapItem.newBuilder()
|
|
|
.itemData(data)
|
|
.itemData(data)
|