| | |
| | | import com.ycl.platform.domain.entity.YwPeople; |
| | | import com.ycl.platform.domain.entity.YwPoint; |
| | | import com.ycl.platform.domain.entity.YwUnit; |
| | | import com.ycl.platform.domain.form.ReportAuditingForm; |
| | | import com.ycl.platform.domain.form.ReportForm; |
| | | import com.ycl.platform.domain.query.ReportQuery; |
| | | import com.ycl.platform.domain.vo.ReportVO; |
| | |
| | | import com.ycl.system.Result; |
| | | import com.ycl.system.page.PageUtil; |
| | | import com.ycl.utils.SecurityUtils; |
| | | import com.ycl.utils.uuid.IdUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.stereotype.Service; |
| | | 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.Objects; |
| | | import java.util.stream.Collectors; |
| | |
| | | form.setUnitId(people.getBelongUnit()); |
| | | Report entity = ReportForm.getEntityByForm(form, null); |
| | | entity.setStatus(0); |
| | | entity.setIdentify(IdUtils.timeAddRandomNO(3)); |
| | | if(baseMapper.insert(entity) > 0) { |
| | | return Result.ok("添加成功"); |
| | | } |
| | |
| | | public Result update(ReportForm form) { |
| | | |
| | | Report entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | if (baseMapper.updateById(entity) > 0) { |
| | | return Result.ok("修改成功"); |
| | | |
| | | if (0 == entity.getStatus()) { |
| | | // 待审核的直接改 |
| | | BeanUtils.copyProperties(form, entity); |
| | | baseMapper.updateById(entity); |
| | | } else if (2 == entity.getStatus()) { |
| | | // 如果是未审核通过,进行修改,那么直接新增(为了保存审核记录) |
| | | Report report = new Report(); |
| | | BeanUtils.copyProperties(entity, report); |
| | | BeanUtils.copyProperties(form, report); |
| | | report.setId(null); |
| | | report.setStatus(0); |
| | | report.setAuditingTime(null); |
| | | report.setAuditOpinion(null); |
| | | baseMapper.insert(report); |
| | | } |
| | | return Result.error("修改失败"); |
| | | return Result.ok("修改成功"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public Result page(ReportQuery query) { |
| | | List<ReportVO> page = baseMapper.page(query); |
| | | return Result.ok().data(page).total(page.size()); |
| | | IPage<ReportVO> page = PageUtil.getPage(query, ReportVO.class); |
| | | baseMapper.page(page, query); |
| | | return Result.ok().data(page).total(page.getTotal()); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | IPage<Report> page = new LambdaQueryChainWrapper<>(baseMapper) |
| | | .eq(StringUtils.isNotBlank(query.getReportType()), Report::getReportType, query.getReportType()) |
| | | .le(Objects.nonNull(query.getBeginCreateTime()), Report::getBeginCreateTime, query.getBeginCreateTime()) |
| | | .ge(Objects.nonNull(query.getEndCreateTime()), Report::getEndCreateTime, query.getEndCreateTime()) |
| | | // .le(Objects.nonNull(query.getBeginCreateTime()), Report::getBeginCreateTime, query.getBeginCreateTime()) |
| | | // .ge(Objects.nonNull(query.getEndCreateTime()), Report::getEndCreateTime, query.getEndCreateTime()) |
| | | .in(!CollectionUtils.isEmpty(query.getPointIdList()), Report::getPointId, query.getPointIdList()) |
| | | .in(!CollectionUtils.isEmpty(query.getPeopleIdList()), Report::getPeopleId, query.getPeopleIdList()) |
| | | .orderByDesc(Report::getCreateTime) |
| | |
| | | return vos; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Result auditingRecord(Integer id) { |
| | | List<ReportVO> reportList = baseMapper.examineRecord(id); |
| | | return Result.ok().data(reportList); |
| | | } |
| | | |
| | | @Override |
| | | public Result auditing(ReportAuditingForm form) { |
| | | Report report = baseMapper.selectById(form.getId()); |
| | | if (Objects.isNull(report)) { |
| | | throw new RuntimeException("审核的报备不存在"); |
| | | } |
| | | if (form.getAuditingResult()) { |
| | | report.setStatus(1); |
| | | } else { |
| | | report.setStatus(2); |
| | | } |
| | | report.setAuditOpinion(form.getAuditOpinion()); |
| | | report.setAuditingTime(new Date()); |
| | | baseMapper.updateById(report); |
| | | return Result.ok("操作成功"); |
| | | } |
| | | } |