|
|
@@ -5198,10 +5198,63 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
// 1. 先将有数据的保险公司进行汇总
|
|
|
// 累计应收金额, 应收手续费(手续费), 应收手续费(手续费)
|
|
|
List<CompanySuperviseSettlementReportDto> allCompaniesIncomeDatas = baseMapper.queryCumulativeAccountsReceivable(systemCode, queryVo);
|
|
|
- allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream().peek(action-> action.setId(action.getCompanyId())).toList();
|
|
|
// for test, 查看一家公司的数据,将不可变对象变成 可变对象
|
|
|
// allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream().filter(action-> "1738811735599338932".equals(action.getCompanyId())).toList();
|
|
|
// allCompaniesIncomeDatas = new ArrayList<>(allCompaniesIncomeDatas);
|
|
|
+
|
|
|
+ // 直接从allCompaniesIncomeDatas获取到incomeId,然后过滤数据
|
|
|
+ List<InsPlyIncomeDto> dtoList = allCompaniesIncomeDatas.stream()
|
|
|
+ .map(CompanySuperviseSettlementReportDto::getId)
|
|
|
+ .map(id -> {
|
|
|
+ InsPlyIncomeDto dto = new InsPlyIncomeDto();
|
|
|
+ dto.setId(id);
|
|
|
+ return dto;
|
|
|
+ })
|
|
|
+ .toList();
|
|
|
+ // 过滤数据
|
|
|
+ List<InsPlyIncomeDto> filterIncomeList = filterIncomeByInvoiceAndSettleCondition(dtoList, queryVo);
|
|
|
+ allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream().filter(all -> filterIncomeList.stream().anyMatch(x -> x.getId().equals(all.getId()))).toList();
|
|
|
+
|
|
|
+ // 将allCompaniesIncomeDatas中相同的companyId的totalReceivable、totalFollowFee、superviseFee、followFee数据相加,并只保留一条
|
|
|
+ // 按公司ID分组聚合求和
|
|
|
+ Map<String, List<CompanySuperviseSettlementReportDto>> groupByCompany = allCompaniesIncomeDatas.stream()
|
|
|
+ .collect(Collectors.groupingBy(CompanySuperviseSettlementReportDto::getCompanyId));
|
|
|
+
|
|
|
+ // 聚合结果集合
|
|
|
+ List<CompanySuperviseSettlementReportDto> resultList = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, List<CompanySuperviseSettlementReportDto>> entry : groupByCompany.entrySet()) {
|
|
|
+ List<CompanySuperviseSettlementReportDto> groupList = entry.getValue();
|
|
|
+ CompanySuperviseSettlementReportDto sumDto = new CompanySuperviseSettlementReportDto();
|
|
|
+ // 赋值固定字段(取第一条即可)
|
|
|
+ sumDto.setCompanyId(entry.getKey());
|
|
|
+ CompanySuperviseSettlementReportDto first = groupList.get(0);
|
|
|
+ sumDto.setCompanyName(first.getCompanyName());
|
|
|
+ // 数值累加
|
|
|
+ BigDecimal totalReceivable = groupList.stream()
|
|
|
+ .map(x -> new BigDecimal(x.getTotalReceivable()))
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal totalFollowFee = groupList.stream()
|
|
|
+ .map(x -> new BigDecimal(x.getTotalFollowFee()))
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal superviseFee = groupList.stream()
|
|
|
+ .map(x -> new BigDecimal(x.getSuperviseFee()))
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal followFee = groupList.stream()
|
|
|
+ .map(x -> new BigDecimal(x.getFollowFee()))
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+
|
|
|
+ sumDto.setTotalReceivable(totalReceivable.toString());
|
|
|
+ sumDto.setTotalFollowFee(totalFollowFee.toString());
|
|
|
+ sumDto.setSuperviseFee(superviseFee.toString());
|
|
|
+ sumDto.setFollowFee(followFee.toString());
|
|
|
+ sumDto.setParentId(first.getParentId());
|
|
|
+ resultList.add(sumDto);
|
|
|
+ }
|
|
|
+ // 最终聚合完成的数据
|
|
|
+ allCompaniesIncomeDatas = resultList;
|
|
|
+
|
|
|
+ allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream().peek(action-> action.setId(action.getCompanyId())).toList();
|
|
|
+
|
|
|
if (CollUtil.isEmpty(allCompaniesIncomeDatas)) {
|
|
|
String msg = String.format("租户%s下暂时没有手续费",systemCode);
|
|
|
log.info(msg);
|
|
|
@@ -5214,6 +5267,14 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
}
|
|
|
// 2. 汇总后,计算得到已开票,未开票,已结算,未结算的数据
|
|
|
allCompaniesIncomeDatas = this.calStatisAmount(allCompaniesIncomeDatas, queryVo, systemCode);
|
|
|
+ // 保留已开票的数据
|
|
|
+ if ("1".equals(queryVo.getInvoiceStatus())){
|
|
|
+ allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream().filter(action-> StrUtil.isNotBlank(action.getSxfUnSettledAmount()) && !"0".equals(action.getSxfUnSettledAmount())).toList();
|
|
|
+ }else if ("0".equals(queryVo.getInvoiceStatus())){
|
|
|
+ // 保留未开票的数据
|
|
|
+ allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream().filter(action-> StrUtil.isBlank(action.getSxfUnSettledAmount()) || "0".equals(action.getSxfUnSettledAmount())).toList();
|
|
|
+ }
|
|
|
+
|
|
|
// 3. 填充保险公司的父级保险公司
|
|
|
allCompaniesIncomeDatas = this.fillParentCompany(allCompaniesIncomeDatas);
|
|
|
log.info("构建树形结构之前的数据:allCompaniesIncomeDatas=[{}]", JSONUtil.toJsonStr(allCompaniesIncomeDatas));
|