| | |
| | | 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; |
| | |
| | | private final CustomerFollowUpFileService customerFollowUpFileService; |
| | | |
| | | private final PlanNodeMapper planNodeMapper; |
| | | private final FileUtil fileUtil; |
| | | |
| | | @Lazy |
| | | @Autowired |
| | |
| | | @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 { |
| | |
| | | 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; |
| | | } |
| | | |