From 307bc98d632594a5081d1bf21b392277df2b6893 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期五, 28 二月 2025 18:32:55 +0800
Subject: [PATCH] 运营加入 房屋和房屋明细功能

---
 service-user/src/main/java/com/java110/user/bmo/owner/impl/QueryOwnerStatisticsBMOImpl.java |  179 +++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 147 insertions(+), 32 deletions(-)

diff --git a/service-user/src/main/java/com/java110/user/bmo/owner/impl/QueryOwnerStatisticsBMOImpl.java b/service-user/src/main/java/com/java110/user/bmo/owner/impl/QueryOwnerStatisticsBMOImpl.java
index 19a8a4a..74c79f9 100644
--- a/service-user/src/main/java/com/java110/user/bmo/owner/impl/QueryOwnerStatisticsBMOImpl.java
+++ b/service-user/src/main/java/com/java110/user/bmo/owner/impl/QueryOwnerStatisticsBMOImpl.java
@@ -1,13 +1,19 @@
 package com.java110.user.bmo.owner.impl;
 
+import com.java110.dto.community.CommunityDto;
 import com.java110.dto.owner.OwnerDto;
-import com.java110.intf.community.IComplaintV1InnerServiceSMO;
+import com.java110.dto.room.RoomDto;
+import com.java110.intf.community.ICommunityV1InnerServiceSMO;
+import com.java110.intf.store.IComplaintV1InnerServiceSMO;
 import com.java110.intf.community.IRepairPoolV1InnerServiceSMO;
 import com.java110.intf.report.IReportOweFeeInnerServiceSMO;
+import com.java110.intf.store.IContractInnerServiceSMO;
 import com.java110.intf.user.IOwnerCarV1InnerServiceSMO;
 import com.java110.intf.user.IOwnerRoomRelV1InnerServiceSMO;
 import com.java110.intf.user.IOwnerV1InnerServiceSMO;
 import com.java110.user.bmo.owner.IQueryOwnerStatisticsBMO;
