md
This commit is contained in:
parent
f720c93e43
commit
87e1fe63ce
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: com.deepoove:poi-ooxml-schemas-extra:4.1.5">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/deepoove/poi-ooxml-schemas-extra/4.1.5/poi-ooxml-schemas-extra-4.1.5.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/deepoove/poi-ooxml-schemas-extra/4.1.5/poi-ooxml-schemas-extra-4.1.5-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/deepoove/poi-ooxml-schemas-extra/4.1.5/poi-ooxml-schemas-extra-4.1.5-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -1,13 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: com.deepoove:poi-tl:1.12.0">
|
||||
<library name="Maven: com.deepoove:poi-tl:1.10.6">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/deepoove/poi-tl/1.12.0/poi-tl-1.12.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/deepoove/poi-tl/1.10.6/poi-tl-1.10.6.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/deepoove/poi-tl/1.12.0/poi-tl-1.12.0-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/deepoove/poi-tl/1.10.6/poi-tl-1.10.6-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/deepoove/poi-tl/1.12.0/poi-tl-1.12.0-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/deepoove/poi-tl/1.10.6/poi-tl-1.10.6-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
13
.idea/libraries/Maven__xalan_serializer_2_7_2.xml
Normal file
13
.idea/libraries/Maven__xalan_serializer_2_7_2.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: xalan:serializer:2.7.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/xalan/serializer/2.7.2/serializer-2.7.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/xalan/serializer/2.7.2/serializer-2.7.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/xalan/serializer/2.7.2/serializer-2.7.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
13
.idea/libraries/Maven__xalan_xalan_2_7_2.xml
Normal file
13
.idea/libraries/Maven__xalan_xalan_2_7_2.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: xalan:xalan:2.7.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/xalan/xalan/2.7.2/xalan-2.7.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/xalan/xalan/2.7.2/xalan-2.7.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/xalan/xalan/2.7.2/xalan-2.7.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@ -113,10 +113,6 @@
|
||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.11.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml:4.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi:4.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:SparseBitSet:1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:4.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:3.1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
|
||||
@ -271,7 +267,12 @@
|
||||
<orderEntry type="library" name="Maven: com.alibaba:easyexcel-support:3.3.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-csv:1.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.ehcache:ehcache:3.9.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.deepoove:poi-tl:1.12.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.deepoove:poi-tl:1.10.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi:4.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:SparseBitSet:1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.deepoove:poi-ooxml-schemas-extra:4.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-transcoder:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-anim:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-css:1.14" level="project" />
|
||||
@ -283,6 +284,8 @@
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-bridge:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-script:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-dom:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: xalan:xalan:2.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: xalan:serializer:2.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.4.01" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-gvt:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-shared-resources:1.14" level="project" />
|
||||
|
||||
@ -11,7 +11,9 @@
|
||||
|
||||
package com.xdadan.erp.web.emis;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -23,15 +25,18 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.data.PictureType;
|
||||
import com.deepoove.poi.data.Pictures;
|
||||
import com.xdadan.erp.common.annotation.filter.jackson.JacksonFilter;
|
||||
import com.xdadan.erp.common.config.PayConfig;
|
||||
import com.xdadan.erp.common.core.domain.entity.SysUser;
|
||||
import com.xdadan.erp.common.utils.BarcodeUtils;
|
||||
import com.xdadan.erp.common.utils.DateUtils;
|
||||
import com.xdadan.erp.common.utils.file.FileUtils;
|
||||
import com.xdadan.erp.common.utils.idgen.UUID;
|
||||
import com.xdadan.erp.emis.domain.EmisBrand;
|
||||
import com.xdadan.erp.emis.domain.EmisCountry;
|
||||
import com.xdadan.erp.emis.domain.EmisTmsScanRecord;
|
||||
import com.xdadan.erp.emis.domain.*;
|
||||
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
||||
import com.xdadan.erp.emis.domain.enumtype.OrderStatus;
|
||||
import com.xdadan.erp.emis.domain.enumtype.ScanType;
|
||||
import com.xdadan.erp.emis.domain.enumtype.WaybillStatus;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
@ -65,8 +70,6 @@ import com.xdadan.erp.common.core.domain.AjaxResult;
|
||||
import com.xdadan.erp.common.core.page.TableDataInfo;
|
||||
import com.xdadan.erp.common.enums.BusinessType;
|
||||
|
||||
import com.xdadan.erp.emis.domain.EmisWaybill;
|
||||
|
||||
/**
|
||||
* 运单列表Controller
|
||||
*
|
||||
@ -233,31 +236,28 @@ public class EmisWaybillController extends EmisBaseController
|
||||
/**
|
||||
* 导出进仓单模板
|
||||
* @param response
|
||||
* @param inNo
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "导出进仓单", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/exportWarehouseInTpl")
|
||||
public void exportWarehouseInTpl(HttpServletResponse response,String inNo) {
|
||||
public AjaxResult exportWarehouseInTpl(HttpServletResponse response,WaybillOrder waybillOrder) {
|
||||
|
||||
try{
|
||||
Map<String,Object> tempMap = new HashMap<>();
|
||||
tempMap.put("name", "模版");
|
||||
tempMap.put("age", 134);
|
||||
OutputStream outputStream=response.getOutputStream();
|
||||
InputStream fis = new ClassPathResource("tpl/ws_in_tpl.docx").getInputStream();
|
||||
/*1.根据模板生成文档*/
|
||||
XWPFTemplate template = XWPFTemplate.compile(fis).render(tempMap);
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;fileName="+ inNo +".docx");
|
||||
response.flushBuffer();
|
||||
template.write(response.getOutputStream());
|
||||
|
||||
IOUtils.closeQuietly(fis);
|
||||
IOUtils.closeQuietly(outputStream);
|
||||
|
||||
}catch (Exception ex){
|
||||
emisWaybillService.genWarehouseInTplFile(response,waybillOrder.getOrderSn());
|
||||
return AjaxResult.success("下载成功");
|
||||
}
|
||||
catch(EmisBizError ex){
|
||||
ex.printStackTrace();
|
||||
return AjaxResult.error("("+ex.getErrorCode()+")"+ex.getMessage());
|
||||
}
|
||||
catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
// 返回子定义异常
|
||||
if(ex instanceof EmisBizError){
|
||||
return AjaxResult.error(ex.getMessage(),((EmisBizError)ex).getErrorCode());
|
||||
}
|
||||
|
||||
return AjaxResult.error("服务器异常,联系客服");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -66,10 +66,6 @@
|
||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.11.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml:4.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi:4.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:SparseBitSet:1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:4.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:3.1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
|
||||
@ -230,7 +226,12 @@
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-csv:1.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.ehcache:ehcache:3.9.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.36" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.deepoove:poi-tl:1.12.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.deepoove:poi-tl:1.10.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi:4.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:SparseBitSet:1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.deepoove:poi-ooxml-schemas-extra:4.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-transcoder:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-anim:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-css:1.14" level="project" />
|
||||
@ -242,6 +243,8 @@
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-bridge:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-script:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-dom:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: xalan:xalan:2.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: xalan:serializer:2.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.4.01" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-gvt:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlgraphics:batik-shared-resources:1.14" level="project" />
|
||||
|
||||
@ -127,18 +127,6 @@
|
||||
<version>1.10.6</version>
|
||||
</dependency>
|
||||
|
||||
<!-- poi -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.poi</groupId>-->
|
||||
<!-- <artifactId>poi</artifactId>-->
|
||||
<!-- <version>3.17</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.poi</groupId>-->
|
||||
<!-- <artifactId>poi-ooxml</artifactId>-->
|
||||
<!-- <version>3.17</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- 江苏移动短信-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.mascloud</groupId>-->
|
||||
|
||||
@ -9,6 +9,8 @@
|
||||
*/
|
||||
package com.xdadan.erp.emis.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -17,6 +19,8 @@ import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.domain.vo.AddressParseResult;
|
||||
import com.xdadan.erp.emis.domain.vo.WaybillOrder;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @ClassName EmisWaybillService
|
||||
* @Description 运单列表
|
||||
@ -189,5 +193,6 @@ public interface IEmisWaybillService
|
||||
|
||||
public List<EmisWaybill> selectPrintWaybillList(EmisWaybill emisWaybill);
|
||||
|
||||
public void genWarehouseInTplFile(HttpServletResponse response, String orderSn) throws EmisBizError, IOException ;
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,12 @@
|
||||
|
||||
package com.xdadan.erp.emis.service.impl;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
|
||||
@ -18,12 +23,18 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Snowflake;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.data.PictureType;
|
||||
import com.deepoove.poi.data.Pictures;
|
||||
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.googlecode.aviator.AviatorEvaluator;
|
||||
import com.xdadan.erp.common.annotation.audit.DataAuditFilter;
|
||||
import com.xdadan.erp.common.core.domain.AjaxResult;
|
||||
import com.xdadan.erp.common.core.domain.entity.SysUser;
|
||||
import com.xdadan.erp.common.core.redis.RedissonService;
|
||||
import com.xdadan.erp.common.utils.BarcodeUtils;
|
||||
import com.xdadan.erp.common.utils.DateUtils;
|
||||
import com.xdadan.erp.common.utils.DictUtils;
|
||||
import com.xdadan.erp.common.utils.SecurityUtils;
|
||||
@ -35,14 +46,19 @@ import com.xdadan.erp.emis.domain.vo.scan.ScanInfo;
|
||||
import com.xdadan.erp.emis.mapper.*;
|
||||
import com.xdadan.erp.emis.service.*;
|
||||
import com.xdadan.erp.emis.utils.WaybillHelper;
|
||||
import com.xdadan.erp.emis.utils.sensitive.Convert;
|
||||
import com.xdadan.erp.system.service.ISysUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 运单列表Service业务层处理
|
||||
*
|
||||
@ -2196,6 +2212,129 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
||||
return emisWaybillMapper.selectPrintWaybillList(emisWaybill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void genWarehouseInTplFile(HttpServletResponse response, String orderSn) throws EmisBizError, IOException {
|
||||
|
||||
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_ls_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";
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
// 生成条码
|
||||
int width=350;
|
||||
int height=40;
|
||||
BufferedImage barcodeImageBuffer = BarcodeUtils.getBarCodeWithWord(emisWaybillOld.getIntoWarehouseBillCode(),width,height,70);
|
||||
|
||||
// 填充模版数据
|
||||
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("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("wsContact", emisWaybillOld.getIntoWarehouseContact());
|
||||
fillMap.put("wsPhone", emisWaybillOld.getIntoWarehousePhone());
|
||||
fillMap.put("wsAddress", emisWaybillOld.getIntoWarehouseAddress());
|
||||
fillMap.put("salesmen", emisWaybillOld.getSalesmen());
|
||||
|
||||
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 +".docx");
|
||||
response.flushBuffer();
|
||||
template.write(response.getOutputStream());
|
||||
|
||||
IOUtils.closeQuietly(fis);
|
||||
IOUtils.closeQuietly(outputStream);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
@ -1,33 +1,175 @@
|
||||
package com.xdadan.erp.emis.service.warehouse;
|
||||
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.data.Numberings;
|
||||
import com.deepoove.poi.data.PictureType;
|
||||
import com.deepoove.poi.data.Pictures;
|
||||
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
|
||||
import com.xdadan.erp.common.utils.BarcodeUtils;
|
||||
import com.xdadan.erp.emis.domain.EmisWaybill;
|
||||
import com.xdadan.erp.emis.domain.vo.Cargo;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WordTplUtils {
|
||||
|
||||
public void genWord(OutputStream out, String tplFile, Map<String, Object> fillMap) throws IOException {
|
||||
// 数据转换
|
||||
// 文件名称
|
||||
// String fileName = URLEncoder.encode("文件名称", StandardCharsets.UTF_8.name());
|
||||
// 指示响应内容的格式
|
||||
public void genWord(OutputStream out, EmisWaybill waybill) throws IOException {
|
||||
|
||||
// response.setContentType("application/octet-stream");
|
||||
// response.setCharacterEncoding("utf-8");
|
||||
// response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".docx");
|
||||
//
|
||||
XWPFTemplate template = XWPFTemplate.compile(tplFile);
|
||||
// XWPFTemplate template = XWPFTemplate.compile(tplFile);
|
||||
// // 数据填充
|
||||
// template.render(fillMap);
|
||||
// template.write(out);
|
||||
// out.flush();
|
||||
|
||||
try {
|
||||
int width=350;
|
||||
int height=40;
|
||||
|
||||
BufferedImage barcodeImageBuffer = BarcodeUtils.getBarCodeWithWord("TAN-SHJD-24072701",width,height,70);
|
||||
|
||||
List<Cargo> cargoList= new ArrayList<>();
|
||||
|
||||
Cargo cargo=new Cargo();
|
||||
cargo.setGoodsName("测试");
|
||||
cargo.setCargoQty(1);
|
||||
cargo.setWeight(BigDecimal.valueOf(1.2D));
|
||||
cargo.setWeight(BigDecimal.valueOf(1.2D));
|
||||
cargo.setLength(BigDecimal.valueOf(1.2D));
|
||||
cargo.setWidth(BigDecimal.valueOf(1.2D));
|
||||
cargo.setHeight(BigDecimal.valueOf(1.2D));
|
||||
cargoList.add(cargo);
|
||||
|
||||
|
||||
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
||||
|
||||
Configure config = Configure.builder()
|
||||
.bind("cargoList", policy).build();
|
||||
|
||||
|
||||
InputStream fis = new ClassPathResource("tpl/ws_in_tpl.docx").getInputStream();
|
||||
XWPFTemplate template = XWPFTemplate.compile("/Users/alan/Downloads/ws_air_in_tpl.docx",config).render(
|
||||
new HashMap<String, Object>(){{
|
||||
put("wsInNo", "TAN-SHJD-24072701");
|
||||
put("country", "越南");
|
||||
put("warehouse", "柯桥");
|
||||
put("productName", "探路特快");
|
||||
put("estDate", "2024-07-22");
|
||||
put("declareType", "快递报关");
|
||||
put("eDeclareType", "快递清关");
|
||||
|
||||
put("supplier", "供应商");
|
||||
|
||||
put("sendName", "发件人");
|
||||
put("sendTel", "发件电话");
|
||||
put("sendAddress", "发件地址");
|
||||
put("sendCompany", "发件公司");
|
||||
|
||||
put("recvName", "收件人");
|
||||
put("recvTel", "收件电话");
|
||||
put("recvAddress", "收件地址");
|
||||
put("recvCompany", "收件公司");
|
||||
|
||||
put("wsContact", "易大伟");
|
||||
put("wsPhone", "123");
|
||||
put("wsAddress", "南京机场");
|
||||
put("payee", "李晓虎");
|
||||
|
||||
put("barcode", Pictures.ofBufferedImage(barcodeImageBuffer, PictureType.JPEG)
|
||||
.size(width, height).create());
|
||||
|
||||
put("cargoList", cargoList);
|
||||
}});
|
||||
|
||||
|
||||
|
||||
template.writeAndClose(new FileOutputStream("/Users/alan/Downloads/1.docx"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// XWPFTemplate template = getTemplate(filePath)) {
|
||||
// 数据填充
|
||||
template.render(fillMap);
|
||||
template.write(out);
|
||||
out.flush();
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
int width=350;
|
||||
int height=40;
|
||||
|
||||
BufferedImage barcodeImageBuffer = BarcodeUtils.getBarCodeWithWord("TAN-SHJD-24072701",width,height,70);
|
||||
|
||||
List<Cargo> cargoList= new ArrayList<>();
|
||||
|
||||
Cargo cargo=new Cargo();
|
||||
cargo.setGoodsName("测试");
|
||||
cargo.setCargoQty(1);
|
||||
cargo.setWeight(BigDecimal.valueOf(1.2D));
|
||||
cargo.setWeight(BigDecimal.valueOf(1.2D));
|
||||
cargo.setLength(BigDecimal.valueOf(1.2D));
|
||||
cargo.setWidth(BigDecimal.valueOf(1.2D));
|
||||
cargo.setHeight(BigDecimal.valueOf(1.2D));
|
||||
cargoList.add(cargo);
|
||||
|
||||
|
||||
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
|
||||
|
||||
Configure config = Configure.builder()
|
||||
.bind("cargoList", policy).build();
|
||||
|
||||
|
||||
|
||||
XWPFTemplate template = XWPFTemplate.compile("/Users/alan/Downloads/ws_air_in_tpl.docx",config).render(
|
||||
new HashMap<String, Object>(){{
|
||||
put("wsInNo", "TAN-SHJD-24072701");
|
||||
put("country", "越南");
|
||||
put("warehouse", "柯桥");
|
||||
put("productName", "探路特快");
|
||||
put("estDate", "2024-07-22");
|
||||
put("declareType", "快递报关");
|
||||
put("eDeclareType", "快递清关");
|
||||
|
||||
put("supplier", "供应商");
|
||||
|
||||
put("sendName", "发件人");
|
||||
put("sendTel", "发件电话");
|
||||
put("sendAddress", "发件地址");
|
||||
put("sendCompany", "发件公司");
|
||||
|
||||
put("recvName", "收件人");
|
||||
put("recvTel", "收件电话");
|
||||
put("recvAddress", "收件地址");
|
||||
put("recvCompany", "收件公司");
|
||||
|
||||
put("wsContact", "易大伟");
|
||||
put("wsPhone", "123");
|
||||
put("wsAddress", "南京机场");
|
||||
put("payee", "李晓虎");
|
||||
|
||||
put("barcode", Pictures.ofBufferedImage(barcodeImageBuffer, PictureType.JPEG)
|
||||
.size(width, height).create());
|
||||
|
||||
put("cargoList", cargoList);
|
||||
}});
|
||||
|
||||
|
||||
|
||||
template.writeAndClose(new FileOutputStream("/Users/alan/Downloads/1.docx"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
emis-biz/src/main/resources/tpl/ws_air_in_tpl.docx
Normal file
BIN
emis-biz/src/main/resources/tpl/ws_air_in_tpl.docx
Normal file
Binary file not shown.
Binary file not shown.
BIN
emis-biz/src/main/resources/tpl/ws_ls_in_tpl.docx
Normal file
BIN
emis-biz/src/main/resources/tpl/ws_ls_in_tpl.docx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user