huminmin
2026-04-27 2a71f6790ddf6be7f63e6b009fc8d325a2a1d13b
src/main/java/com/ruoyi/projectManagement/service/impl/PlanServiceImpl.java
@@ -6,7 +6,10 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.basic.dto.StorageBlobVO;
import com.ruoyi.basic.enums.RecordTypeEnum;
import com.ruoyi.basic.service.CustomerFollowUpFileService;
import com.ruoyi.basic.utils.FileUtil;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.projectManagement.mapper.PlanMapper;
import com.ruoyi.projectManagement.mapper.PlanNodeMapper;
@@ -40,6 +43,7 @@
    private final CustomerFollowUpFileService customerFollowUpFileService;
    private final PlanNodeMapper planNodeMapper;
    private final FileUtil fileUtil;
    @Lazy
    @Autowired
@@ -49,9 +53,8 @@
    @Transactional(rollbackFor = Exception.class)
    public void savePlan(SavePlanVo savePlanVo) {
        Plan plan = BeanUtil.copyProperties(savePlanVo, Plan.class);
        // 附件处理 , 拼接
        String attachments = String.join(",", Optional.ofNullable(savePlanVo.getAttachmentIds()).orElse(Collections.emptyList()));
        plan.setAttachment(attachments);
        // 附件处理
        fileUtil.saveStorageAttachmentByRecordTypeAndRecordId("", RecordTypeEnum.PLAN, savePlanVo.getId(), savePlanVo.getStorageBlobDTOs());
        if (savePlanVo.getId() == null) {
            planMapper.insert(plan);
        } else {
@@ -101,6 +104,9 @@
    }
    private List<PlanNode> getPlanNodeByPlanIds(List<Long> planIds) {
        if(CollUtil.isEmpty(planIds)){
            return Collections.emptyList();
        }
        return planNodeMapper.selectList(new LambdaQueryWrapper<PlanNode>()
                .eq(PlanNode::getIsDelete, 0)
                .in(PlanNode::getProjectManagementPlanId, planIds).orderByAsc(PlanNode::getSort));
@@ -133,12 +139,14 @@
        IPage<Plan> planIPage = planMapper.selectPlanPage(searchPlanVo);
        IPage<PlanVo> resultPage = planIPage.convert(plan -> BeanUtil.copyProperties(plan, PlanVo.class));
        // 文件获取
        customerFollowUpFileService.fillAttachment(resultPage.getRecords(), PlanVo::getAttachment, PlanVo::setAttachmentList);
        Map<Long, List<PlanNodeVo>> collect = getPlanNodeByPlanIds(resultPage.getRecords().stream().map(PlanVo::getId).collect(Collectors.toList()))
                .stream()
                .map(it -> BeanUtil.copyProperties(it, PlanNodeVo.class))
                .collect(Collectors.groupingBy(PlanNodeVo::getProjectManagementPlanId, Collectors.toList()));
        resultPage.getRecords().forEach(planVo -> planVo.setPlanNodeList(collect.getOrDefault(planVo.getId(), Collections.emptyList())));
        resultPage.getRecords().forEach(planVo -> {
            planVo.setPlanNodeList(collect.getOrDefault(planVo.getId(), Collections.emptyList()));
            planVo.setStorageBlobVOs(fileUtil.getStorageBlobVOsByRecordTypeAndRecordId(RecordTypeEnum.PLAN, planVo.getId()));
        });
        return resultPage;
    }