Просмотр исходного кода

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

liuj месяцев назад: 6
Родитель
Сommit
049102e3c0

+ 25 - 27
src/main/java/com/sunxung/factoring/service/fundmanagement/impl/FinancialInstitutionServiceImpl.java

@@ -1,7 +1,6 @@
 package com.sunxung.factoring.service.fundmanagement.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
-import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -30,11 +29,15 @@ import com.sunxung.factoring.entity.financing.review.ReviewQuotaDisburse;
 import com.sunxung.factoring.entity.fundmanagement.*;
 import com.sunxung.factoring.entity.fundmanagement.vo.*;
 import com.sunxung.factoring.entity.invoicemanage.InvoiceGoodsInfo;
+import com.sunxung.factoring.entity.invoicemanage.SalesInvoiceInfo;
 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.*;
+import com.sunxung.factoring.entity.salescontractmanagement.CSalesContract;
+import com.sunxung.factoring.entity.salescontractmanagement.CSalesContractBasicInfo;
+import com.sunxung.factoring.entity.salescontractmanagement.CSalesSignConfirmation;
+import com.sunxung.factoring.entity.salescontractmanagement.CSalesSignConfirmationElectronicInfo;
 import com.sunxung.factoring.entity.settlement.SettlementGoodsInfo;
 import com.sunxung.factoring.entity.supplier.SupplierInfo;
 import com.sunxung.factoring.entity.sys.Dictionary;
@@ -51,6 +54,7 @@ import com.sunxung.factoring.service.financing.review.ReviewFinancingInfoService
 import com.sunxung.factoring.service.financing.review.ReviewQuotaDisburseService;
 import com.sunxung.factoring.service.fundmanagement.*;
 import com.sunxung.factoring.service.invoicemanage.InvoiceGoodsInfoService;
+import com.sunxung.factoring.service.invoicemanage.SalesInvoiceInfoService;
 import com.sunxung.factoring.service.project.BusinessAssigneeService;
 import com.sunxung.factoring.service.project.BusinessProcessingLogService;
 import com.sunxung.factoring.service.project.BusinessProcessingTaskService;
@@ -134,6 +138,9 @@ public class FinancialInstitutionServiceImpl extends ServiceImpl<FinancialInstit
     @Autowired
     private InvoiceGoodsInfoService invoiceGoodsInfoService;
 
+    @Autowired
+    private SalesInvoiceInfoService salesInvoiceInfoService;
+
     @Autowired
     private FinancialCustomerExpenditureContractInfoService financialCustomerExpenditureContractInfoService;
 
@@ -417,7 +424,6 @@ public class FinancialInstitutionServiceImpl extends ServiceImpl<FinancialInstit
     }
 
 
