From 41e0caedb42b1220f7c89cea43c127985c0c2fb3 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期三, 18 六月 2025 15:01:23 +0800
Subject: [PATCH] bug修改

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TProjectTeamController.java |   52 ++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TProjectTeamController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TProjectTeamController.java
index df95aac..e32e42e 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TProjectTeamController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TProjectTeamController.java
@@ -7,12 +7,12 @@
 import com.ruoyi.common.basic.PageInfo;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.core.exception.ServiceException;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.system.dto.TProjectTeamDTO;
 import com.ruoyi.system.dto.UpAndDownDTO;
 import com.ruoyi.system.model.TProjectTeam;
 import com.ruoyi.system.model.TProjectTeamStaff;
-import com.ruoyi.system.query.TProjectProposalQuery;
 import com.ruoyi.system.query.TProjectTeamQuery;
 import com.ruoyi.system.service.ISysUserService;
 import com.ruoyi.system.service.TProjectTeamService;
@@ -22,8 +22,6 @@
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -54,7 +52,7 @@
     /**
      * 获取项目组管理列表
      */
-    @PreAuthorize("@ss.hasPermi('system:projectTeam:list')")
+    //@PreAuthorize("@ss.hasPermi('system:projectTeam:list')")
     @ApiOperation(value = "获取项目组分页列表",response = TProjectTeamQuery.class)
     @PostMapping(value = "/api/t-project-team/pageList")
     public R<PageInfo<TProjectTeamVO>> pageList(@RequestBody String param) {
@@ -66,15 +64,28 @@
     /**
      * 添加项目组管理
      */
-    @PreAuthorize("@ss.hasPermi('system:projectTeam:add')")
+    //@PreAuthorize("@ss.hasPermi('system:projectTeam:add')")
     @Log(title = "项目组信息-新增项目组", businessType = BusinessType.INSERT)
     @ApiOperation(value = "添加项目组",response = TProjectTeamDTO.class)
     @PostMapping(value = "/api/t-project-team/add")
     public R<Boolean> add(@RequestBody String param) {
         TProjectTeamDTO dto = JSON.parseObject(param,TProjectTeamDTO.class);
+        List<TProjectTeamStaff> staffs = dto.getStaffs();
+        // 判断工艺工程师是否存在其他项目组中
+        staffs.stream().filter(staff -> staff.getRoleType() == 3).forEach(staff -> {
+            long count = projectTeamStaffService.count(Wrappers.lambdaQuery(TProjectTeamStaff.class).eq(TProjectTeamStaff::getUserId, staff.getUserId()));
+            if(count > 0){
+                throw new ServiceException("该工艺工程师已存在项目组");
+            }
+        });
+        staffs.stream().filter(staff -> staff.getRoleType() == 2).forEach(staff -> {
+            long count = projectTeamStaffService.count(Wrappers.lambdaQuery(TProjectTeamStaff.class).eq(TProjectTeamStaff::getUserId, staff.getUserId()));
+            if(count > 0){
+                throw new ServiceException("该审批人已存在项目组");
+            }
+        });
         projectTeamService.save(dto);
         // 保存项目组成员
-        List<TProjectTeamStaff> staffs = dto.getStaffs();
         for (TProjectTeamStaff staff : staffs) {
             staff.setTeamId(dto.getId());
         }
@@ -85,17 +96,34 @@
     /**
      * 修改项目组
      */
-    @PreAuthorize("@ss.hasPermi('system:projectTeam:edit')")
+    //@PreAuthorize("@ss.hasPermi('system:projectTeam:edit')")
     @Log(title = "项目组信息-修改项目组", businessType = BusinessType.UPDATE)
     @ApiOperation(value = "修改项目组")
     @PostMapping(value = "/api/t-project-team/update")
     public R<Boolean> update(@RequestBody String param) {
         TProjectTeamDTO dto = JSON.parseObject(param,TProjectTeamDTO.class);
+        List<TProjectTeamStaff> staffs = dto.getStaffs();
+        // 判断工艺工程师是否存在其他项目组中
+        staffs.stream().filter(staff -> staff.getRoleType() == 3).forEach(staff -> {
+            long count = projectTeamStaffService.count(Wrappers.lambdaQuery(TProjectTeamStaff.class)
+                    .ne(TProjectTeamStaff::getTeamId, dto.getId())
+                    .eq(TProjectTeamStaff::getUserId, staff.getUserId()));
+            if(count > 0){
+                throw new ServiceException("该工艺工程师已存在项目组");
+            }
+        });
+        staffs.stream().filter(staff -> staff.getRoleType() == 2).forEach(staff -> {
+            long count = projectTeamStaffService.count(Wrappers.lambdaQuery(TProjectTeamStaff.class)
+                    .ne(TProjectTeamStaff::getTeamId, dto.getId())
+                    .eq(TProjectTeamStaff::getUserId, staff.getUserId()));
+            if(count > 0){
+                throw new ServiceException("该工艺工程师已存在项目组");
+            }
+        });
         projectTeamService.updateById(dto);
         // 删除项目组成员
         projectTeamStaffService.remove(Wrappers.lambdaQuery(TProjectTeamStaff.class).eq(TProjectTeamStaff::getTeamId, dto.getId()));
         // 保存项目组成员
-        List<TProjectTeamStaff> staffs = dto.getStaffs();
         for (TProjectTeamStaff staff : staffs) {
             staff.setTeamId(dto.getId());
         }
@@ -106,7 +134,7 @@
     /**
      * 查看项目组详情
      */
-    @PreAuthorize("@ss.hasPermi('system:projectTeam:detail')")
+    //@PreAuthorize("@ss.hasPermi('system:projectTeam:detail')")
     @ApiOperation(value = "查看项目组详情")
     @GetMapping(value = "/open/t-project-team/getDetailById")
     public R<TProjectTeamVO> getDetailById(@RequestParam String id) {
@@ -130,7 +158,7 @@
     /**
      * 删除项目组
      */
-    @PreAuthorize("@ss.hasPermi('system:projectTeam:delete')")
+    //@PreAuthorize("@ss.hasPermi('system:projectTeam:delete')")
     @Log(title = "项目组信息-删除项目组", businessType = BusinessType.DELETE)
     @ApiOperation(value = "删除项目组")
     @DeleteMapping(value = "/open/t-project-team/deleteById")
@@ -143,7 +171,7 @@
     /**
      * 批量删除项目组
      */
-    @PreAuthorize("@ss.hasPermi('system:projectTeam:delete')")
+    //@PreAuthorize("@ss.hasPermi('system:projectTeam:delete')")
     @Log(title = "项目组信息-删除项目组", businessType = BusinessType.DELETE)
     @ApiOperation(value = "批量删除项目组")
     @DeleteMapping(value = "/open/t-project-team/deleteByIds")
@@ -156,7 +184,7 @@
     /**
      * 修改项目组
      */
-    @PreAuthorize("@ss.hasPermi('system:projectTeam:upAndDown')")
+    //@PreAuthorize("@ss.hasPermi('system:projectTeam:upAndDown')")
     @Log(title = "项目组信息-修改项目组状态", businessType = BusinessType.UPDATE)
     @ApiOperation(value = "修改项目组状态",response = UpAndDownDTO.class)
     @PostMapping(value = "/api/t-project-team/upAndDown")

--
Gitblit v1.7.1