Browse Source

20250214 审核任务

lrj 7 tháng trước cách đây
mục cha
commit
734294aa7e

+ 1 - 0
src/main/java/cn/cslg/pas/common/model/projectTask/FileDTO.java

@@ -8,4 +8,5 @@ public class FileDTO {
      private String guid;
      private String projectId;
      private String fileType;
+     private String rootGuid;
 }

+ 1 - 0
src/main/java/cn/cslg/pas/common/model/projectTask/TaskFormDTO.java

@@ -21,4 +21,5 @@ public class TaskFormDTO {
      */
     private String description;
     private Integer lastTaskId;
+    private Integer taskType;
 }

+ 339 - 0
src/main/java/cn/cslg/pas/common/utils/CustomizeFileUtils.java

@@ -0,0 +1,339 @@
+package cn.cslg.pas.common.utils;
+
+
+import cn.cslg.pas.Application;
+import cn.hutool.core.util.IdUtil;
+import com.alibaba.fastjson.JSON;
+import org.springframework.boot.system.ApplicationHome;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.*;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+
+@Service
+public class CustomizeFileUtils {
+
+    public static final String FILE_SEPARATOR = System.getProperty("file.separator");
+    public static final String COMMON_FILE = "file";
+    public static final String BACKUP_FILE = "backup";
+
+    public static String getStaticPath(String fileName) {
+        //ApplicationHome类 返回target目录层级
+        ApplicationHome ah = new ApplicationHome(Application.class);
+        //获取 applicationHome 内的路径 ...\target\classes 到这一层级下
+        File file = ah.getSource();
+        //获取 file的parentFile 即最后一级之前的所有层级路径(包括盘符) 这里能获得到的最终层级为  ...\target 后续用FILE_SEPARATOR(系统路径分割通配符 即 "\") 以及fileName拼接生成存放文件的目录层级 即为根目录 root
+        String rootPath = null;
+
+        if (fileName != null && !fileName.equals("")) {
+            rootPath = file.getParentFile().toString() + FILE_SEPARATOR + fileName;
+        } else {
+            rootPath = file.getParentFile().toString();
+        }
+        //根据上方生成的根目录路径 生成对应文件夹 没有就新建
+        File root = new File(rootPath);
+        if (!root.exists()) {
+            root.mkdir();
+        }
+        //返回的最终形式为 盘符:\项目层级\target\file
+        return rootPath;
+    }
+
+    public String analysisJsonFile() {
+        ApplicationHome ah = new ApplicationHome(BackupUtils.class);
+        File file = ah.getSource();
+//        String settingFilePath = file.getParentFile().toString() + FileUtils.FILE_SEPARATOR + "\\jsons\\" + "uploadSetting.json";
+        String settingFilePath = file.getParentFile().toString() + CustomizeFileUtils.FILE_SEPARATOR + "uploadSetting.json";
+        BufferedReader reader = null;
+        StringBuilder last = new StringBuilder();
+        InputStreamReader inputStreamReader;
+        try (FileInputStream fileInputStream = new FileInputStream(settingFilePath)) {
+            inputStreamReader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8);
+
+            reader = new BufferedReader(inputStreamReader);
+            String tempString;
+            while ((tempString = reader.readLine()) != null) {
+                last.append(tempString);
+            }
+            reader.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (reader != null) {
+                try {
+                    reader.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return last.toString();
+    }
+
+    public static File getFileByBytes(byte[] bytes, String prefix, String suffix) {
+        BufferedOutputStream bos = null;
+        FileOutputStream fos = null;
+        File file = null;
+        try {
+
+            file = File.createTempFile(prefix, suffix);
+
+            //输出流
+            fos = new FileOutputStream(file);
+
+            //缓冲流
+            bos = new BufferedOutputStream(fos);
+
+            //将字节数组写出
+            bos.write(bytes);
+            return file;
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (bos != null) {
+                try {
+                    bos.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (fos != null) {
+                try {
+                    fos.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            return file;
+        }
+    }
+
+
+    public static File getFileByUrl(String dataUrl) throws IOException {
+
+        URL url = new URL(dataUrl);  //想要读取的url地址
+        InputStream in = url.openStream();
+        File file = File.createTempFile("new_url", ".pdf");  //创建文件
+        OutputStream os = new FileOutputStream(file);  //创建文件输出流
+        int bytesRead;
+        byte[] buffer = new byte[8192];
+        int len = 8192;
+        while ((bytesRead = in.read(buffer, 0, len)) != -1) {
+            os.write(buffer, 0, bytesRead);
+        }
+        //关闭释放流
+        os.close();
+        in.close();
+        return file;
+    }
+
+    public static File getPictureFileByUrl(String dataUrl) throws IOException {
+
+        URL url = new URL(dataUrl);  //想要读取的url地址
+        InputStream in = url.openStream();
+        File file = File.createTempFile("new_url", ".jpg");  //创建文件
+        OutputStream os = new FileOutputStream(file);  //创建文件输出流
+        int bytesRead;
+        byte[] buffer = new byte[8192];
+        int len = 8192;
+        while ((bytesRead = in.read(buffer, 0, len)) != -1) {
+            os.write(buffer, 0, bytesRead);
+        }
+        //关闭释放流
+        os.close();
+        in.close();
+        return file;
+    }
+
+    public String getPath(String url) {
+        return getStaticPath(COMMON_FILE) + url;
+    }
+
+    public String getDirectoryName() {
+        return DateUtils.getNowTimeFormat("yyyyMMdd");
+    }
+
+    public String getSavePath(String directoryName) {
+        return getStaticPath(COMMON_FILE) + FILE_SEPARATOR + directoryName + FILE_SEPARATOR;
+    }
+
+    public String createDirectory() {
+        String directoryName = this.getDirectoryName();
+        String savePath = this.getSavePath(directoryName);
+        File directory = new File(savePath);
+        if (!directory.exists()) {
+            directory.mkdir();
+        }
+        return directoryName;
+    }
+
+    public String createRandomDirectory() {
+        String directoryName = IdUtil.simpleUUID();
+        String savePath = this.getSavePath(directoryName);
+        File directory = new File(savePath);
+        if (!directory.exists()) {
+            directory.mkdir();
+        }
+        return directoryName;
+    }
+
+    public static FileInputStream byteToFile(byte[] bytes) {
+        String fileName = IdUtil.simpleUUID() + ".png";
+        File file = new File(fileName);
+        FileInputStream fileInputStream = null;
+        try {
+            OutputStream output = new FileOutputStream(file);
+            BufferedOutputStream bufferedOutput = new BufferedOutputStream(output);
+            bufferedOutput.write(bytes);
+            fileInputStream = new FileInputStream(file);
+            file.deleteOnExit();
+            return fileInputStream;
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return fileInputStream;
+    }
+
+    public String getTempPath(String fileName) {
+        String tempPath = getStaticPath(COMMON_FILE) + FILE_SEPARATOR + "temp";
+        File file = new File(tempPath);
+        if (!file.exists()) {
+            file.mkdir();
+        }
+        return tempPath + FILE_SEPARATOR + fileName;
+    }
+
+    public String getDirectory(String fileName) {
+        return FILE_SEPARATOR + this.createDirectory() + FILE_SEPARATOR + fileName;
+    }
+
+    public String getSystemPath(String url) {
+        return getStaticPath(COMMON_FILE) + FILE_SEPARATOR + url;
+    }
+
+    public static String getSystemPath2(String url) {
+        return getStaticPath(COMMON_FILE) + FILE_SEPARATOR + url;
+    }
+
+    public static void writeFile(String json, String FilePath) {
+
+        try {
+            File file = new File(FilePath);
+
+            // if file doesnt exists, then create it
+            if (!file.exists()) {
+                file.createNewFile();
+            } else {
+                file.delete();
+                file.createNewFile();
+            }
+
+            // true = append file
+            FileWriter fileWritter = new FileWriter(file, false);
+            BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
+            bufferWritter.write(json);
+            bufferWritter.close();
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static File getFileByName(File file, String name) {
+        for (File file1 : file.listFiles()) {
+            if (file1.getName().equals(name)) {
+                return file1;
+            }
+        }
+        return null;
+    }
+
+
+    public static void writeFile(Object object, File file) {
+        String json = JSON.toJSONString(object);
+        try {
+            // if file doesnt exists, then create it
+            if (!file.exists()) {
+                file.createNewFile();
+            } else {
+                file.delete();
+                file.createNewFile();
+            }
+            // true = append file
+            FileWriter fileWritter = new FileWriter(file, false);
+            BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
+            bufferWritter.write(json);
+            bufferWritter.close();
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static File multipartFileToFile(MultipartFile file) throws Exception {
+        File toFile = null;
+        if (file == null || file.equals("") || file.getSize() <= 0) {
+            file = null;
+        } else {
+            InputStream ins = null;
+            ins = file.getInputStream();
+            toFile = new File(file.getOriginalFilename());
+            inputStreamToFile(ins, toFile);
+            ins.close();
+        }
+        return toFile;
+    }
+
+    //获取流文件
+    private static void inputStreamToFile(InputStream ins, File file) {
+        try {
+            OutputStream os = new FileOutputStream(file);
+            int bytesRead = 0;
+            byte[] buffer = new byte[8192];
+            while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
+                os.write(buffer, 0, bytesRead);
+            }
+            os.close();
+            ins.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static File createTempFileByName(String fileName) {
+        // 选择目标目录(这里使用系统临时目录)
+        String tempDir = System.getProperty("java.io.tmpdir");
+
+        // 拼接完整的文件路径
+        File tempFile = new File(tempDir, fileName);
+
+        try {
+            // 尝试创建文件(如果文件已存在,则创建失败并抛出异常)
+            boolean created = tempFile.createNewFile();
+
+            if (created) {
+                // 文件创建成功
+                System.out.println("File created at: " + tempFile.getAbsolutePath());
+
+                // ... 在这里可以对文件进行读写操作 ...
+
+                // 注意:通常你不会希望立即删除这个文件,因为它可能是你需要的临时数据
+                // 但如果你确实想要在某个时刻删除它,可以调用 tempFile.delete()
+            } else {
+                // 文件创建失败(可能已经存在)
+                System.out.println("File already exists: " + tempFile.getAbsolutePath());
+
+                // 处理文件已存在的情况(例如,生成一个新的唯一名称或覆盖现有文件)
+                // 注意:覆盖现有文件可能会导致数据丢失,因此请谨慎操作
+            }
+        } catch (IOException e) {
+            // 处理文件创建过程中的异常(例如,权限问题)
+            e.printStackTrace();
+        }
+        return tempFile;
+    }
+}

+ 33 - 0
src/main/java/cn/cslg/pas/common/utils/FileUtils.java

@@ -303,4 +303,37 @@ public class FileUtils {
             e.printStackTrace();
         }
     }
+
+    public static File createTempFileByName(String fileName) {
+        // 选择目标目录(这里使用系统临时目录)
+        String tempDir = System.getProperty("java.io.tmpdir");
+
+        // 拼接完整的文件路径
+        File tempFile = new File(tempDir, fileName);
+
+        try {
+            // 尝试创建文件(如果文件已存在,则创建失败并抛出异常)
+            boolean created = tempFile.createNewFile();
+
+            if (created) {
+                // 文件创建成功
+                System.out.println("File created at: " + tempFile.getAbsolutePath());
+
+                // ... 在这里可以对文件进行读写操作 ...
+
+                // 注意:通常你不会希望立即删除这个文件,因为它可能是你需要的临时数据
+                // 但如果你确实想要在某个时刻删除它,可以调用 tempFile.delete()
+            } else {
+                // 文件创建失败(可能已经存在)
+                System.out.println("File already exists: " + tempFile.getAbsolutePath());
+
+                // 处理文件已存在的情况(例如,生成一个新的唯一名称或覆盖现有文件)
+                // 注意:覆盖现有文件可能会导致数据丢失,因此请谨慎操作
+            }
+        } catch (IOException e) {
+            // 处理文件创建过程中的异常(例如,权限问题)
+            e.printStackTrace();
+        }
+        return tempFile;
+    }
 }

+ 1 - 1
src/main/java/cn/cslg/pas/common/vo/business/AssoTaskFileVO.java

@@ -25,7 +25,7 @@ public class AssoTaskFileVO {
      */
     private String fileGuid;
 
-    private String fileName;
+    private String originalName;
 
     private String fileType;
 

+ 4 - 4
src/main/java/cn/cslg/pas/controller/projectTask/ExamineController.java

@@ -40,14 +40,14 @@ public class ExamineController {
     @Autowired
     private TaskHandleResultService taskHandleResultService;
 
-    @Operation(summary = "添加挖掘项目开卷审核任务")
+    @Operation(summary = "添加文件审核任务")
     @PostMapping("/addFileExamineTask")
     public Response addFileExamineTask(@RequestBody AddFileExamineTaskDTO addFileExamineTaskDTO) {
         Integer id = projectTaskService.addFileExamineTask(addFileExamineTaskDTO);
         return Response.success(id);
     }
 
-    @Operation(summary = "添加挖掘项目开卷审核任务")
+    @Operation(summary = "获取审核信息")
     @PostMapping("/getExamineMessage")
     public Response getExamineMessage(@RequestBody GetExamineMessageDTO getExamineMessageDTO) throws IOException {
         Integer taskId = getExamineMessageDTO.getTaskId();
@@ -55,14 +55,14 @@ public class ExamineController {
         return Response.success(assoTaskFiles);
     }
 
-    @Operation(summary = "添加挖掘项目开卷审核任务")
+    @Operation(summary = "获取审核历史")
     @PostMapping("/getExamineHistory")
     public Response getExamineHistory(@RequestBody GetExamineHistoryDTO getExamineHistoryDTO) throws IOException {
         List<TaskResultVO> taskResultVOs = projectTaskService.getExamineHistory(getExamineHistoryDTO);
         return Response.success(taskResultVOs);
     }
 
-    @Operation(summary = "添加挖掘项目开卷审核任务")
+    @Operation(summary = "提交结果")
     @PostMapping("/submitResult")
     public Response submitResult(@RequestBody SubmitResultDTO submitResultDTO) throws IOException {
         Integer id = taskHandleResultService.addTaskAuditResult(submitResultDTO);

+ 28 - 2
src/main/java/cn/cslg/pas/service/business/AssoTaskFileService.java

@@ -4,6 +4,7 @@ import cn.cslg.pas.common.dto.business.AssoTaskFileDTO;
 import cn.cslg.pas.common.model.cronModel.Personnel;
 import cn.cslg.pas.common.model.cronModel.PersonnelVO;
 import cn.cslg.pas.common.model.cronModel.SystemFile;
+import cn.cslg.pas.common.model.projectTask.FileDTO;
 import cn.cslg.pas.common.utils.CacheUtils;
 import cn.cslg.pas.common.utils.LoginUtils;
 import cn.cslg.pas.common.vo.business.AssoTaskFileVO;
@@ -104,7 +105,7 @@ public class AssoTaskFileService extends ServiceImpl<AssoTaskFileMapper, AssoTas
                 if (systemFile != null) {
                     BeanUtils.copyProperties(assoTaskFile, assoTaskFileVO);
                     assoTaskFileVO.setFileType(systemFile.getType());
-                    assoTaskFileVO.setFileName(systemFile.getOriginalName());
+                    assoTaskFileVO.setOriginalName(systemFile.getOriginalName());
                     assoTaskFileVOS.add(assoTaskFileVO);
                 }
             }
@@ -162,7 +163,7 @@ public class AssoTaskFileService extends ServiceImpl<AssoTaskFileMapper, AssoTas
     public AssoTaskFile getAssoTaskFileByGuid(String guid) {
         LambdaQueryWrapper<AssoTaskFile> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(AssoTaskFile::getFileGuid, guid);
-        AssoTaskFile assoTaskFile = this.getOne(queryWrapper);
+        AssoTaskFile assoTaskFile = this.getOne(queryWrapper,false);
         if (assoTaskFile == null) {
             throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "文件不存在");
         }
@@ -170,4 +171,29 @@ public class AssoTaskFileService extends ServiceImpl<AssoTaskFileMapper, AssoTas
 
 
     }
+
+    public List<Integer> addTaskFile(List<FileDTO> fileDTOS ,Integer taskId) {
+        if (taskId == null) {
+            throw new XiaoShiException("任务id不能为空");
+        }
+        if (fileDTOS == null || fileDTOS.size()== 0) {
+            throw new XiaoShiException("文件ids不能为空");
+        }
+        //获取登陆人信息 用于设置创建人
+        PersonnelVO personnelVO = new PersonnelVO();
+        personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+
+        List<AssoTaskFile> assoTaskFiles = new ArrayList<>();
+        for (FileDTO item : fileDTOS) {
+            AssoTaskFile assoTaskFile = new AssoTaskFile();
+            assoTaskFile.setRootFileGuid(item.getRootGuid());
+            assoTaskFile.setFileGuid(item.getGuid());
+            assoTaskFile.setTaskId(taskId);
+            assoTaskFile.setCreateId(personnelVO.getId());
+            assoTaskFiles.add(assoTaskFile);
+        }
+        this.saveBatch(assoTaskFiles);
+        List<Integer> ids = assoTaskFiles.stream().map(AssoTaskFile::getId).collect(Collectors.toList());
+        return ids;
+    }
 }

+ 50 - 21
src/main/java/cn/cslg/pas/service/business/ProjectTaskService.java

@@ -31,6 +31,7 @@ import cn.cslg.pas.service.permissions.PermissionService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -134,23 +135,22 @@ public class ProjectTaskService extends ServiceImpl<ProjectTaskMapper, ProjectTa
     public Object addProjectOpenAuditTask(PatentDigProjectTaskDTO patentDigProjectTaskDTO) {
         PatentDigProjectDTO patentDigProjectDTO = patentDigProjectTaskDTO.getPatentDigProjectDTO();
         ProjectTaskDTO projectTaskDTO = patentDigProjectTaskDTO.getProjectTaskDTO();
+        TaskFormDTO taskFormDTO = toTaskFormDTO(projectTaskDTO);
+
         //如果专利挖掘项目DTO不为空,则需要先建立专利挖掘项目
         if (patentDigProjectDTO != null) {
             Integer projectId = (Integer) patentDigProjectService.addMessage(patentDigProjectDTO);
             if (projectId != null) {
                 projectTaskDTO.setProjectId(projectId);
                 projectTaskDTO.setType(1);
-                Integer projectTaskId = this.addTask(projectTaskDTO);
+                ProjectTask projectTask = this.addTaskByTaskFormDTO(taskFormDTO, projectId);
+                Integer projectTaskId = projectTask.getId();
                 if (projectTaskId != null) {
                     //将专利挖掘项目状态置为开卷审核
-                    LambdaQueryWrapper<PatentDigProject> queryWrapper = new LambdaQueryWrapper<>();
+                    LambdaUpdateWrapper<PatentDigProject> queryWrapper = new LambdaUpdateWrapper<>();
                     queryWrapper.eq(PatentDigProject::getProjectId, projectId);
-                    List<PatentDigProject> patentDigProjects = patentDigProjectService.list(queryWrapper);
-                    if (!patentDigProjects.isEmpty()) {
-                        PatentDigProject patentDigProject = patentDigProjects.get(0);
-                        patentDigProject.setState(0);
-                        patentDigProject.updateById();
-                    }
+                    queryWrapper.set(PatentDigProject::getState, 0);
+                    patentDigProjectService.updateMessage(queryWrapper);
                 }
                 return projectTaskId;
             } else {
@@ -969,19 +969,22 @@ public class ProjectTaskService extends ServiceImpl<ProjectTaskMapper, ProjectTa
     public Object addReportOpenAuditTask(ReportAuditTaskDTO reportAuditTaskDTO) {
         ReportProjectDTO reportProjectDTO = reportAuditTaskDTO.getReportProjectDTO();
         ProjectTaskDTO projectTaskDTO = reportAuditTaskDTO.getProjectTaskDTO();
+        TaskFormDTO taskFormDTO = toTaskFormDTO(projectTaskDTO);
+
         //如果报告DTO不为空,则需要先建立报告
         if (reportProjectDTO != null) {
             Integer projectId = (Integer) reportProjectService.addMessage(reportProjectDTO);
             if (projectId != null) {
                 projectTaskDTO.setProjectId(projectId);
-                Integer projectTaskId = this.addTask(projectTaskDTO);
+                ProjectTask projectTask = this.addTaskByTaskFormDTO(taskFormDTO, projectId);
+                Integer projectTaskId = projectTask.getId();
                 if (projectTaskId != null) {
                     //将侵权分析报告置为开卷审核
-                    LambdaQueryWrapper<ReportProject> queryWrapper = new LambdaQueryWrapper<>();
+                    LambdaUpdateWrapper<ReportProject> queryWrapper = new LambdaUpdateWrapper<>();
                     queryWrapper.eq(ReportProject::getProjectId, projectId);
-                    ReportProject reportProject = reportProjectService.getOne(queryWrapper, false);
-                    reportProject.setStatus(0);
-                    reportProject.updateById();
+                    queryWrapper.set(ReportProject::getStatus, 0);
+                    reportProjectService.update(queryWrapper);
+
                 }
                 return projectTaskId;
             } else {
@@ -1365,6 +1368,7 @@ public class ProjectTaskService extends ServiceImpl<ProjectTaskMapper, ProjectTa
         projectTask.setHandler(handleName);
         projectTask.setDeadLineTime(deadLineTime);
         projectTask.setProjectId(projectId);
+        projectTask.setType(taskFormDTO.getTaskType());
         //任务状态置为处理中
         projectTask.setStatus(2);
         //获取登录人信息
@@ -1372,9 +1376,10 @@ public class ProjectTaskService extends ServiceImpl<ProjectTaskMapper, ProjectTa
         personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
         if (lastTaskId != null) {
             ProjectTask projectTask1 = this.getById(lastTaskId);
+            String lastName = projectTask1.getName();
             projectTask.setLastTaskId(lastTaskId);
             projectTask.setProjectId(projectTask1.getProjectId());
-            Integer rootTaskId = projectTask.getAssoTaskId();
+            Integer rootTaskId = projectTask1.getAssoTaskId();
             if (rootTaskId == null) {
                 rootTaskId = projectTask1.getId();
             }
@@ -1385,6 +1390,15 @@ public class ProjectTaskService extends ServiceImpl<ProjectTaskMapper, ProjectTa
             } else {
                 lastPath += "/";
             }
+
+            Integer b = 1;
+            if (!lastPath.equals("")) {
+                String[] a = lastPath.split("/");
+                b = a.length + 1;
+            }
+            String newName = lastName.substring(0, lastName.lastIndexOf("-"));
+            newName = newName + "-" + b + "级审核";
+            projectTask.setName(newName);
             projectTask.setTaskPath(lastPath + projectTask1.getId());
 
         }
@@ -1397,11 +1411,12 @@ public class ProjectTaskService extends ServiceImpl<ProjectTaskMapper, ProjectTa
     public void addProjectTaskFileByFormDTO(FileFormDTO fileFormDTO, Integer taskId) {
         List<FileDTO> fileDTOS = fileFormDTO.getFiles();
         List<String> fileGuids = fileDTOS.stream().map(FileDTO::getGuid).collect(Collectors.toList());
+
         if (fileGuids != null && fileGuids.size() > 0) {
             AssoTaskFileDTO assoTaskFileDTO = new AssoTaskFileDTO();
             assoTaskFileDTO.setTaskId(taskId);
             assoTaskFileDTO.setFileGuids(fileGuids);
-            assoTaskFileService.addTaskFile(assoTaskFileDTO);
+            assoTaskFileService.addTaskFile(fileDTOS, taskId);
         }
     }
 
@@ -1431,7 +1446,7 @@ public class ProjectTaskService extends ServiceImpl<ProjectTaskMapper, ProjectTa
         Integer taskId = getExamineHistoryDTO.getTaskId();
         String fileGuid = getExamineHistoryDTO.getFileGuid();
         String rootGuid = fileGuid;
-        if (fileGuid != null) {
+        if (fileGuid != null && !fileGuid.equals("")) {
             AssoTaskFile assoTaskFile = assoTaskFileService.getAssoTaskFileByGuid(fileGuid);
             if (taskId == null) {
                 taskId = assoTaskFile.getTaskId();
@@ -1448,20 +1463,25 @@ public class ProjectTaskService extends ServiceImpl<ProjectTaskMapper, ProjectTa
         }
 
         LambdaQueryWrapper<ProjectTask> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(ProjectTask::getAssoTaskId, rootTaskId)
+        queryWrapper.eq(ProjectTask::getAssoTaskId, rootTaskId).or().eq(ProjectTask::getId, rootTaskId)
                 .orderByAsc(ProjectTask::getCreateTime);
         List<ProjectTask> projectTasks = this.list(queryWrapper);
         List<Integer> taskIds = projectTasks.stream().map(ProjectTask::getId).collect(Collectors.toList());
 
-
+        if (taskIds == null || taskIds.size() == 0) {
+            return taskDetailsVOs;
+        }
         LambdaQueryWrapper<TaskHandleResult> resultLambdaQueryWrapper = new LambdaQueryWrapper<>();
         resultLambdaQueryWrapper.in(TaskHandleResult::getTaskId, taskIds);
         List<TaskHandleResult> taskHandleResults = taskHandleResultService.list(resultLambdaQueryWrapper);
 
         List<Integer> resultIds = taskHandleResults.stream().map(TaskHandleResult::getId).collect(Collectors.toList());
+        if (resultIds == null || resultIds.size() == 0) {
+            return taskDetailsVOs;
+        }
         LambdaQueryWrapper<AssoHandleResultFile> resultFileWrapper = new LambdaQueryWrapper<>();
         resultFileWrapper.in(AssoHandleResultFile::getTaskHandleResultId, resultIds);
-        if (fileGuid != null) {
+        if (fileGuid != null && !fileGuid.equals("")) {
             resultFileWrapper.eq(AssoHandleResultFile::getRootFileGuid, rootGuid);
         }
         List<AssoHandleResultFile> resultFiles = assoHandleResultFileService.list(resultFileWrapper);
@@ -1480,9 +1500,8 @@ public class ProjectTaskService extends ServiceImpl<ProjectTaskMapper, ProjectTa
             if (temGuids != null && temGuids.size() > 0) {
                 List<SystemFile> systemFileList = systemFiles.stream().filter(item -> temGuids.contains(item.getGuid())).collect(Collectors.toList());
                 taskResultVO.setFiles(systemFileList);
-                taskDetailsVOs.add(taskResultVO);
             }
-
+            taskDetailsVOs.add(taskResultVO);
         }
         //装载名称
         this.loadTaskResultVos(taskDetailsVOs);
@@ -1519,4 +1538,14 @@ public class ProjectTaskService extends ServiceImpl<ProjectTaskMapper, ProjectTa
         return;
     }
 
+    public TaskFormDTO toTaskFormDTO(ProjectTaskDTO projectTaskDTO) {
+        TaskFormDTO taskFormDTO = new TaskFormDTO();
+        taskFormDTO.setTaskType(1);
+        taskFormDTO.setHandlerType(projectTaskDTO.getHandlerType());
+        taskFormDTO.setHandler(projectTaskDTO.getHandler());
+        taskFormDTO.setDeadLineTime(projectTaskDTO.getDeadLineTime());
+        taskFormDTO.setName(projectTaskDTO.getName());
+        taskFormDTO.setDescription(projectTaskDTO.getDescription());
+        return taskFormDTO;
+    }
 }

+ 55 - 23
src/main/java/cn/cslg/pas/service/business/TaskHandleResultService.java

@@ -17,6 +17,8 @@ import cn.cslg.pas.mapper.TaskHandleResultMapper;
 import cn.cslg.pas.service.common.FileManagerService;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.BeanUtils;
@@ -249,18 +251,13 @@ public class TaskHandleResultService extends ServiceImpl<TaskHandleResultMapper,
         return getHandleResultFileVO;
     }
 
-    @Transactional(rollbackFor = Exception.class)
-    public Integer addTaskAuditResult(SubmitResultDTO submitResultDTO) throws IOException {
-        Integer taskId = submitResultDTO.getTaskId();
-        Integer projectId = submitResultDTO.getProjectId();
+    public TaskHandleResult addResult(SubmitResultDTO submitResultDTO) {
         Integer handlerType = submitResultDTO.getHandlerType();
-        String handler = submitResultDTO.getHandler();
-        Date deadLineTime =submitResultDTO.getDeadLineTime();
-        List<String> extraFiles = submitResultDTO.getFiles();
-        Integer createId = loginUtils.getId();
         PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
         TaskHandleResult taskHandleResult = new TaskHandleResult();
         BeanUtils.copyProperties(submitResultDTO, taskHandleResult);
+        taskHandleResult.setNextAuditor(submitResultDTO.getHandler());
+        taskHandleResult.setHandleResult(submitResultDTO.getResult());
         if (handlerType != null && handlerType.equals(0)) {
             taskHandleResult.setIfInner(true);
         } else {
@@ -269,6 +266,19 @@ public class TaskHandleResultService extends ServiceImpl<TaskHandleResultMapper,
         taskHandleResult.setCreateId(personnelVO.getId());
         //任务处理结果入库
         taskHandleResult.insert();
+        return  taskHandleResult;
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public Integer addTaskAuditResult(SubmitResultDTO submitResultDTO) throws IOException {
+        Integer taskId = submitResultDTO.getTaskId();
+        Integer handlerType = submitResultDTO.getHandlerType();
+
+        String handler = submitResultDTO.getHandler();
+        Date deadLineTime = submitResultDTO.getDeadLineTime();
+        List<String> extraFiles = submitResultDTO.getFiles();
+        Integer createId = loginUtils.getId();
+        TaskHandleResult taskHandleResult = this.addResult(submitResultDTO);
         Integer resultId = taskHandleResult.getId();
         //根据taskId 查询待审核文件
         List<AssoTaskFile> assoTaskFiles = new ArrayList<>();
@@ -277,12 +287,13 @@ public class TaskHandleResultService extends ServiceImpl<TaskHandleResultMapper,
         assoTaskFiles = assoTaskFileService.list(taskFileQueryWrapper);
         List<AssoHandleResultFile> assoHandleResultFiles = new ArrayList<>();
         List<File> files = new ArrayList<>();
+        List<FileDTO> fileDTOS = new ArrayList<>();
         for (AssoTaskFile assoTaskFile : assoTaskFiles) {
             String rootFileGuid = assoTaskFile.getRootFileGuid();
             if (rootFileGuid == null) {
                 rootFileGuid = assoTaskFile.getFileGuid();
             }
-            File file = fileManagerService.getTempFileByGuid(assoTaskFile.getFileGuid());
+            File file = fileManagerService.getOrgTempFileByGuid(assoTaskFile.getFileGuid());
             files.add(file);
             List<String> guids = fileManagerService.uploadFileGetGuid2(Arrays.asList(file));
             if (guids != null && guids.size() > 0) {
@@ -290,9 +301,20 @@ public class TaskHandleResultService extends ServiceImpl<TaskHandleResultMapper,
                 assoHandleResultFile.setRootFileGuid(rootFileGuid);
                 assoHandleResultFile.setFileGuid(guids.get(0));
                 assoHandleResultFile.setTaskHandleResultId(resultId);
-                assoHandleResultFiles.add(assoHandleResultFile);
                 assoHandleResultFile.setCreateId(createId + "");
+                assoHandleResultFiles.add(assoHandleResultFile);
+
+            }
+            if (handler != null) {
+                List<String> guid2s = fileManagerService.uploadFileGetGuid2(Arrays.asList(file));
+                if (guid2s != null && guid2s.size() > 0) {
+                    FileDTO fileDTO = new FileDTO();
+                    fileDTO.setGuid(guid2s.get(0));
+                    fileDTO.setRootGuid(rootFileGuid);
+                    fileDTOS.add(fileDTO);
+                }
             }
+
         }
         if (extraFiles != null && extraFiles.size() > 0) {
             extraFiles.forEach(item -> {
@@ -301,31 +323,41 @@ public class TaskHandleResultService extends ServiceImpl<TaskHandleResultMapper,
                 assoHandleResultFile.setTaskHandleResultId(resultId);
                 assoHandleResultFile.setCreateId(createId + "");
                 assoHandleResultFiles.add(assoHandleResultFile);
+                if (handler != null) {
+                    try {
+                        File file = fileManagerService.getOrgTempFileByGuid(item);
+                        List<String> guids = fileManagerService.uploadFileGetGuid2(Arrays.asList(file));
+                        if (guids != null && guids.size() > 0) {
+                            FileDTO fileDTO = new FileDTO();
+                            fileDTO.setGuid(guids.get(0));
+                            fileDTOS.add(fileDTO);
+                        }
+                    } catch (Exception e) {
+                    }
+                }
             });
         }
-        assoHandleResultFileService.saveBatch(assoHandleResultFiles);
+        if (assoHandleResultFiles.size() > 0) {
+            assoHandleResultFileService.saveBatch(assoHandleResultFiles);
+        }
 
         if (handler != null) {
-         List<String> guids=   fileManagerService.uploadFileGetGuid2(files);
-            FileFormDTO fileFormDTO =new FileFormDTO();
-            List<FileDTO> fileDTOS =new ArrayList<>();
-
-            guids.forEach(item->{
-                FileDTO fileDTO =new FileDTO();
-                fileDTO.setGuid(item);
-                fileDTOS.add(fileDTO);
-            });
+            FileFormDTO fileFormDTO = new FileFormDTO();
             fileFormDTO.setFiles(fileDTOS);
-            TaskFormDTO taskFormDTO =new TaskFormDTO();
+            TaskFormDTO taskFormDTO = new TaskFormDTO();
             taskFormDTO.setLastTaskId(taskId);
             taskFormDTO.setHandler(handler);
             taskFormDTO.setHandlerType(handlerType);
             taskFormDTO.setDeadLineTime(deadLineTime);
-            AddFileExamineTaskDTO addFileExamineTaskDTO =new AddFileExamineTaskDTO();
+            AddFileExamineTaskDTO addFileExamineTaskDTO = new AddFileExamineTaskDTO();
             addFileExamineTaskDTO.setTaskForm(taskFormDTO);
             addFileExamineTaskDTO.setFileForm(fileFormDTO);
-           projectTaskService.addFileExamineTask(addFileExamineTaskDTO);
+            projectTaskService.addFileExamineTask(addFileExamineTaskDTO);
         }
+        LambdaUpdateWrapper<ProjectTask> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.eq(ProjectTask::getId, taskId);
+        updateWrapper.set(ProjectTask::getStatus, 3);
+        projectTaskService.update(updateWrapper);
         return taskHandleResult.getId();
     }
 }

+ 19 - 0
src/main/java/cn/cslg/pas/service/common/FileManagerService.java

@@ -2,6 +2,7 @@ package cn.cslg.pas.service.common;
 
 import cn.cslg.pas.common.dto.FMSDeleteFileDTO;
 import cn.cslg.pas.common.model.cronModel.SystemFile;
+import cn.cslg.pas.common.utils.CustomizeFileUtils;
 import cn.hutool.core.io.FileUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -249,4 +250,22 @@ public class FileManagerService {
         }
         return  tempFile;
     }
+    public  File getOrgTempFileByGuid(String guid)throws IOException{
+        String res = this.getSystemFileFromFMS(Arrays.asList(guid));
+        List<SystemFile> systemFiles = JSONArray.parseArray(res, SystemFile.class);
+        SystemFile systemFile = systemFiles.get(0);
+        String suffix = systemFile.getFileName().substring(systemFile.getFileName().lastIndexOf("."));
+        //调用文件系统取出文件接口,获得文件流
+        byte[] bytes = this.downloadSystemFileFromFMS(guid);
+        //创建临时文件tempFile,并将文件读取到tempFile
+
+        File tempFile = CustomizeFileUtils.createTempFileByName(systemFile.getOriginalName());
+        try (
+                InputStream inputStream = new ByteArrayInputStream(bytes);
+                FileOutputStream outputStream = new FileOutputStream(tempFile);
+        ) {
+            IOUtils.copy(inputStream, outputStream); // 将输入流复制到临时文件
+        }
+        return  tempFile;
+    }
 }