This commit is contained in:
linfso 2025-03-13 16:30:42 +08:00
parent 05ae00ed86
commit 226dfe1ebf
7 changed files with 207 additions and 5 deletions

View File

@ -365,6 +365,40 @@ public class EmisWaybillController extends EmisBaseController
}
/**
* 导出客户账单模版
* @param response
* @param orderSn
*/
@Log(title = "导出客户账单模版", businessType = BusinessType.EXPORT)
@RequestMapping("/exportCustBillTpl")
public void exportCustBillTpl(HttpServletResponse response,String orderSn,String fileType) {
try{
emisWaybillService.genWarehouseInTplFile(response,orderSn,fileType);
}
catch(EmisBizError ex){
ex.printStackTrace();
}
}
/**
* 导出客户账单模版
* @param response
* @param billCode
*/
@Log(title = "导出客户税金账单模版", businessType = BusinessType.EXPORT)
@RequestMapping("/exportCustTaxBillTpl")
public void exportCustTaxBillTpl(HttpServletResponse response,String billCode,String fileType) {
try{
emisWaybillService.genWarehouseInTplFile(response,billCode,fileType);
}
catch(EmisBizError ex){
ex.printStackTrace();
}
}
@Log(title = "运单实时下单", businessType = BusinessType.INSERT)
@PostMapping(value = "/realSubmitOrder")
public AjaxResult realSubmitOrder(@Validated @RequestBody WaybillOrder waybillOrder, Integer isModify)

View File

