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

feat(销售,采购):下载测试

Wangyafan месяцев назад: 7
Родитель
Сommit
94749e7968

+ 8 - 5
src/main/java/com/sunxung/factoring/service/purchcontractmanagement/impl/PurchContractElectronicInfoServiceImpl.java

@@ -683,12 +683,15 @@ public class PurchContractElectronicInfoServiceImpl extends ServiceImpl<PurchCon
         for (AttachmentDto attachmentDtoChange : attachmentDtoChanges) {
             fileStorages.addAll(sysAttachmentRefService.getFiles(attachmentDtoChange));
         }
-        List<File> files = new ArrayList<>();
-        for (FileStorage fileStorage : fileStorages) {
-            File file = new File(fileStorage.getAbsolutePath());
-            files.add(file);
+
+        if (CollectionUtil.isEmpty(fileStorages)) {
+            throw new BusinessException(CodeUtil.FAIL, "为查询到出证文件!");
         }
-        ZipUtils.toZip(files, res.getOutputStream());
+        //文件名去重
+        fileStorageService.renameFileStorageList(fileStorages);
+        //打包下载文件
+        fileStorageService.downloadZipFile(fileStorages, FileModuleDict.ChildEnum.SALES_CONTRACT_ZIP_FILE.getCname(),
+                FileModuleDict.ChildEnum.SALES_CONTRACT_ZIP_FILE, res);
         return null;
     }
 

+ 8 - 0
src/main/java/com/sunxung/factoring/service/salescontractmanagement/SalesContractService.java

