Explorar el Código

Merge remote-tracking branch 'origin/dev1.0' into dev1.0

zhangc hace 9 meses
padre
commit
b79439d275

+ 17 - 0
src/main/java/com/sunxung/factoring/component/util/StringUtil.java

@@ -147,6 +147,23 @@ public class StringUtil extends jodd.util.StringUtil {
         return null;
     }
 
+    /**
+     * 去掉文字里面的逗号和换行空格
+     *
+     * @param str
+     * @return String
+     */
+    public static String formatStrT(String str) {
+        if (StringUtil.isNotEmpty(str)) {
+            String s = formatStr(str);
+            str = s.replaceAll(",", "");
+            str = str.replaceAll(",", "");
+            return str.trim();
+        }
+        return null;
+    }
+
+
     public static String subZeroAndDot(String s) {
         if (StringUtil.isNotEmpty(s)) {
             if (s.indexOf(".") > 0) {

+ 178 - 185
src/main/java/com/sunxung/factoring/service/acceptancesheet/impl/AcceptanceBasicInfoServiceImpl.java

@@ -3,7 +3,6 @@ package com.sunxung.factoring.service.acceptancesheet.impl;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.deepoove.poi.data.*;
 import com.deepoove.poi.data.style.BorderStyle;
@@ -20,7 +19,6 @@ import com.sunxung.factoring.entity.acceptance.*;
 import com.sunxung.factoring.entity.acceptance.vo.GoodsSearch;
 import com.sunxung.factoring.entity.entprise.Enterprise;
 import com.sunxung.factoring.entity.project.BusinessProcessingLog;
-import com.sunxung.factoring.entity.project.ProjectCoreEnterprise;
 import com.sunxung.factoring.entity.project.ProjectInformation;
 import com.sunxung.factoring.entity.project.vo.BusinessProcessingTaskVo;
 import com.sunxung.factoring.entity.project.vo.SearchBusinessProcessingTask;
@@ -29,7 +27,6 @@ import com.sunxung.factoring.entity.salescontractmanagement.*;
 import com.sunxung.factoring.entity.settlement.SettlementBasicInfo;
 import com.sunxung.factoring.entity.settlement.SettlementGoodsInfo;
 import com.sunxung.factoring.entity.steelwaiter.SearchVo;
-import com.sunxung.factoring.entity.supplier.SupplierInfo;
 import com.sunxung.factoring.entity.sys.Dictionary;
 import com.sunxung.factoring.entity.sys.FileStorage;
 import com.sunxung.factoring.entity.sys.FileStorageDO;
@@ -148,6 +145,9 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
     @Autowired
     private ISalesContractSupplementInfoService salesContractSupplementInfoService;
 
+    @Autowired
+    private ICSalesContractSupplementBasicInfoService salesContractSupplementBasicInfoService;
+
     @Autowired
     private IPurchContractSupplementInfoService purchContractSupplementInfoService;
 
@@ -225,11 +225,11 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
         AcceptanceBasicInfo acceptanceBasicInfo = this.baseMapper.getSpecialOneById(id);
 
         List<FileStorageDO> files1 = fileService.findByBusinessId(id,
-            FileModuleDict.ChildEnum.ACCEPTANCE_FILE.getCode());
+                FileModuleDict.ChildEnum.ACCEPTANCE_FILE.getCode());
         List<FileStorageDO> files2 = fileService.findByBusinessId(id,
-            FileModuleDict.ChildEnum.ACCEPTANCE_SUPPLEMENT_FILE.getCode());
+                FileModuleDict.ChildEnum.ACCEPTANCE_SUPPLEMENT_FILE.getCode());
         List<FileStorageDO> files3 = fileService.findByBusinessId(id,
-            FileModuleDict.ChildEnum.ACCEPTANCE_UPSTREAM_FILE.getCode());
+                FileModuleDict.ChildEnum.ACCEPTANCE_UPSTREAM_FILE.getCode());
 
 
         List<FileStorage> signConfirmFiles = Lists.newArrayList();
