From 05eac8f9232d0c18f410311a67b35eec409609c4 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期日, 22 十二月 2019 02:43:43 +0800
Subject: [PATCH] 解决判断小于零的问题

---
 UserService/src/main/java/com/java110/user/smo/impl/OrgInnerServiceSMOImpl.java |   77 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 77 insertions(+), 0 deletions(-)

diff --git a/UserService/src/main/java/com/java110/user/smo/impl/OrgInnerServiceSMOImpl.java b/UserService/src/main/java/com/java110/user/smo/impl/OrgInnerServiceSMOImpl.java
index 3dacb3f..47e148c 100644
--- a/UserService/src/main/java/com/java110/user/smo/impl/OrgInnerServiceSMOImpl.java
+++ b/UserService/src/main/java/com/java110/user/smo/impl/OrgInnerServiceSMOImpl.java
@@ -2,15 +2,21 @@
 
 
 import com.java110.core.base.smo.BaseServiceSMO;
+import com.java110.core.smo.community.ICommunityInnerServiceSMO;
 import com.java110.core.smo.org.IOrgInnerServiceSMO;
 import com.java110.core.smo.user.IUserInnerServiceSMO;
+import com.java110.dto.OwnerDto;
 import com.java110.dto.PageDto;
 import com.java110.dto.UserDto;
+import com.java110.dto.community.CommunityDto;
 import com.java110.dto.org.OrgDto;
 import com.java110.user.dao.IOrgServiceDao;
 import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.ArrayList;
@@ -33,6 +39,10 @@
     @Autowired
     private IUserInnerServiceSMO userInnerServiceSMOImpl;
 
+    @Autowired
+    private ICommunityInnerServiceSMO communityInnerServiceSMOImpl;
+
+
     @Override
     public List<OrgDto> queryOrgs(@RequestBody OrgDto orgDto) {
 
@@ -46,6 +56,21 @@
 
         List<OrgDto> orgs = BeanConvertUtil.covertBeanList(orgServiceDaoImpl.getOrgInfo(BeanConvertUtil.beanCovertMap(orgDto)), OrgDto.class);
 
+        String[] communityIds = getCommunityIds(orgs);
+        if (communityIds == null || communityIds.length < 1) {
+            return orgs;
+        }
+        CommunityDto communityDto = new CommunityDto();
+        communityDto.setCommunityIds(communityIds);
+        List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
+
+        for (CommunityDto tmpCommunityDto : communityDtos) {
+            for (OrgDto tmpOrgDto : orgs) {
+                if (tmpCommunityDto.getCommunityId().equals(tmpOrgDto.getBelongCommunityId())) {
+                    tmpOrgDto.setBelongCommunityName(tmpCommunityDto.getName());
+                }
+            }
+        }
 
         return orgs;
     }
@@ -54,6 +79,50 @@
     @Override
     public int queryOrgsCount(@RequestBody OrgDto orgDto) {
         return orgServiceDaoImpl.queryOrgsCount(BeanConvertUtil.beanCovertMap(orgDto));
+    }
+
+
+    /**
+     * <p>鏌ヨ涓婄骇缁勭粐淇℃伅</p>
+     *
+     * @param orgDto 鏁版嵁瀵硅薄鍒嗕韩
+     * @return OrgDto 瀵硅薄鏁版嵁
+     */
+    @Override
+    public List<OrgDto> queryParentOrgs(@RequestBody OrgDto orgDto) {
+
+        //鏍¢獙鏄惁浼犱簡 鍒嗛〉淇℃伅
+
+        List<OrgDto> orgs = BeanConvertUtil.covertBeanList(orgServiceDaoImpl.getParentOrgInfo(BeanConvertUtil.beanCovertMap(orgDto)), OrgDto.class);
+
+        if (orgs == null) {
+            orgs = new ArrayList<>();
+        }
+
+        return orgs;
+    }
+
+
+    /**
+     * 鑾峰彇鎵归噺userId
+     *
+     * @param orgDtos 灏忓尯妤间俊鎭�
+     * @return 鎵归噺userIds 淇℃伅
+     */
+    private String[] getCommunityIds(List<OrgDto> orgDtos) {
+        List<String> communityIds = new ArrayList<String>();
+        for (OrgDto orgDto : orgDtos) {
+            if ("9999".equals(orgDto.getBelongCommunityId())) {
+                orgDto.setBelongCommunityName("鍏ラ┗鎵�鏈夊皬鍖�");
+                continue;
+            }
+            if (StringUtil.isEmpty(orgDto.getBelongCommunityId())) {
+                orgDto.setBelongCommunityName("鏈煡灏忓尯");
+                continue;
+            }
+            communityIds.add(orgDto.getBelongCommunityId());
+        }
+        return communityIds.toArray(new String[communityIds.size()]);
     }
 
     public IOrgServiceDao getOrgServiceDaoImpl() {
@@ -71,4 +140,12 @@
     public void setUserInnerServiceSMOImpl(IUserInnerServiceSMO userInnerServiceSMOImpl) {
         this.userInnerServiceSMOImpl = userInnerServiceSMOImpl;
     }
+
+    public ICommunityInnerServiceSMO getCommunityInnerServiceSMOImpl() {
+        return communityInnerServiceSMOImpl;
+    }
+
+    public void setCommunityInnerServiceSMOImpl(ICommunityInnerServiceSMO communityInnerServiceSMOImpl) {
+        this.communityInnerServiceSMOImpl = communityInnerServiceSMOImpl;
+    }
 }

--
Gitblit v1.8.0