wujianwei
2026-03-27 279366f14d6e1361b6caf7c05b74f0cea4227a36
service/src/main/java/com/ruoyi/cwgl/service/impl/ReceivableBillManagementServiceImpl.java
@@ -1,18 +1,17 @@
package com.ruoyi.cwgl.service.impl;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import javax.annotation.Resource;
import com.ruoyi.cwgl.domain.ReceivableBillCustomerSummary;
import com.ruoyi.cwgl.domain.*;
import com.ruoyi.cwgl.domain.vo.ReceivableBillAgingAnalysisVo;
import com.ruoyi.cwgl.mapper.ReceivableFeeManagementMapper;
import com.ruoyi.cwgl.domain.vo.ReceivableBillAccountAnalysisVo;
import com.ruoyi.cwgl.mapper.*;
import com.ruoyi.cwgl.service.IAgingLogService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -22,13 +21,7 @@
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.core.service.BaseService;
import com.ruoyi.cwgl.mapper.ReceivableBillManagementMapper;
import com.ruoyi.cwgl.domain.ReceivableBillManagement;
import com.ruoyi.cwgl.domain.ReceivableFeeManagement;
import com.ruoyi.cwgl.domain.ReceivableBillManagementLog;
import com.ruoyi.cwgl.service.IReceivableBillManagementLogService;
import com.ruoyi.cwgl.service.IReceivableBillManagementService;
import com.ruoyi.cwgl.service.IReceivableFeeManagementService;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
@@ -50,7 +43,11 @@
    private ReceivableFeeManagementMapper receivableFeeManagementMapper;
    
    @Resource
    private IReceivableBillManagementLogService receivableBillManagementLogService;
    private ReceivableBillManagementLogMapper receivableBillManagementLogMapper;
    @Resource
    private AgingLogMapper agingLogMapper;
    @Resource
    private AccountLogMapper accountLogMapper;
    /**
@@ -108,6 +105,41 @@
            PageUtils.startPage(pageNum, Constants.EXPORT_PATE_SIZE);
            return selectReceivableBillManagementList(receivableBillManagement);
        });
    }   /**
     * 查询应收账单管理列表 异步 导出
     *
     * @param receivableBillManagement 应收账单管理
     * @param exportKey 导出功能的唯一标识
     * @return 应收账单管理集合
     */
    @DataSource(DataSourceType.SLAVE)
    @Async
    @Override
    public void customerSummaryExport(ReceivableBillManagement receivableBillManagement,String exportKey) {
        super.export2(ReceivableBillCustomerSummary.class,exportKey,"应收账款分析管理",(pageNum)->{
            PageUtils.startPage(pageNum, Constants.EXPORT_PATE_SIZE);
            return selectReceivableBillCustomerSummaryList(receivableBillManagement);
        });
    }  @DataSource(DataSourceType.SLAVE)
    @Async
    @Override
    public void agingAnalysisExport(ReceivableBillManagement receivableBillManagement,String exportKey) {
        super.export2(ReceivableBillAgingAnalysisVo.class,exportKey,"应收账款分析管理",(pageNum)->{
            PageUtils.startPage(pageNum, Constants.EXPORT_PATE_SIZE);
            return selectReceivableBillAgingAnalysisList(receivableBillManagement);
        });
    }
    @Async
    @Override
    public void accountAnalysisExport(ReceivableBillManagement receivableBillManagement,String exportKey) {
        super.export2(ReceivableBillAccountAnalysisVo.class,exportKey,"应收账款分析管理",(pageNum)->{
            PageUtils.startPage(pageNum, Constants.EXPORT_PATE_SIZE);
            return selectReceivableBillAccountAnalysisList(receivableBillManagement);
        });
    }
@@ -156,9 +188,44 @@
            log.setCreateBy(SecurityUtils.getUsername());
            log.setCreateTime(DateUtils.getNowDate());
            log.setOperation("修改应收账单,账单编号:" + receivableBillManagement.getSystemNo());
            receivableBillManagementLogService.insertReceivableBillManagementLog(log);
            receivableBillManagementLogMapper.insertReceivableBillManagementLog(log);
        }
        
        return result;
    } @Override
    public int aging(ReceivableBillManagement receivableBillManagement)
    {
        receivableBillManagement.setUpdateTime(DateUtils.getNowDate());
        int result = receivableBillManagementMapper.updateReceivableBillManagement(receivableBillManagement);
        // 记录操作日志
        if (result > 0) {
            AgingLog log = new AgingLog();
            log.setHeadId(receivableBillManagement.getId());
            log.setCreateBy(SecurityUtils.getUsername());
            log.setCreateTime(DateUtils.getNowDate());
            log.setOperation("编辑账龄分析信息");
            agingLogMapper.insertAgingLog(log);
        }
        return result;
    }
    @Override
    public int account(ReceivableBillManagement receivableBillManagement)
    {
        receivableBillManagement.setUpdateTime(DateUtils.getNowDate());
        int result = receivableBillManagementMapper.updateReceivableBillManagement(receivableBillManagement);
        // 记录操作日志
        if (result > 0) {
            AccountLog log = new AccountLog();
            log.setHeadId(receivableBillManagement.getId());
            log.setCreateBy(SecurityUtils.getUsername());
            log.setCreateTime(DateUtils.getNowDate());
            log.setOperation("编辑账款分析信息");
            accountLogMapper.insertAccountLog(log);
        }
        return result;
    }
@@ -256,7 +323,7 @@
            log.setCreateBy(SecurityUtils.getUsername());
            log.setCreateTime(DateUtils.getNowDate());
            log.setOperation("作废应收账单,账单编号:" + billManagement.getSystemNo());
            receivableBillManagementLogService.insertReceivableBillManagementLog(log);
            receivableBillManagementLogMapper.insertReceivableBillManagementLog(log);
        }
        
        return result;
@@ -315,4 +382,20 @@
    {
        return receivableBillManagementMapper.batchUpdateAgingAnalysisData();
    }
    /**
     * 查询应收账单账款分析列表
     *
     * @param receivableBillManagement 查询条件
     * @return 应收账单账款分析列表
     */
    @DataSource(DataSourceType.SLAVE)
    @Override
    public List<ReceivableBillAccountAnalysisVo> selectReceivableBillAccountAnalysisList(ReceivableBillManagement receivableBillManagement)
    {
        // 直接查询数据库中的账款分析数据
        List<ReceivableBillAccountAnalysisVo> result = receivableBillManagementMapper.selectReceivableBillAccountAnalysisList(receivableBillManagement);
        return result;
    }
}