| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | @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()); |
| | | } |
| | |
| | | @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()); |
| | | } |