md
This commit is contained in:
parent
d3f726a9ee
commit
0ca02c1ebf
@ -212,6 +212,7 @@ public interface IEmisWaybillService extends IDataAuditService
|
||||
|
||||
public List<EmisWaybill> selectPrintWaybillList(EmisWaybill emisWaybill);
|
||||
|
||||
public void genWarehouseInTplFileByOms(HttpServletResponse response, String orderSn) throws EmisBizError ;
|
||||
public void genWarehouseInTplFile(HttpServletResponse response, String orderSn) throws EmisBizError ;
|
||||
|
||||
public void genWaybillOrigAttach(String billCode);
|
||||
|
||||
@ -3413,7 +3413,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
}
|
||||
|
||||
@Override
|
||||
public void genWarehouseInTplFile(HttpServletResponse response, String orderSn) throws EmisBizError {
|
||||
public void genWarehouseInTplFileByOms(HttpServletResponse response, String orderSn) throws EmisBizError {
|
||||
|
||||
if(StringUtils.isEmpty(orderSn)){
|
||||
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS,"订单号为空");
|
||||
@ -3476,9 +3476,166 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
|
||||
EmisWaybillCargo cargoGoods = new EmisWaybillCargo();
|
||||
// [cargoQty] [weight] [volume] [length]*[width]*[height] [goodsName]
|
||||
|
||||
cargoGoods.setGoodsName(emisWaybillOld.getGoodsInfo());
|
||||
cargoGoods.setWeight(emisWaybillOld.getBillWeight());
|
||||
cargoGoods.setVolume(emisWaybillOld.getTotalVolume());
|
||||
cargoGoods.setWeight(emisWaybillOld.getBillWeight().stripTrailingZeros());
|
||||
cargoGoods.setVolume(emisWaybillOld.getTotalVolume().stripTrailingZeros());
|
||||
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<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", 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 genWarehouseInTplFile(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())){
|
||||
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<EmisWaybillCargo> cargoList = emisWaybillCargoMapper.selectEmisWaybillCargoList(queryCargo);
|
||||
List<EmisWaybillCargo> cargoList = new ArrayList<EmisWaybillCargo>();
|
||||
|
||||
EmisWaybillCargo cargoGoods = new EmisWaybillCargo();
|
||||
// [cargoQty] [weight] [volume] [length]*[width]*[height] [goodsName]
|
||||
cargoGoods.setGoodsName(emisWaybillOld.getGoodsInfo());
|
||||
cargoGoods.setWeight(emisWaybillOld.getBillWeight().stripTrailingZeros());
|
||||
cargoGoods.setVolume(emisWaybillOld.getTotalVolume().stripTrailingZeros());
|
||||
cargoGoods.setLength(BigDecimal.ZERO);
|
||||
cargoGoods.setWidth(BigDecimal.ZERO);
|
||||
cargoGoods.setHeight(BigDecimal.ZERO);
|
||||
@ -3552,7 +3709,6 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
// 写入流
|
||||
template.write(bos);
|
||||
// template.write(outputStream);
|
||||
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
|
||||
DocUtils.wordToPdf(bis, outputStream);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user