Browse Source

出口合同代码

chen 3 weeks ago
parent
commit
4b4f879f00

+ 134 - 0
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/controller/admin/exportContract/ExportContractController.java

@@ -1,5 +1,14 @@
 package cn.iocoder.yudao.module.contract.controller.admin.exportContract;
 
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
+import cn.iocoder.yudao.module.contract.controller.admin.orderContract.vo.OrderContractSaveReqVO;
+import cn.iocoder.yudao.module.contract.dal.dataobject.order.OrderDO;
+import cn.iocoder.yudao.module.contract.dal.dataobject.exportContract.ExportContractDO;
+import cn.iocoder.yudao.module.contract.utils.FileDownloadUtil;
+import cn.iocoder.yudao.module.contract.utils.StringUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import org.springframework.validation.annotation.Validated;
@@ -11,6 +20,8 @@ import io.swagger.v3.oas.annotations.Operation;
 import javax.validation.constraints.*;
 import javax.validation.*;
 import javax.servlet.http.*;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
 import java.util.*;
 import java.io.IOException;
 
@@ -18,6 +29,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+
+import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.NOT_IMPLEMENTED;
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
@@ -92,4 +106,124 @@ public class ExportContractController {
                         BeanUtils.toBean(list, ExportContractRespVO.class));
     }
 
