From bf14149db31a33f92349b7d99ccfedd2c509c0bd Mon Sep 17 00:00:00 2001 From: "autumn.g@foxmail.com" Date: Thu, 3 Aug 2023 14:54:46 +0800 Subject: [PATCH] update --- .../impl/OrderBasicInfoServiceImpl.java | 61 ++++++++++++++----- .../mapper/pile/OrderBasicInfoMapper.xml | 1 - 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java index 575654382..1dc98d068 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java @@ -1548,25 +1548,58 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService { dto.setStationIdList(stationIdList); // return orderBasicInfoMapper.getIndexOrderInfo(dto); List voList = orderBasicInfoMapper.getIndexOrderInfoV2(dto); - for (IndexOrderInfoVO indexOrderInfoVO : voList) { - String orderCodes = indexOrderInfoVO.getOrderCodes(); - // 获取到所有的订单号列表 - if (StringUtils.isBlank(orderCodes)) { - continue; + + + Map> map = voList.stream().collect(Collectors.groupingBy(IndexOrderInfoVO::getDate)); + + List resultList = Lists.newArrayList(); + IndexOrderInfoVO vo; + for (Map.Entry> entry : map.entrySet()) { + vo = new IndexOrderInfoVO(); + vo.setDate(entry.getKey()); + + BigDecimal totalElectricity = BigDecimal.ZERO; + BigDecimal totalOrderAmount = BigDecimal.ZERO; + + List orderCodeList = Lists.newArrayList(); + for (IndexOrderInfoVO indexOrderInfoVO : entry.getValue()) { + totalOrderAmount = totalOrderAmount.add(new BigDecimal(indexOrderInfoVO.getTotalOrderAmount())); + totalElectricity = totalElectricity.add(new BigDecimal(indexOrderInfoVO.getTotalElectricity())); + orderCodeList.addAll(Lists.newArrayList(StringUtils.split(indexOrderInfoVO.getOrderCodes(), ","))) } - List orderCodeList = Arrays.asList(orderCodes.split(",")); + // 查询对应数据 IndexOrderInfoVO detailInfo = orderBasicInfoMapper.getIndexOrderDetail(orderCodeList); - if (detailInfo == null) { - continue; - } - indexOrderInfoVO.setTotalSharpUsedElectricity(detailInfo.getTotalSharpUsedElectricity()); - indexOrderInfoVO.setTotalPeakUsedElectricity(detailInfo.getTotalPeakUsedElectricity()); - indexOrderInfoVO.setTotalFlatUsedElectricity(detailInfo.getTotalFlatUsedElectricity()); - indexOrderInfoVO.setTotalValleyUsedElectricity(detailInfo.getTotalValleyUsedElectricity()); + vo.setTotalOrderAmount(totalOrderAmount.toString()); + vo.setTotalElectricity(totalElectricity.toString()); + vo.setTotalPeakUsedElectricity(detailInfo.getTotalPeakUsedElectricity()); + vo.setTotalFlatUsedElectricity(detailInfo.getTotalFlatUsedElectricity()); + vo.setTotalSharpUsedElectricity(detailInfo.getTotalSharpUsedElectricity()); + vo.setTotalValleyUsedElectricity(detailInfo.getTotalValleyUsedElectricity()); + + resultList.add(vo); } - return voList; + + // for (IndexOrderInfoVO indexOrderInfoVO : voList) { + // String orderCodes = indexOrderInfoVO.getOrderCodes(); + // // 获取到所有的订单号列表 + // if (StringUtils.isBlank(orderCodes)) { + // continue; + // } + // List orderCodeList = Arrays.asList(orderCodes.split(",")); + // // 查询对应数据 + // IndexOrderInfoVO detailInfo = orderBasicInfoMapper.getIndexOrderDetail(orderCodeList); + // if (detailInfo == null) { + // continue; + // } + // indexOrderInfoVO.setTotalSharpUsedElectricity(detailInfo.getTotalSharpUsedElectricity()); + // indexOrderInfoVO.setTotalPeakUsedElectricity(detailInfo.getTotalPeakUsedElectricity()); + // indexOrderInfoVO.setTotalFlatUsedElectricity(detailInfo.getTotalFlatUsedElectricity()); + // indexOrderInfoVO.setTotalValleyUsedElectricity(detailInfo.getTotalValleyUsedElectricity()); + // + // } + return resultList; } /** diff --git a/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml index f919ec412..b072e1430 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/OrderBasicInfoMapper.xml @@ -1127,7 +1127,6 @@ #{item,jdbcType=VARCHAR} - group by trade_date