| | |
| | | package com.ycl.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | 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; |
| | | import com.ycl.domain.entity.ProjectPlanExamineRecord; |
| | | import com.ycl.domain.entity.ProjectPlanInfo; |
| | | import com.ycl.domain.entity.ProjectPlanRecord; |
| | | import com.ycl.domain.form.ProjectPlanInfoForm; |
| | | import com.ycl.domain.query.ProjectPlanInfoQuery; |
| | | import com.ycl.domain.vo.ProjectPlanInfoRequest; |
| | | import com.ycl.domain.vo.ProjectPlanInfoResponseVO; |
| | | import com.ycl.domain.vo.ProjectPlanInfoVO; |
| | | import com.ycl.framework.utils.PageUtil; |
| | | import com.ycl.mapper.ProjectPlanExamineRecordMapper; |
| | | import com.ycl.mapper.ProjectPlanInfoMapper; |
| | | import com.ycl.mapper.ProjectPlanRecordMapper; |
| | | import com.ycl.service.ProjectPlanInfoService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.Assert; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | public class ProjectPlanInfoServiceImpl extends ServiceImpl<ProjectPlanInfoMapper, ProjectPlanInfo> implements ProjectPlanInfoService { |
| | | |
| | | private final ProjectPlanInfoMapper projectPlanInfoMapper; |
| | | private final ProjectPlanRecordMapper projectPlanRecordMapper; |
| | | private final ProjectPlanExamineRecordMapper projectPlanExamineRecordMapper; |
| | | |
| | | /** |
| | | * 添加 |
| | |
| | | */ |
| | | @Override |
| | | public Result detail(Integer id) { |
| | | ProjectPlanInfoVO vo = baseMapper.getById(id); |
| | | Assert.notNull(vo, "记录不存在"); |
| | | ProjectPlanInfoResponseVO vo = new ProjectPlanInfoResponseVO(); |
| | | vo.setList(new LambdaQueryChainWrapper<>(baseMapper).eq(ProjectPlanInfo::getProjectPlanRecordId, id).list()); |
| | | vo.setActualInvest(new LambdaQueryChainWrapper<>(projectPlanRecordMapper).eq(ProjectPlanRecord::getId, id).one().getActualInvest()); |
| | | return Result.ok().data(vo); |
| | | } |
| | | |
| | |
| | | .collect(Collectors.toList()); |
| | | return Result.ok().data(vos); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public Result addPlanInfo(ProjectPlanInfoRequest request) { |
| | | if (CollectionUtils.isEmpty(request.getAddList())) {{ |
| | | return Result.error("请选择要添加的计划项"); |
| | | }} |
| | | // 删除原有记录 |
| | | new LambdaUpdateChainWrapper<>(baseMapper) |
| | | .eq(ProjectPlanInfo::getProjectPlanRecordId, request.getProjectPlanRecordId()) |
| | | .remove(); |
| | | // 批量插入新记录 |
| | | List<ProjectPlanInfo> list = new ArrayList<>(); |
| | | request.getAddList().forEach(item -> { |
| | | ProjectPlanInfo projectPlanInfo = new ProjectPlanInfo(); |
| | | projectPlanInfo.setProjectPlanRecordId(request.getProjectPlanRecordId().longValue()); |
| | | projectPlanInfo.setTitle(item.getTitle()); // 计划项标题 |
| | | projectPlanInfo.setPlanStatus(0); // 计划项状态为未开始 |
| | | projectPlanInfo.setProgressStatus(0); // 计划项进度为未开始 |
| | | projectPlanInfo.setStartTime(item.getStartTime()); // 计划项开始时间 |
| | | projectPlanInfo.setEndTime(item.getEndTime()); // 计划项结束时间 |
| | | list.add(projectPlanInfo); |
| | | }); |
| | | this.saveBatch(list); |
| | | // 更新计划记录的投资,以及上报状态 |
| | | new LambdaUpdateChainWrapper<>(projectPlanRecordMapper) |
| | | .eq(ProjectPlanRecord::getId, request.getProjectPlanRecordId()) |
| | | .set(ProjectPlanRecord::getActualInvest, request.getActualInvest()) |
| | | .set(ProjectPlanRecord::getReportStatus, 0) |
| | | .update(); |
| | | |
| | | // 新增一条审核记录 |
| | | ProjectPlanExamineRecord item = new ProjectPlanExamineRecord(); |
| | | item.setProjectPlanRecordId(request.getProjectPlanRecordId()); |
| | | item.setEventType(0); // 计划上报 |
| | | list.stream().forEach(i -> { |
| | | item.setProjectPlanInfoId(i.getId()); |
| | | projectPlanExamineRecordMapper.insert(item); |
| | | }); |
| | | return Result.ok("添加成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result savePlanInfo(ProjectPlanInfo item, Integer planRecordId) { |
| | | item.setProjectPlanRecordId(planRecordId.longValue()); // 项目计划记录id |
| | | item.setProgressStatus(0); // 未开始 |
| | | item.setDeleted(0); // 未删除 |
| | | item.setPlanStatus(0); // 未审核 |
| | | // 判断id是否存在,存在则更新,不存在则新增 |
| | | if (item.getId() == null) { |
| | | baseMapper.insert(item); |
| | | } else { |
| | | new LambdaUpdateChainWrapper<>(baseMapper).eq(ProjectPlanInfo::getId, item.getId()) |
| | | .set(ProjectPlanInfo::getTitle, item.getTitle()) |
| | | .set(ProjectPlanInfo::getStartTime, item.getStartTime()) |
| | | .set(ProjectPlanInfo::getEndTime, item.getEndTime()) |
| | | .update(); |
| | | } |
| | | return Result.ok("保存成功"); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public Result delayPlanInfo(ProjectPlanInfoForm request) { |
| | | // 更改计划项时间 |
| | | new LambdaUpdateChainWrapper<>(baseMapper) |
| | | .eq(ProjectPlanInfo::getId, request.getId()) |
| | | .set(ProjectPlanInfo::getStartTime, request.getStartTime()) |
| | | .set(ProjectPlanInfo::getEndTime, request.getEndTime()) |
| | | .update(); |
| | | // 新增一条审核记录 |
| | | ProjectPlanExamineRecord item = new ProjectPlanExamineRecord(); |
| | | item.setProjectPlanRecordId(request.getProjectPlanRecordId().longValue()); |
| | | item.setProjectPlanInfoId(request.getId().longValue()); |
| | | item.setEventType(1); |
| | | item.setDelayStartTime(request.getStartTime()); |
| | | item.setDelayEndTime(request.getEndTime()); |
| | | item.setGmtCreate(new Date()); |
| | | item.setDeleted(0); |
| | | projectPlanExamineRecordMapper.insertOne(item); |
| | | return Result.ok("延期成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result resubmitPlanInfo(ProjectPlanInfoForm form) { |
| | | // 更新重新上报后的内容 |
| | | new LambdaUpdateChainWrapper<>(baseMapper) |
| | | .eq(ProjectPlanInfo::getId, form.getId()) |
| | | .set(ProjectPlanInfo::getTitle, form.getTitle()) |
| | | .set(ProjectPlanInfo::getStartTime, form.getStartTime()) |
| | | .set(ProjectPlanInfo::getEndTime, form.getEndTime()) |
| | | .set(ProjectPlanInfo::getPlanStatus, 0) // 将该计划项设置为未审核的状态 |
| | | .update(); |
| | | |
| | | // 新增一条计划上报的审核记录 |
| | | ProjectPlanExamineRecord item = new ProjectPlanExamineRecord(); |
| | | item.setProjectPlanRecordId(form.getProjectPlanRecordId().longValue()); |
| | | item.setProjectPlanInfoId(form.getId().longValue()); |
| | | item.setEventType(0); // 计划上报 |
| | | item.setDelayStartTime(form.getStartTime()); |
| | | item.setDelayEndTime(form.getEndTime()); |
| | | item.setGmtCreate(new Date()); |
| | | item.setDeleted(0); // 未删除 |
| | | projectPlanExamineRecordMapper.insertOne(item); |
| | | return Result.ok("重新上报成功"); |
| | | } |
| | | } |