Просмотр исходного кода

Merge remote-tracking branch 'origin/dev_jzg_lipf_v20260622' into dev_jzg_lipf_v20260622

lipf 2 недель назад
Родитель
Сommit
da1c5e4930

+ 3 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/SettlementQueryVo.java

@@ -77,6 +77,9 @@ public class SettlementQueryVo extends PageRequest {
     @Schema(description = "开票类型集合")
     private List<String> invoiceTypes;
 
+    @Schema(description = "公司id集合")
+    private List<String> companyIdList;
+
     @Schema(description = "协议类型 1-平台协议 2-私有协议")
     private String agreementType;
 

+ 47 - 0
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -942,6 +942,35 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         // 5. 将其他费用收入合并进结果集合
         mergeOtherCostIncomeToResult(filterIncomeList, resultList, companyMap);
 
+        if (CollUtil.isEmpty(resultList)){
+            return resultList;
+        }
+
+        // 按companyName分组,组内year+month升序,最后打平
+        resultList = resultList.stream()
+                // 按公司名称分组
+                .collect(Collectors.groupingBy(FollowCompanyFeeVO::getCompanyName))
+                // 获取分组后的value集合
+                .values()
+                .stream()
+                // 组内排序:先转数字,year升序,month升序
+                .map(group -> group.stream()
+                        .sorted((o1, o2) -> {
+                            // year、month字符串转Integer
+                            int y1 = Integer.parseInt(o1.getYear());
+                            int m1 = Integer.parseInt(o1.getMonth());
+                            int y2 = Integer.parseInt(o2.getYear());
+                            int m2 = Integer.parseInt(o2.getMonth());
+                            if (y1 != y2) {
+                                return Integer.compare(y1, y2);
+                            }
+                            return Integer.compare(m1, m2);
+                        })
+                        .collect(Collectors.toList()))
+                // 将各个公司分组的list打平成一个大list
+                .flatMap(List::stream)
+                .collect(Collectors.toList());
+
         return resultList;
     }
 
@@ -5551,6 +5580,24 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         log.info("superviseSettlementDetailExcel:settlementQueryVo=[{}]", JSONUtil.toJsonStr(settlementQueryVo));
         settlementQueryVo.setSystemCode(baseController.getSystemCode());
         Page<ExportSuperviseSettlementDetailExcelDto> exportSuperviseSettlementDetailExcelDtos = null;
+
+        // 1. 一次性获取保险公司全量Map,全局复用
+        Map<String, EsmInsCompany> companyMap = getAllInsCompanyMap();
+        if (CollUtil.isEmpty(companyMap)) {
+            return exportSuperviseSettlementDetailExcelDtos;
+        }
+
+        // 查询当前公司下所有的子公司
+        if (StrUtil.isNotBlank(settlementQueryVo.getCompanyId())){
+            // 将全量数据按照 parentId 进行分组,key 是 parentId,value 是该 parentId 下的所有公司列表
+            Map<String, List<EsmInsCompany>> parentGroupMap = companyMap.values().stream()
+                    .filter(c -> c.getParentId() != null)
+                    .collect(Collectors.groupingBy(EsmInsCompany::getParentId));
+            List<String> allChildIdspOtimized = getAllChildIdsOptimized(settlementQueryVo.getCompanyId(), parentGroupMap);
+            allChildIdspOtimized.add(settlementQueryVo.getCompanyId());
+            settlementQueryVo.setCompanyIdList(allChildIdspOtimized);
+        }
+
         if (settlementQueryVo.getInvoiceTypes().contains("5") && settlementQueryVo.getInvoiceTypes().contains("6")) {
             exportSuperviseSettlementDetailExcelDtos = baseMapper.getPlatFormSettlementDetailExcelDtos(page, settlementQueryVo);
         }else{

+ 10 - 4
tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

@@ -978,8 +978,11 @@
             <if test="settlementQueryVo.invoiceId != null and settlementQueryVo.invoiceId != ''">
                 AND ipii.id = #{settlementQueryVo.invoiceId}
             </if>
-            <if test="settlementQueryVo.companyId != null and settlementQueryVo.companyId != ''">
-                AND ipi.partner_company_id = #{settlementQueryVo.companyId}
+            <if test="settlementQueryVo.companyIdList != null and settlementQueryVo.companyIdList.size() > 0" >
+                AND ipi.partner_company_id in
+                <foreach collection="settlementQueryVo.companyIdList" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
             </if>
             <if test="settlementQueryVo.invoiceParty != null and settlementQueryVo.invoiceParty != ''">
                 AND ipii.invoice_party = #{settlementQueryVo.invoiceParty}
@@ -1048,8 +1051,11 @@
             <if test="settlementQueryVo.invoiceId != null and settlementQueryVo.invoiceId != ''">
                 AND ipiis.invoice_id = #{settlementQueryVo.invoiceId}
             </if>
-            <if test="settlementQueryVo.companyId != null and settlementQueryVo.companyId != ''">
-                AND ipi.company_id = #{settlementQueryVo.companyId}
+            <if test="settlementQueryVo.companyIdList != null and settlementQueryVo.companyIdList.size() > 0" >
+                AND ipi.partner_company_id in
+                <foreach collection="settlementQueryVo.companyIdList" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
             </if>
             <if test="settlementQueryVo.contactPerson != null and settlementQueryVo.contactPerson != ''">
                 AND ipii.contact_person = #{settlementQueryVo.contactPerson}