@@ -237,11 +237,11 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
         AcceptanceSignConfirmation acceptanceSignConfirmation = acceptanceSignConfirmationService.lambdaQuery().eq(AcceptanceSignConfirmation::getAcceptanceBasicInfoId, id).one();
         if (acceptanceSignConfirmation != null) {
             List<AcceptanceSignConfirmationElectronicInfo> acceptanceSignConfirmationElectronicInfos = acceptanceSignConfirmationElectronicInfoService.lambdaQuery()
-                .eq(AcceptanceSignConfirmationElectronicInfo::getAcceptanceSignConfirmationId, acceptanceSignConfirmation.getId())
-                .eq(AcceptanceSignConfirmationElectronicInfo::getCallBack,1)
-                .list();
-            if(CollectionUtil.isNotEmpty(acceptanceSignConfirmationElectronicInfos)){
-                acceptanceSignConfirmationElectronicInfos.forEach(x->{
+                    .eq(AcceptanceSignConfirmationElectronicInfo::getAcceptanceSignConfirmationId, acceptanceSignConfirmation.getId())
+                    .eq(AcceptanceSignConfirmationElectronicInfo::getCallBack, 1)
+                    .list();
+            if (CollectionUtil.isNotEmpty(acceptanceSignConfirmationElectronicInfos)) {
+                acceptanceSignConfirmationElectronicInfos.forEach(x -> {
 //                    List<FileStorage> files = fileStorageService.findByBelongIdAndBelongType(
 //                        x.getContractId(),
 //                        FileModuleDict.ChildEnum.ACCEPTANCE_SIGN_CONFIRM_BACK_FILE.getCode());
@@ -250,11 +250,11 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
 //                    }
                     //获取已签署文件
                     AttachmentDto attachmentDto = AttachmentDto.builder()
-                        .setEntityId(x.getId())
-                        .setChildEnum(FileModuleDict.ChildEnum.ACCEPTANCE_SIGN_CONFIRM_BACK_FILE)
-                        .build();
+                            .setEntityId(x.getId())
+                            .setChildEnum(FileModuleDict.ChildEnum.ACCEPTANCE_SIGN_CONFIRM_BACK_FILE)
+                            .build();
                     List<FileStorage> files = attachmentRefService.getFiles(attachmentDto);
-                        if(CollectionUtil.isNotEmpty(files)){
+                    if (CollectionUtil.isNotEmpty(files)) {
                         signConfirmFiles.addAll(files);
                     }
                 });
@@ -284,86 +284,13 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
 //        List<FileStorageDO> files5 = fileService.findByBusinessId(
 //            purchContractBasicInfo.getId(), FileModuleDict.ChildEnum.PURCHASE_CONTRACT_FILE.getCode());
 
-
-        //销售合同 文件
-        List<FileStorage> salesContract = new ArrayList<>();
-        CSalesContract salesContractManagement = salesContractService.getByBusinessNumber(acceptanceBasicInfo.getBusinessNumber());
-        CSalesContractBasicInfo salesContractBasicInfo = salesContractBasicInfoService
-            .getOne(new QueryWrapper<CSalesContractBasicInfo>().eq("c_sales_contract_management_id",salesContractManagement.getId()));
-        CSalesSignConfirmation salesSignConfirmation = salesSignConfirmationService
-                .lambdaQuery().eq(CSalesSignConfirmation::getcSalesContractManagementId, salesContractManagement.getId()).one();
-        if(salesSignConfirmation!=null){
-            List<CSalesSignConfirmationElectronicInfo> signElectronicInfos = signConfirmationElectronicInfoService
-                .list(new QueryWrapper<CSalesSignConfirmationElectronicInfo>().eq("c_sales_sign_confirmation_id", salesSignConfirmation.getId()));
-            if (CollectionUtil.isNotEmpty(signElectronicInfos)){
-                signElectronicInfos.forEach(signElectronicInfo->{
-                    salesContract.addAll(sysAttachmentRefService.getFiles(AttachmentDto.builder()
-                        .setChildEnum(FileModuleDict.ChildEnum.SIGN_CONFIRM_BACK_FILE).setEntityId(signElectronicInfo.getId()).build()));
-                });
-            }
-        }
-        //销售合同补充文件
-        List<CSalesContractSupplementInfo> salesContractSupplementInfos = salesContractSupplementInfoService
-            .list(new QueryWrapper<CSalesContractSupplementInfo>().eq("c_sales_contract_management_id", salesContractManagement.getId()));
-        if (CollectionUtil.isNotEmpty(salesContractSupplementInfos)) {
-            salesContractSupplementInfos.stream().forEach(s -> {
-                if (salesContractManagement.getContractStatus().equals(ProjectInitiationStatusDict.ChildEnum.COMPLETED.getCode())) {
-
-                    CSalesSupplementSignConfirmation salesSupplementSignConfirmation = salesSupplementSignConfirmationService
-                            .lambdaQuery().eq(CSalesSupplementSignConfirmation::getcSalesContractSupplementInfoId, s.getId()).one();
-                    if(salesSupplementSignConfirmation!=null){
-                        List<CSalesSupplementSignConfirmationElectronicInfo> supplementSignConfirmationElectronicInfos = salesSupplementSignConfirmationElectronicInfoService
-                                .lambdaQuery().eq(CSalesSupplementSignConfirmationElectronicInfo::getcSalesSupplementSignConfirmationId, salesSupplementSignConfirmation.getId()).list();
-                        if (CollectionUtil.isNotEmpty(supplementSignConfirmationElectronicInfos)){
-                            //获取销售合同补充签署的附件
-                            supplementSignConfirmationElectronicInfos.forEach(supplementSignConfirmationElectronicInfo -> {
-                                List<FileStorage> salesContractSupplementFiles = sysAttachmentRefService.getFiles(AttachmentDto.builder()
-                                        .setChildEnum(FileModuleDict.ChildEnum.SALES_SUPPLEMENT_SIGN_CONFIRM_BACK_FILE)
-                                        .setEntityId(supplementSignConfirmationElectronicInfo.getId()).build());
-                                salesContract.addAll(salesContractSupplementFiles);
-                            });
-                        }
-
-                    }
-                }
-            });
-        }
-        acceptanceBasicInfo.setSaleContractFiles(salesContract);
-
-        //采购合同 文件
-        PurchContractManagement purchContractManagement = purchContractService
-            .getOne(new QueryWrapper<PurchContractManagement>().eq("business_number", acceptanceBasicInfo.getBusinessNumber())
-                );  //.eq("c_supplier_info_id", acceptanceBasicInfo.getcSupplierInfoId())
-        PurchContractBasicInfo purchContractBasicInfo = purchContractBasicInfoService.lambdaQuery().eq(PurchContractBasicInfo::getPurchContractManagementId, purchContractManagement.getId()).one();
-
-        List<FileStorage> purchaseContract = sysAttachmentRefService.getFiles(AttachmentDto.builder()
-            .setChildEnum(FileModuleDict.ChildEnum.PURCHASE_CONTRACT_SIGN_FILE)
-                .setEntityId(purchContractBasicInfo.getId()).build());
-
-        //采购合同补充合同
-        List<PurchContractSupplementInfo> contractSupplementInfos = purchContractSupplementInfoService
-            .list(new QueryWrapper<PurchContractSupplementInfo>().eq("c_purch_contract_management_id", purchContractManagement.getId()));
-        //采购合同状态
-        if (purchContractManagement.getContractStatus().equals(ProjectInitiationStatusDict.ChildEnum.COMPLETED.getCode())){
-            if (CollectionUtil.isNotEmpty(contractSupplementInfos)) {
-                contractSupplementInfos.stream().forEach(contractSupplementInfo -> {
-                    //采购合同变更已签署文件
-                    AttachmentDto attachmentDto = AttachmentDto.builder()
-                            .setEntityId(contractSupplementInfo.getId())
-                        .setChildEnum(FileModuleDict.ChildEnum.PURCHASE_CONTRACT_SUPPLEMENT_SIGN_FILE).build();
-                    purchaseContract.addAll(attachmentRefService.getFiles(attachmentDto));
-
-                });
-            }
-        }
-
-
+        autoSalesFiles(acceptanceBasicInfo);
+        autoPurchFiles(acceptanceBasicInfo);
 
         acceptanceBasicInfo.setFileStorageDOList(files1);
         acceptanceBasicInfo.setSupplementFiles(files2);
 
         acceptanceBasicInfo.setAcceptanceUpstreamFiles(files3);
-        acceptanceBasicInfo.setProcureContractFile(purchaseContract);
 
         return acceptanceBasicInfo;
     }
@@ -382,7 +309,7 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
     public List<BusinessProcessingTaskVo> findAllList(SearchBusinessProcessingTask search) {
         List<BusinessProcessingTaskVo> processingTaskVoList = baseMapper.findAllList(search);
         processingTaskVoList.stream().forEach(p -> {
-          //  p.setStatusStr(p.getStatus().getCode());
+            //  p.setStatusStr(p.getStatus().getCode());
             autoButtonFlag(p);
             autoInfo(p);
         });
@@ -503,8 +430,6 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
 //                .setChildEnum(FileModuleDict.ChildEnum.ACCEPTANCE_UPSTREAM_FILE).setEntityId(acceptanceBasicInfoId).build()));
 
 
-
-
         //下游验收单
         AcceptanceSignConfirmation acceptanceSignConfirmation = acceptanceSignConfirmationService.lambdaQuery().eq(AcceptanceSignConfirmation::getAcceptanceBasicInfoId, acceptanceBasicInfoId).one();
         if (acceptanceSignConfirmation != null) {
@@ -514,62 +439,11 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
             ).collect(Collectors.toList());
             acceptanceApproval.setSignConfirmFiles(signConfirmFiles);
         }
-        //销售合同
-        AcceptanceBasicInfo acceptanceBasicInfo = getById(acceptanceBasicInfoId);
-        CSalesContract salesContractManagement = salesContractService.getByBusinessNumber(acceptanceBasicInfo.getBusinessNumber());
-        CSalesContractBasicInfo salesContractBasicInfo = salesContractBasicInfoService
-                .getOne(new QueryWrapper<CSalesContractBasicInfo>().eq("c_sales_contract_management_id",salesContractManagement.getId()));
-        List<FileStorage> salesContract = sysAttachmentRefService.getFiles(AttachmentDto.builder()
-                .setChildEnum(FileModuleDict.ChildEnum.SALES_CONTRACT_FILE).setEntityId(salesContractBasicInfo.getId()).build());
-        //销售合同补充合同
-        //销售合同补充文件
-        List<CSalesContractSupplementInfo> salesContractSupplementInfos = salesContractSupplementInfoService
-                .list(new QueryWrapper<CSalesContractSupplementInfo>().eq("c_sales_contract_management_id", salesContractManagement.getId()));
-        if (CollectionUtil.isNotEmpty(salesContractSupplementInfos)) {
-            salesContractSupplementInfos.stream().forEach(s -> {
-                if (salesContractManagement.getContractStatus().equals(ProjectInitiationStatusDict.ChildEnum.COMPLETED.getCode())) {
-                    List<FileStorage> salesContractSupplementFiles = sysAttachmentRefService.getFiles(AttachmentDto.builder()
-                            .setChildEnum(FileModuleDict.ChildEnum.SALES_CONTRACT_SUPPLEMENT_FILE).setEntityId(s.getId()).build());
-                    salesContract.addAll(salesContractSupplementFiles);
-                }
-            });
-        }
-
-        acceptanceApproval.setSalesContract(salesContract);
-        //采购合同
-        PurchContractManagement purchContractManagement = purchContractService
-                .getOne(new QueryWrapper<PurchContractManagement>().eq("business_number", acceptanceBasicInfo.getBusinessNumber())
-                        .eq("supplier_id", acceptanceBasicInfo.getcSupplierInfoId()));
-        PurchContractBasicInfo purchContractBasicInfo = purchContractBasicInfoService.lambdaQuery().eq(PurchContractBasicInfo::getPurchContractManagementId, purchContractManagement.getId()).one();
-
-        List<FileStorage> purchaseContract = sysAttachmentRefService.getFiles(AttachmentDto.builder()
-                .setChildEnum(FileModuleDict.ChildEnum.PURCHASE_CONTRACT_FILE).setEntityId(purchContractBasicInfo.getId()).build());
-
-        //线下签署节点的附件
-        PurchContractSignConclusion purchContractSignConclusion = purchContractSignConclusionService
-                .getOne(new QueryWrapper<PurchContractSignConclusion>().eq("c_purch_contract_basic_info_id", purchContractBasicInfo.getId())
-                        .orderByDesc("gmt_create").last("limit 1"));
-        if (purchContractSignConclusion != null) {
-            purchaseContract.addAll(attachmentRefService.getFiles(AttachmentDto.builder()
-                    .setChildEnum(FileModuleDict.ChildEnum.PURCHASE_CONTRACT_SIGN_UNDERLINE).setEntityId(purchContractSignConclusion.getId()).build()));
-        }
-        //采购合同补充合同
-        List<PurchContractSupplementInfo> contractSupplementInfos = purchContractSupplementInfoService
-                .list(new QueryWrapper<PurchContractSupplementInfo>().eq("c_purch_contract_management_id", purchContractManagement.getId()));
-        //采购合同状态
 
-        if (purchContractManagement.getContractStatus().equals(ProjectInitiationStatusDict.ChildEnum.COMPLETED.getCode())){
-            if (CollectionUtil.isNotEmpty(contractSupplementInfos)) {
-                contractSupplementInfos.stream().forEach(contractSupplementInfo -> {
-                    //采购合同变更已签署文件
-                    AttachmentDto attachmentDto = AttachmentDto.builder().setEntityId(contractSupplementInfo.getId())
-                            .setChildEnum(FileModuleDict.ChildEnum.PURCHASE_CONTRACT_SUPPLEMENT_SIGN_FILE).build();
-                    purchaseContract.addAll(attachmentRefService.getFiles(attachmentDto));
+        AcceptanceBasicInfo acceptanceBasicInfo = getById(acceptanceBasicInfoId);
+        autoSalesFiles(acceptanceBasicInfo);
+        autoPurchFiles(acceptanceBasicInfo);
 
-                });
-            }
-        }
-        acceptanceApproval.setPurchContract(purchaseContract);
         return acceptanceApproval;
     }
 
@@ -604,7 +478,7 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
         CSalesContract salesManagement = salesContractService.getOne(new QueryWrapper<CSalesContract>()
                 .eq("business_number", businessNumber));
         CSalesContractBasicInfo salesContractBasicInfo = salesContractBasicInfoService
-                .getOne(new QueryWrapper<CSalesContractBasicInfo>().eq("c_sales_contract_management_id",salesManagement.getId()));
+                .getOne(new QueryWrapper<CSalesContractBasicInfo>().eq("c_sales_contract_management_id", salesManagement.getId()));
         //采购合同供应商发货人
         List<PurchContractBuyerSeller> purchContractSellers = purchContractBuyerSellerService.lambdaQuery()
                 .eq(PurchContractBuyerSeller::getPurchContractBasicInfoId, purchContractBasicInfo.getId()).list();
@@ -671,20 +545,20 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
         String legalSpecias = legalSpecialists.stream().map(c -> c.toString()).collect(Collectors.joining(","));
 
         if (acceptanceBasicInfo == null) {
-            throw new ValidatorException(CodeUtil.FAIL,"验收单信息不能为空!");
+            throw new ValidatorException(CodeUtil.FAIL, "验收单信息不能为空!");
         }
         //保存历史
         Long historyId = addHistoryAcceptanceSheet(acceptanceBasicInfo);
         User admin = userService.getByLoginName("admin");
         Map<String, Object> procVariables = new HashMap<>();
         Map<String, Object> msgVariables = new HashMap<>();
-        if (acceptanceBasicInfo.getSignConfirm().equals(1) ) {
+        if (acceptanceBasicInfo.getSignConfirm().equals(1)) {
             procVariables.put(ConstantUtil.ACCEPTANCE_SIGN_CONFIRM_ASSIGNEE, admin.getId());
             procVariables.put("result", "签署确认");
             flowableService.completeMyTask(acceptanceBasicInfo.getTaskId(), acceptanceBasicInfo, procVariables,
                     null, historyId, msgVariables, ConstantUtil.ACCEPTANCE_SHEET);
         } else if (acceptanceBasicInfo.getSignConfirm().equals(0)) {
-            procVariables.put(ConstantUtil.ACCEPTANCE_SHEET_APPROVAL_CANDIDATE,legalSpecias);
+            procVariables.put(ConstantUtil.ACCEPTANCE_SHEET_APPROVAL_CANDIDATE, legalSpecias);
             procVariables.put("result", "法务审核");
             msgVariables.put(ConstantUtil.FLOWABLE_MSG_TITLE, "验收单编号:" + acceptanceBasicInfo.getAcceptanceNumber());
             msgVariables.put(ConstantUtil.FLOWABLE_MSG_CONTENT,
@@ -797,30 +671,30 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
                     //模板中填充数据-c端其实已经生成了
                     //file = inputData(acceptanceBasicInfo, xmlDoc);
                     fileDOs = fileService.findByBusinessId(
-                        acceptanceApproval.getAcceptanceBasicInfoId(),
-                        FileModuleDict.ChildEnum.ACCEPTANCE_UPSTREAM_FILE.getCode());
+                            acceptanceApproval.getAcceptanceBasicInfoId(),
+                            FileModuleDict.ChildEnum.ACCEPTANCE_UPSTREAM_FILE.getCode());
                 } catch (Exception e) {
                     e.printStackTrace();
                     throw new BusinessException(CodeUtil.FAIL, "生成验收单据出错");
                 }
-                for(FileStorageDO file:fileDOs){
+                for (FileStorageDO file : fileDOs) {
                     File f = new File(file.getAbsolutePath());
 
-                //上传合同 TODO  调用发大大报错 为了不影响流程 先这样
-                String contractId = UUID.randomUUID().toString().trim().replaceAll("-", "").toUpperCase();
-                String docTitle = "上游验收单" + acceptanceBasicInfo.getAcceptanceNumber();
-                String transactionId = UUID.randomUUID().toString().trim().replaceAll("-", "").toUpperCase();
-                ElectronicSignatureUtil.uploadContract(contractId, docTitle, f);
-                //采购合同自动签署
-                Platform platform = platformService.getById(acceptanceBasicInfo.getTradingPlatformId());
-                String signKeyword = "gz";
-                ElectronicSignatureUtil.autoSign(transactionId, contractId, platform.getFddCustomerId(), docTitle, signKeyword);
-                //合同下载
-                String contDownUrl = ElectronicSignatureUtil.downloadContract(contractId);
-                FileStorage contractSupplementFile = fileStorageService.addFileStorageWithBelongAndName(contractId, FileModuleDict.ChildEnum.ACCEPTANCE_UPSTREAM_FILE_SIGN, contDownUrl, null);
-                fileStorageService.saveAttachmentRefByFileStorage(contractSupplementFile, FileModuleDict.ChildEnum.ACCEPTANCE_UPSTREAM_FILE_SIGN, acceptanceBasicInfo.getId());
-                //合同归档
-                ElectronicSignatureUtil.contractFiled(contractId);
+                    //上传合同 TODO  调用发大大报错 为了不影响流程 先这样
+                    String contractId = UUID.randomUUID().toString().trim().replaceAll("-", "").toUpperCase();
+                    String docTitle = "上游验收单" + acceptanceBasicInfo.getAcceptanceNumber();
+                    String transactionId = UUID.randomUUID().toString().trim().replaceAll("-", "").toUpperCase();
+                    ElectronicSignatureUtil.uploadContract(contractId, docTitle, f);
+                    //采购合同自动签署
+                    Platform platform = platformService.getById(acceptanceBasicInfo.getTradingPlatformId());
+                    String signKeyword = "gz";
+                    ElectronicSignatureUtil.autoSign(transactionId, contractId, platform.getFddCustomerId(), docTitle, signKeyword);
+                    //合同下载
+                    String contDownUrl = ElectronicSignatureUtil.downloadContract(contractId);
+                    FileStorage contractSupplementFile = fileStorageService.addFileStorageWithBelongAndName(contractId, FileModuleDict.ChildEnum.ACCEPTANCE_UPSTREAM_FILE_SIGN, contDownUrl, null);
+                    fileStorageService.saveAttachmentRefByFileStorage(contractSupplementFile, FileModuleDict.ChildEnum.ACCEPTANCE_UPSTREAM_FILE_SIGN, acceptanceBasicInfo.getId());
+                    //合同归档
+                    ElectronicSignatureUtil.contractFiled(contractId);
                 }
                 break;
             case ConstantConversionUtil.APPROVAL_RESULT_BACK:
@@ -882,12 +756,12 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
         }
         //合同信息
         PurchContractManagement purchContractManagement = purchContractService.getOne(
-            new QueryWrapper<PurchContractManagement>()
-                .eq("business_number", acceptanceBasicInfo.getBusinessNumber()));
+                new QueryWrapper<PurchContractManagement>()
+                        .eq("business_number", acceptanceBasicInfo.getBusinessNumber()));
         PurchContractBasicInfo purchContractBasicInfo = purchContractBasicInfoService.getOne(
-            new QueryWrapper<PurchContractBasicInfo>()
-                .eq("c_purch_contract_management_id", purchContractManagement.getId())
-                .orderByDesc("gmt_create").last("LIMIT 1")
+                new QueryWrapper<PurchContractBasicInfo>()
+                        .eq("c_purch_contract_management_id", purchContractManagement.getId())
+                        .orderByDesc("gmt_create").last("LIMIT 1")
         );
 //        List<PurchContractBuyerSeller> purchContractBuyerSellers = purchContractBuyerSellerService
 //            .list(new QueryWrapper<PurchContractBuyerSeller>()
@@ -896,15 +770,15 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
 
         //最后一次审核的信息
         PurchContractApproval purchContractApproval = purchContractApprovalService.getOne(
-            new LambdaQueryWrapper<PurchContractApproval>()
-                .eq(PurchContractApproval::getPurchContractBasicInfoId,
-                    purchContractBasicInfo.getId())
-                .orderByDesc(PurchContractApproval::getGmtCreate).last("LIMIT 1"));
+                new LambdaQueryWrapper<PurchContractApproval>()
+                        .eq(PurchContractApproval::getPurchContractBasicInfoId,
+                                purchContractBasicInfo.getId())
+                        .orderByDesc(PurchContractApproval::getGmtCreate).last("LIMIT 1"));
 
         List<PurchContractNeedUserRel> buyers = purchContractNeedUserRelService.list(
-            new LambdaQueryWrapper<PurchContractNeedUserRel>()
-                .eq(PurchContractNeedUserRel::getPurchContractApprovalId,
-                    purchContractApproval.getId()));
+                new LambdaQueryWrapper<PurchContractNeedUserRel>()
+                        .eq(PurchContractNeedUserRel::getPurchContractApprovalId,
+                                purchContractApproval.getId()));
 
 
         StringBuffer names = new StringBuffer();
@@ -1048,7 +922,6 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
     }
 
     /**
-     *
      * @param oldAcceptanceBasicInfo
      * @return
      */
@@ -1058,7 +931,7 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
         Long oldId = oldAcceptanceBasicInfo.getId();
         //保存基础信息
         AcceptanceHisInfo acceptanceHisInfo = new AcceptanceHisInfo();
-        BeanUtils.copyProperties(oldAcceptanceBasicInfo, acceptanceHisInfo,"id");
+        BeanUtils.copyProperties(oldAcceptanceBasicInfo, acceptanceHisInfo, "id");
         //保存历史基础信息
         acceptanceHisInfoService.save(acceptanceHisInfo);
         //保存相关货物信息
@@ -1099,8 +972,8 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
             });
         }
         //保存生成的验收单历史
