zxl
2025-03-14 23b688e436a89845e92d861adb5875e625e90d9f
business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
@@ -7,9 +7,11 @@
import cn.hutool.core.util.ZipUtil;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.common.base.Result;
@@ -17,6 +19,7 @@
import com.ycl.common.constant.Constants;
import com.ycl.common.core.domain.BaseEntity;
import com.ycl.common.core.domain.entity.SysDictData;
import com.ycl.common.enums.YesOrNo;
import com.ycl.common.enums.business.FileTypeEnum;
import com.ycl.common.enums.business.ImportanceTypeEnum;
import com.ycl.common.enums.business.ProjectCategoryEnum;
@@ -66,6 +69,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.time.Year;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -151,23 +155,20 @@
     * @return
     */
    public boolean  checkProjectNameAndIdIsUnique(ProjectInfo entity,Long updateId){
        QueryWrapper<ProjectInfo> queryWrapper = new QueryWrapper<ProjectInfo>();
        LambdaQueryWrapper<ProjectInfo> queryWrapper = new LambdaQueryWrapper<>();
        if (updateId == null) {
            queryWrapper.eq("project_name", entity.getProjectName());
            queryWrapper.eq("deleted",0);
            if (StringUtils.isNotEmpty(entity.getProjectCode())) {
                queryWrapper.eq("project_code", entity.getProjectCode());
            }
            List<ProjectInfo> project = projectInfoMapper.selectList(queryWrapper);
            return project == null || project.isEmpty();
        }else {
            List<ProjectInfo> project = projectInfoMapper.checkProjectNameAndIdIsUnique(updateId,entity.getProjectName(),entity.getProjectCode());
            return project == null || project.isEmpty();
            List<ProjectInfo> list = new LambdaQueryChainWrapper<>(baseMapper)
                    .eq(ProjectInfo::getProjectName, entity.getProjectName())
                    .eq(ProjectInfo::getProjectCode, entity.getProjectCode())
                    .list();
            return list == null || list.isEmpty();
        } else {
            List<ProjectInfo> list = new LambdaQueryChainWrapper<>(baseMapper)
                    .eq(ProjectInfo::getProjectName, entity.getProjectName())
                    .eq(ProjectInfo::getProjectCode, entity.getProjectCode())
                    .ne(ProjectInfo::getId, updateId)
                    .list();
            return list == null || list.isEmpty();
        }
    }