+    /**
+     * 本地资源通用下载
+     */
+    @GetMapping("/download")
+    public ResponseEntity<?> download(String ids) throws UnsupportedEncodingException {
+        String[] id = ids.split(",");
+        if (id.length == 1) {
+            //单文件下载
+            ExportContractDO exportContract = exportContractService.getById(id[0]);
+            exportContract.setDownloadCount(exportContract.getDownloadCount() + 1);
+            exportContractService.updateById(exportContract);
+            //orderDO.getVbeln()+orderDO.getKname()+orderDO.getVkorg()+orderDO.getYwyt()
+            String fileNmae = exportContract.getKname()+exportContract.getBstnk()+exportContract.getVkorg();
+            return FileDownloadUtil.downloadFile(exportContract.getContractFileUrl(), URLEncoder.encode(fileNmae,"UTF-8") );
+        } else if (id.length > 1) {
+            //批量下载
+            List<ExportContractDO> list = exportContractService.list(Wrappers.<ExportContractDO>lambdaQuery().in(ExportContractDO::getId, id));
+            List<String> fileUrls = new ArrayList<>();
+            List<String> fileNames = new ArrayList<>();
+            for (ExportContractDO exportContract : list) {
+                fileUrls.add(exportContract.getContractFileUrl());
+                String fileNmae = exportContract.getKname()+exportContract.getBstnk()+exportContract.getVkorg();
+                fileNames.add(fileNmae);
+//                fileNames.add(orderDO.getVbeln()+orderDO.getKname()+orderDO.getVkorg()+orderDO.getYwyt());
+            }
+            exportContractService.update(Wrappers.<ExportContractDO>update().setSql(" download_count = download_count + 1").in("id", id));
+            return FileDownloadUtil.downloadZip(fileUrls, fileNames);
+        } else {
+            throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(), "请选择要下载的合同");
+
+        }
+    }
+
+    /**
+     * 合同打印计数
+     */
+    @GetMapping("/prints")
+    public CommonResult<?> prints(String ids) {
+        String[] id = ids.split(",");
+        if (id.length != 0) {
+            exportContractService.update(Wrappers.<ExportContractDO>update().setSql(" print_count = print_count + 1").in("id", id));
+            return success("操作成功");
+        } else {
+            return CommonResult.error(NOT_IMPLEMENTED);
+        }
+    }
+
+    @PutMapping("/fileUpload")
+    @Operation(summary = "合同上传")
+    public CommonResult<Boolean> fileUpload(@Valid @RequestBody OrderContractSaveReqVO updateReqVO) {
+//        if (StringUtils.isBlank(updateReqVO.getFileIds()) && StringUtils.isBlank(updateReqVO.getScanFileIds()) ) {
+//            return error("请上传文件");
+//        }
+        ExportContractDO exportContract = exportContractService.getById(updateReqVO.getId());
+
+        ExportContractDO updateObj = BeanUtils.toBean(updateReqVO, ExportContractDO.class);
+        exportContractService.updateById(updateObj);
+////        exportContractService.fileUpload(updateReqVO);
+////        exportContract.setFileIds(updateReqVO.getFileIds());
+//        if (StringUtils.isNotBlank(updateReqVO.getFileIds()) || StringUtils.isNotBlank(updateReqVO.getScanFileIds()) ) {
+//            if(!"4".equals(exportContract.getOrderStatus())){
+//                updateObj.setOrderStatus("4");
+//                contractWebService.pushOrderStatus(orderDO.getVbeln(),"4",updateObj);
+//                exportContractService.updateById(updateObj);
+//            }
+//        }
+////        updateObj.setStatus("2");
+        return success(true);
+    }
+
+//    @GetMapping("/pushRelease")
+//    @Operation(summary = "推送释放")
+//    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+//    public CommonResult<?> pushRelease(@RequestParam("id") Long id) {
+//        ExportContractDO exportContract = exportContractService.getOrderContract(id);
+//        OrderDO orderDO = orderService.getOrder(exportContract.getOrderId());
+//        if(orderDO==null){
+//            throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"订单不存在");
+//        }
+//        contractWebService.pushOrderStatus(orderDO.getVbeln(),exportContract.getOrderStatus(),exportContract);
+//        exportContractService.updateById(exportContract);
+//        if("1".equals(exportContract.getIsPushRelease())){
+//            return success(true);
+//        }else{
+//            return error(exportContract.getAbnormalCause());
+//        }
+//
+//    }
+
+    @GetMapping("/cancellation")
+    @Operation(summary = "作废")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    public CommonResult<?> cancellation(@RequestParam("id") Long id) {
+        ExportContractDO exportContract = exportContractService.getById(id);
+//        OrderDO orderDO = orderService.getOrder(exportContract.getOrderId());
+//        if(orderDO==null){
+//            throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"订单不存在");
+//        }
+//        exportContract.setOrderStatus("3");
+//        exportContract.setStatus("0");
+//        exportContract.setContractHtml("");
+//        exportContract.setContractFileUrl("");
+//        exportContractService.updateById(exportContract);
+//        contractWebService.pushOrderStatus(orderDO.getVbeln(),"3",exportContract);
+//        exportContractService.updateById(exportContract);
+//
+//        OrderDO order = new OrderDO();
+//        order.setId(orderDO.getId());
+//        order.setContractId("");
+//        order.setContractNo("");
+//        order.setStatus("0");
+//        orderService.updateById(order);
+
+        if("1".equals(exportContract.getIsPushRelease())){
+            return success(true);
+        }else{
+            return error(exportContract.getAbnormalCause());
+        }
+
+    }
 }

+ 9 - 1
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/dal/dataobject/exportContract/ExportContractDO.java

