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

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

lipf 2 месяцев назад
Родитель
Сommit
dafe410c80

+ 31 - 7
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -802,7 +802,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         Map<String, List<FollowCompanyFeeVO>> followGroupMap = followCompanyFeeVos.stream()
                 .collect(Collectors.groupingBy(this::buildGroupKey));
 
-        // 【核心优化】提前收集所有需要查询的ID,批量查询,彻底解决循环N+1
+        // 提前收集所有需要查询的ID,批量查询,彻底解决循环N+1
         Set<String> allFollowIds = new HashSet<>();
         Set<String> allSettlementIds = new HashSet<>();
         followGroupMap.values().forEach(list -> {
@@ -838,10 +838,14 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
 
             // 应收金额(取第一条)
             InsFeeFollowOrder firstFollow = followOrderMap.get(followIds.get(0));
-            BigDecimal receivablePremium = Optional.ofNullable(firstFollow)
-                    .map(InsFeeFollowOrder::getReceivablePremium)
+//            BigDecimal receivablePremium = Optional.ofNullable(firstFollow)
+//                    .map(InsFeeFollowOrder::getReceivablePremium)
+//                    .orElse(BigDecimal.ZERO);
+            // 对账金额
+            BigDecimal reconciliationAmount = Optional.ofNullable(firstFollow)
+                    .map(InsFeeFollowOrder::getReconciliationAmount)
                     .orElse(BigDecimal.ZERO);
-            vo.setTotalReceivable(receivablePremium);
+            vo.setTotalReceivable(reconciliationAmount);
 
             // 已开票总额
             BigDecimal totalInvoiced = followIds.stream()
@@ -850,7 +854,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                     .map(InsFeeFollowOrder::getInvoiced)
                     .reduce(BigDecimal.ZERO, BigDecimal::add);
             vo.setTotalInvoiced(totalInvoiced);
-            vo.setTotalUnInvoiced(receivablePremium.subtract(totalInvoiced));
+            // 根据需求,未开票总金额 = 对账金额 - 已开票金额
+            vo.setTotalUnInvoiced(reconciliationAmount.subtract(totalInvoiced));
 
             // 已结算总额
             BigDecimal totalSettlementAmount = settlementIds.stream()
@@ -3971,12 +3976,31 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                     if (StrUtil.isEmpty(search)) {
                         return true;
                     }
+                    List<String> companyIds = Arrays.asList(search.split(","));
+                    HttpResult parentIds = null;
+                    if (companyIds.size() <= 2){
+                        parentIds = esmInsCompanyClient.getParentIds(companyIds);
+                    }
                     if ("等于".equalsIgnoreCase(type) || "包含".equalsIgnoreCase(type)) {
-                        List<String> companyIds = Arrays.asList(search.split(","));
+                        if (null != parentIds && parentIds.isSuccess()){
+                            List<String> data = (List<String>) parentIds.getData();
+                            if (CollUtil.isNotEmpty(data) && data.contains(insPlyIncome.getPartnerCompanyId())){
+                                return true;
+                            }else{
+                                return false;
+                            }
+                        }
                         return companyIds.contains(insPlyIncome.getPartnerCompanyId());
                     }
                     if ("不等于".equalsIgnoreCase(type) || "不包含".equalsIgnoreCase(type)) {
-                        List<String> companyIds = Arrays.asList(search.split(","));
+                        if (null != parentIds && parentIds.isSuccess()){
+                            List<String> data = (List<String>) parentIds.getData();
+                            if (CollUtil.isNotEmpty(data) && !data.contains(insPlyIncome.getPartnerCompanyId())){
+                                return true;
+                            }else{
+                                return false;
+                            }
+                        }
                         return !companyIds.contains(insPlyIncome.getPartnerCompanyId());
                     }
                     return true;