@ -15,6 +15,9 @@ import java.util.Map;
import com.xdadan.erp.common.core.audit.IDataAuditService;
import com.xdadan.erp.emis.domain.EmisSettleSubBill;
import com.xdadan.erp.emis.domain.EmisWaybill;
import com.xdadan.erp.emis.domain.exception.EmisBizError;
import javax.servlet.http.HttpServletResponse;
/**
* @ClassName EmisSettleSubBillService
@ -44,6 +47,8 @@ public interface IEmisSettleSubBillService extends IDataAuditService
public List<Map> selectHasPayMapList(String settleBillNo);
public void genCustBillTplFile(HttpServletResponse response, String billCode,String tplType, String fileType) throws EmisBizError;
/**
* 查询统计信息

View File

@ -755,7 +755,6 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
continue;
}
EmisSettleSubBill subBill = emisSettleSubBillMapper.selectSettleSubBillBySubBillNo(billNo);
BigDecimal sumMoney = BigDecimal.valueOf(Double.valueOf(item.get("sumMoney").toString()));
totalMoney = totalMoney.add(sumMoney);

View File

@ -10,26 +10,55 @@
package com.xdadan.erp.emis.service.impl;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.xdadan.erp.emis.domain.EmisWaybill;
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.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.DictUtils;
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.exception.EmisBizError;
import com.xdadan.erp.emis.mapper.EmisSettleInvoiceRelMapper;
import com.xdadan.erp.emis.mapper.EmisSettlePayRelMapper;
import com.xdadan.erp.emis.service.EmisBaseService;
import com.xdadan.erp.emis.service.warehouse.DocUtils;
import com.xdadan.erp.emis.utils.sensitive.Convert;
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 com.xdadan.erp.emis.domain.EmisSettleSubBill;
import com.xdadan.erp.emis.mapper.EmisSettleSubBillMapper;
import com.xdadan.erp.emis.service.IEmisSettleSubBillService;
import org.springframework.util.CollectionUtils;
/**
import javax.servlet.http.HttpServletResponse;
/**
* 结算子账单Service业务层处理
*
* @author linfso
* @date 2024-07-03 18:54:52
*/
@Service
public class EmisSettleSubBillServiceImpl implements IEmisSettleSubBillService
public class EmisSettleSubBillServiceImpl extends EmisBaseService implements IEmisSettleSubBillService
{
@Autowired
private EmisSettleSubBillMapper emisSettleSubBillMapper;
@ -53,6 +82,139 @@ public class EmisSettleSubBillServiceImpl implements IEmisSettleSubBillService
return emisSettleSubBillMapper.selectEmisSettleSubBillById((Long)id);
}
@Override
public void genCustBillTplFile(HttpServletResponse response, String billCode,String tplType, String fileType) throws EmisBizError {
if(StringUtils.isEmpty(billCode)){
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS,"运单号为空");
}
EmisWaybill emisWaybillOld = getWaybillByBillCode(billCode);
if(emisWaybillOld==null){
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS,"运单不存在");
}
if(OrderStatus.CANCEL.statusCode.equals(emisWaybillOld.getOrderStatus())){
throw new EmisBizError(EmisBizErrorType.FAIL,"订单已取消");
}
String tplName="";
// 根据不同线路使用不同模版
// 账单模版
if("1".equals(tplType) ){
tplName="tpl/cust_bill_tpl.docx";
}
// 空运
else if("2".equals(tplType) ){
tplName="tpl/cust_tax_bill_tpl.docx";
}
try {
OutputStream outputStream = response.getOutputStream();
InputStream fis = new ClassPathResource(tplName).getInputStream();
/*1.根据模板生成文档*/
String fileName = URLEncoder.encode(emisWaybillOld.getIntoWarehouseBillCode(), "UTF-8");
// 填充模版数据
LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();
Configure config = Configure.builder().bind("feeList", policy).build();
Map<String, Object> fillMap = new HashMap<>();
fillMap.put("productName", emisWaybillOld.getProductTypeName());
fillMap.put("sendDate", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, emisWaybillOld.getSendDate()));
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("goodsInfo", emisWaybillOld.getGoodsInfo());
fillMap.put("parcelQty", emisWaybillOld.getParcelQty());
fillMap.put("settlementWeight", emisWaybillOld.getSettlementWeight());
fillMap.put("productTypeName", emisWaybillOld.getProductTypeName());
fillMap.put("salesmen", emisWaybillOld.getSalesmen());
String salesmenPhone = "";
if (!StringUtils.isEmpty(emisWaybillOld.getSalesmen())) {
SysUser salesmenUser = getEmisStaffByEmpName(emisWaybillOld.getSalesmen());
if (salesmenUser != null) {
salesmenPhone = salesmenUser.getPhonenumber();
}
}
fillMap.put("salesmenPhone", salesmenPhone);
fillMap.put("sendProvinceName", emisWaybillOld.getSendProvinceName());
fillMap.put("recvProvinceName", emisWaybillOld.getReceiveProvinceName());
fillMap.put("recvCityName", emisWaybillOld.getReceiveCityName());
BigDecimal dutyFee = BigDecimal.ZERO;
String dutyFeeCurrency = "CNY";
EmisSettleSubBill billItem = getSettleSubBillBySubBillNo(emisWaybillOld.getBillCode());
List<EmisSettleSubBillFeeitem> feeItemList = billItem.getFeeitemList();
List<Map<String, Object>> listMap = new ArrayList<>();
if (!CollectionUtils.isEmpty(feeItemList)) {
for (EmisSettleSubBillFeeitem feeitem : feeItemList) {
Map<String, Object> voMap = new HashMap<>();
voMap.put("feeName", feeitem.getFeeName());
voMap.put("fee", feeitem.getBillFee().stripTrailingZeros().toPlainString());
voMap.put("currency", feeitem.getCurrency());
listMap.add(voMap);
if("2004".equals(feeitem.getFeeCode())){
dutyFee=feeitem.getBillFee();
dutyFeeCurrency = feeitem.getCurrency();
}
}
}
fillMap.put("feeList", listMap);
fillMap.put("totalFee", billItem.getBillFee().stripTrailingZeros().toPlainString());
fillMap.put("dutyFee", dutyFee.stripTrailingZeros().toPlainString());
fillMap.put("dutyFeeCurrency", dutyFeeCurrency);
// 生成模版
XWPFTemplate template = XWPFTemplate.compile(fis, config).render(fillMap);
// docx
if("docx".equals(fileType)){
response.setContentType("application/octet-stream;charset=UTF-8");
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".docx");
response.addHeader("Access-Control-Expose-Headers", "Content-disposition");
template.write(outputStream);
}
// pdf
else {
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){
ex.printStackTrace();
throw new EmisBizError(EmisBizErrorType.FAIL,"生成文件出错:"+ ex.getMessage());
}
}
/**
* 查询结算子账单
*

View File

@ -1364,6 +1364,8 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
}
/**
* 下单接口
* @param emisWaybillSave

Binary file not shown.

Binary file not shown.