| | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gkhy.common.enums.DeleteFlagEnum; |
| | | import com.gkhy.common.exception.ServiceException; |
| | | import com.gkhy.common.utils.DateUtils; |
| | | import com.gkhy.common.utils.SecurityUtils; |
| | |
| | | import com.gkhy.system.mapper.ProjectExpertMapper; |
| | | import com.gkhy.system.mapper.ProjectFileMapper; |
| | | import com.gkhy.system.mapper.ProjectManagementMapper; |
| | | import com.gkhy.system.service.IProjectFileService; |
| | | import com.gkhy.system.service.IProjectManagementService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Autowired |
| | | private ProjectExpertDetailMapper projectExpertDetailMapper; |
| | | |
| | | @Autowired |
| | | private IProjectFileService projectFileService; |
| | | |
| | | /** |
| | | * 查询项目管理 |
| | | * |
| | |
| | | */ |
| | | @Override |
| | | public List<ProjectManagement> selectProjectManagementList(ProjectManagement projectManagement) { |
| | | if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ |
| | | projectManagement.setDeptId(SecurityUtils.getDeptId()); |
| | | } |
| | | return projectManagementMapper.selectProjectManagementList(projectManagement); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public Long insertProjectManagement(ProjectManageSaveReq projectManagement) { |
| | | ProjectManagement projectManagementSave = new ProjectManagement(); |
| | | |
| | | projectManagementSave.setDelFlag(0L); |
| | | if (SecurityUtils.isAdmin(SecurityUtils.getUserId())){ |
| | | throw new ServiceException("无权新增"); |
| | | } |
| | | projectManagementSave.setDelFlag(DeleteFlagEnum.UN_DELETE.getCode()); |
| | | BeanUtil.copyProperties(projectManagement, projectManagementSave); |
| | | if (projectManagement.getId() != null){ |
| | | checkDataPer(projectManagement.getId()); |
| | |
| | | projectManagementSave.setUpdateBy(SecurityUtils.getUsername()); |
| | | projectManagementSave.setUpdateTime(DateUtils.getNowDate()); |
| | | projectManagementSave.setId(projectManagement.getId()); |
| | | if (projectManagement1.getState() != 1 && projectManagement1.getState() != 0){ |
| | | if (projectManagement1.getState() != 1 && projectManagement1.getState() != 0 ){ |
| | | throw new ServiceException("该步骤不可操作专家数据!"); |
| | | } |
| | | |
| | |
| | | if (hasDuplicateExpertId(saveData)){ |
| | | throw new ServiceException("专家重复!"); |
| | | } |
| | | long count = saveData.stream() |
| | | .filter(dto -> dto.getSelectionMode() == 1) |
| | | .count(); |
| | | if (count < 1){ |
| | | throw new ServiceException("固定专家不能为空!"); |
| | | } |
| | | // long count = saveData.stream() |
| | | // .filter(dto -> dto.getSelectionMode() == 1) |
| | | // .count(); |
| | | // if (count < 1){ |
| | | // throw new ServiceException("固定专家不能为空!"); |
| | | // } |
| | | |
| | | if (projectManagement1.getStep() == 1 || projectManagement1.getStep() == 2){ |
| | | if ((projectManagement1.getStep() == 1 || projectManagement1.getStep() == 2) && (projectManagement.getStep() == 2 ) ){ |
| | | projectManagementSave.setStep(2L); |
| | | projectManagementSave.setState(1L); |
| | | }else if (projectManagement1.getStep() == 3){ |
| | | projectManagementSave.setStep(3L); |
| | | }else if (projectManagement1.getStep() == 2 && projectManagement.getStep() == 3){ |
| | | projectManagementSave.setStep(2L); |
| | | projectManagementSave.setState(2L); |
| | | projectManagementSave.setProjectCheckTime(new Date()); |
| | | List<ProjectExpertSaveReqDto> collect = saveData.stream() |
| | |
| | | throw new ServiceException("保存专家失败!"); |
| | | } |
| | | } |
| | | |
| | | int i = projectManagementMapper.updateProjectManagement(projectManagementSave); |
| | | if (i < 1){ |
| | | throw new ServiceException("保存专家失败!"); |
| | |
| | | .collect(Collectors.groupingBy(ProjectExpertSaveReqDto::getExpertId, Collectors.counting())); |
| | | |
| | | // 检查是否有任何 expertId 的频率大于 1 |
| | | boolean hasDuplicates = frequencyMap.values().stream().anyMatch(count -> count > 1); |
| | | |
| | | if (hasDuplicates) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | return frequencyMap.values().stream().anyMatch(count -> count > 1); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public int deleteProjectManagementByIds(Long[] ids) { |
| | | //todo 校验 |
| | | // 校验 |
| | | for (Long id : ids) { |
| | | checkDataPer(id); |
| | | } |
| | |
| | | if (req.getState() != 3L && req.getState() != 1 ){ |
| | | throw new ServiceException("参数异常!"); |
| | | } |
| | | if (projectManagement.getStep() != 3){ |
| | | throw new ServiceException("非审批步骤!"); |
| | | } |
| | | Long state = projectManagement.getState(); |
| | | if (req.getState() == 3 && state != 2){ |
| | | if (state != 2){ |
| | | throw new ServiceException("未生成审批单不可审批通过操作!"); |
| | | }else if (req.getState() == 1 && state != 2){ |
| | | throw new ServiceException("不可操作!"); |
| | | } |
| | | |
| | | List<ProjectFile> projectFile = req.getProjectFile(); |
| | |
| | | projectManagementUp.setState(req.getState()); |
| | | projectManagementUp.setUpdateBy(SecurityUtils.getUsername()); |
| | | if (req.getState() == 3){ |
| | | projectManagementUp.setStep(4L); |
| | | projectManagementUp.setStep(3L); |
| | | }else if (req.getState() == 1){ |
| | | projectManagementUp.setStep(2L); |
| | | } |
| | |
| | | file.setCreateBy(username); |
| | | file.setProjectId(req.getId()); |
| | | }); |
| | | int i1 = projectFileMapper.insertProjectFiles(projectFile); |
| | | if (i1 < 1){ |
| | | //int i1 = projectFileMapper.insertProjectFiles(projectFile); |
| | | Boolean b = projectFileService.saveBatchProjectFile(projectFile); |
| | | if (!b){ |
| | | throw new ServiceException("保存附件失败!"); |
| | | } |
| | | } |
| | |
| | | ProjectManagement projectManagementUp = new ProjectManagement(); |
| | | projectManagementUp.setId(req.getId()); |
| | | projectManagementUp.setState(4L); |
| | | projectManagementUp.setStep(4L); |
| | | projectManagementUp.setDesc(req.getDesc()); |
| | | projectManagementUp.setProjectEndTime(req.getProjectEndTime()); |
| | | projectManagementUp.setUpdateBy(SecurityUtils.getUsername()); |
| | |
| | | file.setCreateBy(username); |
| | | file.setProjectId(req.getId()); |
| | | }); |
| | | int i1 = projectFileMapper.insertProjectFiles(projectFile); |
| | | if (i1 < 1){ |
| | | // int i1 = projectFileMapper.insertProjectFiles(projectFile); |
| | | // if (i1 < 1){ |
| | | // throw new ServiceException("保存附件失败!"); |
| | | // } |
| | | Boolean b = projectFileService.saveBatchProjectFile(projectFile); |
| | | if (!b){ |
| | | throw new ServiceException("保存附件失败!"); |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | public List<ProjectExpertStateResp> getProjectExpertSate(ProjectExpertStateReq req) { |
| | | |
| | | if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ |
| | | req.setDeptId(SecurityUtils.getDeptId()); |
| | | } |
| | | return projectManagementMapper.getProjectExpertSate(req); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public List<ProjectExpertResp> projectExpertEvaList(SysProjectExpertReq req) { |
| | | if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ |
| | | req.setDeptId(SecurityUtils.getDeptId()); |
| | | } |
| | | return projectExpertMapper.projectExpertEvaList(req); |
| | | } |
| | | |
| | |
| | | if (!StringUtils.isEmpty(dataNum)){ |
| | | Map<Integer, Long> statusCounts = dataNum.stream() |
| | | .collect(Collectors.groupingBy( |
| | | status -> status, // 分组键 |
| | | Collectors.counting() // 计数 |
| | | status -> status, |
| | | Collectors.counting() |
| | | )); |
| | | projectNumResp.setTotal(dataNum.size()); |
| | | projectNumResp.setApproval(statusCounts.get(3) == null ? 0 : statusCounts.get(3).intValue()); |