md
This commit is contained in:
parent
888f8317dc
commit
f18d6b698a
@ -193,6 +193,6 @@ public interface IEmisWaybillService
|
|||||||
|
|
||||||
public List<EmisWaybill> selectPrintWaybillList(EmisWaybill emisWaybill);
|
public List<EmisWaybill> selectPrintWaybillList(EmisWaybill emisWaybill);
|
||||||
|
|
||||||
public void genWarehouseInTplFile(HttpServletResponse response, String orderSn) throws EmisBizError, IOException ;
|
public void genWarehouseInTplFile(HttpServletResponse response, String orderSn) throws EmisBizError ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2212,7 +2212,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void genWarehouseInTplFile(HttpServletResponse response, String orderSn) throws EmisBizError, IOException {
|
public void genWarehouseInTplFile(HttpServletResponse response, String orderSn) throws EmisBizError {
|
||||||
|
|
||||||
if(StringUtils.isEmpty(orderSn)){
|
if(StringUtils.isEmpty(orderSn)){
|
||||||
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS,"订单号为空");
|
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS,"订单号为空");
|
||||||
@ -2260,90 +2260,94 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
tplName="tpl/ws_ls_in_tpl.docx";
|
tplName="tpl/ws_ls_in_tpl.docx";
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputStream outputStream=response.getOutputStream();
|
try {
|
||||||
InputStream fis = new ClassPathResource(tplName).getInputStream();
|
OutputStream outputStream = response.getOutputStream();
|
||||||
/*1.根据模板生成文档*/
|
InputStream fis = new ClassPathResource(tplName).getInputStream();
|
||||||
String fileName= URLEncoder.encode(emisWaybillOld.getIntoWarehouseBillCode(),"UTF-8");
|
/*1.根据模板生成文档*/
|
||||||
|
String fileName = URLEncoder.encode(emisWaybillOld.getIntoWarehouseBillCode(), "UTF-8");
|
||||||
|
|
||||||
|
|
||||||
// 货物清单
|
// 货物清单
|
||||||
EmisWaybillCargo queryCargo = new EmisWaybillCargo();
|
EmisWaybillCargo queryCargo = new EmisWaybillCargo();
|
||||||
queryCargo.setWaybillId(emisWaybillOld.getId());
|
queryCargo.setWaybillId(emisWaybillOld.getId());
|
||||||
List<EmisWaybillCargo> cargoList=emisWaybillCargoMapper.selectEmisWaybillCargoList(queryCargo);
|
List<EmisWaybillCargo> cargoList = emisWaybillCargoMapper.selectEmisWaybillCargoList(queryCargo);
|
||||||
|
|
||||||
// 生成条码
|
// 生成条码
|
||||||
int width=400;
|
int width = 400;
|
||||||
int height=70;
|
int height = 70;
|
||||||
BufferedImage barcodeImageBuffer = BarcodeUtils.getBarCodeWithWord(emisWaybillOld.getIntoWarehouseBillCode(),width,height,100);
|
BufferedImage barcodeImageBuffer = BarcodeUtils.getBarCodeWithWord(emisWaybillOld.getIntoWarehouseBillCode(), width, height, 100);
|
||||||
|
|
||||||
// 填充模版数据
|
// 填充模版数据
|
||||||
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
||||||
Configure config = Configure.builder().bind("cargoList", policy).build();
|
Configure config = Configure.builder().bind("cargoList", policy).build();
|
||||||
|
|
||||||
String customsEclaration="";
|
String customsEclaration = "";
|
||||||
if(!StringUtils.isEmpty(emisWaybillOld.getCustomsEclaration())){
|
if (!StringUtils.isEmpty(emisWaybillOld.getCustomsEclaration())) {
|
||||||
customsEclaration=DictUtils.getDictLabel("emis_declare_mode",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<String, Object> 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", emisWaybillOld.getCargoList());
|
||||||
|
|
||||||
|
// 生成模版
|
||||||
|
XWPFTemplate template = XWPFTemplate.compile(fis, config).render(fillMap);
|
||||||
|
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
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){
|
||||||
String customsClear="";
|
throw new EmisBizError(EmisBizErrorType.FAIL,"生成进仓单出错:"+ ex.getMessage());
|
||||||
if(!StringUtils.isEmpty(emisWaybillOld.getCustomsClear())){
|
|
||||||
customsClear=DictUtils.getDictLabel("emis_customs_clear",emisWaybillOld.getCustomsClear());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String,Object> 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", emisWaybillOld.getCargoList());
|
|
||||||
|
|
||||||
// 生成模版
|
|
||||||
XWPFTemplate template = XWPFTemplate.compile(fis,config).render(fillMap);
|
|
||||||
|
|
||||||
response.setContentType("application/octet-stream");
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user