-
     /**
      * 获取客户信息和客户支用信息的处理人(融资经理(所有)+项目经理(对应企业)+项目经理所在部门的对应的再融资操作岗人员)
      *
@@ -485,7 +491,7 @@ public class FinancialInstitutionServiceImpl extends ServiceImpl<FinancialInstit
                             //合同信息
                             ContractInfo contractInfo = contractInfoService.lambdaQuery()
                                     .eq(ContractInfo::getReviewQuotaDisburseId, reviewQuotaDisburse.getId())
-                                    .eq(ContractInfo::getConclusion,ConstantConversionUtil.APPROVAL_RESULT_PASS)
+                                    .eq(ContractInfo::getConclusion, ConstantConversionUtil.APPROVAL_RESULT_PASS)
                                     .orderByDesc(ContractInfo::getGmtCreate)
                                     .last("limit 1")
                                     .one();
@@ -782,29 +788,32 @@ public class FinancialInstitutionServiceImpl extends ServiceImpl<FinancialInstit
                             });
                         }
                     }
+
                     List<InvoiceGoodsInfo> invoiceGoodsInfoList = invoiceGoodsInfoService.list(new QueryWrapper<InvoiceGoodsInfo>()
                             .in("c_settlement_basic_info_id", settlementBasicInfoIds));
                     if (CollectionUtil.isNotEmpty(invoiceGoodsInfoList)) {
                         List<Long> InvoiceBasicInfoIdList = invoiceGoodsInfoList.stream().map(InvoiceGoodsInfo::getInvoiceBasicInfoId).distinct().collect(Collectors.toList());
                         for (Long invoiceBasicInfoId : InvoiceBasicInfoIdList) {
                             //采购发票
-                            List<FileStorageDO> purchaseFileList = fileService.findByBusinessId(invoiceBasicInfoId, FileModuleDict.ChildEnum.SETTLEMENT_FILE.getCode());
+                            List<FileStorageDO> purchaseFileList = fileService.findByBusinessId(invoiceBasicInfoId, FileModuleDict.ChildEnum.INVOICE_PURCHASE_FILE.getCode());
                             if (CollectionUtil.isNotEmpty(purchaseFileList)) {
                                 purchaseFileList.stream().forEach(p -> {
                                     sysAttachmentRefService.copyFile(p, FileModuleDict.ChildEnum.FINANCIAL_EXPENDITURE_UPSTREAM_INVOICE_FILE,
                                             AttachmentDto.builder().setEntityId(customerExpenditureContractInfo.getId()).build());
                                 });
                             }
-                            //销售待开发票
-                                List<FileStorage> salesFileList = sysAttachmentRefService.getFiles(AttachmentDto.builder().setChildEnum(FileModuleDict.ChildEnum.INVOICE_SALES_FILE)
-                                        .setEntityId(invoiceBasicInfoId).build());
-                                if (CollectionUtil.isNotEmpty(salesFileList)) {
-                                    salesFileList.stream().forEach(p -> {
-                                        sysAttachmentRefService.copyFile(p, FileModuleDict.ChildEnum.FINANCIAL_EXPENDITURE_DOWNSTREAM_INVOICE_FILE,
-                                                AttachmentDto.builder().setEntityId(customerExpenditureContractInfo.getId()).build());
-                                    });
-                                }
+
+                            SalesInvoiceInfo salesInvoiceInfo = salesInvoiceInfoService.lambdaQuery().eq(SalesInvoiceInfo::getInvoiceBasicInfoId, invoiceBasicInfoId).one();
+                            //销售发票附件(销售发票未在B端中间表存储 所以取数逻辑不同)
+                            List<FileStorage> salesFileList = fileStorageService.findByBelongIdAndBelongType(salesInvoiceInfo.getId().toString(), FileModuleDict.ChildEnum.INVOICE_SALES_FILE.getCode());
+                            if (CollectionUtil.isNotEmpty(salesFileList)) {
+                                salesFileList.stream().forEach(p -> {
+                                    sysAttachmentRefService.copyFile(p, FileModuleDict.ChildEnum.FINANCIAL_EXPENDITURE_DOWNSTREAM_INVOICE_FILE,
+                                            AttachmentDto.builder().setEntityId(customerExpenditureContractInfo.getId()).build());
+                                });
+                            }
                         }
+
                     }
                 }
                 if (salesContract != null) {
@@ -1164,21 +1173,10 @@ public class FinancialInstitutionServiceImpl extends ServiceImpl<FinancialInstit
                     contractFileList.add(fileStorageDO);
                 }
             }
-            FileModuleDict.ChildEnum childEnum = FileModuleDict.ChildEnum.FINANCIAL_EXPENDITURE_ATTACHMENT_FILE;
             if (CollectionUtil.isNotEmpty(contractFileList)) {
                 contractFileList.forEach(contractFile -> {
-                    String fileName = contractFile.getOriginalName().substring(0, contractFile.getOriginalName().lastIndexOf("."));
-                    String localFilePath = FileUtil.getAbsolutePath(fileName, contractFile.getType(), childEnum);
-                    File destFile = new File(localFilePath);
-                    if (!destFile.getParentFile().exists()) {
-                        destFile.getParentFile().mkdirs();
-                    }
-                    //新建FileStorage
-                    FileStorage newFileStorage = new FileStorage(contractFile, localFilePath, childEnum);
-                    fileStorageService.add(newFileStorage);
-                    //新建关联关系
-                    AttachmentDto attachmentDto = AttachmentDto.builder().setEntityId(customerExpenditureInfoId).setChildEnum(childEnum).build();
-                    sysAttachmentRefService.saveRef(Arrays.asList(newFileStorage.getId()), attachmentDto);
+                    sysAttachmentRefService.copyFile(contractFile, FileModuleDict.ChildEnum.FINANCIAL_EXPENDITURE_ATTACHMENT_FILE,
+                            AttachmentDto.builder().setEntityId(customerExpenditureInfoId).build());
                 });
             }
         }