| | |
| | | import com.ycl.platform.service.ICalculateRuleService; |
| | | import com.ycl.system.Result; |
| | | import com.ycl.system.page.PageUtil; |
| | | import com.ycl.utils.SecurityUtils; |
| | | import enumeration.general.CalculateReportStatusEnum; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | @Override |
| | | public Result page(CalculateReportQuery query) { |
| | | IPage<CalculateReportVO> page = PageUtil.getPage(query, CalculateReportVO.class); |
| | | query.setUnitId(SecurityUtils.getUnitId()); |
| | | baseMapper.page(query, page); |
| | | page.getRecords().stream().forEach(item -> { |
| | | if (Objects.isNull(item)) { |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result detail(Long id) { |
| | | public Result detail(CalculateReportQuery query) { |
| | | // 明细列表 |
| | | CalculateReportDetailVO detail = baseMapper.getById(id); |
| | | CalculateReportDetailVO detail = baseMapper.getById(query); |
| | | if (Objects.nonNull(detail) && ! CollectionUtils.isEmpty(detail.getRecordList())) { |
| | | if (CalculateReportStatusEnum.NOT_PUBLISH.equals(detail.getStatus())) { |
| | | detail.getRecordList().get(0).setLatest(Boolean.TRUE); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result backfill(CalculateReportBackfillForm form) { |
| | | CalculateReport report = baseMapper.selectById(form.getId()); |
| | | if (Objects.isNull(report)) { |
| | | throw new RuntimeException("该核算报告不存在"); |
| | | } |
| | | if (CalculateReportStatusEnum.PUBLISHED.equals(report.getStatus())) { |
| | | throw new RuntimeException("最新一次核算报告已经发布,无法修改"); |
| | | } |
| | | CalculateReportBackfillForm.RecordForm latestRecord = form.getRecordList().get(0); |
| | | CalculateRecord beforeRecord = calculateRecordMapper.selectById(latestRecord.getId()); |
| | | if (Objects.isNull(beforeRecord)) { |
| | | throw new RuntimeException("最近一次核算记录不存在"); |
| | | } |
| | | // 计算得到扣款总额(只算最近一条) |
| | | BigDecimal totalDeduct = report.getDeductMoney().subtract(latestRecord.getDeductMoney()).add(latestRecord.getDeductMoney()); |
| | | report.setDeductMoney(totalDeduct); |
| | | baseMapper.updateById(report); |
| | | |
| | | beforeRecord.setDeductMoney(latestRecord.getDeductMoney()); |
| | | calculateRecordMapper.updateById(beforeRecord); |
| | | // CalculateReport report = baseMapper.selectById(form.getId()); |
| | | // if (Objects.isNull(report)) { |
| | | // throw new RuntimeException("该核算报告不存在"); |
| | | // } |
| | | // if (CalculateReportStatusEnum.PUBLISHED.equals(report.getStatus())) { |
| | | // throw new RuntimeException("最新一次核算报告已经发布,无法修改"); |
| | | // } |
| | | // CalculateReportBackfillForm.RecordForm latestRecord = form.getRecordList().get(0); |
| | | // CalculateRecord beforeRecord = calculateRecordMapper.selectById(latestRecord.getId()); |
| | | // if (Objects.isNull(beforeRecord)) { |
| | | // throw new RuntimeException("最近一次核算记录不存在"); |
| | | // } |
| | | // // 计算得到扣款总额(只算最近一条) |
| | | // BigDecimal totalDeduct = report.getDeductMoney().subtract(latestRecord.getDeductMoney()).add(latestRecord.getDeductMoney()); |
| | | // report.setDeductMoney(totalDeduct); |
| | | // baseMapper.updateById(report); |
| | | // |
| | | // beforeRecord.setDeductMoney(latestRecord.getDeductMoney()); |
| | | // calculateRecordMapper.updateById(beforeRecord); |
| | | List<CalculateReportBackfillForm.RecordForm> recordList = form.getRecordList(); |
| | | if(!CollectionUtils.isEmpty(recordList)) calculateRecordMapper.updateBatch(recordList); |
| | | return Result.ok("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result updatePublishStatus(Long reportId) { |
| | | CalculateReport report = baseMapper.selectById(reportId); |
| | | if (Objects.isNull(report)) { |
| | | throw new RuntimeException("该核算报告不存在"); |
| | | } |
| | | if (CalculateReportStatusEnum.NOT_PUBLISH.equals(report.getStatus())) { |
| | | report.setStatus(CalculateReportStatusEnum.PUBLISHED); |
| | | } else if (CalculateReportStatusEnum.PUBLISHED.equals(report.getStatus())) { |
| | | report.setStatus(CalculateReportStatusEnum.NOT_PUBLISH); |
| | | } |
| | | baseMapper.updateById(report); |
| | | public Result updatePublishStatus(Integer contractId,Integer whichYear) { |
| | | |
| | | calculateRecordMapper.batchPublish(contractId,whichYear); |
| | | return Result.ok("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result updatePublishStatusById(Integer id, String status) { |
| | | calculateRecordMapper.updatePublishById(id,status); |
| | | return Result.ok("操作成功"); |
| | | } |
| | | |