-        if(CollectionUtil.isNotEmpty(oldAcceptanceBasicInfo.getAcceptanceUpstreamFiles())){
-            for(FileStorageDO f:oldAcceptanceBasicInfo.getAcceptanceUpstreamFiles()){
+        if (CollectionUtil.isNotEmpty(oldAcceptanceBasicInfo.getAcceptanceUpstreamFiles())) {
+            for (FileStorageDO f : oldAcceptanceBasicInfo.getAcceptanceUpstreamFiles()) {
                 FileStorageDO fileStorageDOHis = new FileStorageDO();
                 BeanUtils.copyProperties(f, fileStorageDOHis);
                 fileStorageDOHis.setBusinessType(FileModuleDict.ChildEnum.ACCEPTANCE_HIS_UPSTREAM_FILE.getCode());
@@ -1135,4 +1008,124 @@ public class AcceptanceBasicInfoServiceImpl extends ServiceImpl<AcceptanceBasicI
         return acceptanceHisInfo.getId();
     }
 
+    /**
+     * 填充销售合同附件
+     *
+     * @param acceptanceBasicInfo
+     */
+    void autoSalesFiles(AcceptanceBasicInfo acceptanceBasicInfo) {
+        //销售合同 文件
+        List<FileStorage> salesContract = new ArrayList<>();
+        CSalesContract salesContractManagement = salesContractService.getByBusinessNumber(acceptanceBasicInfo.getBusinessNumber());
+        CSalesContractBasicInfo salesContractBasicInfo = salesContractBasicInfoService
+                .getOne(new QueryWrapper<CSalesContractBasicInfo>().eq("c_sales_contract_management_id", salesContractManagement.getId()));
+        //销售合同原件
+        //合同文件
+        List<FileStorageDO> fileStorageDOS = fileService.findByBusinessId(salesContractBasicInfo.getId(), FileModuleDict.ChildEnum.SALES_CONTRACT_FILE.getCode());
+        if (CollectionUtil.isNotEmpty(fileStorageDOS)) {
+            fileStorageDOS.forEach(fileStorageDO -> {
+                FileStorage fileStorage = new FileStorage();
+                fileStorage.setAbsolutePath(fileStorageDO.getAbsolutePath());
+                fileStorage.setName(fileStorageDO.getOriginalName());
+                fileStorage.setPath(fileStorageDO.getPath());
+                fileStorage.setId(fileStorageDO.getId());
+                fileStorage.setOriginalName(fileStorageDO.getOriginalName());
+                salesContract.add(fileStorage);
+            });
+        }
+        //已签署的文件
+        CSalesSignConfirmation salesSignConfirmation = salesSignConfirmationService
+                .lambdaQuery().eq(CSalesSignConfirmation::getcSalesContractManagementId, salesContractManagement.getId()).one();
+        if (salesSignConfirmation != null) {
+            List<CSalesSignConfirmationElectronicInfo> signElectronicInfos = signConfirmationElectronicInfoService
+                    .list(new QueryWrapper<CSalesSignConfirmationElectronicInfo>().eq("c_sales_sign_confirmation_id", salesSignConfirmation.getId()));
+            if (CollectionUtil.isNotEmpty(signElectronicInfos)) {
+                signElectronicInfos.forEach(signElectronicInfo -> {
+                    salesContract.addAll(sysAttachmentRefService.getFiles(AttachmentDto.builder()
+                            .setChildEnum(FileModuleDict.ChildEnum.SIGN_CONFIRM_BACK_FILE).setEntityId(signElectronicInfo.getId()).build()));
+                });
+            }
+        }
+        //销售合同补充文件
+        List<CSalesContractSupplementInfo> salesContractSupplementInfos = salesContractSupplementInfoService
+                .list(new QueryWrapper<CSalesContractSupplementInfo>().eq("c_sales_contract_management_id", salesContractManagement.getId()));
+        if (CollectionUtil.isNotEmpty(salesContractSupplementInfos)) {
+            salesContractSupplementInfos.stream().forEach(s -> {
+                if (salesContractManagement.getContractStatus().equals(ProjectInitiationStatusDict.ChildEnum.COMPLETED.getCode())) {
+
+                    //补充合同原件
+                    CSalesContractSupplementBasicInfo salesContractSupplementBasicInfo = salesContractSupplementBasicInfoService.lambdaQuery()
+                            .eq(CSalesContractSupplementBasicInfo::getcSalesContractSupplementInfoId, s.getId())
+                            .one();
+                    List<FileStorageDO> SupplementFileStorageDOS = fileService.findByBusinessId(salesContractSupplementBasicInfo.getId(),
+                            FileModuleDict.ChildEnum.SALES_CONTRACT_SUPPLEMENT_CONTRACT_FILE.getCode());
+                    if (CollectionUtil.isNotEmpty(SupplementFileStorageDOS)) {
+                        SupplementFileStorageDOS.forEach(fileStorageDO -> {
+                            FileStorage fileStorage = new FileStorage();
+                            fileStorage.setAbsolutePath(fileStorageDO.getAbsolutePath());
+                            fileStorage.setName(fileStorageDO.getOriginalName());
+                            fileStorage.setPath(fileStorageDO.getPath());
+                            fileStorage.setId(fileStorageDO.getId());
+                            fileStorage.setOriginalName(fileStorageDO.getOriginalName());
+                            salesContract.add(fileStorage);
+                        });
+                    }
+
+                    CSalesSupplementSignConfirmation salesSupplementSignConfirmation = salesSupplementSignConfirmationService
+                            .lambdaQuery().eq(CSalesSupplementSignConfirmation::getcSalesContractSupplementInfoId, s.getId()).one();
+                    if (salesSupplementSignConfirmation != null) {
+                        List<CSalesSupplementSignConfirmationElectronicInfo> supplementSignConfirmationElectronicInfos = salesSupplementSignConfirmationElectronicInfoService
+                                .lambdaQuery().eq(CSalesSupplementSignConfirmationElectronicInfo::getcSalesSupplementSignConfirmationId, salesSupplementSignConfirmation.getId()).list();
+                        if (CollectionUtil.isNotEmpty(supplementSignConfirmationElectronicInfos)) {
+                            //获取销售合同补充签署的附件
+                            supplementSignConfirmationElectronicInfos.forEach(supplementSignConfirmationElectronicInfo -> {
+                                List<FileStorage> salesContractSupplementFiles = sysAttachmentRefService.getFiles(AttachmentDto.builder()
+                                        .setChildEnum(FileModuleDict.ChildEnum.SALES_SUPPLEMENT_SIGN_CONFIRM_BACK_FILE)
+                                        .setEntityId(supplementSignConfirmationElectronicInfo.getId()).build());
+                                salesContract.addAll(salesContractSupplementFiles);
+                            });
+                        }
+
+                    }
+                }
+            });
+        }
+        acceptanceBasicInfo.setSaleContractFiles(salesContract);
+    }
+
+    /**
+     * 填充采购合同附件
+     *
+     * @param acceptanceBasicInfo
+     */
+    void autoPurchFiles(AcceptanceBasicInfo acceptanceBasicInfo) {
+        //采购合同 文件
+        PurchContractManagement purchContractManagement = purchContractService
+                .getOne(new QueryWrapper<PurchContractManagement>().eq("business_number", acceptanceBasicInfo.getBusinessNumber())
+                );  //.eq("c_supplier_info_id", acceptanceBasicInfo.getcSupplierInfoId())
+        PurchContractBasicInfo purchContractBasicInfo = purchContractBasicInfoService.lambdaQuery().eq(PurchContractBasicInfo::getPurchContractManagementId, purchContractManagement.getId()).one();
+
+        List<FileStorage> purchaseContract = sysAttachmentRefService.getFiles(AttachmentDto.builder()
+                .setChildEnum(FileModuleDict.ChildEnum.PURCHASE_CONTRACT_SIGN_FILE)
+                .setEntityId(purchContractBasicInfo.getId()).build());
+
+        //采购合同补充合同
+        List<PurchContractSupplementInfo> contractSupplementInfos = purchContractSupplementInfoService
+                .list(new QueryWrapper<PurchContractSupplementInfo>().eq("c_purch_contract_management_id", purchContractManagement.getId()));
+        //采购合同状态
+        if (purchContractManagement.getContractStatus().equals(ProjectInitiationStatusDict.ChildEnum.COMPLETED.getCode())) {
+            if (CollectionUtil.isNotEmpty(contractSupplementInfos)) {
+                contractSupplementInfos.stream().forEach(contractSupplementInfo -> {
+                    //采购合同变更已签署文件
+                    AttachmentDto attachmentDto = AttachmentDto.builder()
+                            .setEntityId(contractSupplementInfo.getId())
+                            .setChildEnum(FileModuleDict.ChildEnum.PURCHASE_CONTRACT_SUPPLEMENT_SIGN_FILE).build();
+                    purchaseContract.addAll(attachmentRefService.getFiles(attachmentDto));
+
+                });
+            }
+        }
+        acceptanceBasicInfo.setProcureContractFile(purchaseContract);
+    }
+
 }

+ 1 - 1
src/main/java/com/sunxung/factoring/service/acceptancesheet/impl/AcceptanceSheetLegalFlowServiceImpl.java

@@ -80,7 +80,7 @@ public class AcceptanceSheetLegalFlowServiceImpl extends ServiceImpl<AcceptanceA
         /**法务审核完成后*/
         List<FileStorage> acceptanceUpstreamFileSign = sysAttachmentRefService.getFiles(AttachmentDto.builder()
             .setChildEnum(FileModuleDict.ChildEnum.ACCEPTANCE_UPSTREAM_FILE_SIGN)
-            .setEntityId(acceptanceHisInfo.getId()).build());
+            .setEntityId(detail.getId()).build());
 
 //        List<FileStorage> acceptanceUpstreamFileSign = fileStorageService.findByBelongIdAndBelongType(acceptanceHisInfo.getId().toString(),
 //            FileModuleDict.ChildEnum.ACCEPTANCE_UPSTREAM_FILE_SIGN.getCode());

+ 146 - 84
src/main/java/com/sunxung/factoring/service/invoicemanage/impl/InvoiceApprovalServiceImpl.java

@@ -6,6 +6,7 @@ import com.sunxung.factoring.component.exception.BusinessException;
 import com.sunxung.factoring.component.exception.ValidatorException;
 import com.sunxung.factoring.component.util.*;
 import com.sunxung.factoring.dict.impl.*;
+import com.sunxung.factoring.entity.acceptance.AcceptanceBasicInfo;
 import com.sunxung.factoring.entity.customerinformation.Customer;
 import com.sunxung.factoring.entity.entprise.Enterprise;
 import com.sunxung.factoring.entity.invoicemanage.*;
@@ -14,11 +15,10 @@ import com.sunxung.factoring.entity.purchcontractmanagement.PurchContractBasicIn
 import com.sunxung.factoring.entity.purchcontractmanagement.PurchContractManagement;
 import com.sunxung.factoring.entity.purchcontractmanagement.PurchContractSignConclusion;
 import com.sunxung.factoring.entity.purchcontractmanagement.PurchContractSupplementInfo;
-import com.sunxung.factoring.entity.salescontractmanagement.CSalesContract;
-import com.sunxung.factoring.entity.salescontractmanagement.CSalesContractBasicInfo;
-import com.sunxung.factoring.entity.salescontractmanagement.CSalesContractSupplementInfo;
+import com.sunxung.factoring.entity.salescontractmanagement.*;
 import com.sunxung.factoring.entity.settlement.SettlementBasicInfo;
 import com.sunxung.factoring.entity.sys.FileStorage;
+import com.sunxung.factoring.entity.sys.FileStorageDO;
 import com.sunxung.factoring.entity.sys.SysAttachmentRef;
 import com.sunxung.factoring.mapper.invoicemanage.InvoiceApprovalMapper;
 import com.sunxung.factoring.service.customerinformation.CustomerService;
@@ -29,9 +29,7 @@ import com.sunxung.factoring.service.purchcontractmanagement.IPurchContractSignC
 import com.sunxung.factoring.service.purchcontractmanagement.IPurchContractSupplementInfoService;
 import com.sunxung.factoring.service.purchcontractmanagement.PurchContractBasicInfoService;
 import com.sunxung.factoring.service.purchcontractmanagement.PurchContractService;
-import com.sunxung.factoring.service.salescontractmanagement.ISalesContractSupplementInfoService;
-import com.sunxung.factoring.service.salescontractmanagement.ICSalesContractBasicInfoService;
-import com.sunxung.factoring.service.salescontractmanagement.SalesContractService;
+import com.sunxung.factoring.service.salescontractmanagement.*;
 import com.sunxung.factoring.service.settlement.SettlementBasicInfoService;
 import com.sunxung.factoring.service.sys.*;
 import com.sunxung.factoring.service.sys.dto.AttachmentDto;
@@ -120,6 +118,21 @@ public class InvoiceApprovalServiceImpl extends ServiceImpl<InvoiceApprovalMappe
     @Autowired
     private IEnterpriseService iEnterpriseService;
 
+    @Autowired
+    private ICSalesSignConfirmationService salesSignConfirmationService;
+
+    @Autowired
+    private ICSalesSignConfirmationElectronicInfoService signConfirmationElectronicInfoService;
+
+    @Autowired
+    private ICSalesContractSupplementBasicInfoService salesContractSupplementBasicInfoService;
+
+    @Autowired
+    private ICSalesSupplementSignConfirmationService salesSupplementSignConfirmationService;
+
+    @Autowired
+    private ICSalesSupplementSignConfirmationElectronicInfoService salesSupplementSignConfirmationElectronicInfoService;
+
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -232,33 +245,13 @@ public class InvoiceApprovalServiceImpl extends ServiceImpl<InvoiceApprovalMappe
                 amount = amount.add(invoiceGoodsInfo.getOpenAmount());
             }
         }