+import com.java110.utils.util.ListUtil;
+import com.java110.utils.util.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -20,7 +26,7 @@
 public class QueryOwnerStatisticsBMOImpl implements IQueryOwnerStatisticsBMO {
 
     public static final int MAX_LINE_COUNT = 15;
-    
+
     @Autowired
     private IOwnerRoomRelV1InnerServiceSMO ownerRoomRelV1InnerServiceSMOImpl;
 
@@ -39,60 +45,134 @@
     @Autowired
     private IReportOweFeeInnerServiceSMO reportOweFeeInnerServiceSMOImpl;
 
+    @Autowired
+    private IContractInnerServiceSMO contractInnerServiceSMOImpl;
+
+    @Autowired
+    private ICommunityV1InnerServiceSMO communityV1InnerServiceSMOImpl;
+
     @Override
     public List<OwnerDto> query(List<OwnerDto> ownerDtos) {
 
-        if(ownerDtos == null || ownerDtos.size() < 1){
+        if (ListUtil.isNull(ownerDtos)) {
             return ownerDtos;
         }
 
         //杩欓噷闄愬埗琛屾暟锛屼互鍏嶅奖鍝嶇郴缁熸�ц兘
-        if(ownerDtos.size() > MAX_LINE_COUNT){
+        if (ownerDtos.size() > MAX_LINE_COUNT) {
             return ownerDtos;
         }
         List<String> ownerIds = new ArrayList<>();
+        List<String> memberIds = new ArrayList<>();
         List<String> ownerTels = new ArrayList<>();
-        for(OwnerDto ownerDto : ownerDtos){
+        for (OwnerDto ownerDto : ownerDtos) {
             ownerIds.add(ownerDto.getOwnerId());
             ownerTels.add(ownerDto.getLink());
+            memberIds.add(ownerDto.getMemberId());
         }
 
 
         // 鏌ヨ 鎴垮眿鏁伴噺
-        queryRoomCount(ownerIds,ownerDtos);
+        queryRoomCount(ownerIds, ownerDtos);
 
         // 鏌ヨ 瀹跺涵鎴愬憳鏁�
-        queryOwnerMemberCount(ownerIds,ownerDtos);
+        queryOwnerMemberCount(ownerIds, ownerDtos);
 
         // 鏌ヨ 杞﹁締鏁�
-        queryCarCount(ownerIds,ownerDtos);
+        queryCarCount(memberIds, ownerDtos);
 
         // 鏌ヨ 鎶曡瘔鏁�
-        queryComplaintCount(ownerTels,ownerDtos);
+        //queryComplaintCount(ownerTels,ownerDtos);
 
         // 鏌ヨ 鎶ヤ慨鏁�
-        queryRepairCount(ownerTels,ownerDtos);
+        //queryRepairCount(ownerTels,ownerDtos);
 
         // 鏌ヨ涓氫富娆犺垂
-        queryOwnerOweFee(ownerIds,ownerDtos);
+        queryOwnerOweFee(ownerIds, ownerDtos);
+
+        // 鏌ヨ涓氫富鍚堝悓
+        //queryOwnerContractCount(ownerIds,ownerDtos);
 
         return ownerDtos;
     }
 
+    @Override
+    public List<OwnerDto> queryAdminData(List<OwnerDto> ownerDtos) {
+        if (ListUtil.isNull(ownerDtos)) {
+            return ownerDtos;
+        }
+
+        //杩欓噷闄愬埗琛屾暟锛屼互鍏嶅奖鍝嶇郴缁熸�ц兘
+        if (ownerDtos.size() > MAX_LINE_COUNT) {
+            return ownerDtos;
+        }
+        List<String> ownerIds = new ArrayList<>();
+        List<String> memberIds = new ArrayList<>();
+        List<String> ownerTels = new ArrayList<>();
+        List<String> communityIds = new ArrayList<>();
+        for (OwnerDto ownerDto : ownerDtos) {
+            ownerIds.add(ownerDto.getOwnerId());
+            ownerTels.add(ownerDto.getLink());
+            memberIds.add(ownerDto.getMemberId());
+            communityIds.add(ownerDto.getCommunityId());
+        }
+// 鏌ヨ灏忓尯鍚嶇О
+        queryCommunityName(communityIds,ownerDtos);
+
+        // 鏌ヨ 鎴垮眿鏁伴噺
+        queryRoomCount(ownerIds, ownerDtos);
+
+        // 鏌ヨ 瀹跺涵鎴愬憳鏁�
+        queryOwnerMemberCount(ownerIds, ownerDtos);
+
+        // 鏌ヨ 杞﹁締鏁�
+        queryCarCount(memberIds, ownerDtos);
+
+        // 鏌ヨ 鎶曡瘔鏁�
+        //queryComplaintCount(ownerTels,ownerDtos);
+
+        // 鏌ヨ 鎶ヤ慨鏁�
+        //queryRepairCount(ownerTels,ownerDtos);
+
+        // 鏌ヨ涓氫富娆犺垂
+        queryOwnerOweFee(ownerIds, ownerDtos);
+
+        // 鏌ヨ涓氫富鍚堝悓
+        //queryOwnerContractCount(ownerIds,ownerDtos);
+
+        return ownerDtos;
+    }
+
+    private void queryOwnerContractCount(List<String> ownerIds, List<OwnerDto> ownerDtos) {
+        Map info = new HashMap();
+        info.put("communityId", ownerDtos.get(0).getCommunityId());
+        info.put("ownerIds", ownerIds.toArray(new String[ownerIds.size()]));
+        List<Map> contractsCount = contractInnerServiceSMOImpl.queryContractsByOwnerIds(info);
+
+        for (OwnerDto ownerDto : ownerDtos) {
+            for (Map count : contractsCount) {
+                if (ownerDto.getOwnerId().equals(count.get("ownerId"))) {
+                    ownerDto.setContractCount(count.get("contractCount").toString());
+                }
+            }
+        }
+    }
+
     /**
      * 鏌ヨ涓氫富娆犺垂
+     *
      * @param ownerIds
      * @param ownerDtos
      */
     private void queryOwnerOweFee(List<String> ownerIds, List<OwnerDto> ownerDtos) {
         Map info = new HashMap();
-        info.put("communityId",ownerDtos.get(0).getCommunityId());
-        info.put("ownerIds",ownerIds.toArray(new String[ownerIds.size()]));
+        info.put("communityId", ownerDtos.get(0).getCommunityId());
+        info.put("ownerIds", ownerIds.toArray(new String[ownerIds.size()]));
         List<Map> repairCounts = reportOweFeeInnerServiceSMOImpl.queryOweFeesByOwnerIds(info);
 
-        for(OwnerDto ownerDto : ownerDtos) {
+        for (OwnerDto ownerDto : ownerDtos) {
             for (Map count : repairCounts) {
-                if(ownerDto.getOwnerId().equals(count.get("ownerId"))){
+                if (ownerDto.getOwnerId().equals(count.get("ownerId"))) {
                     ownerDto.setOweFee(count.get("oweFee").toString());
                 }
             }
@@ -102,6 +182,7 @@
 
     /**
      * 鏌ヨ涓氫富鎶曡瘔鏁�
+     *
      * @param ownerTels
      * @param ownerDtos
      */
@@ -109,13 +190,13 @@
 
 
         Map info = new HashMap();
-        info.put("communityId",ownerDtos.get(0).getCommunityId());
-        info.put("ownerTels",ownerTels.toArray(new String[ownerTels.size()]));
+        info.put("communityId", ownerDtos.get(0).getCommunityId());
+        info.put("ownerTels", ownerTels.toArray(new String[ownerTels.size()]));
         List<Map> repairCounts = repairPoolV1InnerServiceSMOImpl.queryRepairCountByOwnerTels(info);
 
-        for(OwnerDto ownerDto : ownerDtos) {
+        for (OwnerDto ownerDto : ownerDtos) {
             for (Map count : repairCounts) {
-                if(ownerDto.getLink().equals(count.get("ownerTel"))){
+                if (ownerDto.getLink().equals(count.get("ownerTel"))) {
                     ownerDto.setRepairCount(count.get("repairCount").toString());
                 }
             }
@@ -124,6 +205,7 @@
 
     /**
      * 鏌ヨ涓氫富鎶曡瘔鏁�
+     *
      * @param ownerTels
      * @param ownerDtos
      */
@@ -131,13 +213,13 @@
 
 
         Map info = new HashMap();
-        info.put("communityId",ownerDtos.get(0).getCommunityId());
-        info.put("ownerTels",ownerTels.toArray(new String[ownerTels.size()]));
+        info.put("communityId", ownerDtos.get(0).getCommunityId());
+        info.put("ownerTels", ownerTels.toArray(new String[ownerTels.size()]));
         List<Map> complaintCounts = complaintV1InnerServiceSMOImpl.queryComplaintCountByOwnerTels(info);
 
-        for(OwnerDto ownerDto : ownerDtos) {
+        for (OwnerDto ownerDto : ownerDtos) {
             for (Map count : complaintCounts) {
-                if(ownerDto.getLink().equals(count.get("ownerTel"))){
+                if (ownerDto.getLink().equals(count.get("ownerTel"))) {
                     ownerDto.setComplaintCount(count.get("complaintCount").toString());
                 }
             }
@@ -146,16 +228,17 @@
 
     /**
      * 鏌ヨ涓氫富杞﹁締鏁�
-     * @param ownerIds
+     *
+     * @param memberIds
      * @param ownerDtos
      */
-    private void queryCarCount(List<String> ownerIds, List<OwnerDto> ownerDtos) {
+    private void queryCarCount(List<String> memberIds, List<OwnerDto> ownerDtos) {
 
-        List<Map> memberCounts = ownerCarV1InnerServiceSMOImpl.queryOwnerCarCountByOwnerIds(ownerIds);
+        List<Map> memberCounts = ownerCarV1InnerServiceSMOImpl.queryOwnerCarCountByOwnerIds(memberIds);
 
-        for(OwnerDto ownerDto : ownerDtos) {
+        for (OwnerDto ownerDto : ownerDtos) {
             for (Map count : memberCounts) {
-                if(ownerDto.getOwnerId().equals(count.get("ownerId"))){
+                if (ownerDto.getMemberId().equals(count.get("ownerId"))) {
                     ownerDto.setCarCount(count.get("carCount").toString());
                 }
             }
@@ -164,6 +247,7 @@
 
     /**
      * 鏌ヨ 涓氫富鎴愬憳鏁�
+     *
      * @param ownerIds
      * @param ownerDtos
      */
@@ -171,9 +255,13 @@
 
         List<Map> memberCounts = ownerV1InnerServiceSMOImpl.queryOwnerMembersCount(ownerIds);
 
-        for(OwnerDto ownerDto : ownerDtos) {
+        for (OwnerDto ownerDto : ownerDtos) {
+            if (OwnerDto.OWNER_TYPE_CD_MEMBER.equals(ownerDto.getOwnerTypeCd())) {
+                ownerDto.setMemberCount("0");
+                continue;
+            }
             for (Map count : memberCounts) {
-                if(ownerDto.getOwnerId().equals(count.get("ownerId"))){
+                if (ownerDto.getOwnerId().equals(count.get("ownerId"))) {
                     ownerDto.setMemberCount(count.get("memberCount").toString());
                 }
             }
@@ -182,6 +270,7 @@
 
     /**
      * 鏌ヨ 鎴垮眿鏁伴噺
+     *
      * @param ownerIds
      * @param ownerDtos
      */
@@ -190,12 +279,38 @@
         //鏌ヨ涓氫富鎴垮眿鏁�
         List<Map> ownerRoomCounts = ownerRoomRelV1InnerServiceSMOImpl.queryRoomCountByOwnerIds(ownerIds);
 
-        for(OwnerDto ownerDto : ownerDtos) {
+        for (OwnerDto ownerDto : ownerDtos) {
             for (Map count : ownerRoomCounts) {
-                if(ownerDto.getOwnerId().equals(count.get("ownerId"))){
+                if (StringUtil.isEmpty(ownerDto.getOwnerId())) {
+                    continue;
+                }
+                if (StringUtil.isEmpty(count.get("ownerId").toString())) {
+                    continue;
+                }
+                if (ownerDto.getOwnerId().equals(count.get("ownerId").toString())) {
                     ownerDto.setRoomCount(count.get("roomCount").toString());
                 }
             }
         }
     }
+
+    private void queryCommunityName(List<String> communityIds, List<OwnerDto> ownerDtos) {
+        if(ListUtil.isNull(communityIds)){
+            return ;
+        }
+        CommunityDto communityDto = new CommunityDto();
+        communityDto.setCommunityIds(communityIds.toArray(new String[communityIds.size()]));
+        List<CommunityDto> communityDtos = communityV1InnerServiceSMOImpl.queryCommunitys(communityDto);
+        if(ListUtil.isNull(communityDtos)){
+            return;
+        }
+        for (OwnerDto tmpOwnerDto : ownerDtos) {
+            for (CommunityDto tCommunityDto : communityDtos) {
+                if (!tmpOwnerDto.getCommunityId().equals(tCommunityDto.getCommunityId())) {
+                    continue;
+                }
+                tmpOwnerDto.setCommunityName(tCommunityDto.getName());
+            }
+        }
+    }
 }

--
Gitblit v1.8.0