@@ -10,6 +10,7 @@ import com.sunxung.factoring.entity.salescontractmanagement.vo.SalesContractBasi
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -113,6 +114,13 @@ public interface SalesContractService extends IService<CSalesContract> {
      */
     void downloadAllSalesContractFile(Long id,HttpServletResponse response);
 
+    /**
+     * 出证下载
+     * @param id
+     * @param res
+     */
+    void downloadReportUrl(Long id, HttpServletResponse res) throws IOException;
+
     /**
      * 获取审核需要的信息
      * @param businessKey

+ 145 - 25
src/main/java/com/sunxung/factoring/service/salescontractmanagement/impl/SalesContractServiceImpl.java

@@ -8,8 +8,6 @@ import com.sunxung.factoring.component.exception.ValidatorException;
 import com.sunxung.factoring.component.util.*;
 import com.sunxung.factoring.dict.impl.FileModuleDict;
 import com.sunxung.factoring.dict.impl.ProjectInitiationStatusDict;
-import com.sunxung.factoring.dict.impl.SalesContractStatusDict;
-import com.sunxung.factoring.entity.project.BusinessAssignee;
 import com.sunxung.factoring.entity.project.BusinessProcessingLog;
 import com.sunxung.factoring.entity.project.ProjectInformation;
 import com.sunxung.factoring.entity.project.vo.BusinessProcessingTaskVo;
@@ -22,14 +20,12 @@ import com.sunxung.factoring.entity.sys.FileStorage;
 import com.sunxung.factoring.entity.sys.FileStorageDO;
 import com.sunxung.factoring.entity.sys.User;
 import com.sunxung.factoring.mapper.salescontractmanagement.SalesContractMapper;
-import com.sunxung.factoring.service.project.BusinessAssigneeService;
 import com.sunxung.factoring.service.project.BusinessProcessingLogService;
 import com.sunxung.factoring.service.project.IProjectInformationService;
 import com.sunxung.factoring.service.salescontractmanagement.*;
 import com.sunxung.factoring.service.sys.*;
 import com.sunxung.factoring.service.sys.dto.AttachmentDto;
 import com.sunxung.factoring.service.sys.flowable.FlowableService;
-import org.apache.commons.lang3.StringUtils;
 import org.flowable.engine.runtime.ProcessInstance;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.ClassPathResource;
@@ -66,9 +62,6 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, C
     @Autowired
     private DictionaryService dictService;
 
-    @Autowired
-    private BusinessAssigneeService assigneeService;
-
     @Autowired
     private FlowableService flowableService;
 
@@ -96,6 +89,21 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, C
     @Autowired
     private ISalesContractSupplementInfoService salesContractSupplementInfoService;
 
+    @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)
     public void doCreate(CSalesContract salesContractManagement) {
@@ -118,8 +126,8 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, C
             //开启流程
             startSalesContractProcess(salesContractManagement);
             //变更项目的是否已做销售合同标识
-            projectInformationService.lambdaUpdate().set(ProjectInformation::getSales,1)
-                    .eq(ProjectInformation::getBusinessNumber,salesContractManagement.getBusinessNumber())
+            projectInformationService.lambdaUpdate().set(ProjectInformation::getSales, 1)
+                    .eq(ProjectInformation::getBusinessNumber, salesContractManagement.getBusinessNumber())
                     .update();
         } else {
             updateById(salesContractManagement);
@@ -172,7 +180,6 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, C
     }
 
 
-
     @Override
     public List<BusinessProcessingTaskVo> findMyCompletedList(SearchBusinessProcessingTask search) {
         return baseMapper.findMyCompletedList(search);
@@ -187,11 +194,11 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, C
                 BusinessProcessingLog log = businessProcessingLogService.getByBusinessTypeBusinessKey(search.getSimpleClassName(), r.getId());
                 if (log != null && log.getEndTime() == null) {
                     String taskName = log.getTaskName();
-                    if (taskName.contains("创建") || taskName.contains("录入") || taskName.contains("签署确认")){
+                    if (taskName.contains("创建") || taskName.contains("录入") || taskName.contains("签署确认")) {
                         r.setExecutor("供应商");
-                    }else if (taskName.contains("初审") || taskName.contains("审核") || taskName.contains("签署确认审核")){
+                    } else if (taskName.contains("初审") || taskName.contains("审核") || taskName.contains("签署确认审核")) {
                         r.setExecutor("法务专员");
-                    } else if (taskName.contains("模板复审")){
+                    } else if (taskName.contains("模板复审")) {
                         r.setExecutor("法务经理");
                     }
                 }
@@ -369,24 +376,80 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, C
 
     @Override
     public void downloadAllSalesContractFile(Long id, HttpServletResponse response) {
-        List<FileStorage> salesContractAllFile = new ArrayList<>();
-
-        CSalesContractBasicInfo basicInfo = salesContractBasicInfoService
-                .lambdaQuery().eq(CSalesContractBasicInfo::getcSalesContractManagementId,id).one();
-        //销售合同文件
-        List<FileStorage> salesContractFile = attachmentRefService.getFiles(AttachmentDto.builder()
-                .setChildEnum(FileModuleDict.ChildEnum.SALES_CONTRACT_FILE).setEntityId(basicInfo.getId()).build());
-        salesContractAllFile.addAll(salesContractFile);
 
+        List<FileStorage> salesContractAllFile = new ArrayList<>();
+        CSalesContract salesContractManagement = get(id);
+        CSalesContractBasicInfo salesContractBasicInfo = salesContractBasicInfoService
+                .getOne(new QueryWrapper<CSalesContractBasicInfo>().eq("c_sales_contract_management_id", id));
+        //销售合同原件
+        //合同文件
+        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());
+                salesContractAllFile.add(fileStorage);
+            });
+        }
+        //已签署的文件
+        CSalesSignConfirmation salesSignConfirmation = salesSignConfirmationService
+                .lambdaQuery().eq(CSalesSignConfirmation::getcSalesContractManagementId, id).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 -> {
+                    salesContractAllFile.addAll(attachmentRefService.getFiles(AttachmentDto.builder()
+                            .setChildEnum(FileModuleDict.ChildEnum.SIGN_CONFIRM_BACK_FILE).setEntityId(signElectronicInfo.getId()).build()));
+                });
+            }
+        }
         //销售合同补充文件
         List<CSalesContractSupplementInfo> salesContractSupplementInfos = salesContractSupplementInfoService
-                .lambdaQuery().eq(CSalesContractSupplementInfo::getcSalesContractManagementId,id).list();
+                .list(new QueryWrapper<CSalesContractSupplementInfo>().eq("c_sales_contract_management_id", salesContractManagement.getId()));
         if (CollectionUtil.isNotEmpty(salesContractSupplementInfos)) {
             salesContractSupplementInfos.stream().forEach(s -> {
-                List<FileStorage> salesContractSupplementFiles = attachmentRefService.getFiles(AttachmentDto.builder()
-                        .setChildEnum(FileModuleDict.ChildEnum.SALES_CONTRACT_SUPPLEMENT_FILE).setEntityId(s.getId()).build());
-                salesContractAllFile.addAll(salesContractSupplementFiles);
+                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());
+                            salesContractAllFile.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 = attachmentRefService.getFiles(AttachmentDto.builder()
+                                        .setChildEnum(FileModuleDict.ChildEnum.SALES_SUPPLEMENT_SIGN_CONFIRM_BACK_FILE)
+                                        .setEntityId(supplementSignConfirmationElectronicInfo.getId()).build());
+                                salesContractAllFile.addAll(salesContractSupplementFiles);
+                            });
+                        }
 
+                    }
+                }
             });
         }
 
@@ -397,5 +460,62 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, C
                 FileModuleDict.ChildEnum.SALES_CONTRACT_ZIP_FILE, response);
     }
 
+    @Override
+    public void downloadReportUrl(Long id, HttpServletResponse res) throws IOException {
+
+        List<FileStorage> salesReportFiles = new ArrayList<>();
+
+        CSalesContract cSalesContract = get(id);
+        CSalesSignConfirmation salesSignConfirmation = salesSignConfirmationService
+                .lambdaQuery().eq(CSalesSignConfirmation::getcSalesContractManagementId, id).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 -> {
+                    salesReportFiles.addAll(attachmentRefService.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", id));
+        if (CollectionUtil.isNotEmpty(salesContractSupplementInfos)) {
+            salesContractSupplementInfos.stream().forEach(s -> {
+                if (cSalesContract.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 = attachmentRefService.getFiles(AttachmentDto.builder()
+                                        .setChildEnum(FileModuleDict.ChildEnum.SSALES_SUPPLEMENT_SIGN_CONFIRM_BACK_REPORT_FILE)
+                                        .setEntityId(supplementSignConfirmationElectronicInfo.getId()).build());
+                                salesReportFiles.addAll(salesContractSupplementFiles);
+                            });
+                        }
+
+                    }
+                }
+            });
+        }
+
+        if (CollectionUtil.isEmpty(salesReportFiles)) {
+            throw new BusinessException(CodeUtil.FAIL, "为查询到出证文件!");
+        }
+
+        //文件名去重
+        fileStorageService.renameFileStorageList(salesReportFiles);
+        //打包下载文件
+        fileStorageService.downloadZipFile(salesReportFiles, FileModuleDict.ChildEnum.SALES_CONTRACT_ZIP_FILE.getCname(),
+                FileModuleDict.ChildEnum.SALES_CONTRACT_ZIP_FILE, res);
+    }
+
 }
 

+ 0 - 17
src/main/java/com/sunxung/factoring/web/purchcontractmanagement/PurchContractConfirmController.java

@@ -205,23 +205,6 @@ public class PurchContractConfirmController {
         }
     }
 
-
-
-
-    /**
-     * 下载出证
-     *
-     * @param managerId
-     * @param res
-     * @return
-     */
-    @RequestMapping("/downloadReportUrl")
-    @ResponseBody
-    @OperationLog(operationModule = "采购合同",operationType = OperationTypeEnum.OTHER,description = "下载出证")
-    public ResponseEntity<Object> downloadReportUrl(Long managerId, HttpServletResponse res) throws IOException {
-        return purchContractElectronicInfoService.downloadReportUrl(managerId, res);
-    }
-
     /**
      * 获取认证信息
      *

+ 19 - 0
src/main/java/com/sunxung/factoring/web/purchcontractmanagement/PurchContractController.java

@@ -6,14 +6,17 @@ import com.sunxung.factoring.entity.GridPage;
 import com.sunxung.factoring.entity.ResponseJson;
 import com.sunxung.factoring.entity.purchcontractmanagement.vo.PurchContractVo;
 import com.sunxung.factoring.entity.purchcontractmanagement.vo.SearchGoods;
+import com.sunxung.factoring.service.purchcontractmanagement.PurchContractElectronicInfoService;
 import com.sunxung.factoring.service.purchcontractmanagement.PurchContractService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 
 /**
  * @Description : 采购合同管理控制层
@@ -26,6 +29,8 @@ public class PurchContractController {
 
     @Autowired
     private PurchContractService purchContractService;
+    @Autowired
+    private PurchContractElectronicInfoService purchContractElectronicInfoService;
 
 
 //    /**
@@ -61,4 +66,18 @@ public class PurchContractController {
         purchContractService.downloadAllPurchFile(id,response);
     }
 
+    /**
+     * 下载出证
+     *
+     * @param id
+     * @param res
+     * @return
+     */
+    @GetMapping("/downloadReportUrl")
+    @ResponseBody
+    @OperationLog(operationModule = "采购合同",operationType = OperationTypeEnum.OTHER,description = "下载采购合同出证文件")
+    public ResponseEntity<Object> downloadPurchReport(Long id, HttpServletResponse res) throws IOException {
+        return purchContractElectronicInfoService.downloadReportUrl(id, res);
+    }
+
 }

+ 14 - 1
src/main/java/com/sunxung/factoring/web/salescontractmanagement/SalesContractController.java

@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 
 /**
  * @Description : 销售合同管理控制层
@@ -121,12 +122,24 @@ public class SalesContractController {
      * @param id
      * @param response
      */
-    @GetMapping("/downloadAllSalesContractFile")
+    @GetMapping("/downloadAllSalesFile")
     @OperationLog(operationModule = "销售合同", operationType = OperationTypeEnum.OTHER, description = "下载所有销售合同文件")
     public void downloadAllSalesContractFile(Long id, HttpServletResponse response) {
         salesContractService.downloadAllSalesContractFile(id, response);
     }
 
+    /**
+     * 下载销售合同出证文件
+     *
+     * @param id
+     * @param response
+     */
+    @GetMapping("/downloadSalesReport")
+    @OperationLog(operationModule = "销售合同", operationType = OperationTypeEnum.OTHER, description = "下载所有销售合同出证文件")
+    public void downloadSalesReport(Long id, HttpServletResponse response) throws IOException {
+        salesContractService.downloadReportUrl(id, response);
+    }
+
     /**
      * 销售合同变更签署审核-详情
      * @param id