-        Set<Long> supplierIds = new HashSet<>();
-        List<InvoiceSupplierInfo> invoiceSupplierInfos = invoiceSupplierInfoService.list(new QueryWrapper<InvoiceSupplierInfo>().eq("c_invoice_basic_info_id", businessKey));
-        if (invoiceSupplierInfos != null && invoiceSupplierInfos.size() > 0) {
-            for (InvoiceSupplierInfo invoiceSupplierInfo : invoiceSupplierInfos) {
-                supplierIds.add(invoiceSupplierInfo.getSupplierId());
-            }
-        }
-        //销售合同
-        CSalesContract salesContractManagement = salesContractService.getByBusinessNumber(invoiceBasicInfo.getBusinessNumber());
-        CSalesContractBasicInfo salesContractBasicInfo = salesContractBasicInfoService.getOne(new QueryWrapper<CSalesContractBasicInfo>()
-                .eq("c_sales_contract_management_id",salesContractManagement.getId()));
-        List<FileStorage> salesContract = sysAttachmentRefService.getFiles(AttachmentDto.builder()
-                .setChildEnum(FileModuleDict.ChildEnum.SALES_CONTRACT_FILE).setEntityId(salesContractBasicInfo.getId()).build());
 
-        //销售合同补充文件
-        List<CSalesContractSupplementInfo> salesContractSupplementInfos = salesContractSupplementInfoService
-                .list(new QueryWrapper<CSalesContractSupplementInfo>().eq("c_sales_contract_management_id", salesContractManagement.getId()));
-        if (CollectionUtil.isNotEmpty(salesContractSupplementInfos)) {
-            salesContractSupplementInfos.stream().forEach(s -> {
-                if (salesContractManagement.getContractStatus().equals(ProjectInitiationStatusDict.ChildEnum.COMPLETED.getCode()) ) {
-                    List<FileStorage> salesContractSupplementFiles = sysAttachmentRefService.getFiles(AttachmentDto.builder()
-                            .setChildEnum(FileModuleDict.ChildEnum.SALES_CONTRACT_SUPPLEMENT_FILE).setEntityId(s.getId()).build());
-                    salesContract.addAll(salesContractSupplementFiles);
-                }
-            });
-        }
+        //销售合同文件
+        List<FileStorage> salesContract = autoSalesFiles(invoiceBasicInfo);
         invoiceApproval.setSalesContract(salesContract);
