Răsfoiți Sursa

修改bug:
私有应收-手续费 筛选结算状态时,显示的不对,筛选什么都是全部显示;筛选未结算时,将有未结算金额的显示

jiakai 2 luni în urmă
părinte
comite
651b353328

+ 2 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/CompanySuperviseSettlementReportDto.java

@@ -2,6 +2,7 @@ package com.jzg.commons.entity.finance.dto;
 
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import java.io.Serial;
 import java.io.Serializable;
@@ -13,6 +14,7 @@ import java.util.List;
  */
 
 @Data
+@NoArgsConstructor
 public class CompanySuperviseSettlementReportDto implements Serializable {
 
 

+ 62 - 1
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -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));

+ 2 - 0
tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

@@ -1914,6 +1914,7 @@
     <select id="queryCumulativeAccountsReceivable"
             resultType="com.jzg.commons.entity.finance.dto.CompanySuperviseSettlementReportDto">
         select
+        ipi.id,
         eic.parent_id,
         ipi.company_id,
         ipi.system_code,
@@ -1938,6 +1939,7 @@
             </if>
         </where>
         group by
+        ipi.id,
         eic.parent_id,
         ipi.company_id,
         ipi.system_code