@@ -324,8 +325,11 @@
        if (query.getProjectEndTime() != null) {
            query.setProjectEndTime(DateUtils.getDayEnd(query.getProjectEndTime()));
        }
        if (YesOrNo.YES.getCode().equals(query.getCenter())) {
            query.setProjectPhase("6");
        }
        // 异常项目暂时返回空
        if (ProjectCategoryEnum.EXCEPTION.getType().equals(query.getProjectPhase())) {
        if (YesOrNo.YES.getCode().equals(query.getExe())) {
            return Result.ok().data(new ArrayList<>()).total(0);
        }
        Long userId = SecurityUtils.getUserId();
@@ -349,14 +353,15 @@
        baseMapper.getPage(query, page);
        List<ProjectInfoVO> records = page.getRecords();
        List<ProjectVO> list = new ArrayList<>();
        int year = Year.now().getValue();
        records.forEach(vo -> {
            ProjectInfoVO.transform(vo);
            ProjectVO projectVO = new ProjectVO();
            copyToProjectVO(vo, projectVO);
            List<Long> departmentList = vo.getCompetentDepartmentList();
            projectVO.setAuditRole(SecurityUtils.isAdmin(SecurityUtils.getUserId()) || (!CollectionUtils.isEmpty(departmentList) && departmentList.contains(SecurityUtils.getDeptId())));
            String competentDepartment = vo.getCompetentDepartment();
            projectVO.setAuditRole(SecurityUtils.isAdmin(SecurityUtils.getUserId()) || (StringUtils.isNotEmpty(competentDepartment) && competentDepartment.equals(SecurityUtils.getDeptId() + "")));
            // 翻译项目阶段
            String phase = ProjectCategoryEnum.getPhaseByProjectStatus(projectVO.getProjectStatus(), projectVO.getProcessId() != null);
            String phase = ProjectCategoryEnum.getPhaseByProjectStatus(projectVO.getProjectPhase());
            projectVO.setProjectPhase(phase);
            if (StringUtils.isNotEmpty(projectVO.getProjectSubType())) {
                // 翻译项目子类型
@@ -364,6 +369,14 @@
                if (Objects.nonNull(dictData)) {
                    projectVO.setProjectSubType(dictData.getDictLabel());
                }
            }
            // 获取本年度的投资金额
            List<ProjectInfoYearPlan> yearPlans = new LambdaQueryChainWrapper<>(projectInfoYearPlanService.getBaseMapper())
                    .eq(ProjectInfoYearPlan::getProjectInfoId, projectVO.getId())
                    .eq(ProjectInfoYearPlan::getYear, year)
                    .list();
            if (! CollectionUtils.isEmpty(yearPlans)) {
                projectVO.setYearInvestAmount(yearPlans.get(0).getYearTotalMoney());
            }
            list.add(projectVO);
        });
@@ -394,8 +407,8 @@
        ProjectInfo entity = baseMapper.getById(id);
        Assert.notNull(entity, "记录不存在");
        ProjectInfoVO vo = ProjectInfoVO.getVoByEntity(entity, null);
        List<Long> departmentList = vo.getCompetentDepartmentList();
        vo.setAuditRole(SecurityUtils.isAdmin(SecurityUtils.getUserId()) || (!CollectionUtils.isEmpty(departmentList) && departmentList.contains(SecurityUtils.getDeptId())));
        String competentDepartment = vo.getCompetentDepartment();
        vo.setAuditRole(SecurityUtils.isAdmin(SecurityUtils.getUserId()) || (StringUtils.isNotEmpty(competentDepartment) && competentDepartment.equals(SecurityUtils.getDeptId() + "")));
        QueryWrapper<File> fileQueryWrapper = new QueryWrapper<>();
        fileQueryWrapper.eq("type", FileTypeEnum.PROJECT_INFO.getType());
        fileQueryWrapper.eq("bus_id", vo.getId());
@@ -455,25 +468,32 @@
        List<ProjectVO> city = new ArrayList<>();
        List<ProjectVO> county = new ArrayList<>();
        projectVOS.forEach(item -> {
            if (ProjectCategoryEnum.RESERVE.getDesc().equals(ProjectCategoryEnum.getPhaseByProjectStatus(item.getProjectStatus(), item.getProcessId() != null))) {
            if (ProjectCategoryEnum.RESERVE.getDesc().equals(ProjectCategoryEnum.getPhaseByProjectStatus(item.getProjectPhase()))) {
                reserve.add(item);
            } else if (ProjectCategoryEnum.PREVIOUS.getDesc().equals(ProjectCategoryEnum.getPhaseByProjectStatus(item.getProjectStatus(), item.getProcessId() != null))) {
            } else if (ProjectCategoryEnum.PREVIOUS.getDesc().equals(ProjectCategoryEnum.getPhaseByProjectStatus(item.getProjectPhase()))) {
                previous.add(item);
            } else if (ProjectCategoryEnum.IMPLEMENT.getDesc().equals(ProjectCategoryEnum.getPhaseByProjectStatus(item.getProjectStatus(), item.getProcessId() != null))) {
            } else if (ProjectCategoryEnum.IMPLEMENT.getDesc().equals(ProjectCategoryEnum.getPhaseByProjectStatus(item.getProjectPhase()))) {
                implement.add(item);
            } else if (ProjectCategoryEnum.FINISH.getDesc().equals(ProjectCategoryEnum.getPhaseByProjectStatus(item.getProjectStatus(), item.getProcessId() != null))) {
            } else if (ProjectCategoryEnum.FINISH.getDesc().equals(ProjectCategoryEnum.getPhaseByProjectStatus(item.getProjectPhase()))) {
                finish.add(item);
            }
            if (ImportanceTypeEnum.PROVINCIAL_KEY.getType().equals(item.getImportanceType())) {
                province.add(item);
            } else if (ImportanceTypeEnum.SUINING_KEY.getType().equals(item.getImportanceType())) {
                city.add(item);
            } else if (ImportanceTypeEnum.SHEHONG_KEY.getType().equals(item.getImportanceType())) {
                county.add(item);
            } else // if  (ImportanceTypeEnum.NORMAL.getType().equals(item.getImportanceType()))
            {
            if (StringUtils.isBlank(item.getImportanceType())) {
                normal.add(item);
                // 使用contains,因为重点分类可多选,使用,分割存储的
            } else {
                if (item.getImportanceType().contains(ImportanceTypeEnum.PROVINCIAL_KEY.getType())) {
                    province.add(item);
                }
                if (item.getImportanceType().contains(ImportanceTypeEnum.SUINING_KEY.getType())) {
                    city.add(item);
                }
                if (item.getImportanceType().contains(ImportanceTypeEnum.SHEHONG_KEY.getType())) {
                    county.add(item);
                }
                if (item.getImportanceType().contains(ImportanceTypeEnum.NORMAL.getType())) {
                    normal.add(item);
                }
            }
        });
        //单位先默认为元
@@ -586,7 +606,7 @@
            ProjectExcelTemplate excel = new ProjectExcelTemplate();
            BeanUtils.copyProperties(item, excel);
            //项目阶段
            excel.setProjectPhase(ProjectCategoryEnum.getPhaseByProjectStatus(item.getProjectStatus(), item.getProcessId() != null));
            excel.setProjectPhase(ProjectCategoryEnum.getPhaseByProjectStatus(item.getProjectPhase()));
            excelList.add(excel);
        });
        Set<Integer> indexes = OutputExcelUtils.getSelectFields(query.getFieldList(), ProjectExcelTemplate.class);
@@ -817,7 +837,7 @@
                entity.setCreateBy(userId);
                entity.setUpdateBy(userId);
                //如果是储备项目(未开工项目)不需要审核
                if ("0".equals(entity.getProjectPhase())) {
                if (ProjectCategoryEnum.RESERVE.getType().equals(entity.getProjectPhase())) {
                    entity.setUsedStatus(ProjectConstant.PASS);
                }
                // 管理员修改的直接通过
@@ -862,7 +882,7 @@
                Long userId = SecurityUtils.getUserId();
                entity.setUpdateBy(userId);
                //如果是储备项目(未开工项目)不需要审核
                if (ProjectConstant.COMMIT.equals(entity.getUsedStatus()) && ProjectStatusEnum.PENDDING.getType().equals(entity.getProjectStatus())) {
                if (ProjectCategoryEnum.RESERVE.getType().equals(entity.getProjectPhase())) {
                    entity.setUsedStatus(ProjectConstant.PASS);
                }
                // 管理员修改的直接通过