+        //采购合同文件
+        List<FileStorage> purchFilelist = autoPurchFiles(invoiceBasicInfo);
+        invoiceApproval.setPurchContract(purchFilelist);
 
         //下游结算单文件
         List<FileStorage> settlementFiles = new ArrayList<>();
@@ -267,14 +260,12 @@ public class InvoiceApprovalServiceImpl extends ServiceImpl<InvoiceApprovalMappe
             settlementFiles.addAll(files);
         }
         invoiceApproval.setSettlementFile(settlementFiles);
-        //采购合同
-        List<FileStorage> purchFilelist = new ArrayList<>();
+
         //上游结算单文件
         List<FileStorage> settlementUpstreamSignedFile = new ArrayList<>();
         for (Long settlementInfoId : settlementInfoIds) {
             SettlementBasicInfo settlementBasicInfo = settlementBasicInfoService.getById(settlementInfoId);
             if (settlementBasicInfo != null) {
-                supplierIds.add(settlementBasicInfo.getSupplierId());
                 List<FileStorage> files = new ArrayList<>();
                 if (ProjectInitiationStatusDict.ChildEnum.PROCESSING.getCode().equals(settlementBasicInfo.getSettlementStatus())) {
                     files = sysAttachmentRefService.getCfiles(AttachmentDto.builder()
@@ -300,57 +291,7 @@ public class InvoiceApprovalServiceImpl extends ServiceImpl<InvoiceApprovalMappe
                 settlementUpstreamSignedFile.addAll(files);
             }
         }
-        for (Long supplierId : supplierIds) {
-
-            //采购合同
-            PurchContractManagement purchContractManagement = purchContractService.getOne(new QueryWrapper<PurchContractManagement>().eq("business_number", invoiceBasicInfo.getBusinessNumber()).eq("c_supplier_info_id", supplierId));
-
-            if (purchContractManagement == null || purchContractManagement.getId() == null) {
-                throw new BusinessException(CodeUtil.FAIL, "采购合同管理不能为空");
-            }
-            PurchContractBasicInfo purchContractBasicInfo = purchContractBasicInfoService.lambdaQuery().eq(PurchContractBasicInfo::getPurchContractManagementId, purchContractManagement.getId()).one();
 
-            if (purchContractBasicInfo == null || purchContractBasicInfo.getId() == null) {
-                throw new BusinessException(CodeUtil.FAIL, "采购合同基础信息不能为空");
-            }
-            purchFilelist.addAll(sysAttachmentRefService.getCfiles(AttachmentDto.builder()
-                    .setChildEnum(FileModuleDict.ChildEnum.PURCHASE_CONTRACT_FILE).setEntityId(purchContractBasicInfo.getId()).build()));
-            //线下签署节点的附件
-            PurchContractSignConclusion purchContractSignConclusion = purchContractSignConclusionService
-                    .getOne(new QueryWrapper<PurchContractSignConclusion>().eq("c_purch_contract_basic_info_id", purchContractBasicInfo.getId())
-                            .orderByDesc("gmt_create").last("limit 1"));
-            if (purchContractSignConclusion != null) {
-                purchFilelist.addAll(sysAttachmentRefService.getCfiles(AttachmentDto.builder()
-                        .setChildEnum(FileModuleDict.ChildEnum.PURCHASE_CONTRACT_SIGN_UNDERLINE).setEntityId(purchContractSignConclusion.getId()).build()));
-            }
-            //采购合同补充合同
-            List<PurchContractSupplementInfo> contractSupplementInfos = purchContractSupplementInfoService
-                    .list(new QueryWrapper<PurchContractSupplementInfo>().eq("c_purch_contract_management_id", purchContractManagement.getId()));
-            //采购合同状态
-            Long purchStatus = dictService.getByCode(PurchContractStatusDict.ChildEnum.CONFIRM_CHANGE.getCode()).getId();
-            if (dictService.getByCode(PurchContractStatusDict.ChildEnum.CONFIRM_CHANGE.getCode()).getId()
-                    .equals(purchContractManagement.getContractStatus())) {
-                if (CollectionUtil.isNotEmpty(contractSupplementInfos)) {
-                    contractSupplementInfos.stream().forEach(contractSupplementInfo -> {
-
-                        //采购合同变更审核是选择是否签署 TODO
-//                        if (contractSupplementInfo.getApproval() == 0) {
-//                            //采购合同变更上传的合同文件
-//                            AttachmentDto attachmentDto = AttachmentDto.builder().setEntityId(contractSupplementInfo.getId())
-//                                    .setChildEnum(FileModuleDict.ChildEnum.PURCHASE_CONTRACT_SUPPLEMENT_FILE).build();
-//                            purchFilelist.addAll(sysAttachmentRefService.getFiles(attachmentDto));
-//                        } else if (contractSupplementInfo.getApproval() == 1 && purchContractManagement.getContractStatus().equals(purchStatus)) {
-//                            //采购合同变更已签署文件
-//                            AttachmentDto attachmentDto = AttachmentDto.builder().setEntityId(contractSupplementInfo.getId())
-//                                    .setChildEnum(FileModuleDict.ChildEnum.PURCHASE_CONTRACT_SUPPLEMENT_SIGN_FILE).build();
-//                            purchFilelist.addAll(sysAttachmentRefService.getFiles(attachmentDto));
-//                        }
-
-                    });
-                }
-            }
-        }
-        invoiceApproval.setPurchContract(purchFilelist);
         invoiceApproval.setSettlementUpstreamSignedFile(settlementUpstreamSignedFile);
         //参考待开发票
         invoiceApproval.setPendingInvoice(sysAttachmentRefService.getCfiles(AttachmentDto.builder().setChildEnum(FileModuleDict.ChildEnum.INVOICE_SALES_FILE).setEntityId(invoiceBasicInfo.getId()).build()));
@@ -386,4 +327,125 @@ public class InvoiceApprovalServiceImpl extends ServiceImpl<InvoiceApprovalMappe
         }
         return invoiceApproval;
     }
