Browse Source

feat(资方管理):销售合同文件拉取

Wangyafan 6 months ago
parent
commit
5b28656a2d

+ 28 - 18
src/main/java/com/sunxung/factoring/service/fundmanagement/impl/FinancialInstitutionServiceImpl.java

@@ -34,9 +34,7 @@ import com.sunxung.factoring.entity.project.BusinessAssignee;
 import com.sunxung.factoring.entity.project.BusinessProcessingLog;
 import com.sunxung.factoring.entity.purchcontractmanagement.PurchContractBasicInfo;
 import com.sunxung.factoring.entity.purchcontractmanagement.PurchContractManagement;
-import com.sunxung.factoring.entity.salescontractmanagement.CSalesContract;
-import com.sunxung.factoring.entity.salescontractmanagement.CSalesContractBasicInfo;
-import com.sunxung.factoring.entity.salescontractmanagement.SalesContractBasicInfoHistory;
+import com.sunxung.factoring.entity.salescontractmanagement.*;
 import com.sunxung.factoring.entity.settlement.SettlementGoodsInfo;
 import com.sunxung.factoring.entity.supplier.SupplierInfo;
 import com.sunxung.factoring.entity.sys.Dictionary;
@@ -58,10 +56,7 @@ import com.sunxung.factoring.service.project.BusinessProcessingLogService;
 import com.sunxung.factoring.service.project.BusinessProcessingTaskService;
 import com.sunxung.factoring.service.purchcontractmanagement.PurchContractBasicInfoService;
 import com.sunxung.factoring.service.purchcontractmanagement.PurchContractService;
-import com.sunxung.factoring.service.salescontractmanagement.ICSalesContractBasicInfoService;
-import com.sunxung.factoring.service.salescontractmanagement.ISalesContractBasicInfoHistoryService;
-import com.sunxung.factoring.service.salescontractmanagement.SalesContractService;
-import com.sunxung.factoring.service.salescontractmanagement.SalesContractSettleInfoService;
+import com.sunxung.factoring.service.salescontractmanagement.*;
 import com.sunxung.factoring.service.settlement.SettlementGoodsInfoService;
 import com.sunxung.factoring.service.supplier.ISupplierInfoService;
 import com.sunxung.factoring.service.sys.*;
@@ -118,6 +113,12 @@ public class FinancialInstitutionServiceImpl extends ServiceImpl<FinancialInstit
     @Autowired
     private ICSalesContractBasicInfoService salesContractBasicInfoService;
 
+    @Autowired
+    private ICSalesSignConfirmationService salesSignConfirmationService;
+
+    @Autowired
+    private ICSalesSignConfirmationElectronicInfoService signConfirmationElectronicInfoService;
+
     @Autowired
     private SalesContractSettleInfoService salesContractSettleInfoService;
 
@@ -809,17 +810,26 @@ public class FinancialInstitutionServiceImpl extends ServiceImpl<FinancialInstit
                     }
                 }
                 if (salesContract != null) {
-                    //销售合同
-                    salesContractBasicInfo = salesContractBasicInfoService.lambdaQuery()
-                            .eq(CSalesContractBasicInfo::getcSalesContractManagementId, salesContract.getId()).one();
-                    List<FileStorage> salesFileList = sysAttachmentRefService
-                            .getFiles(AttachmentDto.builder().setChildEnum(FileModuleDict.ChildEnum.SALES_CONTRACT_FILE)
-                            .setEntityId(salesContractBasicInfo.getId()).build());
-                    if (CollectionUtil.isNotEmpty(salesFileList)) {
-                        salesFileList.stream().forEach(s -> {
-                            sysAttachmentRefService.copyFile(s, FileModuleDict.ChildEnum.FINANCIAL_EXPENDITURE_DOWNSTREAM_SALES_FILE,
-                                    AttachmentDto.builder().setEntityId(customerExpenditureContractInfo.getId()).build());
-                        });
+                    //已签署的文件
+                    CSalesSignConfirmation salesSignConfirmation = salesSignConfirmationService
+                            .lambdaQuery().eq(CSalesSignConfirmation::getcSalesContractManagementId, salesContract.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)) {
+                            List<FileStorage> salesFileList = new ArrayList<>();
+                            signElectronicInfos.forEach(signElectronicInfo -> {
+                                salesFileList.addAll(sysAttachmentRefService.getFiles(AttachmentDto.builder()
+                                        .setChildEnum(FileModuleDict.ChildEnum.SIGN_CONFIRM_BACK_FILE).setEntityId(signElectronicInfo.getId()).build()));
+                            });
+
+                            if (CollectionUtil.isNotEmpty(salesFileList)) {
+                                salesFileList.stream().forEach(s -> {
+                                    sysAttachmentRefService.copyFile(s, FileModuleDict.ChildEnum.FINANCIAL_EXPENDITURE_DOWNSTREAM_SALES_FILE,
+                                            AttachmentDto.builder().setEntityId(customerExpenditureContractInfo.getId()).build());
+                                });
+                            }
+                        }
                     }
                 }
             }