fuliqi
2025-01-06 7a93f4097430703dc60c4aee0240ed348a0ab1df
ycl-server/src/main/java/com/ycl/platform/service/impl/CalculateReportServiceImpl.java
@@ -143,9 +143,9 @@
     * @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);
@@ -172,40 +172,40 @@
    @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("操作成功");
    }