sen
2025-12-22 84897f28662a94a6caec972c543538c2c9fdf0f5
service/src/main/java/com/ruoyi/cwgl/service/impl/ReceivableFeeManagementServiceImpl.java
@@ -4,7 +4,10 @@
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import com.ruoyi.common.enums.SystemDataNoEnum;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import javax.annotation.Resource;
@@ -12,6 +15,7 @@
import com.ruoyi.cwgl.domain.vo.ReceivableFeeStatisticsVo;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.mapper.SysConfigMapper;
import com.ruoyi.system.service.ISystemDataNoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
@@ -61,6 +65,8 @@
    @Autowired
    private IReceivableBillSettlementDetailService receivableBillSettlementDetailService;
    @Autowired
    ISystemDataNoService systemDataNoService;
    /**
     * 查询应收费用管理
@@ -130,7 +136,9 @@
    public int insertReceivableFeeManagement(ReceivableFeeManagement receivableFeeManagement)
    {
        receivableFeeManagement.setCreateTime(DateUtils.getNowDate());
        String noByKey = systemDataNoService.getNoByKey(SystemDataNoEnum.YS);
        receivableFeeManagement.setSystemNo(noByKey);
        // 保存主表信息
        int result = receivableFeeManagementMapper.insertReceivableFeeManagement(receivableFeeManagement);
        
@@ -239,6 +247,17 @@
        // 查询应收费用主表记录
        List<ReceivableFeeManagement> receivableFeeList = receivableFeeManagementMapper.selectReceivableFeeManagementByIds(ids);
        
        // 检查所有记录是否属于同一个客户
        if (!receivableFeeList.isEmpty()) {
            Integer firstCustomerId = receivableFeeList.get(0).getCustomerId();
            boolean allSameCustomer = receivableFeeList.stream()
                    .allMatch(item -> Objects.equals(item.getCustomerId(), firstCustomerId));
            if (!allSameCustomer) {
                throw new ServiceException("所选记录包含不同客户的数据,无法进行统计");
            }
        }
        // 计算单据数量
        int documentCount = receivableFeeList.size();
        SysConfig sysConfig = sysConfigMapper.selectConfig(new SysConfig() {{