From 686bd303ddc68db338fe352c38392194217168a5 Mon Sep 17 00:00:00 2001 From: heheng <475597332@qq.com> Date: 星期二, 11 三月 2025 15:27:59 +0800 Subject: [PATCH] 修改业务逻辑增加项目编码 --- expert-system/src/main/java/com/gkhy/system/service/impl/ProjectManagementServiceImpl.java | 137 +++++++++++++++++++++++++++++++++++---------- 1 files changed, 105 insertions(+), 32 deletions(-) diff --git a/expert-system/src/main/java/com/gkhy/system/service/impl/ProjectManagementServiceImpl.java b/expert-system/src/main/java/com/gkhy/system/service/impl/ProjectManagementServiceImpl.java index 1d331e4..0cc440c 100644 --- a/expert-system/src/main/java/com/gkhy/system/service/impl/ProjectManagementServiceImpl.java +++ b/expert-system/src/main/java/com/gkhy/system/service/impl/ProjectManagementServiceImpl.java @@ -3,20 +3,16 @@ 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.common.utils.StringUtils; -import com.gkhy.system.domain.ProjectExpert; -import com.gkhy.system.domain.ProjectExpertDetail; -import com.gkhy.system.domain.ProjectFile; -import com.gkhy.system.domain.ProjectManagement; +import com.gkhy.common.utils.uuid.RandomStringGenerator; +import com.gkhy.system.domain.*; import com.gkhy.system.domain.vo.request.*; import com.gkhy.system.domain.vo.response.*; -import com.gkhy.system.mapper.ProjectExpertDetailMapper; -import com.gkhy.system.mapper.ProjectExpertMapper; -import com.gkhy.system.mapper.ProjectFileMapper; -import com.gkhy.system.mapper.ProjectManagementMapper; +import com.gkhy.system.mapper.*; import com.gkhy.system.service.IProjectFileService; import com.gkhy.system.service.IProjectManagementService; import org.springframework.beans.factory.annotation.Autowired; @@ -48,6 +44,8 @@ @Autowired private IProjectFileService projectFileService; + @Autowired + private SysExpertInfoMapper sysExpertInfoMapper; /** * 查询项目管理 @@ -68,6 +66,9 @@ */ @Override public List<ProjectManagement> selectProjectManagementList(ProjectManagement projectManagement) { + if (!SecurityUtils.isAdmin(SecurityUtils.getUserId()) && SecurityUtils.getUserId() != 130L){ + projectManagement.setDeptId(SecurityUtils.getDeptId()); + } return projectManagementMapper.selectProjectManagementList(projectManagement); } @@ -80,20 +81,25 @@ @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()); - projectManagementMapper.updateProjectManagement(projectManagementSave); + // projectManagementMapper.updateProjectManagement(projectManagementSave); + updateById(projectManagementSave); }else { + projectManagementSave.setProjectCode(RandomStringGenerator.generateRandomString(10)); projectManagementSave.setStep(1L); projectManagementSave.setCreateBy(SecurityUtils.getUsername()); projectManagementSave.setCreateTime(DateUtils.getNowDate()); - projectManagementMapper.insertProjectManagement(projectManagementSave); + save(projectManagementSave); + // projectManagementMapper.insertProjectManagement(projectManagementSave); } @@ -127,12 +133,12 @@ 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) && (projectManagement.getStep() == 2 ) ){ projectManagementSave.setStep(2L); @@ -222,13 +228,7 @@ .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); } /** @@ -239,10 +239,13 @@ */ @Override public int deleteProjectManagementByIds(Long[] ids) { - //todo 校验 + // 校验 for (Long id : ids) { - checkDataPer(id); + checkDelData(id); } +// if (!SecurityUtils.isAdmin(SecurityUtils.getUserId()) ){ +// throw new ServiceException("无权操作!"); +// } return projectManagementMapper.deleteProjectManagementByIds(ids); } @@ -319,7 +322,7 @@ projectManagementUp.setId(req.getId()); projectManagementUp.setState(4L); projectManagementUp.setStep(4L); - projectManagementUp.setDesc(req.getDesc()); +// projectManagementUp.setDesc(req.getDesc()); projectManagementUp.setProjectEndTime(req.getProjectEndTime()); projectManagementUp.setUpdateBy(SecurityUtils.getUsername()); int i = projectManagementMapper.updateProjectManagement(projectManagementUp); @@ -343,6 +346,10 @@ @Override public List<ProjectExpertStateResp> getProjectExpertSate(ProjectExpertStateReq req) { + + if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ + req.setDeptId(SecurityUtils.getDeptId()); + } return projectManagementMapper.getProjectExpertSate(req); } @@ -372,9 +379,10 @@ //更新项目专家表 ProjectExpert projectExpert = new ProjectExpert(); + BeanUtil.copyProperties(req, projectExpert); projectExpert.setId(req.getProjectExpertId()); projectExpert.setScore(req.getScore()); - projectExpert.setevaluationState(1L); + projectExpert.setEvaluationState(1L); int i = projectExpertMapper.updateProjectExpert(projectExpert); if (i < 1){ throw new ServiceException("保存失败!"); @@ -421,6 +429,9 @@ @Override public List<ProjectExpertResp> projectExpertEvaList(SysProjectExpertReq req) { + if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ + req.setDeptId(SecurityUtils.getDeptId()); + } return projectExpertMapper.projectExpertEvaList(req); } @@ -450,8 +461,8 @@ 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()); @@ -460,6 +471,55 @@ projectNumResp.setEnd(statusCounts.get(4) == null ? 0:statusCounts.get(4).intValue()); } return projectNumResp; + } + + @Override + public ProjectDetailResp selectProjectExpertDetail(Long projectExpertId) { + ProjectDetailResp projectDetailResp = new ProjectDetailResp(); + ProjectExpert projectExpert = projectExpertMapper.selectProjectExpertById(projectExpertId); + BeanUtil.copyProperties(projectExpert, projectDetailResp); + if (projectDetailResp != null){ + ProjectExpertDetail projectExpertDetail = new ProjectExpertDetail(); + projectExpertDetail.setProjectExpertId(projectExpertId); + List<ProjectExpertDetail> projectExpertDetails = projectExpertDetailMapper.selectProjectExpertDetailList(projectExpertDetail); + if (StringUtils.isNotEmpty(projectExpertDetails)){ + projectDetailResp.setExpertDetails(projectExpertDetails); + } + Long projectId = projectDetailResp.getProjectId(); + ProjectManagement projectManagement = projectManagementMapper.selectProjectManagementById(projectId); + projectDetailResp.setDeptId(projectManagement.getDeptId()); + projectDetailResp.setDeptName(projectDetailResp.getDeptName()); + projectDetailResp.setProjectName(projectManagement.getProjectName()); + projectDetailResp.setProjectDateStart(projectManagement.getProjectDateStart()); + projectDetailResp.setProjectDateEnd(projectManagement.getProjectDateEnd()); + if (StringUtils.isNotEmpty(projectManagement.getJobCategory())){ + projectDetailResp.setJobCategory(projectManagement.getJobCategory()); + } + SysExpertInfo sysExpertInfo = sysExpertInfoMapper.selectById(projectDetailResp.getExpertId()); + if (sysExpertInfo != null){ + projectDetailResp.setTitle(sysExpertInfo.getTitle()); + projectDetailResp.setJob(sysExpertInfo.getJob()); + } + + } + return projectDetailResp; + } + + @Override + public List<ProjectExpertExportInfoRes> projectExpertExportList(Long projectId) { + ProjectManagement projectManagement = checkData(projectId); + if (!SecurityUtils.isAdmin(SecurityUtils.getUserId()) && projectManagement.getDeptId().intValue() != SecurityUtils.getDeptId().intValue()){ + throw new ServiceException("非本部门数据,无权操作!"); + } + if (projectManagement.getState() != 4){ + throw new ServiceException("项目未完成,无权操作!"); + } + if (projectManagement.getEvaluationState() == 0){ + throw new ServiceException("有专家未完成评定与报销,请完善后再试"); + } + + return projectExpertMapper.projectExpertExportList(projectId); + } private List<ProjectExpertDetail> dealData(List<ProjectExpertScoreSaveReq.Score> data,Long projectExpertId){ @@ -496,11 +556,24 @@ Long deptId = projectManagement.getDeptId(); // 本部门审批? if (!SecurityUtils.isAdmin(SecurityUtils.getUserId()) && deptId.intValue() != SecurityUtils.getDeptId().intValue()){ - throw new ServiceException("非本部门数据,无权操作!"); + throw new ServiceException("非本处室数据,无权操作!"); } if (projectManagement.getState() == 4){ throw new ServiceException("已结项,无权操作!"); } return projectManagement; } + + + private void checkDelData(Long id){ + ProjectManagement projectManagement = checkData(id); + Long deptId = projectManagement.getDeptId(); + // 本部门审批? + if (!SecurityUtils.isAdmin(SecurityUtils.getUserId()) && deptId.intValue() != SecurityUtils.getDeptId().intValue()){ + throw new ServiceException("非本处室数据,无权操作!"); + } + } + + + } \ No newline at end of file -- Gitblit v1.9.2