| | |
| | | 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.ycl.common.base.Result; |
| | | import com.ycl.common.enums.business.FileTypeEnum; |
| | | import com.ycl.common.utils.SecurityUtils; |
| | | import com.ycl.domain.entity.File; |
| | | import com.ycl.domain.entity.ProjectPlanExamineRecord; |
| | | import com.ycl.domain.entity.ProjectPlanInfo; |
| | | import com.ycl.domain.entity.ProjectPlanProgressReport; |
| | | import com.ycl.domain.vo.ProgressReportResponseVO; |
| | | import com.ycl.framework.utils.PageUtil; |
| | | import com.ycl.mapper.FileMapper; |
| | | import com.ycl.mapper.ProjectPlanExamineRecordMapper; |
| | | import com.ycl.mapper.ProjectPlanInfoMapper; |
| | | import com.ycl.mapper.ProjectPlanProgressReportMapper; |
| | | import com.ycl.service.ProjectPlanProgressReportService; |
| | | |
| | |
| | | import com.ycl.domain.form.ProjectPlanProgressReportForm; |
| | | import com.ycl.domain.vo.ProjectPlanProgressReportVO; |
| | | import com.ycl.domain.query.ProjectPlanProgressReportQuery; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.Assert; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | public class ProjectPlanProgressReportServiceImpl extends ServiceImpl<ProjectPlanProgressReportMapper, ProjectPlanProgressReport> implements ProjectPlanProgressReportService { |
| | | |
| | | private final ProjectPlanProgressReportMapper projectPlanProgressReportMapper; |
| | | @Autowired |
| | | private final ProjectPlanExamineRecordMapper projectPlanExamineRecordMapper; |
| | | @Autowired |
| | | private ProjectPlanInfoMapper projectPlanInfoMapper; |
| | | @Autowired |
| | | private FileMapper fileMapper; |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public Result add(ProjectPlanProgressReportForm form) { |
| | | ProjectPlanProgressReport entity = ProjectPlanProgressReportForm.getEntityByForm(form, null); |
| | | baseMapper.insert(entity); |
| | | public Result add(ProgressReportResponseVO form) { |
| | | |
| | | // 判断上报状态 |
| | | if (form.getProgressStatusInt() == 0) { // 未开始 上报进度 |
| | | ProjectPlanProgressReport projectPlanProgressReport = new ProjectPlanProgressReport(); |
| | | projectPlanProgressReport.setProjectPlanInfoId(form.getId().longValue()); |
| | | projectPlanProgressReport.setStartTime(form.getActualStartTime()); |
| | | projectPlanProgressReport.setEndTime(form.getActualEndTime()); |
| | | projectPlanProgressReport.setProgressStatus(form.getProgressStatusStr()); |
| | | projectPlanProgressReport.setActualInvest(form.getActualInvest()); |
| | | // 新增进度上报内容 |
| | | baseMapper.insert(projectPlanProgressReport); |
| | | }else if (form.getProgressStatusInt() == 2) { // 已驳回 重新上报 |
| | | ProjectPlanProgressReport projectPlanProgressReport = baseMapper.selectById(form.getProgressReportId()); |
| | | projectPlanProgressReport.setProjectPlanInfoId(form.getId().longValue()); |
| | | projectPlanProgressReport.setStartTime(form.getActualStartTime()); |
| | | projectPlanProgressReport.setEndTime(form.getActualEndTime()); |
| | | projectPlanProgressReport.setProgressStatus(form.getProgressStatusStr()); |
| | | projectPlanProgressReport.setActualInvest(form.getActualInvest()); |
| | | // 更新进度上报内容 |
| | | baseMapper.updateById(projectPlanProgressReport); |
| | | } |
| | | |
| | | // 文件上传 |
| | | new LambdaUpdateChainWrapper<>(fileMapper) |
| | | .eq(File::getBusId, form.getId()) |
| | | .eq(File::getType, FileTypeEnum.PROJECT_PROGRESS_INFO_REPORT.getType()) |
| | | .set(File::getDeleted,1) |
| | | .update(); |
| | | if (form.getFileList() != null && form.getFileList().size() > 0) { |
| | | form.getFileList().stream() |
| | | .forEach(file -> { |
| | | file.setId(null); |
| | | file.setBusId(form.getId().longValue()); |
| | | file.setType(FileTypeEnum.PROJECT_PROGRESS_INFO_REPORT); |
| | | file.setGmtCreate(new Date()); |
| | | file.setGmtUpdate(new Date()); |
| | | file.setDeleted(0); |
| | | fileMapper.insert(file); |
| | | }); |
| | | } |
| | | // 更新计划项的进度状态为未审核 |
| | | new LambdaUpdateChainWrapper<>(projectPlanInfoMapper) |
| | | .eq(ProjectPlanInfo::getId, form.getId()) |
| | | .set(ProjectPlanInfo::getProgressStatus, 1) |
| | | .update(); |
| | | return Result.ok("添加成功"); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public Result detail(Integer id) { |
| | | ProgressReportResponseVO vo = baseMapper.getDetail(id); |
| | | if (vo != null) { |
| | | vo.setFileList(new LambdaQueryChainWrapper<>(fileMapper).eq(File::getBusId, id).eq(File::getType, FileTypeEnum.PROJECT_PROGRESS_INFO_REPORT).list()); |
| | | } |
| | | return Result.ok().data(vo); |
| | | } |
| | | |
| | |
| | | .collect(Collectors.toList()); |
| | | return Result.ok().data(vos); |
| | | } |
| | | |
| | | @Override |
| | | public Result examine(ProgressReportResponseVO form) { |
| | | // 获得审批记录副本 |
| | | ProjectPlanExamineRecord record = projectPlanExamineRecordMapper.selectById(form.getExamineRecordId()); |
| | | |
| | | // 新增一条审批记录 |
| | | ProjectPlanExamineRecord newRecord = new ProjectPlanExamineRecord();; |
| | | newRecord.setProjectPlanRecordId(record.getProjectPlanRecordId()); |
| | | newRecord.setProjectPlanInfoId(record.getProjectPlanInfoId()); |
| | | newRecord.setDepartmentUserId(SecurityUtils.getUserId()); |
| | | newRecord.setDepartmentExamine(form.getDepartmentExamine()); |
| | | newRecord.setDepartmentApproval(form.getDepartmentApproval()); |
| | | newRecord.setManagerUserId(SecurityUtils.getUserId()); |
| | | newRecord.setManageExamine(form.getManageExamine()); |
| | | newRecord.setManageApproval(form.getManageApproval()); |
| | | newRecord.setEventType(2); |
| | | newRecord.setDeleted(0); |
| | | projectPlanExamineRecordMapper.insert(newRecord); |
| | | |
| | | // 判断审批结果 |
| | | if (form.getDepartmentExamine() == 0 && form.getManageExamine() == 0) { // 审批通过 |
| | | // 计划项进度状态更新为已完成 |
| | | new LambdaUpdateChainWrapper<>(projectPlanInfoMapper) |
| | | .eq(ProjectPlanInfo::getId, form.getId()) |
| | | .set(ProjectPlanInfo::getProgressStatus, 3) |
| | | .update(); |
| | | }else { // 审批不通过 |
| | | // 计划项进度状态更新为已驳回 |
| | | new LambdaUpdateChainWrapper<>(projectPlanInfoMapper) |
| | | .eq(ProjectPlanInfo::getId, form.getId()) |
| | | .set(ProjectPlanInfo::getProgressStatus, 2) |
| | | .update(); |
| | | } |
| | | return Result.ok("审批成功"); |
| | | } |
| | | } |