From 2dbec7fb8471a147f9662d48706fc48cb745f62a Mon Sep 17 00:00:00 2001 From: linfso Date: Tue, 14 Jan 2025 13:22:16 +0800 Subject: [PATCH] md --- .../service/impl/EmisWaybillServiceImpl.java | 171 ++---------------- 1 file changed, 14 insertions(+), 157 deletions(-) diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillServiceImpl.java index 91a6063ff..bbfa3abc5 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillServiceImpl.java @@ -3974,163 +3974,6 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb return emisWaybillMapper.selectPrintWaybillList(emisWaybill); } - @Deprecated - public void tmp_genWarehouseInTplFileByOms(HttpServletResponse response, String orderSn) throws EmisBizError { - - if(StringUtils.isEmpty(orderSn)){ - throw new EmisBizError(EmisBizErrorType.NOT_EXISTS,"订单号为空"); - } - - EmisWaybill emisWaybillOld = this.selectEmisWaybillByOrderSn(orderSn); - if(emisWaybillOld==null){ - throw new EmisBizError(EmisBizErrorType.NOT_EXISTS,"订单不存在"); - } - - if(OrderStatus.CANCEL.statusCode.equals(emisWaybillOld.getOrderStatus())){ - throw new EmisBizError(EmisBizErrorType.FAIL,"订单已取消"); - } - - - if(!"1".equals(emisWaybillOld.getPickupMethod()) && !"3".equals(emisWaybillOld.getPickupMethod())){ - throw new EmisBizError(EmisBizErrorType.FAIL,"取件方式非仓库收货/整柜提货"); - } - - if(StringUtils.isEmpty(emisWaybillOld.getIntoWarehouseBillCode())){ - throw new EmisBizError(EmisBizErrorType.NOT_EXISTS,"进仓预报单号为空"); - } - - // 根据不同线路使用不同模版 - String tplName="tpl/ws_ls_in_tpl.docx"; - EmisTransLine emisTransLine = getTransLineByCode(emisWaybillOld.getTransLineType()); - // 快递 - if("1".equals(emisTransLine.getTransType()) ){ - tplName="tpl/ws_kd_in_tpl.docx"; - } - // 空运 - else if("2".equals(emisTransLine.getTransType()) ){ - tplName="tpl/ws_air_in_tpl.docx"; - } - // 陆运 - else if("3".equals(emisTransLine.getTransType()) ){ - tplName="tpl/ws_ls_in_tpl.docx"; - } - // 海运 - else if("4".equals(emisTransLine.getTransType()) ){ - tplName="tpl/ws_ls_in_tpl.docx"; - } - // 铁路 - else if("4".equals(emisTransLine.getTransType()) ){ - tplName="tpl/ws_ls_in_tpl.docx"; - } - - try { - OutputStream outputStream = response.getOutputStream(); - InputStream fis = new ClassPathResource(tplName).getInputStream(); - /*1.根据模板生成文档*/ - String fileName = URLEncoder.encode(emisWaybillOld.getIntoWarehouseBillCode(), "UTF-8"); - - - // 货物清单 使用货物总览 - EmisWaybillCargo queryCargo = new EmisWaybillCargo(); -// queryCargo.setWaybillId(emisWaybillOld.getId()); -// List cargoList = emisWaybillCargoMapper.selectEmisWaybillCargoList(queryCargo); - List cargoList = new ArrayList(); - - EmisWaybillCargo cargoGoods = new EmisWaybillCargo(); -// [cargoQty] [weight] [volume] [length]*[width]*[height] [goodsName] - - cargoGoods.setGoodsName(emisWaybillOld.getGoodsInfo()); - cargoGoods.setWeight(BigDecimal.valueOf(Double.valueOf(emisWaybillOld.getBillWeight().stripTrailingZeros().toPlainString()))); - cargoGoods.setVolume(BigDecimal.valueOf(Double.valueOf(emisWaybillOld.getTotalVolume().stripTrailingZeros().toPlainString()))); - - cargoGoods.setLength(BigDecimal.ZERO); - cargoGoods.setWidth(BigDecimal.ZERO); - cargoGoods.setHeight(BigDecimal.ZERO); - cargoGoods.setCargoQty(emisWaybillOld.getParcelQty()); - cargoList.add(cargoGoods); - - // 生成条码 - int width = 400; - int height = 70; - BufferedImage barcodeImageBuffer = BarcodeUtils.getBarCodeWithWord(emisWaybillOld.getIntoWarehouseBillCode(), width, height, 100); - - // 填充模版数据 - LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy(); - Configure config = Configure.builder().bind("cargoList", policy).build(); - - String customsEclaration = ""; - if (!StringUtils.isEmpty(emisWaybillOld.getCustomsEclaration())) { - customsEclaration = DictUtils.getDictLabel("emis_declare_mode", emisWaybillOld.getCustomsEclaration()); - } - - String customsClear = ""; - if (!StringUtils.isEmpty(emisWaybillOld.getCustomsClear())) { - customsClear = DictUtils.getDictLabel("emis_customs_clear", emisWaybillOld.getCustomsClear()); - } - - Map fillMap = new HashMap<>(); - fillMap.put("wsInNo", emisWaybillOld.getIntoWarehouseBillCode()); - fillMap.put("country", emisWaybillOld.getReceiveCountryName()); - fillMap.put("warehouse", emisWaybillOld.getIntoWarehouseName()); - fillMap.put("productName", emisWaybillOld.getProductTypeName()); - fillMap.put("estDate", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, emisWaybillOld.getPickStartDate() == null ? emisWaybillOld.getOrderDate() : emisWaybillOld.getPickStartDate())); - fillMap.put("declareType", customsEclaration); - fillMap.put("eDeclareType", customsClear); - fillMap.put("supplier", ""); - - fillMap.put("sendName", Convert.chineseName(emisWaybillOld.getSendName())); - fillMap.put("sendTel", Convert.mobile(emisWaybillOld.getSendMobile())); - fillMap.put("sendAddress", Convert.address(emisWaybillOld.getSendAddress())); - fillMap.put("sendCompany", emisWaybillOld.getSendCompany()); - fillMap.put("sendCountry", emisWaybillOld.getSendCountryName()); - - fillMap.put("recvName", Convert.chineseName(emisWaybillOld.getReceiveName())); - fillMap.put("recvTel", Convert.mobile(emisWaybillOld.getReceiveMobile())); - fillMap.put("recvAddress", Convert.address(emisWaybillOld.getReceiveAddress())); - fillMap.put("recvCompany", emisWaybillOld.getReceiveCompany()); - fillMap.put("recvCountry", emisWaybillOld.getReceiveCountryName()); - - fillMap.put("wsContact", emisWaybillOld.getIntoWarehouseContact()); - fillMap.put("wsPhone", emisWaybillOld.getIntoWarehousePhone()); - fillMap.put("wsAddress", emisWaybillOld.getIntoWarehouseAddress()); - fillMap.put("salesmen", emisWaybillOld.getSalesmen()); - - fillMap.put("sendProvinceName", emisWaybillOld.getSendProvinceName()); - fillMap.put("sendCityName", emisWaybillOld.getSendCityName()); - - fillMap.put("recvProvinceName", emisWaybillOld.getReceiveProvinceName()); - fillMap.put("recvCityName", emisWaybillOld.getReceiveCityName()); - - fillMap.put("barcode", Pictures.ofBufferedImage(barcodeImageBuffer, PictureType.JPEG).size(width, height).create()); - - fillMap.put("cargoList", cargoList); -// fillMap.put("cargoList", emisWaybillOld.getCargoList()); - - // 生成模版 - XWPFTemplate template = XWPFTemplate.compile(fis, config).render(fillMap); - -// response.setContentType("application/octet-stream"); - response.setContentType("application/pdf"); - response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".pdf"); - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - // 写入流 - template.write(bos); - - ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); - DocUtils.wordToPdf(bis, outputStream); - - response.flushBuffer(); - - IOUtils.closeQuietly(fis); - IOUtils.closeQuietly(outputStream); - } - catch (Exception ex){ - throw new EmisBizError(EmisBizErrorType.FAIL,"生成进仓单出错:"+ ex.getMessage()); - } - - } - @Override public void genWarehouseInTplFileByOms(HttpServletResponse response, String orderSn,String fileType) throws EmisBizError { @@ -4212,6 +4055,13 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb } } } + else{ + declareGoodsList = new ArrayList(); + EmisWaybillDeclareGoods cargoDeclareGoods = new EmisWaybillDeclareGoods(); + cargoDeclareGoods.setGoodsName(emisWaybillOld.getGoodsInfo()); + cargoDeclareGoods.setCargoQty(new BigDecimal(emisWaybillOld.getParcelQty().toString())); + declareGoodsList.add(cargoDeclareGoods); + } } // 非快递不需要明细 @@ -4405,6 +4255,13 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb } } } + else{ + declareGoodsList = new ArrayList(); + EmisWaybillDeclareGoods cargoDeclareGoods = new EmisWaybillDeclareGoods(); + cargoDeclareGoods.setGoodsName(emisWaybillOld.getGoodsInfo()); + cargoDeclareGoods.setCargoQty(new BigDecimal(emisWaybillOld.getParcelQty().toString())); + declareGoodsList.add(cargoDeclareGoods); + } } // 非快递不需要明细