Ver código fonte

质控签章完成后一天内数据可重新复核功能、批量导出签章文件功能代码提交

user5 1 ano atrás
pai
commit
3df8894043

+ 86 - 6
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/controller/CwProjectReportController.java

@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.common.collect.Lists;
 import com.jeeplus.common.TokenProvider;
 import com.jeeplus.common.excel.ExcelOptions;
 import com.jeeplus.common.excel.annotation.ExportMode;
@@ -22,6 +23,7 @@ import com.jeeplus.finance.projectReport.mapper.ProjectReportWorkAttachmentMappe
 import com.jeeplus.finance.projectReport.service.CwProjectReportService;
 import com.jeeplus.finance.projectReport.service.dto.CwProjectReportDTO;
 import com.jeeplus.finance.projectReport.service.dto.CwProjectReportSignatureDTO;
+import com.jeeplus.finance.projectReport.service.dto.ProjectReportWorkAttachmentDTO;
 import com.jeeplus.finance.workClientInfo.service.dto.CwWorkClientBaseDTO;
 import com.jeeplus.flowable.feign.IFlowableApi;
 import com.jeeplus.logging.annotation.ApiLog;
@@ -47,14 +49,12 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.io.*;
+import java.net.URLEncoder;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
@@ -715,6 +715,86 @@ public class CwProjectReportController {
     }
 
 
+    /**
+     * 批量导出已签章文件
+     * @param ids
+     * @param request
+     * @param response
+     * @throws IOException
+     */
+    @RequestMapping("/exportAllSignatureFile")
+    public void exportAllSignatureFile(@RequestParam("ids") String ids, HttpServletRequest request, HttpServletResponse response) {
+        //将字符串转换成list
+        List<String> idList = Arrays.asList(ids.split(","));
+        List<ProjectReportWorkAttachmentDTO> listAll = Lists.newArrayList();
+        for (String id : idList) {
+            List<ProjectReportWorkAttachmentDTO> signatureFileInfoList = projectReportService.getSignatureFileInfoList(id);
+            listAll.addAll(signatureFileInfoList);
+        }
+        String filePathUrl = projectReportService.getSignatureFileZipUrl(listAll);
+        String downUrl = filePathUrl + ".zip";
+
+        OutputStream outputStream = null;
+        InputStream inputStream = null;
+        BufferedInputStream bufferedInputStream = null;
+        byte[] bytes = new byte[1024];
+        File file = new File(downUrl);
+        String fileName = file.getName();
+        // 获取输出流
+        try {
+            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
+            // 以流的形式返回文件
+            response.setContentType("application/octet-stream;charset=utf-8");
+            inputStream = new FileInputStream(file);
+            bufferedInputStream = new BufferedInputStream(inputStream);
+            outputStream = response.getOutputStream();
+            int i = bufferedInputStream.read(bytes);
+            while (i != -1) {
+                outputStream.write(bytes, 0, i);
+                i = bufferedInputStream.read(bytes);
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (inputStream != null) {
+                    inputStream.close();
+                }
+                if (outputStream != null) {
+                    outputStream.close();
+                }
+                if (bufferedInputStream != null) {
+                    bufferedInputStream.close();
+                }
 
+                //根据路径创建文件对象
+                File downFile = new File(filePathUrl);
+                deleteFile(downFile);
+
+                //根据路径创建文件对象
+                File downFileZip = new File(downUrl);
+                //路径是个文件且不为空时删除文件
+                if(downFileZip.isFile()&&downFileZip.exists()){
+                    downFileZip.delete();
+                }
+
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+
+        }
+    }
+
+    public static void deleteFile(File folder) {
+        if(folder.isDirectory()) {
+            File[] files = folder.listFiles();
+            if(files != null) { // 如果文件夹为空,files可能为null
+                for(File file : files) {
+                    deleteFile(file); // 递归删除子文件夹和文件
+                }
+            }
+        }
+        folder.delete(); // 删除空文件夹或者文件
+    }
 
 }

+ 10 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/domain/CwProjectReportData.java

