zhangwencui
8 天以前 f76bf27bf93e523ae4572d9e10e9ca541c324185
src/main/java/com/ruoyi/projectManagement/service/impl/handle/InfoHandleService.java
@@ -4,10 +4,13 @@
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.google.common.collect.Lists;
import com.ruoyi.basic.service.CustomerFollowUpFileService;
import com.ruoyi.common.enums.PlanStageEnum;
import com.ruoyi.common.enums.ReviewStatusEnum;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.projectManagement.dto.InfoStageDto;
import com.ruoyi.projectManagement.dto.PlanStageDto;
import com.ruoyi.projectManagement.dto.SaveInfoDto;
import com.ruoyi.projectManagement.mapper.InfoMapper;
@@ -18,7 +21,7 @@
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.validation.constraints.NotNull;
import jakarta.validation.constraints.NotNull;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
@@ -56,16 +59,29 @@
        }
        info.setTeam(saveInfoDto.getTeamList());
        if (info.getId() == null) {
            // 生成对应的阶段关系数据
            info.setPlanStage(getPlanStageList(info.getProjectManagementPlanId()));
            // 新项目阶段由 project_management_phase 独立维护,不再生成旧计划模板阶段。
            info.setPlanStage(Collections.emptyList());
            if (StrUtil.isBlank(info.getCurrentPhase())) {
                info.setCurrentPhase("未开始");
            }
            // 插入默认状态
            info.setStatus(PlanStageEnum.TO_BEGIN.getCode());
            info.setReviewStatus(ReviewStatusEnum.PENDING_REVIEW.getCode());
            infoMapper.insert(info);
        } else {
            Info existing = infoMapper.selectById(info.getId());
            if (existing == null) throw new ServiceException("项目不存在");
            if (!StrUtil.isBlank(existing.getCurrentPhase()) && !"未开始".equals(existing.getCurrentPhase())) {
                throw new ServiceException("项目开始后基本信息和团队信息已锁定,仅可通过人员调整功能修改项目执行人");
            }
            infoMapper.updateById(info);
        }
        return info.getId();
    }
    @Transactional
    public void updateById(@NotNull Info info){
        infoMapper.updateById(info);
    }
    public SaveInfoDto getInfoById(@NotNull Long id) {
@@ -99,7 +115,7 @@
    private List<PlanStageDto> getPlanStageList(@NotNull Long planId) {
        List<PlanNode> planNodeByPlanId = planService.getPlanNodeByPlanId(planId);
        return planNodeByPlanId.stream().map(it -> new PlanStageDto(it.getId(), it.getName(), PlanStageEnum.TO_BEGIN)).collect(Collectors.toList());
        return planNodeByPlanId.stream().map(it -> new PlanStageDto(it.getId(), it.getName(), PlanStageEnum.TO_BEGIN, it.getSort(), it.getEstimatedDuration())).collect(Collectors.toList());
    }