@@ -28,9 +28,17 @@ public class ExportContractDO extends BaseDO {
     @TableId
     private Long id;
     /**
-     * 合同类型
+     * 合同类型 1出口订单合同 2佣金合同
      */
     private String type;
+    /**
+     * 模板id
+     */
+    private Long contractTemplateId;
+    /**
+     * /**
+     */
+    private String contractTemplateName;
     /**
      * 合同流水号
      */

+ 259 - 8
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/service/exportContract/ExportContractServiceImpl.java

@@ -1,22 +1,40 @@
 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.object.ObjectUtils;
-import cn.iocoder.yudao.module.contract.dal.dataobject.basicData.BasicVarietyDO;
-import cn.iocoder.yudao.module.contract.dal.dataobject.invoice.InvoiceDO;
+import cn.iocoder.yudao.framework.common.util.number.MoneyUtil;
+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.InvoiceDetailsDO;
 import cn.iocoder.yudao.module.contract.dal.dataobject.order.OrderDO;
-import cn.iocoder.yudao.module.contract.dal.mysql.basicData.BasicVarietyMapper;
+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.client.ClientService;
+import cn.iocoder.yudao.module.contract.service.company.CompanyService;
+import cn.iocoder.yudao.module.contract.service.contractTemplate.ContractTemplateService;
 import cn.iocoder.yudao.module.contract.service.order.OrderService;
+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 org.springframework.security.core.parameters.P;
+import lombok.extern.slf4j.Slf4j;
+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 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;
 
@@ -39,12 +57,23 @@ import static cn.iocoder.yudao.module.contract.enums.ErrorCodeConstants.*;
  */
 @Service
 @Validated
+@Slf4j
 public class ExportContractServiceImpl extends ServiceImpl<ExportContractMapper, ExportContractDO> implements ExportContractService {
 
     @Resource
     private ExportContractMapper exportContractMapper;
     @Resource
     private OrderService orderService;
+    @Resource
+    private OrderDetailsMapper orderDetailsMapper;
+    @Resource
+    private CompanyService companyService;
+    @Resource
+    private ContractTemplateService contractTemplateService;
+    @Resource
+    private ClientService clientService;
+    @Resource
+    private HtmlToFileConverter htmlToFileConverter;
 
     @Override
     public Long createExportContract(ExportContractSaveReqVO createReqVO) {
@@ -104,21 +133,243 @@ public class ExportContractServiceImpl extends ServiceImpl<ExportContractMapper,
         if(ordersMap.size()>1){
             throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"请选择售达方、公司主体、国际贸易条件相同的订单数据");
         }
+        ExportContractDO exportContract = exportContractGenerate.getExportContract();
 
-        if(ObjectUtil.isEmpty(exportContractGenerate.getExportContract().getId())){
+        if(ObjectUtil.isEmpty(exportContract.getId())){
             for(OrderDO orderDO : orderList){
                 if(!"0".equals(orderDO.getStatus())){
                     throw exception("订单:"+orderDO.getVbeln()+"已生成合同,请勿重复生成");
                 }
             }
         }else{
-            ExportContractDO exportContractDO = getById(exportContractGenerate.getExportContract().getId());
+            ExportContractDO exportContractDO = getById(exportContract.getId());
             if(exportContractDO==null){
                 throw exception("合同数据异常");
             }
         }
-        saveOrUpdate(exportContractGenerate.getExportContract());
+        exportContract.setType("1");
+        generateContractFile(exportContract,exportContractGenerate.getDetailsList());
+        saveOrUpdate(exportContract);
+        orderDetailsMapper.updateBatch(exportContractGenerate.getDetailsList());
+
+        if(StringUtils.isNotBlank(exportContract.getZzlifnr())){
+            //供应商不为空时生成佣金合同
+            ExportContractDO exportContractDO = BeanUtils.toBean(exportContract,ExportContractDO.class);
+            exportContractDO.setType("2");
+            generateContractFile(exportContractDO,exportContractGenerate.getDetailsList());
+            saveOrUpdate(exportContractDO);
+        }
+    }
+
+    public void generateContractFile(ExportContractDO exportContract, List<OrderDetailsDO> detailsList)  {
+        try {
+            CompanyDO company = companyService.getOne(Wrappers.<CompanyDO>lambdaQuery().eq(CompanyDO::getCompanyCode,exportContract.getBukrs()));
+            ContractTemplateDO contractTemplate = null;
+            String contractTypeCode = "1".equals(exportContract.getType())?"Y4":"Y4-1";
+            contractTemplate = contractTemplateService.getOne(Wrappers.<ContractTemplateDO>lambdaQuery().eq(ContractTemplateDO::getContractTypeCode,contractTypeCode).eq(ContractTemplateDO::getClientCode,exportContract.getKunnr()));
+            if(contractTemplate==null){
+                contractTemplate = contractTemplateService.getOne(Wrappers.<ContractTemplateDO>lambdaQuery().eq(ContractTemplateDO::getContractTypeCode,contractTypeCode));
+            }
+            if(contractTemplate==null){
+                throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"合同模板不存在");
+            }
+            exportContract.setContractTemplateId(contractTemplate.getId());
+            exportContract.setContractTemplateName(contractTemplate.getContractName());
+
+            ClientDO clientDO = clientService.getOne(Wrappers.<ClientDO>lambdaQuery().eq(ClientDO::getClientCode,exportContract.getKunnr()),false);
+            if(clientDO==null){
+                throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"未找到售达方"+exportContract.getKunnr()+"的客户信息");
+            }
+
+            String htmlContent = contractTemplate.getContractContent();
+            htmlContent = htmlInit(htmlContent);
+            Map<String,Object> param = buildContractParam(exportContract,detailsList,company,clientDO);
+            htmlContent = HtmlToFileConverter.authHtmlToPdf(htmlContent, param);
+            String fileUrl = htmlToFileConverter.htmlToWord(htmlContent,"exportContract/"+exportContract.getContractNo(),"fpht-");
+            if("2".equals(exportContract.getType())){
+                //佣金合同,需要与出口订单合同合并
+
+            }
+//            exportContract.setGeneratedTime(LocalDateTime.now());
+            exportContract.setContractHtml(htmlContent);
+            exportContract.setContractFileUrl(fileUrl);
+            exportContract.setStatus("1");
+            exportContract.setAbnormalCause("");
+        }catch (Exception e){
+            exportContract.setStatus("0");
+            exportContract.setAbnormalCause("合同生成失败:系统异常");
+            log.error("合同生成失败-{}:",exportContract.getId(),e);
+            throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),e.getMessage());
+        }
+    }
+
+    /**
+     * 处理富文本html
+     * @param htmlContent
+     * @return
+     */
+    private String htmlInit(String htmlContent) {
+        htmlContent= htmlContent.replaceAll("\\$\\{序号}","\\$\\{orderInfo.序号}");
+        htmlContent= htmlContent.replaceAll("\\$\\{行项目}","\\$\\{orderInfo.行项目}");
+        htmlContent= htmlContent.replaceAll("\\$\\{产品组}","\\$\\{orderInfo.产品组}");
+        htmlContent= htmlContent.replaceAll("\\$\\{产品组描述}","\\$\\{orderInfo.产品组描述}");
+        htmlContent= htmlContent.replaceAll("\\$\\{产品规格}","\\$\\{orderInfo.产品规格}");
+        htmlContent= htmlContent.replaceAll("\\$\\{物料号}","\\$\\{orderInfo.物料号}");
+        htmlContent= htmlContent.replaceAll("\\$\\{物料描述}","\\$\\{orderInfo.物料描述}");
+        htmlContent= htmlContent.replaceAll("\\$\\{旧物料号}","\\$\\{orderInfo.旧物料号}");
+        htmlContent= htmlContent.replaceAll("\\$\\{订单数量}","\\$\\{orderInfo.订单数量}");
+        htmlContent= htmlContent.replaceAll("\\$\\{成交单价}","\\$\\{orderInfo.成交单价}");
+        htmlContent= htmlContent.replaceAll("\\$\\{加工费}","\\$\\{orderInfo.加工费}");
+        htmlContent= htmlContent.replaceAll("\\$\\{订单金额}","\\$\\{orderInfo.订单金额}");
+        htmlContent= htmlContent.replaceAll("\\$\\{等级}","\\$\\{orderInfo.等级}");
+        htmlContent= htmlContent.replaceAll("\\$\\{备注}","\\$\\{orderInfo.备注}");
+        htmlContent= htmlContent.replaceAll("\\$\\{产品质量}","\\$\\{orderInfo.产品质量}");
+//        htmlContent= htmlContent.replaceAll("\\$\\{再生产品备注}","\\$\\{orderInfo.再生产品备注}");
+        htmlContent= htmlContent.replaceAll("\\$\\{不含税总金额}","\\$\\{orderInfo.不含税总金额}");
+        htmlContent= htmlContent.replaceAll("\\$\\{原销售订单}","\\$\\{orderInfo.原销售订单}");
+        htmlContent= htmlContent.replaceAll("\\$\\{原项目}","\\$\\{orderInfo.原项目}");
+        htmlContent= htmlContent.replaceAll("\\$\\{拒绝原因}","\\$\\{orderInfo.拒绝原因}");
 
+//        htmlContent = addWatermark(htmlContent);
+        Document doc = Jsoup.parse(htmlContent);
+        Elements tdElements =  doc.select("td");
+        for (Element cell : tdElements) {
+            String text = cell.text(); // 获取td元素及其所有子元素的文本内容
+            if (text.startsWith("${orderInfo")) {
+                Element tr = cell.parent(); // 获取单元格的父元素
+                if (tr.tagName().equals("tr")) { // 确保父元素是tr
+                    Element trr = tr.parent(); // 获取单元格的父元素
+                    if(!trr.tagName().equals("list")) {
+                        // 创建<#list></#list>元素
+                        tr.wrap("<list>");
+                    }
+                }
+            }
+        }
+
+        htmlContent = doc.html();
+        htmlContent = htmlContent.replaceAll("<list>","<#list orderDetails as orderInfo>");
+        htmlContent = htmlContent.replaceAll("</list>","</#list>");
+        return htmlContent;
     }
 