+
+    /**
+     * 填充销售合同附件
+     *
+     * @param invoiceBasicInfo
+     */
+    List<FileStorage> autoSalesFiles(InvoiceBasicInfo invoiceBasicInfo) {
+        //销售合同 文件
+        List<FileStorage> salesContract = new ArrayList<>();
+        CSalesContract salesContractManagement = salesContractService.getByBusinessNumber(invoiceBasicInfo.getBusinessNumber());
+        CSalesContractBasicInfo salesContractBasicInfo = salesContractBasicInfoService
+                .getOne(new QueryWrapper<CSalesContractBasicInfo>().eq("c_sales_contract_management_id", salesContractManagement.getId()));
+        //销售合同原件
+        //合同文件
+        List<FileStorageDO> fileStorageDOS = fileService.findByBusinessId(salesContractBasicInfo.getId(), FileModuleDict.ChildEnum.SALES_CONTRACT_FILE.getCode());
+        if (CollectionUtil.isNotEmpty(fileStorageDOS)) {
+            fileStorageDOS.forEach(fileStorageDO -> {
+                FileStorage fileStorage = new FileStorage();
+                fileStorage.setAbsolutePath(fileStorageDO.getAbsolutePath());
+                fileStorage.setName(fileStorageDO.getOriginalName());
+                fileStorage.setPath(fileStorageDO.getPath());
+                fileStorage.setId(fileStorageDO.getId());
+                fileStorage.setOriginalName(fileStorageDO.getOriginalName());
+                salesContract.add(fileStorage);
+            });
+        }
+        //已签署的文件
+        CSalesSignConfirmation salesSignConfirmation = salesSignConfirmationService
+                .lambdaQuery().eq(CSalesSignConfirmation::getcSalesContractManagementId, salesContractManagement.getId()).one();
+        if (salesSignConfirmation != null) {
+            List<CSalesSignConfirmationElectronicInfo> signElectronicInfos = signConfirmationElectronicInfoService
+                    .list(new QueryWrapper<CSalesSignConfirmationElectronicInfo>().eq("c_sales_sign_confirmation_id", salesSignConfirmation.getId()));
+            if (CollectionUtil.isNotEmpty(signElectronicInfos)) {
+                signElectronicInfos.forEach(signElectronicInfo -> {
+                    salesContract.addAll(sysAttachmentRefService.getFiles(AttachmentDto.builder()
+                            .setChildEnum(FileModuleDict.ChildEnum.SIGN_CONFIRM_BACK_FILE).setEntityId(signElectronicInfo.getId()).build()));
+                });
+            }
+        }
+        //销售合同补充文件
+        List<CSalesContractSupplementInfo> salesContractSupplementInfos = salesContractSupplementInfoService
+                .list(new QueryWrapper<CSalesContractSupplementInfo>().eq("c_sales_contract_management_id", salesContractManagement.getId()));
+        if (CollectionUtil.isNotEmpty(salesContractSupplementInfos)) {
+            salesContractSupplementInfos.stream().forEach(s -> {
+                if (salesContractManagement.getContractStatus().equals(ProjectInitiationStatusDict.ChildEnum.COMPLETED.getCode())) {
+
+                    //补充合同原件
+                    CSalesContractSupplementBasicInfo salesContractSupplementBasicInfo = salesContractSupplementBasicInfoService.lambdaQuery()
+                            .eq(CSalesContractSupplementBasicInfo::getcSalesContractSupplementInfoId, s.getId())
+                            .one();
+                    List<FileStorageDO> SupplementFileStorageDOS = fileService.findByBusinessId(salesContractSupplementBasicInfo.getId(),
+                            FileModuleDict.ChildEnum.SALES_CONTRACT_SUPPLEMENT_CONTRACT_FILE.getCode());
+                    if (CollectionUtil.isNotEmpty(SupplementFileStorageDOS)) {
+                        SupplementFileStorageDOS.forEach(fileStorageDO -> {
+                            FileStorage fileStorage = new FileStorage();
+                            fileStorage.setAbsolutePath(fileStorageDO.getAbsolutePath());
+                            fileStorage.setName(fileStorageDO.getOriginalName());
+                            fileStorage.setPath(fileStorageDO.getPath());
+                            fileStorage.setId(fileStorageDO.getId());
+                            fileStorage.setOriginalName(fileStorageDO.getOriginalName());
+                            salesContract.add(fileStorage);
+                        });
+                    }
+
+                    CSalesSupplementSignConfirmation salesSupplementSignConfirmation = salesSupplementSignConfirmationService
+                            .lambdaQuery().eq(CSalesSupplementSignConfirmation::getcSalesContractSupplementInfoId, s.getId()).one();
+                    if (salesSupplementSignConfirmation != null) {
+                        List<CSalesSupplementSignConfirmationElectronicInfo> supplementSignConfirmationElectronicInfos = salesSupplementSignConfirmationElectronicInfoService
+                                .lambdaQuery().eq(CSalesSupplementSignConfirmationElectronicInfo::getcSalesSupplementSignConfirmationId, salesSupplementSignConfirmation.getId()).list();
+                        if (CollectionUtil.isNotEmpty(supplementSignConfirmationElectronicInfos)) {
+                            //获取销售合同补充签署的附件
+                            supplementSignConfirmationElectronicInfos.forEach(supplementSignConfirmationElectronicInfo -> {
+                                List<FileStorage> salesContractSupplementFiles = sysAttachmentRefService.getFiles(AttachmentDto.builder()
+                                        .setChildEnum(FileModuleDict.ChildEnum.SALES_SUPPLEMENT_SIGN_CONFIRM_BACK_FILE)
+                                        .setEntityId(supplementSignConfirmationElectronicInfo.getId()).build());
+                                salesContract.addAll(salesContractSupplementFiles);
+                            });
+                        }
+
+                    }
+                }
+            });
+        }
+        return salesContract;
+    }
+
+    /**
+     * 填充采购合同附件
+     *
+     * @param invoiceBasicInfo
+     */
+    List<FileStorage> autoPurchFiles(InvoiceBasicInfo invoiceBasicInfo) {
+        //采购合同 文件
+        PurchContractManagement purchContractManagement = purchContractService
+                .getOne(new QueryWrapper<PurchContractManagement>().eq("business_number", invoiceBasicInfo.getBusinessNumber())
+                );  //.eq("c_supplier_info_id", acceptanceBasicInfo.getcSupplierInfoId())
+        PurchContractBasicInfo purchContractBasicInfo = purchContractBasicInfoService.lambdaQuery().eq(PurchContractBasicInfo::getPurchContractManagementId, purchContractManagement.getId()).one();
+
+        List<FileStorage> purchaseContract = sysAttachmentRefService.getFiles(AttachmentDto.builder()
+                .setChildEnum(FileModuleDict.ChildEnum.PURCHASE_CONTRACT_SIGN_FILE)
+                .setEntityId(purchContractBasicInfo.getId()).build());
+
+        //采购合同补充合同
+        List<PurchContractSupplementInfo> contractSupplementInfos = purchContractSupplementInfoService
+                .list(new QueryWrapper<PurchContractSupplementInfo>().eq("c_purch_contract_management_id", purchContractManagement.getId()));
+        //采购合同状态
+        if (purchContractManagement.getContractStatus().equals(ProjectInitiationStatusDict.ChildEnum.COMPLETED.getCode())) {
+            if (CollectionUtil.isNotEmpty(contractSupplementInfos)) {
+                contractSupplementInfos.stream().forEach(contractSupplementInfo -> {
+                    //采购合同变更已签署文件
+                    AttachmentDto attachmentDto = AttachmentDto.builder()
+                            .setEntityId(contractSupplementInfo.getId())
+                            .setChildEnum(FileModuleDict.ChildEnum.PURCHASE_CONTRACT_SUPPLEMENT_SIGN_FILE).build();
+                    purchaseContract.addAll(sysAttachmentRefService.getFiles(attachmentDto));
+
+                });
+            }
+        }
+        return purchaseContract;
+    }
+
 }

