|
@@ -1,25 +1,16 @@
|
|
|
package cn.iocoder.yudao.module.contract.service.exportContract;
|
|
|
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
|
|
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
|
|
|
import cn.iocoder.yudao.framework.common.util.number.MoneyUtil;
|
|
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
-import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
|
|
-import cn.iocoder.yudao.module.contract.dal.dataobject.basicData.BasicBankDO;
|
|
|
-import cn.iocoder.yudao.module.contract.dal.dataobject.basicData.BasicPackingDO;
|
|
|
-import cn.iocoder.yudao.module.contract.dal.dataobject.basicData.BasicPaymentDO;
|
|
|
-import cn.iocoder.yudao.module.contract.dal.dataobject.basicData.BasicSupplierDO;
|
|
|
+import cn.iocoder.yudao.module.contract.dal.dataobject.basicData.*;
|
|
|
import cn.iocoder.yudao.module.contract.dal.dataobject.client.ClientDO;
|
|
|
import cn.iocoder.yudao.module.contract.dal.dataobject.company.CompanyDO;
|
|
|
import cn.iocoder.yudao.module.contract.dal.dataobject.contractTemplate.ContractTemplateDO;
|
|
|
-import cn.iocoder.yudao.module.contract.dal.dataobject.frameworkAgreement.FrameworkAgreementDO;
|
|
|
-import cn.iocoder.yudao.module.contract.dal.dataobject.invoice.InvoiceDO;
|
|
|
-import cn.iocoder.yudao.module.contract.dal.dataobject.invoice.InvoiceDetailsDO;
|
|
|
import cn.iocoder.yudao.module.contract.dal.dataobject.order.OrderDO;
|
|
|
import cn.iocoder.yudao.module.contract.dal.dataobject.order.OrderDetailsDO;
|
|
|
-import cn.iocoder.yudao.module.contract.dal.dataobject.orderContract.OrderContractDO;
|
|
|
import cn.iocoder.yudao.module.contract.dal.mysql.order.OrderDetailsMapper;
|
|
|
import cn.iocoder.yudao.module.contract.service.basicData.*;
|
|
|
import cn.iocoder.yudao.module.contract.service.client.ClientService;
|
|
@@ -28,38 +19,32 @@ import cn.iocoder.yudao.module.contract.service.contractTemplate.ContractTemplat
|
|
|
import cn.iocoder.yudao.module.contract.service.order.OrderService;
|
|
|
import cn.iocoder.yudao.module.contract.utils.DateEnFormatUtil;
|
|
|
import cn.iocoder.yudao.module.contract.utils.HtmlToFileConverter;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import cn.iocoder.yudao.module.contract.utils.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.checkerframework.checker.units.qual.C;
|
|
|
import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
|
import org.jsoup.select.Elements;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import javax.annotation.Resource;
|
|
|
-import javax.jnlp.BasicService;
|
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import cn.iocoder.yudao.module.contract.controller.admin.exportContract.vo.*;
|
|
|
import cn.iocoder.yudao.module.contract.dal.dataobject.exportContract.ExportContractDO;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
|
import cn.iocoder.yudao.module.contract.dal.mysql.exportContract.ExportContractMapper;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
-import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
|
|
|
import static cn.iocoder.yudao.module.contract.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
/**
|
|
@@ -206,6 +191,7 @@ public class ExportContractServiceImpl extends ServiceImpl<ExportContractMapper,
|
|
|
if(StringUtils.isNotBlank(exportContract.getZzlifnr())){
|
|
|
//供应商不为空时生成佣金合同
|
|
|
ExportContractDO exportContractDO = BeanUtils.toBean(exportContract,ExportContractDO.class);
|
|
|
+ exportContractDO.setId(null);
|
|
|
exportContractDO.setType("2");
|
|
|
generateContractFile(exportContractDO,exportContractGenerate.getDetailsList());
|
|
|
saveOrUpdate(exportContractDO);
|
|
@@ -246,10 +232,23 @@ public class ExportContractServiceImpl extends ServiceImpl<ExportContractMapper,
|
|
|
}
|
|
|
Map<String,Object> param = buildContractParam(exportContract,detailsList,basicBankDO,company,clientDO);
|
|
|
htmlContent = HtmlToFileConverter.authHtmlToPdf(htmlContent, param);
|
|
|
- String fileUrl = htmlToFileConverter.htmlToWord(htmlContent,"exportContract/"+exportContract.getBstnk(),"fpht-");
|
|
|
- if("2".equals(exportContract.getType())){
|
|
|
+ String fileUrl = null;
|
|
|
+ if("1".equals(exportContract.getType())){
|
|
|
+ fileUrl = htmlToFileConverter.htmlToWord(htmlContent,"exportContract/"+exportContract.getBstnk(),"fpht-");
|
|
|
+ }else{
|
|
|
//佣金合同,需要与出口订单合同合并
|
|
|
-
|
|
|
+ List<String> htmlContents = new ArrayList<>();
|
|
|
+ ExportContractDO exportContractDO = getOne(Wrappers.<ExportContractDO>lambdaQuery().eq(ExportContractDO::getBstnk,exportContract.getBstnk()).eq(ExportContractDO::getType,"1").ne(ExportContractDO::getStatus,"3"));
|
|
|
+ if(exportContractDO==null){
|
|
|
+ throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"佣金合同生成失败,未找到"+exportContract.getBstnk()+"的出口合同");
|
|
|
+ }
|
|
|
+ htmlContents.add(exportContractDO.getContractHtml());
|
|
|
+ htmlContents.add(htmlContent);
|
|
|
+ fileUrl = htmlToFileConverter.htmlToWord(htmlContents,"exportContract/"+exportContract.getBstnk(),"fpht-");
|
|
|
+ htmlContent = StringUtils.join(htmlContents,"<div style='break-after: page;'></div><div class='page-break'>")+"</div>";
|
|
|
+ }
|
|
|
+ if(fileUrl==null){
|
|
|
+ throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"文件生成失败");
|
|
|
}
|
|
|
// exportContract.setGeneratedTime(LocalDateTime.now());
|
|
|
exportContract.setContractHtml(htmlContent);
|
|
@@ -343,8 +342,12 @@ public class ExportContractServiceImpl extends ServiceImpl<ExportContractMapper,
|
|
|
param.put("付款条件", StringUtils.nvl(exportContract.getPaymentName(), ""));
|
|
|
if(StringUtils.isNotBlank(exportContract.getVdatu())){
|
|
|
param.put("装运期限", DateEnFormatUtil.convertToCustomFormat(exportContract.getVdatu()));
|
|
|
+ param.put("凭证日期后一月", DateEnFormatUtil.convertToCustomFormat(exportContract.getVdatu(),1));
|
|
|
+ param.put("凭证日期后三月", DateEnFormatUtil.convertToCustomFormat(exportContract.getVdatu(),2));
|
|
|
}else{
|
|
|
param.put("装运期限", "");
|
|
|
+ param.put("凭证日期后一月", "");
|
|
|
+ param.put("凭证日期后三月", "");
|
|
|
}
|
|
|
param.put("经销商名称", StringUtils.nvl(exportContract.getZzlifnrt(), ""));
|
|
|
param.put("公司代码", StringUtils.nvl(exportContract.getBukrs(), ""));
|
|
@@ -359,10 +362,6 @@ public class ExportContractServiceImpl extends ServiceImpl<ExportContractMapper,
|
|
|
param.put("联行号", StringUtils.nvl(basicBankDO.getBankCode(), ""));
|
|
|
param.put("银行账号", StringUtils.nvl(basicBankDO.getBankAccount(), ""));
|
|
|
|
|
|
- param.put("品种海关编码", StringUtils.nvl("", ""));
|
|
|
- param.put("价格组合并", StringUtils.nvl("", ""));
|
|
|
- param.put("凭证日期后一月", StringUtils.nvl("", ""));
|
|
|
- param.put("凭证日期后三月", StringUtils.nvl("", ""));
|
|
|
//产品信息
|
|
|
List<Map<String,Object>> details = new ArrayList<>();
|
|
|
BigDecimal quantityTotal= BigDecimal.ZERO;
|
|
@@ -370,8 +369,30 @@ public class ExportContractServiceImpl extends ServiceImpl<ExportContractMapper,
|
|
|
BigDecimal noTaxAmountSum = BigDecimal.ZERO;
|
|
|
String rebirthRemark = "";
|
|
|
|
|
|
+ List<String> brokerageList = new ArrayList<>();
|
|
|
+ List<String> varietyList = new ArrayList<>();
|
|
|
for(int i=0;i<orderDeatils.size();i++){
|
|
|
OrderDetailsDO orderDetailsDO = orderDeatils.get(i);
|
|
|
+ BasicBrokerageDO brokerage = null;
|
|
|
+ BasicVarietyDO variety = null;
|
|
|
+ if(StringUtils.isNotBlank(orderDetailsDO.getKonda())){
|
|
|
+ brokerage = basicBrokerageService.getOne(Wrappers.<BasicBrokerageDO>lambdaQuery().eq(BasicBrokerageDO::getCode,orderDetailsDO.getKonda()),false);
|
|
|
+ if(brokerage==null){
|
|
|
+ throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"佣金组-"+orderDetailsDO.getKonda()+"不存在");
|
|
|
+ }
|
|
|
+ if(!brokerageList.contains(brokerage.getValue())){
|
|
|
+ brokerageList.add(brokerage.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(orderDetailsDO.getZzpz())){
|
|
|
+ variety = basicVarietyService.getOne(Wrappers.<BasicVarietyDO>lambdaQuery().eq(BasicVarietyDO::getName,orderDetailsDO.getZzpz()),false);
|
|
|
+ if(variety==null){
|
|
|
+ throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"品种编码-"+orderDetailsDO.getZzpz()+"不存在");
|
|
|
+ }
|
|
|
+ if(!varietyList.contains(variety.getValue())){
|
|
|
+ varietyList.add(variety.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
Map<String,Object> data = new HashMap<>();
|
|
|
data.put("序号",i+1);
|
|
|
data.put("行项目", StringUtils.nvl(orderDetailsDO.getPosnr(),""));
|
|
@@ -395,7 +416,7 @@ public class ExportContractServiceImpl extends ServiceImpl<ExportContractMapper,
|
|
|
data.put("物料功能性", StringUtils.nvl(orderDetailsDO.getZzwlgnx(),""));
|
|
|
|
|
|
data.put("凭证货币", StringUtils.nvl(orderDetailsDO.getWaerk(),""));
|
|
|
- data.put("佣金组", StringUtils.nvl("",""));
|
|
|
+ data.put("佣金组", brokerage!=null?brokerage.getValue():"");
|
|
|
data.put("佣金金额", StringUtils.nvl(MoneyUtil.toSeparator(orderDetailsDO.getKwert()),""));
|
|
|
data.put("销售单位", StringUtils.nvl(orderDetailsDO.getVrkme(),""));
|
|
|
data.put("物料类型", StringUtils.nvl(orderDetailsDO.getMtart(),""));
|
|
@@ -419,6 +440,9 @@ public class ExportContractServiceImpl extends ServiceImpl<ExportContractMapper,
|
|
|
}
|
|
|
param.put("orderDetails",details);
|
|
|
|
|
|
+ param.put("价格组合并", brokerageList.size()>0?String.join(";", brokerageList):"");
|
|
|
+ param.put("品种海关编码", varietyList.size()>0?String.join(";", varietyList):"");
|
|
|
+
|
|
|
//产品合计
|
|
|
param.put("再生产品备注",rebirthRemark);
|
|
|
param.put("数量合计",MoneyUtil.toSeparator(quantityTotal.toString()));
|