@@ -354,6 +354,16 @@ public class CwProjectReportData extends BaseDTO {
     private String reviewStatus;
 
     /**
+     * 质量复核审核通过时间
+     */
+    private Date auditTime;
+
+    /**
+     *  重复质量复核判定条件
+     */
+    private Boolean repetitionReviewFlag = false;
+
+    /**
      *业务类型
      */
     private String businessType;

+ 7 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/domain/CwProjectReview.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import com.jeeplus.core.domain.BaseEntity;
 import lombok.Data;
 
+import java.util.Date;
+
 /**
  * @author: 王强
  * @create: 2022-12-12 20:37
@@ -127,4 +129,9 @@ public class CwProjectReview extends BaseEntity {
      * 区分新旧数据
      */
     private String newType;
+
+    /**
+     * 审核通过时间
+     */
+    private Date auditTime;
 }

+ 3 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/mapper/xml/CwProjectReportMapper.xml

@@ -84,6 +84,7 @@
         ifnull(cw_rev.review_status,'0') as reviewStatus,
         cw_rev.proc_ins_id as procInsId3,
         cw_rev.new_type as newType,
+        cw_rev.audit_time as auditTime,
         new_line.report_no as reportNo,
         cwcb.name as servedUnitName,
         art.ID_ as rev_task_id,
@@ -189,6 +190,8 @@
         new_line.opinion_type as opinionType,
         new_line.seal_type as sealType,
         cw_re.proc_ins_id as procInsId3,
+        ifnull(cw_re.review_status,'0') as reviewStatus,
+        cw_re.audit_time as auditTime,
         suser.name as real_header_name,
         b.project_master_id as project_master_id1,
         b.real_header as project_master_id2,

+ 3 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/mapper/xml/CwProjectReportReviewMapper.xml

@@ -123,6 +123,9 @@
         <if test="reviewBy != null and reviewBy != ''">
             review_by = #{reviewBy},
         </if>
+        <if test="auditTime != null">
+            audit_time = #{auditTime},
+        </if>
         update_by_id = #{updateById},
         update_time = #{updateTime}
         WHERE

+ 1 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/service/CwProjectReportReviewService.java

