| | |
| | | import com.ruoyi.basic.service.CustomerFollowUpFileService; |
| | | import com.ruoyi.common.enums.PlanStageEnum; |
| | | import com.ruoyi.common.enums.ReviewStatusEnum; |
| | | import com.ruoyi.common.utils.EnumUtil; |
| | | import com.ruoyi.projectManagement.dto.PlanStageDto; |
| | | import com.ruoyi.projectManagement.dto.SaveInfoDto; |
| | | import com.ruoyi.projectManagement.mapper.InfoMapper; |
| | | import com.ruoyi.projectManagement.pojo.Info; |
| | | import com.ruoyi.projectManagement.pojo.PlanNode; |
| | | import com.ruoyi.projectManagement.service.PlanService; |
| | | import com.ruoyi.projectManagement.service.impl.PlanServiceImpl; |
| | | import com.ruoyi.projectManagement.vo.PlanVo; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | */ |
| | | @Component |
| | | @RequiredArgsConstructor |
| | | @Transactional(rollbackFor = Exception.class,readOnly = true) |
| | | @Transactional(rollbackFor = Exception.class, readOnly = true) |
| | | public class InfoHandleService { |
| | | |
| | | private static final String GENERATE_SERIAL_NUMBER_PREFIX = "XM"; |
| | |
| | | private final CustomerFollowUpFileService customerFollowUpFileService; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long save(@NotNull SaveInfoDto saveInfoDto){ |
| | | public Long save(@NotNull SaveInfoDto saveInfoDto) { |
| | | Info info = BeanUtil.copyProperties(saveInfoDto, Info.class); |
| | | |
| | | // 附件特殊处理 |
| | |
| | | info.setAttachment(attachmentIds); |
| | | |
| | | // 生成序号 (如果需要自动生成的话) |
| | | if(StrUtil.isBlank(info.getNo())){ |
| | | if (StrUtil.isBlank(info.getNo())) { |
| | | info.setNo(generateSerialNumber()); |
| | | } |
| | | info.setTeam(saveInfoDto.getTeamList()); |
| | | if(info.getId() == null){ |
| | | if (info.getId() == null) { |
| | | // 生成对应的阶段关系数据 |
| | | info.setPlanStage(getPlanStageList(info.getProjectManagementPlanId())); |
| | | // 插入默认状态 |
| | | info.setStatus(PlanStageEnum.TO_BEGIN.getCode()); |
| | | info.setReviewStatus(ReviewStatusEnum.PENDING_REVIEW.getCode()); |
| | | infoMapper.insert(info); |
| | | }else { |
| | | } else { |
| | | infoMapper.updateById(info); |
| | | } |
| | | return info.getId(); |
| | | } |
| | | |
| | | public SaveInfoDto getInfoById(@NotNull Long id){ |
| | | public SaveInfoDto getInfoById(@NotNull Long id) { |
| | | Info info = infoMapper.selectById(id); |
| | | return convert(info); |
| | | } |
| | | |
| | | private SaveInfoDto convert(Info info) { |
| | | SaveInfoDto saveInfoDto = BeanUtil.copyProperties(info, SaveInfoDto.class); |
| | | // 附件处理 |
| | | saveInfoDto.setTeamList(info.getTeam()); |
| | | customerFollowUpFileService.fillAttachment(Lists.newArrayList(saveInfoDto), SaveInfoDto::getAttachment, SaveInfoDto::setAttachmentList); |
| | | return saveInfoDto; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 获取改id下子项目信息 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public List<SaveInfoDto> getSubordinateInfo(@NotNull Long id) { |
| | | LambdaQueryWrapper<Info> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Info::getProjectManagementInfoParentId, id); |
| | | queryWrapper.orderByAsc(Info::getCreateTime); |
| | | List<Info> infoList = infoMapper.selectList(queryWrapper); |
| | | return infoList.stream().map(this::convert).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | 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)).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 生成项目编号 |
| | | * |
| | | * @return |
| | | */ |
| | | private String generateSerialNumber() { |