+    /**
+     * 构建合同变量参数
+     * @return
+     */
+    private Map<String,Object> buildContractParam(ExportContractDO exportContract, List<OrderDetailsDO> orderDeatils, CompanyDO companyDO, ClientDO clientDO){
+
+        Map<String,Object> param = new HashMap<>();
+        //订单信息
+        param.put("凭证日期", StringUtils.nvl(exportContract.getAudat(), ""));
+//        param.put("销售凭证", StringUtils.nvl(exportContract.getVbeln(), ""));
+//        param.put("销售凭证类型", StringUtils.nvl(exportContract.getAuart(), ""));
+//        param.put("凭证类型描述", StringUtils.nvl(exportContract.getAuartt(), ""));
+        param.put("销售组织", StringUtils.nvl(exportContract.getVkorg(), ""));
+        param.put("公司代码", StringUtils.nvl(exportContract.getBukrs(), ""));
+        param.put("公司名称", StringUtils.nvl(exportContract.getButxt(), ""));
+        param.put("售达方", StringUtils.nvl(exportContract.getKunnr(), ""));
+        param.put("售达方描述", StringUtils.nvl(exportContract.getKname(), ""));
+//        param.put("销售部门", StringUtils.nvl(exportContract.getVkbur(), ""));
+//        param.put("部门描述", StringUtils.nvl(exportContract.getVkburt(), ""));
+//        param.put("销售组", StringUtils.nvl(exportContract.getVkgrp(), ""));
+//        param.put("组描述", StringUtils.nvl(exportContract.getVkgrpt(), ""));
+//        param.put("业务员", StringUtils.nvl(exportContract.getYwy(), ""));
+//        param.put("业务员名称", StringUtils.nvl(exportContract.getYwyt(), ""));
+//        param.put("装运条件", StringUtils.nvl(exportContract.getVsbed(), ""));
+//        param.put("合同管控类型", StringUtils.nvl(exportContract.getZzhtgklx(), ""));
+//        param.put("合同管控类型描述", StringUtils.nvl(exportContract.getZzhtgklxms(), ""));
+//        param.put("抬头合同打印备注", StringUtils.nvl(exportContract.getZzhthbz(), ""));
+//        param.put("送货地址", StringUtils.nvl((StringUtils.isBlank(exportContract.getZzshdz())?clientDO.getStreet():exportContract.getZzshdz()), ""));
+//        param.put("付款条件", StringUtils.nvl(exportContract.getZterm(), ""));
+//        param.put("付款条件解释", StringUtils.nvl(exportContract.getZtermt(), ""));
+//        param.put("交货冻结", StringUtils.nvl(exportContract.getLifsk(), ""));
+//        param.put("信用期", StringUtils.nvl(exportContract.getZmonth(), ""));
+//        param.put("订单原因", StringUtils.nvl(exportContract.getAugru(), ""));
+//        param.put("订单原因解释", StringUtils.nvl(exportContract.getAugrut(), ""));
+//        param.put("运输方式费用负担", StringUtils.nvl(exportContract.getYffd(), ""));
+//        param.put("付款方式", StringUtils.nvl(exportContract.getFkfs(), ""));
+//        param.put("产品质量汇总", StringUtils.nvl(exportContract.getCpzl(), ""));
+        //产品信息
+        List<Map<String,Object>> details = new ArrayList<>();
+        BigDecimal quantityTotal= BigDecimal.ZERO;
+        BigDecimal amountSum = BigDecimal.ZERO;
+        BigDecimal noTaxAmountSum = BigDecimal.ZERO;
+        String rebirthRemark = "";
+
+        for(int i=0;i<orderDeatils.size();i++){
+            OrderDetailsDO orderDetailsDO = orderDeatils.get(i);
+            Map<String,Object> data = new HashMap<>();
+            data.put("序号",i+1);
+            data.put("行项目", StringUtils.nvl(orderDetailsDO.getPosnr(),""));
+            data.put("产品组", StringUtils.nvl(orderDetailsDO.getSpart(),""));
+            data.put("产品组描述", StringUtils.nvl(orderDetailsDO.getSpartt(),""));
+            data.put("产品规格", StringUtils.nvl(orderDetailsDO.getZzcpgg(),""));
+            data.put("物料号", StringUtils.nvl(orderDetailsDO.getMatnr(),""));
+            data.put("物料描述", StringUtils.nvl(orderDetailsDO.getArktx(),""));
+            data.put("旧物料号", StringUtils.nvl(orderDetailsDO.getBismt(),""));
+            data.put("订单数量", StringUtils.nvl(MoneyUtil.toSeparator(orderDetailsDO.getKwmeng()),""));
+            data.put("成交单价", StringUtils.nvl(orderDetailsDO.getCjdj(),""));
+            data.put("加工费", StringUtils.nvl(orderDetailsDO.getZyp(),""));
+            data.put("订单金额", StringUtils.nvl(MoneyUtil.toSeparator(orderDetailsDO.getDdje()),""));
+            data.put("等级", StringUtils.nvl(orderDetailsDO.getDj(),""));
+            data.put("备注", StringUtils.nvl(orderDetailsDO.getZzhtibz(),""));
+            data.put("产品质量", StringUtils.nvl(orderDetailsDO.getCpzl(),""));
+            data.put("不含税总金额", StringUtils.nvl(MoneyUtil.toSeparator(orderDetailsDO.getNetwr()),""));
+            data.put("原销售订单", StringUtils.nvl(orderDetailsDO.getZzvbeln(),""));
+            data.put("原项目", StringUtils.nvl(orderDetailsDO.getZzposnr(),""));
+            data.put("拒绝原因", StringUtils.nvl(orderDetailsDO.getAbgru(),""));
+            data.put("物料功能性", StringUtils.nvl(orderDetailsDO.getZzwlgnx(),""));
+
+            if(StringUtils.isNotBlank(orderDetailsDO.getKwmeng())){
+                quantityTotal = quantityTotal .add(new BigDecimal(orderDetailsDO.getKwmeng()));
+            }
+            if(StringUtils.isNotBlank(orderDetailsDO.getDdje())){
+                amountSum = amountSum.add(new BigDecimal(orderDetailsDO.getDdje()));
+            }
+            if(StringUtils.isNotBlank(orderDetailsDO.getNetwr())){
+                noTaxAmountSum = noTaxAmountSum.add(new BigDecimal(orderDetailsDO.getNetwr()));
+            }
+            if(StringUtils.isNotBlank(orderDetailsDO.getZscpbz())){
+                rebirthRemark = orderDetailsDO.getZscpbz();
+            }
+            details.add(data);
+        }
+        param.put("orderDetails",details);
+
+        //产品合计
+        param.put("再生产品备注",rebirthRemark);
+        param.put("数量合计",MoneyUtil.toSeparator(quantityTotal.toString()));
+        param.put("不含税总金额合计", StringUtils.nvl(MoneyUtil.toSeparator(noTaxAmountSum.toString()), ""));
+        param.put("订单金额合计", StringUtils.nvl(MoneyUtil.toSeparator(amountSum.toString()), ""));
+        param.put("合计金额大写", StringUtils.nvl(MoneyUtil.toChinese(String.valueOf(amountSum)), ""));
+        //公司信息(乙方)
+        param.put("供方单位名称", StringUtils.nvl(companyDO.getCompanyName(), ""));
+        param.put("供方单位地址", StringUtils.nvl(companyDO.getAddress(), ""));
+        param.put("供方法定代表", StringUtils.nvl(companyDO.getLegalPerson(), ""));
+        param.put("供方电话", StringUtils.nvl(companyDO.getPhone(), ""));
+        param.put("供方传真", StringUtils.nvl(companyDO.getFaxes(), ""));
+        param.put("供方开户银行", StringUtils.nvl(companyDO.getBankName(), ""));
+        param.put("供方账号", StringUtils.nvl(companyDO.getBankAccount(), ""));
+        param.put("供方税号", StringUtils.nvl(companyDO.getTaxNumber(), ""));
+        param.put("签订地点", StringUtils.nvl(companyDO.getSigningAddress(), ""));
+        //客户信息(甲方)
+
+        param.put("客户名称", StringUtils.nvl(clientDO.getClientName(), ""));
+        param.put("客户简称", StringUtils.nvl(clientDO.getCalledForShort(), ""));
+        param.put("客户电话", StringUtils.nvl(clientDO.getPhone(), ""));
+        param.put("客户传真", StringUtils.nvl(clientDO.getFaxes(), ""));
+        param.put("客户街道", StringUtils.nvl(clientDO.getStreet(), ""));
+        param.put("客户法定代表", StringUtils.nvl(clientDO.getLegalPerson(), ""));
+        param.put("客户委托代表", StringUtils.nvl(clientDO.getProxy(), ""));
+        param.put("客户开户银行", StringUtils.nvl(clientDO.getBankName(), ""));
+        param.put("客户开户账号", StringUtils.nvl(clientDO.getBankAccount(), ""));
+        param.put("客户QQ", StringUtils.nvl(clientDO.getQqNumber(), ""));
+        param.put("客户微信", StringUtils.nvl(clientDO.getWeChatNumber(), ""));
+        param.put("客户收票地址", StringUtils.nvl(clientDO.getCollectionAddress(), ""));
+        param.put("客户接收人姓名", StringUtils.nvl(clientDO.getReceiverName(), ""));
+        param.put("客户接收人职务", StringUtils.nvl(clientDO.getReceiverDuty(), ""));
+        param.put("客户接收人电话", StringUtils.nvl(clientDO.getReceiverPhone(), ""));
+        return param;
+    }
 }