heheng
2024-11-27 3c633caa438147d94cbc37993b818766de06aafb
expert-system/src/main/java/com/gkhy/system/service/impl/ProjectManagementServiceImpl.java
@@ -3,6 +3,7 @@
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;
@@ -68,6 +69,9 @@
     */
    @Override
    public List<ProjectManagement> selectProjectManagementList(ProjectManagement projectManagement) {
        if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
           projectManagement.setDeptId(SecurityUtils.getDeptId());
        }
        return projectManagementMapper.selectProjectManagementList(projectManagement);
    }
@@ -80,8 +84,10 @@
    @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());
@@ -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,7 +239,7 @@
     */
    @Override
    public int deleteProjectManagementByIds(Long[] ids) {
        //todo 校验
        // 校验
        for (Long id : ids) {
            checkDataPer(id);
        }
@@ -343,6 +343,10 @@
    @Override
    public List<ProjectExpertStateResp> getProjectExpertSate(ProjectExpertStateReq req) {
        if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
            req.setDeptId(SecurityUtils.getDeptId());
        }
        return projectManagementMapper.getProjectExpertSate(req);
    }
@@ -421,6 +425,9 @@
    @Override
    public List<ProjectExpertResp> projectExpertEvaList(SysProjectExpertReq req) {
        if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
            req.setDeptId(SecurityUtils.getDeptId());
        }
        return projectExpertMapper.projectExpertEvaList(req);
    }
@@ -450,8 +457,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());