diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/dto/ExportShippingPackingDto.java b/ruoyi-admin/src/main/java/com/ruoyi/system/dto/ExportShippingPackingDto.java index dda12cc2..4cbf0b2f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/dto/ExportShippingPackingDto.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/dto/ExportShippingPackingDto.java @@ -18,5 +18,15 @@ public class ExportShippingPackingDto { private Integer materialNum; + private String box; + private String oneBox; + + private String twoBox; + + private String totalNW; + + private String totalGW; + + private String meas; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesShippingInformServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesShippingInformServiceImpl.java index 1b86e8ad..902d0aab 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesShippingInformServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesShippingInformServiceImpl.java @@ -853,9 +853,11 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor SysSalesShippingInform sysSalesShippingInform = sysSalesShippingInformMapper.selectSysSalesShippingInformByCode(outOrderCode); String shippingInformationType = "0"; String shippingTemplateType = "销售出货箱单1"; + + String salesOrderCode = sysSalesShippingInform.getSalesOrderCode(); + //生成出货资料 insertShippingInformation(outOrderCode,shippingInformationType,shippingTemplateType,sysSalesShippingInform); - String salesOrderCode = sysSalesShippingInform.getSalesOrderCode(); String realFileName = salesOrderCode + "-" + fileName.substring(0, fileName.lastIndexOf(".")) + ".xlsx"; @@ -863,35 +865,65 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(realFileName, "UTF-8")); response.setContentType("application/octet-stream"); - SysMakeOrder sysMakeOrder = sysMakeOrderMapper.selectMakeOrderBySaleNo(salesOrderCode); - if (sysMakeOrder == null){ - log.warn("未找到对应的生产订单,请检查:{}", salesOrderCode); - throw new RuntimeException("未找到对应的生产订单,请检查"); + + + List salesOrderCodes = new ArrayList<>(); + + if (StringUtils.isNotEmpty(salesOrderCode)){ + String[] splitSalesOrderCode = salesOrderCode.split(","); + salesOrderCodes = Arrays.asList(splitSalesOrderCode); } - Map map = new HashMap<>(); - map.put("customerContactBillto",sysSalesShippingInform.getCustomerContactBillto()); - map.put("contactAddressBillto",sysSalesShippingInform.getContactAddressBillto()); - map.put("customerContact",sysSalesShippingInform.getCustomerContact()); - map.put("customerContactAddress",sysSalesShippingInform.getCustomerContactAddress()); + //生产订主表的数据 + List sysMakeOrders = sysMakeOrderMapper.selectMakeOrderListBySalesOrderCodes(salesOrderCodes); + + //获取销售订单的明细 + List sysSalesOrderChildren = salesOrderChildMapper.selectBatchOrderChildListBySalesOrderCode(salesOrderCodes); + + + + Map makeOrderMap = new HashMap<>(); + + for (SysMakeOrder sysMakeOrder : sysMakeOrders) { + makeOrderMap.put(sysMakeOrder.getSaleNo(),sysMakeOrder); + } + List shippingPackingDtos = new ArrayList<>(); AtomicInteger index = new AtomicInteger(1); - List shippingDeviceList = salesShippingDeviceMapper.selectShippingDeviceBySalesOrderCode(salesOrderCode); - for (AfterSalesShippingDevice shippingDevice : shippingDeviceList) { + + for (SysSalesOrderChild sysSalesOrderChild : sysSalesOrderChildren) { + SysMakeOrder sysMakeOrder = makeOrderMap.get(sysSalesOrderChild.getQuoteId()); ExportShippingPackingDto exportShippingPackingDto = new ExportShippingPackingDto(); exportShippingPackingDto.setIndex(index.getAndIncrement()); - exportShippingPackingDto.setMaterialDescribe(shippingDevice.getMaterialDescribe()); - exportShippingPackingDto.setMaterialModel(shippingDevice.getMaterialModelCode()); - exportShippingPackingDto.setMakeNo(shippingDevice.getMakeNo()); - exportShippingPackingDto.setMaterialNum(1); + exportShippingPackingDto.setMaterialDescribe(sysSalesOrderChild.getDescribe()); + exportShippingPackingDto.setMaterialModel(sysSalesOrderChild.getMaterialModel()); + exportShippingPackingDto.setMakeNo(sysMakeOrder.getMakeNo()); + exportShippingPackingDto.setMaterialNum(sysSalesOrderChild.getMaterialNum()); + exportShippingPackingDto.setBox(null); + exportShippingPackingDto.setOneBox(null); + exportShippingPackingDto.setMeas(null); + exportShippingPackingDto.setTwoBox(null); + exportShippingPackingDto.setTotalGW(null); + exportShippingPackingDto.setTotalNW(null); shippingPackingDtos.add(exportShippingPackingDto); + } + + + Map map = new HashMap<>(); + + map.put("customerContactBillto",sysSalesShippingInform.getCustomerContactBillto()); + map.put("contactAddressBillto",sysSalesShippingInform.getContactAddressBillto()); + map.put("customerContact",sysSalesShippingInform.getCustomerContact()); + map.put("customerContactAddress",sysSalesShippingInform.getCustomerContactAddress()); + + //构建模板 ExcelWriter workBook = EasyExcel.write(response.getOutputStream()).withTemplate(fileAbsolutePath).build(); WriteSheet sheet = EasyExcel.writerSheet().build(); @@ -944,35 +976,60 @@ public class SysSalesShippingInformServiceImpl implements ISysSalesShippingInfor response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(realFileName, "UTF-8")); response.setContentType("application/octet-stream"); - SysMakeOrder sysMakeOrder = sysMakeOrderMapper.selectMakeOrderBySaleNo(salesOrderCode); - if (sysMakeOrder == null){ - log.warn("未找到对应的生产订单,请检查:{}", salesOrderCode); - throw new RuntimeException("未找到对应的生产订单,请检查"); + List salesOrderCodes = new ArrayList<>(); + + if (StringUtils.isNotEmpty(salesOrderCode)){ + String[] splitSalesOrderCode = salesOrderCode.split(","); + salesOrderCodes = Arrays.asList(splitSalesOrderCode); } - Map map = new HashMap<>(); - map.put("customerContactBillto",sysSalesShippingInform.getCustomerContactBillto()); - map.put("contactAddressBillto",sysSalesShippingInform.getContactAddressBillto()); - map.put("customerContact",sysSalesShippingInform.getCustomerContact()); - map.put("customerContactAddress",sysSalesShippingInform.getCustomerContactAddress()); + //生产订主表的数据 + List sysMakeOrders = sysMakeOrderMapper.selectMakeOrderListBySalesOrderCodes(salesOrderCodes); + + //获取销售订单的明细 + List sysSalesOrderChildren = salesOrderChildMapper.selectBatchOrderChildListBySalesOrderCode(salesOrderCodes); + + + + Map makeOrderMap = new HashMap<>(); + + for (SysMakeOrder sysMakeOrder : sysMakeOrders) { + makeOrderMap.put(sysMakeOrder.getSaleNo(),sysMakeOrder); + } + List shippingPackingDtos = new ArrayList<>(); AtomicInteger index = new AtomicInteger(1); - List shippingDeviceList = salesShippingDeviceMapper.selectShippingDeviceBySalesOrderCode(salesOrderCode); - for (AfterSalesShippingDevice shippingDevice : shippingDeviceList) { + + for (SysSalesOrderChild sysSalesOrderChild : sysSalesOrderChildren) { + SysMakeOrder sysMakeOrder = makeOrderMap.get(sysSalesOrderChild.getQuoteId()); ExportShippingPackingDto exportShippingPackingDto = new ExportShippingPackingDto(); exportShippingPackingDto.setIndex(index.getAndIncrement()); - exportShippingPackingDto.setMaterialDescribe(shippingDevice.getMaterialDescribe()); - exportShippingPackingDto.setMaterialModel(shippingDevice.getMaterialModelCode()); - exportShippingPackingDto.setMakeNo(shippingDevice.getMakeNo()); - exportShippingPackingDto.setMaterialNum(1); + exportShippingPackingDto.setMaterialDescribe(sysSalesOrderChild.getDescribe()); + exportShippingPackingDto.setMaterialModel(sysSalesOrderChild.getMaterialModel()); + exportShippingPackingDto.setMakeNo(sysMakeOrder.getMakeNo()); + exportShippingPackingDto.setMaterialNum(sysSalesOrderChild.getMaterialNum()); + exportShippingPackingDto.setBox(null); + exportShippingPackingDto.setOneBox(null); + exportShippingPackingDto.setMeas(null); + exportShippingPackingDto.setTwoBox(null); + exportShippingPackingDto.setTotalGW(null); + exportShippingPackingDto.setTotalNW(null); shippingPackingDtos.add(exportShippingPackingDto); + } + Map map = new HashMap<>(); + + map.put("customerContactBillto",sysSalesShippingInform.getCustomerContactBillto()); + map.put("contactAddressBillto",sysSalesShippingInform.getContactAddressBillto()); + map.put("customerContact",sysSalesShippingInform.getCustomerContact()); + map.put("customerContactAddress",sysSalesShippingInform.getCustomerContactAddress()); + //构建模板 ExcelWriter workBook = EasyExcel.write(response.getOutputStream()).withTemplate(fileAbsolutePath).build(); WriteSheet sheet = EasyExcel.writerSheet().build(); diff --git a/ruoyi-admin/src/main/resources/static/attachments/销售出货箱单1.xlsx b/ruoyi-admin/src/main/resources/static/attachments/销售出货箱单1.xlsx index eef3e6f7..b93f752e 100644 Binary files a/ruoyi-admin/src/main/resources/static/attachments/销售出货箱单1.xlsx and b/ruoyi-admin/src/main/resources/static/attachments/销售出货箱单1.xlsx differ diff --git a/ruoyi-admin/src/main/resources/static/attachments/销售出货箱单2.xlsx b/ruoyi-admin/src/main/resources/static/attachments/销售出货箱单2.xlsx index 115fd875..e823b97b 100644 Binary files a/ruoyi-admin/src/main/resources/static/attachments/销售出货箱单2.xlsx and b/ruoyi-admin/src/main/resources/static/attachments/销售出货箱单2.xlsx differ