From 94e96829f65343629501f32c4c398da3628caf46 Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Wed, 25 Dec 2024 18:15:58 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=201.=E8=B0=83=E6=95=B42C=E7=9A=84?= =?UTF-8?q?=E9=A2=84=E5=AF=B9=E8=B4=A6=E5=8D=95=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MerchantStatisticsController.java | 16 +- .../mapper/StatisticsOrderInfoMapper.java | 1 + .../mapper/StatisticsOrderInfoMapper.xml | 124 ++++++++++++++ .../service/IStatisticsOrderInfoService.java | 1 + .../impl/StatisticsOrderInfoServiceImpl.java | 156 ++++++++++++++++++ 5 files changed, 297 insertions(+), 1 deletion(-) diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/controller/MerchantStatisticsController.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/controller/MerchantStatisticsController.java index 65ab5ab43..297015d77 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/controller/MerchantStatisticsController.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/controller/MerchantStatisticsController.java @@ -73,7 +73,21 @@ public class MerchantStatisticsController { List ls = statisticsOrderInfoService.orderInfoListExport(merchantStatisticsDTO); //导出ls - ExcelUtil.export(response, "预对账单数据", "预对账单数据", ls, StatisticsOrderInfoExportVO.class); + ExcelUtil.export(response, "预对账单数据2B", "预对账单数据2B", ls, StatisticsOrderInfoExportVO.class); + } + + + @ResponseBody + @PostMapping("/orderInfoListExport2C") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "预对账单列表导出", notes = "传入merchantStatisticsDTO") + public void orderInfoListExport2C(@RequestBody MerchantStatisticsDTO merchantStatisticsDTO, HttpServletResponse response) { + String method = "############orderInfoListExport: "; + log.info(method + "请求参数{}", merchantStatisticsDTO); + + List ls = statisticsOrderInfoService.orderInfoListExport2C(merchantStatisticsDTO); + //导出ls + ExcelUtil.export(response, "预对账单数据2C", "预对账单数据2C", ls, StatisticsOrderInfoExportVO.class); } @ResponseBody diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.java index 6a4a88978..8a0423f97 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.java @@ -20,6 +20,7 @@ import java.util.Set; public interface StatisticsOrderInfoMapper extends BaseMapper { IPage pageList(IPage page, @Param("param") MerchantStatisticsDTO merchantStatisticsDTO); + List pageList2CExport( @Param("param") MerchantStatisticsDTO merchantStatisticsDTO); List findStatementListByOrderInfoIds(@Param("orderInfoIds") List orderInfoIds); diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.xml b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.xml index a98a45841..5c22aa35e 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.xml +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.xml @@ -924,6 +924,130 @@ group by lsoi.waybill_id + diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/IStatisticsOrderInfoService.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/IStatisticsOrderInfoService.java index ba9237674..3fe94e72f 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/IStatisticsOrderInfoService.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/IStatisticsOrderInfoService.java @@ -62,4 +62,5 @@ public interface IStatisticsOrderInfoService extends BaseService orderInfoListExport2C(MerchantStatisticsDTO merchantStatisticsDTO); } diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsOrderInfoServiceImpl.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsOrderInfoServiceImpl.java index c0c41bcaa..a91d7ef3e 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsOrderInfoServiceImpl.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsOrderInfoServiceImpl.java @@ -1445,6 +1445,162 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl orderInfoListExport2C(MerchantStatisticsDTO merchantStatisticsDTO) { + + List result = new ArrayList<>(); + List warehouseIds = warehouseClient.getWarehouseIds(); + if (!warehouseIds.isEmpty()) { + merchantStatisticsDTO.setWarehouseIds(warehouseIds); + } + List records = baseMapper.pageList2CExport(merchantStatisticsDTO); + + //把records中所有的orderInfoId放入一个集合 + List orderInfoIdList = records.stream().map(StatisticsOrderInfoVO::getOrderInfoId).collect(Collectors.toList()); + // 得到运单ID集合 + Set waybillIds = records.stream().map(StatisticsOrderInfoVO::getWaybillId).collect(Collectors.toSet()); + + // 查询运单明细集合 + List waybillDetailByWaybillId = baseMapper.findWaybillDetailByWaybillId(waybillIds); + + //得到运单号 + Set orderCodeSet = records.stream().map(StatisticsOrderInfoVO::getOrderCode).collect(Collectors.toSet()); + + // 通过运单号进行分组 + Map> waybillDetailByWaybillIdMap = waybillDetailByWaybillId.stream().collect(Collectors.groupingBy(WaybillDetailByWaybillNoVo::getWaybillId)); + + Map orderPackageInfoMap; + if (CollUtil.isNotEmpty(orderInfoIdList)) { + List orderPackageInfoList = baseMapper.findPackageListByOrderIdsGroupById(orderInfoIdList); + //把orderPackageInfoList转化成以orderInfoId为key的Map + if (CollUtil.isNotEmpty(orderPackageInfoList)) { + orderPackageInfoMap = orderPackageInfoList.stream() + .collect(Collectors.toMap(StatisticsPackageFeeInfoVO::getOrderInfoId, statisticsPackageFeeInfoVO -> statisticsPackageFeeInfoVO)); + } else { + orderPackageInfoMap = null; + } + } else { + orderPackageInfoMap = null; + } + + List advanceDetailDTOS = baseMapper.selectAdvinceDetail(waybillIds, orderCodeSet); + records.forEach(statisticsOrderInfoVO -> { +// Long waybillId = statisticsOrderInfoVO.getWaybillId(); + + + Long waybillId = statisticsOrderInfoVO.getWaybillId(); + String orderCode = statisticsOrderInfoVO.getOrderCode(); + // 查询站存单上的 + + List advanceDetailDTOList = advanceDetailDTOS.stream(). + filter(advanceDetailDTO -> advanceDetailDTO.getWaybillId().equals(waybillId) && advanceDetailDTO.getOrderCode().equals(orderCode)).collect(Collectors.toList()); + + // 对advanceDetailDTOList 按照 incomeCategoryName 进分组 并统计数量 + Map> collect = advanceDetailDTOList.stream().filter(advanceDetailDTO -> !Objects.isNull(advanceDetailDTO.getIncomeCategoryName())).collect(Collectors.groupingBy(AdvanceDetailDTO::getIncomeCategoryName)); + + Long orderInfoId = statisticsOrderInfoVO.getOrderInfoId(); + if (orderPackageInfoMap != null) { + StatisticsPackageFeeInfoVO statisticsPackageFeeInfoVO = orderPackageInfoMap.get(orderInfoId); + + if (statisticsPackageFeeInfoVO != null) { +// statisticsPackageFeeInfoVO.setGoodsName(statisticsOrderInfoVO.getGoodsName()); + BeanUtil.copy(statisticsPackageFeeInfoVO, statisticsOrderInfoVO); + + if (StringUtil.isNotBlank(statisticsOrderInfoVO.getGoodsName())) { +// String[] split = statisticsOrderInfoVO.getGoodsName().split(","); + List waybillDetailByWaybillNoVos = waybillDetailByWaybillIdMap.get(statisticsOrderInfoVO.getWaybillId()); + + StringBuffer sb = new StringBuffer(); + StringBuffer sb1 = new StringBuffer(); + StringBuffer sb3 = new StringBuffer(); + + if (collect.isEmpty()) { + + if (waybillDetailByWaybillNoVos != null && !waybillDetailByWaybillNoVos.isEmpty()) { + + for (WaybillDetailByWaybillNoVo waybillDetailByWaybillNoVo : waybillDetailByWaybillNoVos) { + + if (!sb3.toString().isEmpty()) { + sb3.append(","); + } + sb3.append(waybillDetailByWaybillNoVo.getProductName()); + + if (!sb.toString().isEmpty()) { + sb.append(","); + } + sb.append(waybillDetailByWaybillNoVo.getNum()); + + if (!sb1.toString().isEmpty()) { + sb1.append(","); + } + sb1.append(waybillDetailByWaybillNoVo.getPrice()); + + } + + } + + } else { + collect.keySet().forEach(s -> { + if (!sb3.toString().isEmpty()) { + sb3.append(","); + } + sb3.append(s); + List advanceDetailDTOS1 = collect.get(s); + + if (waybillDetailByWaybillNoVos != null) { + Optional first = waybillDetailByWaybillNoVos.stream().filter(waybillDetailByWaybillNoVo -> waybillDetailByWaybillNoVo.getProductName().equals(s)).findFirst(); + + if (first.isPresent()) { + WaybillDetailByWaybillNoVo waybillDetailByWaybillNoVo = first.get(); + + if (!sb.toString().isEmpty()) { + sb.append(","); + } + + //统计 advanceDetailDTOS1 这个集合种 quantity 的和值 + int sum = advanceDetailDTOS1.stream().mapToInt(AdvanceDetailDTO::getQuantity).sum(); + sb.append(sum); + + if (!sb1.toString().isEmpty()) { + sb1.append(","); + } + sb1.append(waybillDetailByWaybillNoVo.getPrice()); + } + } + + + }); + + } + + statisticsOrderInfoVO.setGoodsName(sb3.toString()); + statisticsOrderInfoVO.setGoodsNum(sb.toString()); + statisticsOrderInfoVO.setGoodsPrice(sb1.toString()); + } + + } + } + StatisticsOrderInfoExportVO statisticsOrderInfoExportVO = new StatisticsOrderInfoExportVO(); + BeanUtil.copy(statisticsOrderInfoVO, statisticsOrderInfoExportVO); + statisticsOrderInfoExportVO.setTypeServiceName(DistributionTypeConstant.getName(statisticsOrderInfoVO.getTypeService())); + statisticsOrderInfoExportVO.setPayType(DictBizCache.getValue(DictBizConstant.OPEN_ORDER_PAY_TYPE, statisticsOrderInfoVO.getPayType())); + statisticsOrderInfoExportVO.setPayWay(DictBizCache.getValue(DictBizConstant.OPEN_ORDER_PAY_WAY, statisticsOrderInfoVO.getPayWay())); + + String signName = "未签收"; + if (1 == statisticsOrderInfoVO.getSignStatus()) { + signName = "部分签收"; + } else if (2 == statisticsOrderInfoVO.getSignStatus()) { + signName = "已签收"; + } +// statisticsOrderInfoExportVO.setSignStatus(); + statisticsOrderInfoExportVO.setSignStatusName(signName); + + result.add(statisticsOrderInfoExportVO); + + }); + return result; + } + @Override public Integer findBalanceOrderStatus(Long waybillId) {