|
|
@@ -405,11 +405,9 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
incomeDataVO.setAgreementType("1");
|
|
|
}
|
|
|
List<InsPlyIncome> incomes = baseMapper.queryIncomeDatasByOrderIds(orderNos,companyId,incomeDataVO.getInvoiceType(),incomeDataVO.getAgreementType());
|
|
|
- log.info("根据订单号和保司id查询出[{}]条记录。 orderNos =[{}],companyId=[{}]",CollUtil.size(incomes), JSONUtil.toJsonStr(orderNos), companyId);
|
|
|
+ log.info("根据订单号查询出[{}]条记录。 orderNos =[{}]",CollUtil.size(incomes), JSONUtil.toJsonStr(orderNos));
|
|
|
// 需要查询未结算的数据 modify by lipf 2026年6月4日11:06:50
|
|
|
- incomes = incomes.stream().filter(action->{
|
|
|
- return "0".equals(action.getSettlementStatus());
|
|
|
- }).toList();
|
|
|
+ incomes = incomes.stream().filter(action-> "0".equals(action.getSettlementStatus())).toList();
|
|
|
List<InsPlyIncome> filterIncomes = new ArrayList<>();
|
|
|
if(CollUtil.isEmpty(incomeDataVO.getSearchList())){
|
|
|
filterIncomes = incomes;
|
|
|
@@ -5728,12 +5726,6 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
List<CompanySuperviseSettlementReportDto> allCompaniesIncomeDatas = baseMapper.queryCumulativeAccountsReceivable(systemCode, queryVo);
|
|
|
// 结算状态在上面的sql进行过筛选了,后面就不再筛选了
|
|
|
queryVo.setStatus(null);
|
|
|
-// if("20".equals(queryVo.getAccountsReceivable())){
|
|
|
-// allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream().peek(action->{
|
|
|
-// // 统计非车的手续费
|
|
|
-// action.setSuperviseFee(action.getSuperviseFee4Other());
|
|
|
-// }).toList();
|
|
|
-// }
|
|
|
|
|
|
// 车险
|
|
|
if("10".equals(queryVo.getAccountsReceivable())){
|
|
|
@@ -5750,11 +5742,6 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
action.setSuperviseFee(BigDecimalUtil.add(action.getSuperviseFee(), action.getSuperviseFee4Other()));
|
|
|
}).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)
|
|
|
@@ -5768,7 +5755,6 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
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::getPartnerCompanyId));
|
|
|
@@ -5777,15 +5763,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
List<CompanySuperviseSettlementReportDto> resultList = new ArrayList<>();
|
|
|
for (Map.Entry<String, List<CompanySuperviseSettlementReportDto>> entry : groupByCompany.entrySet()) {
|
|
|
List<CompanySuperviseSettlementReportDto> groupList = entry.getValue();
|
|
|
- CompanySuperviseSettlementReportDto sumDto = new CompanySuperviseSettlementReportDto();
|
|
|
- // 赋值固定字段(取第一条即可)
|
|
|
- sumDto.setPartnerCompanyId(entry.getKey());
|
|
|
-
|
|
|
- CompanySuperviseSettlementReportDto first = groupList.get(0);
|
|
|
- sumDto.setParentId(first.getParentId());
|
|
|
- sumDto.setCompanyId(first.getCompanyId());
|
|
|
- sumDto.setPartnerCompanyName(first.getPartnerCompanyName());
|
|
|
- sumDto.setCompanyName(first.getCompanyName());
|
|
|
+ CompanySuperviseSettlementReportDto firstReportDto = groupList.get(0);
|
|
|
+ CompanySuperviseSettlementReportDto sumDto = new CompanySuperviseSettlementReportDto(firstReportDto.getCompanyId(), firstReportDto.getSecondCompanyId(),firstReportDto.getPartnerCompanyId());
|
|
|
// 数值累加
|
|
|
BigDecimal totalReceivable = groupList.stream()
|
|
|
.map(x -> new BigDecimal(x.getTotalReceivable()))
|
|
|
@@ -5828,7 +5807,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
allCompaniesIncomeDatas = this.fillParentCompany(allCompaniesIncomeDatas);
|
|
|
log.info("构建树形结构之前的数据:allCompaniesIncomeDatas.size=[{}]", CollUtil.size(allCompaniesIncomeDatas));
|
|
|
// 4. 构建树型结构
|
|
|
- List<Tree<String>> roots = buildTree(allCompaniesIncomeDatas);
|
|
|
+ List<Tree<String>> roots = this.buildTree(allCompaniesIncomeDatas);
|
|
|
return HttpResult.ok(roots);
|
|
|
}
|
|
|
|
|
|
@@ -5879,14 +5858,14 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
Map<String, CompanySuperviseSettlementReportDto> companyMap;
|
|
|
companyMap = allCompaniesIncomeDatas.stream()
|
|
|
.peek(action->{
|
|
|
- EsmInsCompany esmInsCompany = bsMap.get(action.getCompanyId());
|
|
|
+ EsmInsCompany esmInsCompany = bsMap.get(action.getPartnerCompanyId());
|
|
|
if(esmInsCompany != null){
|
|
|
action.setCompanyName(esmInsCompany.getNameSimple());
|
|
|
}else{
|
|
|
- action.setCompanyName(action.getCompanyId());
|
|
|
+ action.setCompanyName(action.getPartnerCompanyId());
|
|
|
}
|
|
|
}).collect(Collectors.toMap(
|
|
|
- CompanySuperviseSettlementReportDto::getCompanyId,
|
|
|
+ CompanySuperviseSettlementReportDto::getPartnerCompanyId,
|
|
|
Function.identity(),
|
|
|
(a, b) -> a
|
|
|
));
|
|
|
@@ -5948,6 +5927,21 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
return new ArrayList<>(companyMap.values().stream().toList());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 通用金额汇总方法
|
|
|
+ * @param list 数据列表
|
|
|
+ * @param getter 获取字段值的函数
|
|
|
+ * @return 汇总后的金额字符串
|
|
|
+ */
|
|
|
+ private String sumAmount(List<CompanySuperviseSettlementReportDto> list,
|
|
|
+ Function<CompanySuperviseSettlementReportDto, String> getter) {
|
|
|
+ return list.stream()
|
|
|
+ .map(getter)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(BigDecimal::new)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add)
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 填充父级保司信息
|
|
|
@@ -5973,54 +5967,90 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
HttpResult<Map<String, EsmInsCompany>> allCompanyMapRes = esmInsCompanyClient.queryAllCompanyMap();
|
|
|
Map<String, EsmInsCompany> companys = allCompanyMapRes.getData();
|
|
|
|
|
|
-// // 填充保险公司的, 这里保险公司最多三级
|
|
|
- List<CompanySuperviseSettlementReportDto> secondCompanyList = new ArrayList<>();
|
|
|
- Set<String> existCompanyIds = allCompaniesIncomeDatas.stream().map(CompanySuperviseSettlementReportDto::getCompanyId).collect(Collectors.toSet());
|
|
|
-
|
|
|
- for (CompanySuperviseSettlementReportDto thirdCompany : allCompaniesIncomeDatas) {
|
|
|
- if(!"0".equals(thirdCompany.getParentId()) && !existCompanyIds.contains(thirdCompany.getParentId()) ){
|
|
|
- String companyName = thirdCompany.getParentId();
|
|
|
- EsmInsCompany esmInsCompany = companys.get(thirdCompany.getParentId());
|
|
|
- if(esmInsCompany != null){
|
|
|
- companyName = esmInsCompany.getNameSimple();
|
|
|
- secondCompanyList.add(new CompanySuperviseSettlementReportDto(thirdCompany.getParentId(),companyName,esmInsCompany.getParentId()));
|
|
|
- log.info("====获取保险公司的名称:[{}]-[{}]",thirdCompany.getParentId(),companyName);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- List<CompanySuperviseSettlementReportDto> firstCompanyList = new ArrayList<>();
|
|
|
- for (CompanySuperviseSettlementReportDto secondCompany : secondCompanyList) {
|
|
|
- EsmInsCompany pp = companys.get(secondCompany.getCompanyId());
|
|
|
- if(pp != null){
|
|
|
- String parentId = pp.getParentId();
|
|
|
- String companyName;
|
|
|
- EsmInsCompany firstCompany = companys.get(parentId);
|
|
|
- if(firstCompany != null){
|
|
|
- companyName = firstCompany.getNameSimple();
|
|
|
- firstCompanyList.add(new CompanySuperviseSettlementReportDto(firstCompany.getId(),companyName,firstCompany.getParentId()));
|
|
|
- log.info("====获取保险公司的名称:[{}]-[{}]",firstCompany.getId(),companyName);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(CollUtil.isNotEmpty(secondCompanyList)){
|
|
|
- allCompaniesIncomeDatas.addAll(secondCompanyList);
|
|
|
+ allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream().peek(action->{
|
|
|
+ // 第三级别
|
|
|
+ action.setId(action.getPartnerCompanyId());
|
|
|
+ action.setParentId(action.getSecondCompanyId());
|
|
|
+ }).toList();
|
|
|
+ List<CompanySuperviseSettlementReportDto> result = new ArrayList<>(allCompaniesIncomeDatas);
|
|
|
+ Map<String, List<CompanySuperviseSettlementReportDto>> secondCompanys = allCompaniesIncomeDatas.stream().collect(Collectors.groupingBy(CompanySuperviseSettlementReportDto::getSecondCompanyId));
|
|
|
+ for (Map.Entry<String, List<CompanySuperviseSettlementReportDto>> entry : secondCompanys.entrySet()) {
|
|
|
+ String secondCompanyId = entry.getKey(); // 获取 Map 的键
|
|
|
+ List<CompanySuperviseSettlementReportDto> reportList = entry.getValue(); // 获取对应的 List
|
|
|
+ CompanySuperviseSettlementReportDto dto = fillReportDto4Money(reportList);
|
|
|
+ dto.setId(secondCompanyId);
|
|
|
+ dto.setParentId(reportList.get(0).getCompanyId());
|
|
|
+ result.add(dto);
|
|
|
}
|
|
|
- if(CollUtil.isNotEmpty(firstCompanyList)){
|
|
|
- allCompaniesIncomeDatas.addAll(firstCompanyList);
|
|
|
+
|
|
|
+ Map<String, List<CompanySuperviseSettlementReportDto>> firstCompanys = allCompaniesIncomeDatas.stream().collect(Collectors.groupingBy(CompanySuperviseSettlementReportDto::getCompanyId));
|
|
|
+ for (Map.Entry<String, List<CompanySuperviseSettlementReportDto>> entry : firstCompanys.entrySet()) {
|
|
|
+ List<CompanySuperviseSettlementReportDto> reportList = entry.getValue(); // 获取对应的 List
|
|
|
+ CompanySuperviseSettlementReportDto dto = fillReportDto4Money(reportList);
|
|
|
+ dto.setParentId("0");
|
|
|
+ dto.setId(reportList.get(0).getCompanyId());
|
|
|
+ result.add(dto);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
log.info("填充父级目录后,保险公司级别的数据[{}]条,原先的数据条数是[{}]条", CollUtil.size(allCompaniesIncomeDatas),count);
|
|
|
- allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream()
|
|
|
+ result = result.stream()
|
|
|
.peek(action->{
|
|
|
- EsmInsCompany esmInsCompany = companys.get(action.getCompanyId());
|
|
|
+ EsmInsCompany esmInsCompany = companys.get(action.getId());
|
|
|
if(esmInsCompany != null){
|
|
|
action.setCompanyName(esmInsCompany.getNameSimple());
|
|
|
}else{
|
|
|
action.setCompanyName(action.getCompanyId());
|
|
|
}
|
|
|
}).toList();
|
|
|
-// var res = allCompaniesIncomeDatas.stream().map(CompanySuperviseSettlementReportDto::getCompanyName).toList();
|
|
|
-// log.info("res=[{}]", JSONUtil.toJsonStr(res));
|
|
|
- return allCompaniesIncomeDatas;
|
|
|
+ return result;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 对金额进行汇总求和
|
|
|
+ *
|
|
|
+ *
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/8/1 8:44
|
|
|
+ */
|
|
|
+ private CompanySuperviseSettlementReportDto fillReportDto4Money(List<CompanySuperviseSettlementReportDto> reportList) {
|
|
|
+ CompanySuperviseSettlementReportDto dto = new CompanySuperviseSettlementReportDto();
|
|
|
+ // 累计应收金额(手续费页面展示)
|
|
|
+ dto.setTotalReceivable(sumAmount(reportList, CompanySuperviseSettlementReportDto::getTotalReceivable));
|
|
|
+ // 累计应收金额(跟单费页面展示)
|
|
|
+ dto.setTotalFollowFee(sumAmount(reportList, CompanySuperviseSettlementReportDto::getTotalFollowFee));
|
|
|
+ // 应收手续费(车险)
|
|
|
+ dto.setSuperviseFee(sumAmount(reportList, CompanySuperviseSettlementReportDto::getSuperviseFee));
|
|
|
+ // 应收手续费(非车险)
|
|
|
+ dto.setSuperviseFee4Other(sumAmount(reportList, CompanySuperviseSettlementReportDto::getSuperviseFee4Other));
|
|
|
+ // 应收跟单费
|
|
|
+ dto.setFollowFee(sumAmount(reportList, CompanySuperviseSettlementReportDto::getFollowFee));
|
|
|
+ // 手续费已开票金额
|
|
|
+ dto.setSxfInvoicedAmount(sumAmount(reportList, CompanySuperviseSettlementReportDto::getSxfInvoicedAmount));
|
|
|
+ // 手续费未开票金额
|
|
|
+ dto.setSxfUnInvoicedAmount(sumAmount(reportList, CompanySuperviseSettlementReportDto::getSxfUnInvoicedAmount));
|
|
|
+ // 跟单费已开票金额
|
|
|
+ dto.setGdfInvoicedAmount(sumAmount(reportList, CompanySuperviseSettlementReportDto::getGdfInvoicedAmount));
|
|
|
+ // 跟单费未开票金额
|
|
|
+ dto.setGdfUnInvoicedAmount(sumAmount(reportList, CompanySuperviseSettlementReportDto::getGdfUnInvoicedAmount));
|
|
|
+ // 平台已开票金额
|
|
|
+ dto.setPtInvoicedAmount(sumAmount(reportList, CompanySuperviseSettlementReportDto::getPtInvoicedAmount));
|
|
|
+ // 平台未开票金额
|
|
|
+ dto.setPtUnInvoicedAmount(sumAmount(reportList, CompanySuperviseSettlementReportDto::getPtUnInvoicedAmount));
|
|
|
+ // 手续费已结算金额
|
|
|
+ dto.setSxfSettledAmount(sumAmount(reportList, CompanySuperviseSettlementReportDto::getSxfSettledAmount));
|
|
|
+ // 手续费未结算金额
|
|
|
+ dto.setSxfUnSettledAmount(sumAmount(reportList, CompanySuperviseSettlementReportDto::getSxfUnSettledAmount));
|
|
|
+ // 跟单费已结算金额
|
|
|
+ dto.setGdfSettledAmount(sumAmount(reportList, CompanySuperviseSettlementReportDto::getGdfSettledAmount));
|
|
|
+ // 跟单费未结算金额
|
|
|
+ dto.setGdfUnSettledAmount(sumAmount(reportList, CompanySuperviseSettlementReportDto::getGdfUnSettledAmount));
|
|
|
+ // 虚增金额合计
|
|
|
+ dto.setTotalOverinflatedAmount(sumAmount(reportList, CompanySuperviseSettlementReportDto::getTotalOverinflatedAmount));
|
|
|
+ // 回款差额合计
|
|
|
+ dto.setSettlementPaymentDifference(sumAmount(reportList, CompanySuperviseSettlementReportDto::getSettlementPaymentDifference));
|
|
|
+ return dto;
|
|
|
}
|
|
|
|
|
|
/**
|