+ 5 - 5
src/main/java/com/sunxung/factoring/service/project/impl/BusinessProcessingLogServiceImpl.java

@@ -1,10 +1,7 @@
 package com.sunxung.factoring.service.project.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.sunxung.factoring.component.util.ConstantConversionUtil;
-import com.sunxung.factoring.component.util.DateUtil;
-import com.sunxung.factoring.component.util.ThreadLocalUtil;
-import com.sunxung.factoring.component.util.ValidatorUtil;
+import com.sunxung.factoring.component.util.*;
 import com.sunxung.factoring.entity.ValidatorEntity.ValidatorType;
 import com.sunxung.factoring.entity.acceptance.AcceptanceApproval;
 import com.sunxung.factoring.entity.project.BusinessProcessingLog;
@@ -99,7 +96,9 @@ public class BusinessProcessingLogServiceImpl extends ServiceImpl<BusinessProces
                         BusinessProcessingLogVo vo = new BusinessProcessingLogVo();
                         if (null != log.getAssignee()) {
                             User assign = userService.get(log.getAssignee().getId());
-                            vo.setAssigneeName(assign != null ? assign.getName() : "");
+                            String assigneeName = assign != null ? assign.getName() : "";
+                            String adminName = "超级管理员";
+                            vo.setAssigneeName(adminName.equals(assigneeName) ? "供应商" : assigneeName);
                         }
                         vo.setAssigneeTypeName(ConstantConversionUtil.assigneeType.get(log.getAssigneeType()));
                         // 上午、下午开始时间换算