@@ -318,6 +318,7 @@ public class CwProjectReportReviewService extends ServiceImpl<CwProjectReportRev
                 }
                 if ("三级复核".equals(currentTask) || "三级复核及签章".equals(currentTask)) {
                     review.setReviewStatus("5");
+                    review.setAuditTime(new Date());
                     if("1".equals(detail.getNewType())){
                         //原签章表中的状态值也调整为5
                         String signatureId = cwProjectReportService.modifySignatureStatus(reportData,"5");

+ 145 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/service/CwProjectReportService.java

@@ -27,6 +27,7 @@ import com.jeeplus.finance.projectReport.service.mapstruct.CwProjectReportFileWr
 import com.jeeplus.finance.projectReportArchive.domain.CwProjectReportArchive;
 import com.jeeplus.finance.projectReportArchive.mapper.CwProjectReportArchiveMapper;
 import com.jeeplus.finance.projectReportArchive.service.dto.CwProjectReportArchiveDTO;
+import com.jeeplus.finance.utils.FileUtil;
 import com.jeeplus.finance.utils.Global;
 import com.jeeplus.finance.workClientInfo.domain.CwWorkClientBase;
 import com.jeeplus.finance.workClientInfo.service.dto.CwWorkClientBaseDTO;
@@ -55,6 +56,7 @@ import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
+
 import org.springframework.core.env.Environment;
 
 /**
@@ -681,12 +683,44 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
                 li.setSigReason(sigById.getReason());
                 li.setTaskSigId(sigById.getTaskId());
             }
+
+            //如果质控审核已经完成且审核通过时间存在,则判断审核时间是否已经超过一天,若不超过,则可以重复发起质控审核
+            if (null != li.getAuditTime() && "5".equals(li.getReviewStatus())){
+                li.setRepetitionReviewFlag(getRepetitionReviewFlag(li.getAuditTime()));
+            }
+
         });
         return list;
 
     }
 
     /**
+     * 计算两时间是否超过一天(秒)
+     * @param auditTime
+     * @return
+     */
+    public Boolean getRepetitionReviewFlag(Date auditTime){
+        // 创建一个Calendar对象,表示当前时间
+        Calendar currentTime = Calendar.getInstance();
+        // 获取当前时间的毫秒数
+        long currentTimeInMillis = currentTime.getTimeInMillis();
+        // 获取质控审核已经完成的毫秒数
+        long targetTimeInMillis = auditTime.getTime();
+        // 计算时间差异(以毫秒为单位)
+        long timeDifferenceInMillis = currentTimeInMillis - targetTimeInMillis;
+        // 将时间差异转换为秒
+        long timeDifferenceInMinutes = timeDifferenceInMillis / (1000);
+        if(timeDifferenceInMinutes > 86400){
+            //若超过86400, 则超过一天,即不可进行重新复核操作
+            return false;
+        }else{
+            //可进行重复质控操作
+            return true;
+        }
+
+    }
+
+    /**
      * 修改状态
      * @param data
      * @return
@@ -702,6 +736,11 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
 
         CwProjectReportData reportData = reportMapper.queryById(id);
 
+        //如果质控审核已经完成且审核通过时间存在,则判断审核时间是否已经超过一天,若不超过,则可以重复发起质控审核
+        if (null != reportData && null != reportData.getAuditTime() && "5".equals(reportData.getReviewStatus())){
+            reportData.setRepetitionReviewFlag(getRepetitionReviewFlag(reportData.getAuditTime()));
+        }
+
         //将新增行数据查询出来放入到cwProjectInfoList中
         CwProjectInfoData cwProjectInfoData = infoMapper.selectByReportId(id);
         if (null != cwProjectInfoData){
@@ -879,6 +918,12 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
             if (null != review) {
                 reportData = reportMapper.queryById(review.getReportId());
                 if ( null != reportData){
+
+                    //如果质控审核已经完成且审核通过时间存在,则判断审核时间是否已经超过一天,若不超过,则可以重复发起质控审核
+                    if (null != reportData.getAuditTime() && "5".equals(reportData.getReviewStatus())){
+                        reportData.setRepetitionReviewFlag(getRepetitionReviewFlag(reportData.getAuditTime()));
+                    }
+
                     List<ProjectReportWorkAttachmentDTO> dtos = attachmentMapper.selectByInfoId(reportData.getId());
                     if (null != dtos){
 
@@ -3843,4 +3888,104 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
 
 
     }
+    /**
+     * 根据报告id查询已签章文件信息
+     * @param id
+     * @return
+     */
+    public List<ProjectReportWorkAttachmentDTO> getSignatureFileInfoList (String id) {
+        List<ProjectReportWorkAttachmentDTO> signatureList = new ArrayList<>();
+
+        List<ProjectReportWorkAttachmentDTO> dtos = attachmentMapper.selectByInfoId(id);
+        if (null != dtos){
+
+            Iterator<ProjectReportWorkAttachmentDTO> it = dtos.iterator();
+            while(it.hasNext()){
+                ProjectReportWorkAttachmentDTO d = it.next();
+                //已签章附件
+                CwProjectReportFile signatureFile = attachmentMapper.selectInfoByFileId(d.getId(),"1");
+                if (null != signatureFile){
+                    d.setFileType(signatureFile.getFileType());
+                    d.setSealType(signatureFile.getSealType());
+                    d.setSealedFile(signatureFile.getSealedFile());
+                    d.setSealUser(signatureFile.getSealUser());
+                    d.setSealDate(signatureFile.getSealDate());
+                    d.setRemarks(signatureFile.getRemarks());
+                    UserDTO userDTO2 = new UserDTO();
+                    //根据创建人id查出创建人名称
+                    String name2 = reportMapper.getUserNameById(signatureFile.getCreateById());
+                    userDTO2.setId(signatureFile.getCreateById());
+                    userDTO2.setName(name2);
+                    d.setCreateBy(userDTO2);
+                    d.setCreateTime(signatureFile.getCreateTime());
+                    signatureList.add(d);
+                    it.remove();
+                }
+            }
+        }
+        return signatureList;
+    }
+
+    /**
+     * 已盖章文件下载并压缩
+     * @param listAll
+     * @return
+     */
+    public String getSignatureFileZipUrl (List<ProjectReportWorkAttachmentDTO> listAll) {
+        long timestamp = System.currentTimeMillis();
+        UserDTO userDTO = SpringUtil.getBean ( IUserApi.class ).getByToken(TokenProvider.getCurrentToken ( ));
+        String filePath = null;
+        if(System.getProperty("os.name").toLowerCase().contains("win")){
+            filePath = "D:/attachment-file/" + userDTO.getName() + timestamp;
+        }else{
+            filePath = "/attachment-file/" + userDTO.getName() + timestamp;
+        }
+
+        File folder = new File(filePath);
+        if (!folder.exists()) {
+            if (folder.mkdirs()) {
+                System.out.println("文件夹创建成功!");
+            } else {
+                System.out.println("文件夹创建失败!");
+            }
+        } else {
+            System.out.println("文件夹已存在!");
+        }
+        String path = filePath + "/";
+
+        try{
+            //文件下载到指定文件夹
+            for (ProjectReportWorkAttachmentDTO info : listAll) {
+                String aliyunUrl = "http://cdn.gangwaninfo.com";
+                String aliDownloadUrl = "http://oss.gangwaninfo.com";
+
+
+                String file = aliyunUrl + info.getUrl();
+                file = file.replace("amp;","");
+                String fileName = file.substring(file.lastIndexOf("/") + 1, file.length());
+                String cons = "";
+                if (file.contains(aliyunUrl)){
+                    cons = aliyunUrl;
+                }else if (file.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")){
+                    cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
+                }else {
+                    cons = aliDownloadUrl;
+                }
+                String ossKey = file.split(cons+"/")[1];
+                SpringUtil.getBean ( IWorkAttachmentApi.class ).downByStreamSaveLocal(ossKey,fileName,path+fileName);
+            }
+
+            //文件打包压缩成zip
+            FileUtil.zipFolder(filePath, filePath+".zip");
+
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+
+        return filePath;
+    }
+
+
+
+
 }

+ 63 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/utils/FileUtil.java

@@ -0,0 +1,63 @@
+package com.jeeplus.finance.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * 文件管理
+ * @author: 徐滕
+ * @version: 2023-12-29 09:54
+ */
+public class FileUtil {
+
+    /**
+     * 文件压缩
+     * @param sourceFolder
+     * @param zipFile
+     */
+    public static void zipFolder(String sourceFolder, String zipFile) {
+        try {
+            FileOutputStream fos = new FileOutputStream(zipFile);
+            ZipOutputStream zos = new ZipOutputStream(fos);
+
+            File folder = new File(sourceFolder);
+            addFolderToZip("", folder, zos);
+
+            zos.close();
+            fos.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static void addFolderToZip(String parentFolder, File folder, ZipOutputStream zos) throws IOException {
+        for (String fileName : folder.list()) {
+            if (parentFolder.equals("")) {
+                addFileToZip(folder.getName(), new File(folder, fileName), zos);
+            } else {
+                addFileToZip(parentFolder + "/" + folder.getName(), new File(folder, fileName), zos);
+            }
+        }
+    }
+
+    public static void addFileToZip(String path, File file, ZipOutputStream zos) throws IOException {
+        if (file.isDirectory()) {
+            addFolderToZip(path, file, zos);
+        } else {
+            byte[] buffer = new byte[1024];
+            FileInputStream fis = new FileInputStream(file);
+            zos.putNextEntry(new ZipEntry(path + "/" + file.getName()));
+            int length;
+            while ((length = fis.read(buffer)) > 0) {
+                zos.write(buffer, 0, length);
+            }
+            zos.closeEntry();
+            fis.close();
+        }
+    }
+
+}

+ 2 - 2
jeeplus-modules/jeeplus-finance/src/main/resources/application-finance.yml

@@ -1,2 +1,2 @@
-#active: development
-active: production
+active: development
+#active: production