From 2d4d4e6c66387117ae2143f31eebda9ebac8750f Mon Sep 17 00:00:00 2001 From: PigBaoBei <2739175034@qq.com> Date: Fri, 15 Dec 2023 23:43:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=93=E5=AD=98=E5=93=81=E5=A4=87=E8=B4=A7?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logpm/distribution/bean/MyExcelUtil.java | 59 +++++++++++++++++++ .../DistributionStockupController.java | 3 +- .../dto/app/StockConfigInfoVO.java | 5 ++ ...ributionStockupPackageListDetailExcel.java | 13 ++-- .../mapper/DistributionStockupMapper.xml | 2 +- .../impl/DistributionStockupServiceImpl.java | 12 ++++ 6 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 blade-service/logpm-distribution/src/main/java/com/logpm/distribution/bean/MyExcelUtil.java diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/bean/MyExcelUtil.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/bean/MyExcelUtil.java new file mode 100644 index 000000000..6eb22f6c6 --- /dev/null +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/bean/MyExcelUtil.java @@ -0,0 +1,59 @@ +package com.logpm.distribution.bean; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.builder.ExcelWriterBuilder; +import com.alibaba.excel.write.handler.WriteHandler; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.logpm.distribution.excel.DistributionStockupPackageListDetailExcel; +import org.apache.commons.codec.Charsets; +import org.springblade.core.excel.util.ExcelUtil; + +import javax.servlet.http.HttpServletResponse; +import java.net.URLEncoder; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class MyExcelUtil extends ExcelUtil { + + + + + public static void export(HttpServletResponse response, List stockupList) { + try { + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding(Charsets.UTF_8.name()); + response.setHeader("Content-disposition", "attachment;filename=" + "备货清单列表" + ".xlsx"); + response.setHeader("content-Type", "application/vnd.ms-excel"); + ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build(); + //将清单进行分组,首先区分是否是库存品,其次进行区分订制品和零担 + Map> isInventoryMap = stockupList.stream().collect(Collectors.groupingBy(DistributionStockupPackageListDetailExcel::getIsInventory)); + isInventoryMap.forEach((k,v)->{ + if (k.equals(0)){ + //进行是否零担的区分 + Map> isZeroMap = v.stream().collect(Collectors.groupingBy(DistributionStockupPackageListDetailExcel::getIsZero)); + isZeroMap.forEach((m,n)->{ + if (m.equals(0)){ + //订制品 + WriteSheet writeSheet = EasyExcel.writerSheet("订制品备货清单").head(DistributionStockupPackageListDetailExcel.class).build(); + }else { + //零担 + WriteSheet writeSheet = EasyExcel.writerSheet("零担备货清单").head(DistributionStockupPackageListDetailExcel.class).build(); + } + }); + + }else { + //库存品 + } + }); + + + } catch (Exception e) { + + throw new RuntimeException("请稍后再试...."); + } + } + + +} diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionStockupController.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionStockupController.java index 57510804c..13409b023 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionStockupController.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/controller/DistributionStockupController.java @@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.logpm.basicdata.entity.BasicdataWarehouseEntity; import com.logpm.basicdata.feign.IBasicdataWarehouseClient; +import com.logpm.distribution.bean.MyExcelUtil; import com.logpm.distribution.entity.DistributionStockupEntity; import com.logpm.distribution.excel.DistributionCityExcel; import com.logpm.distribution.excel.DistributionMarketExcel; @@ -209,7 +210,7 @@ public class DistributionStockupController extends BladeController { List list = Func.toLongList(stockUpIds); //查询计划包件的EXCEL列表数据 List listExcel = distributionStockupService.exportStockUptDetail(list); - ExcelUtil.export(response, "自提备货数据" + DateUtil.time(), "自提备货数据表", listExcel, DistributionStockupPackageListDetailExcel.class); + MyExcelUtil.export(response,listExcel); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/dto/app/StockConfigInfoVO.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/dto/app/StockConfigInfoVO.java index 455984fda..71c562d70 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/dto/app/StockConfigInfoVO.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/dto/app/StockConfigInfoVO.java @@ -12,6 +12,11 @@ public class StockConfigInfoVO { */ private String customer; + /** + * 以备数量 + */ + private Integer realityNum; + /** * 地址 */ diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/excel/DistributionStockupPackageListDetailExcel.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/excel/DistributionStockupPackageListDetailExcel.java index 7fbe6ad87..6377bda8c 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/excel/DistributionStockupPackageListDetailExcel.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/excel/DistributionStockupPackageListDetailExcel.java @@ -1,5 +1,6 @@ package com.logpm.distribution.excel; +import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; import com.alibaba.excel.annotation.write.style.ContentRowHeight; @@ -52,19 +53,23 @@ public class DistributionStockupPackageListDetailExcel { @ExcelProperty("计划件数") private Integer reservationNum; + @ExcelIgnore + private Integer isInventory; + @ExcelIgnore private String isZero; /** * 包件码 */ + @ExcelIgnore private String orderPackageCode; - @ColumnWidth(20) - @ExcelProperty("是否零担") + @ColumnWidth(200) + @ExcelProperty("托盘名称") private String trayNames; - @ColumnWidth(20) - @ExcelProperty("是否零担") + @ColumnWidth(50) + @ExcelProperty("库存名称") private String allocationNames; diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockupMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockupMapper.xml index 33e8a8b5b..8e37c9b1a 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockupMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockupMapper.xml @@ -1166,7 +1166,7 @@ ldrs.reservation_num reservationNum, lds.remarks remarks, ldrs.is_zero isZero, - + 0 AS isInventory, GROUP_CONCAT(DISTINCT ldpl.material_name) AS productName, GROUP_CONCAT(DISTINCT ldpl.order_package_code) AS orderPackageCode FROM diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockupServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockupServiceImpl.java index 6a121b731..58ac4ce8c 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockupServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockupServiceImpl.java @@ -2964,9 +2964,21 @@ public class DistributionStockupServiceImpl extends BaseServiceImpl ls = new ArrayList<>(); //过滤出同物料库存品的ID信息 List stockListIds = distributionStockListEntities.stream().map(DistributionStockListEntity::getId).collect(Collectors.toList()); + //查询该物料的库存品信息 + List reservationStocklistEntityList = distributionReservationStocklistService.list(Wrappers.query().lambda() + .eq(DistributionReservationStocklistEntity::getReservationId, stockupDTO.getReservationId()) + .in(DistributionReservationStocklistEntity::getStocklistId, stockListIds) + .notIn(DistributionReservationStocklistEntity::getStockListStatus, 1, 3) + ); + if (Func.isNotEmpty(reservationStocklistEntityList)){ + int realityNum = reservationStocklistEntityList.stream().mapToInt(DistributionReservationStocklistEntity::getRealityNum).sum(); + stockConfigInfoVO.setRealityNum(realityNum); //地址 + + } LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(DistributionStockEntity::getReservationId, stockupDTO.getReservationId()); lambdaQueryWrapper.eq(DistributionStockEntity::getAllocationId, stockupDTO.getAllocationId());