@@ -132,6 +131,7 @@ public class BusinessProcessingLogServiceImpl extends ServiceImpl<BusinessProces
                     businessLogs.add(new BusinessProcessingLogDetailVo(taskName, voList));
                 }
             }
+
             return businessLogs;
         }
         return null;

+ 3 - 1
src/main/java/com/sunxung/factoring/service/project/impl/BusinessProcessingTaskServiceImpl.java

@@ -978,7 +978,9 @@ public class BusinessProcessingTaskServiceImpl implements BusinessProcessingTask
         BusinessProcessingLogVo vo = new BusinessProcessingLogVo();
         if (null != businessProcessingLog.getAssignee()) {
             User assign = userService.get(businessProcessingLog.getAssignee().getId());
-            vo.setAssigneeName(assign != null ? assign.getName() : "");
+            String assigneeName = assign != null ? assign.getName() : "";
+            String adminName = "超级管理员";
+            vo.setAssigneeName(adminName.equals(assigneeName)?"供应商":assigneeName);
         }
         vo.setAssigneeTypeName(ConstantConversionUtil.assigneeType.get(businessProcessingLog.getAssigneeType()));
         // 上午、下午开始时间换算

+ 2 - 0
src/main/java/com/sunxung/factoring/service/salescontractmanagement/impl/CSalesContractBasicInfoServiceImpl.java

@@ -188,6 +188,8 @@ public class CSalesContractBasicInfoServiceImpl extends ServiceImpl<CSalesContra
             salesContractBasicInfo.getGoodsInfoList().forEach(goods -> {
                 goods.setcSalesContractBasicInfoId(basicId);
                 goods.setOccupy(0);
+                String salesPrice = StringUtil.formatStrT(goods.getSalesPrice());
+                goods.setSalesPrice(salesPrice);
                 goodsInfoService.save(goods);
             });
         }

+ 2 - 0
src/main/java/com/sunxung/factoring/service/salescontractmanagement/impl/CSalesContractSupplementBasicInfoServiceImpl.java

@@ -111,6 +111,8 @@ public class CSalesContractSupplementBasicInfoServiceImpl extends ServiceImpl<CS
             supplementBasicInfo.getSupplementGoodsInfos().forEach(goods -> {
                 goods.setcSalesContractSupplementBasicInfoId(supplementBasicInfo.getId());
                 goods.setOccupy(0);
+                String salesPrice = StringUtil.formatStrT(goods.getSalesPrice());
+                goods.setSalesPrice(salesPrice);
                 supplementGoodsInfoService.save(goods);
             });
         }

+ 3 - 3
src/main/java/com/sunxung/factoring/service/salescontractmanagement/impl/SalesSupplementSignConfirmationApprovalServiceImpl.java

@@ -100,10 +100,10 @@ public class SalesSupplementSignConfirmationApprovalServiceImpl extends ServiceI
     public SalesSupplementSignConfirmationApproval getView(Long id) {
 
         SalesSupplementSignConfirmationApproval confirmationApproval = getById(id);
-        CSalesContractSupplementInfo supplementInfo = salesContractSupplementInfoService.lambdaQuery().eq(CSalesContractSupplementInfo::getcSalesContractManagementId, id)
-                .orderByDesc(CSalesContractSupplementInfo::getGmtCreate).last("limit 1").one();
+//        CSalesContractSupplementInfo supplementInfo = salesContractSupplementInfoService.lambdaQuery().eq(CSalesContractSupplementInfo::getcSalesContractManagementId, id)
+//                .orderByDesc(CSalesContractSupplementInfo::getGmtCreate).last("limit 1").one();
         CSalesSupplementSignConfirmation supplementSignConfirmation = salesSupplementSignConfirmationService
-                .lambdaQuery().eq(CSalesSupplementSignConfirmation::getcSalesContractSupplementInfoId, supplementInfo.getId())
+                .lambdaQuery().eq(CSalesSupplementSignConfirmation::getcSalesContractSupplementInfoId, confirmationApproval.getcSalesContractSupplementInfoId())
                 .one();
         List<CSalesSupplementSignConfirmationElectronicInfo> list = salesSupplementSignConfirmationElectronicInfoService
                 .lambdaQuery().eq(CSalesSupplementSignConfirmationElectronicInfo::getcSalesSupplementSignConfirmationId,

+ 5 - 5
src/main/java/com/sunxung/factoring/service/settlement/impl/SettlementManagementServiceImpl.java

@@ -839,12 +839,12 @@ public class SettlementManagementServiceImpl implements SettlementManagementServ
         //货物相关
         List<SettlementGoodsInfo> settlementGoodsInfos;
         //货物信息
-        if (settlementBasicInfo.getId() != null) {
-            settlementGoodsInfos = settlementGoodsInfoService.list(
-                    new QueryWrapper<SettlementGoodsInfo>().eq("c_settlement_basic_info_id", settlementBasicInfo.getId()));
-        } else {
+//        if (settlementBasicInfo.getId() != null) {
+//            settlementGoodsInfos = settlementGoodsInfoService.list(
+//                    new QueryWrapper<SettlementGoodsInfo>().eq("c_settlement_basic_info_id", settlementBasicInfo.getId()));
+//        } else {
             settlementGoodsInfos = settlementBasicInfo.getSettlementGoodsInfos();
-        }
+//        }
         //合同信息 采购合同
         PurchContractManagement purchContractManagement = purchContractService.getOne(
                 new QueryWrapper<PurchContractManagement>()