From c77cab7ca85f219df136ec2aac24a22efa7837f8 Mon Sep 17 00:00:00 2001
From: luohairen <3399054449@qq.com>
Date: 星期五, 29 十一月 2024 02:38:46 +0800
Subject: [PATCH] 项目计划审批

---
 business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java |   54 +++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java b/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
index 1cddb79..05a25e8 100644
--- a/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
+++ b/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
@@ -8,6 +8,7 @@
 import com.ycl.common.utils.SecurityUtils;
 import com.ycl.domain.entity.File;
 import com.ycl.domain.entity.ProjectInfo;
+import com.ycl.domain.form.DocumentInfoForm;
 import com.ycl.domain.form.ProjectInfoForm;
 import com.ycl.domain.query.ProjectInfoQuery;
 import com.ycl.domain.vo.*;
@@ -22,10 +23,7 @@
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.Assert;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -81,7 +79,8 @@
         ProjectInfoForm.getEntityByForm(form,entity);
         Long userId = SecurityUtils.getUserId();
         entity.setUpdateBy(userId);
-
+        //鏇存柊椤圭洰淇℃伅
+        baseMapper.updateById(entity);
         List<File> fileList = form.getFileList();
         fileList.forEach(item->{
             item.setBusId(entity.getId());
@@ -94,8 +93,6 @@
         fileMapper.delete(fileQueryWrapper);
         //鏇挎崲鎴愮幇鏈�
         fileService.saveBatch(fileList);
-        //鏇存柊椤圭洰淇℃伅
-        baseMapper.updateById(entity);
         return Result.ok("淇敼鎴愬姛");
     }
 
@@ -211,4 +208,47 @@
         map.put("processExceptionProject", 0);
         return map;
     }
+
+    @Override
+    public Result docDetail(Integer id) {
+        DocumentInfoForm documentInfoForm = new DocumentInfoForm();
+        QueryWrapper<File> fileQueryWrapper = new QueryWrapper<>();
+        fileQueryWrapper.eq("type",FileTypeEnum.DOCUMENT_INFO.getType());
+        fileQueryWrapper.eq("bus_id",id);
+        List<File> files = fileMapper.selectList(fileQueryWrapper);
+        documentInfoForm.setFileList(files);
+        return Result.ok().data(documentInfoForm);
+    }
+
+    @Override
+    public Result addDoc(DocumentInfoForm form) {
+        List<File> fileList = form.getFileList();
+        fileList.forEach(item->{
+            item.setBusId(form.getProjectId());
+            item.setType(FileTypeEnum.DOCUMENT_INFO);
+        });
+        //鍒犻櫎鍘熸湁鏂囦欢
+        QueryWrapper<File> fileQueryWrapper = new QueryWrapper<>();
+        fileQueryWrapper.eq("type",FileTypeEnum.DOCUMENT_INFO.getType());
+        fileQueryWrapper.eq("bus_id",form.getProjectId());
+        fileMapper.delete(fileQueryWrapper);
+        //鏇挎崲鎴愮幇鏈�
+        fileService.saveBatch(fileList);
+        return Result.ok();
+    }
+
+    @Override
+    public Result getManagerFlag(Integer recordId) {
+        ProjectInfo projectInfo = baseMapper.selectById(recordId);
+        // 鍒ゆ柇褰撳墠鐢ㄦ埛id鏄惁鍦ㄤ富绠″垪琛ㄤ腑
+        String competentDepartment = projectInfo.getCompetentDepartment();
+        List<String> list = Arrays.asList(competentDepartment.split(","));
+        // 鑾峰緱褰撳墠鐢ㄦ埛id
+        Long userId = SecurityUtils.getUserId();
+        if (list.contains(userId.toString())) {
+            return Result.ok().data(true);
+        } else {
+            return Result.ok().data(false);
+        }
+    }
 }

--
Gitblit v1.8.0