diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommunityController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommunityController.java index 847bfc96..d108e691 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommunityController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommunityController.java @@ -1,5 +1,6 @@ package com.xhpc.user.controller; +import com.xhpc.common.core.domain.R; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.page.TableDataInfo; @@ -27,6 +28,16 @@ public class XhpcCommunityController extends BaseController { @Autowired private IXhpcCommunityService xhpcCommunityService; + + /** + * 社区组树列表 + */ + @GetMapping("/userList") + public R userList(HttpServletRequest request, String name) { + return R.ok(xhpcCommunityService.userList(request,name)); + } + + /** * 社区组树列表 */ diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCustomersController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCustomersController.java index 3e38adba..f674cc9c 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCustomersController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCustomersController.java @@ -1,5 +1,6 @@ package com.xhpc.user.controller; +import com.xhpc.common.core.domain.R; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.page.TableDataInfo; @@ -28,6 +29,14 @@ public class XhpcCustomersController extends BaseController { @Autowired private IXhpcCustomersService xhpcCustomersService; + + @GetMapping("/userList") + public R userList(HttpServletRequest request, String name) { + List> list = xhpcCustomersService.userList(request,name); + return R.ok(list); + } + + /** * 大客户组树列表 */ diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCommunityMapper.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCommunityMapper.java index 2b64041f..e4da7a1d 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCommunityMapper.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCommunityMapper.java @@ -22,6 +22,14 @@ public interface XhpcCommunityMapper { */ List> list(@Param("name") String name,@Param("tenantId") String tenantId); + /** + * 社区组树列表 + * + * @param name 桩名称 + * @return + */ + List> tree(@Param("name") String name,@Param("tenantId") String tenantId); + /** * 添加社区组 * @param xhpcCommunity @@ -57,6 +65,8 @@ public interface XhpcCommunityMapper { Map getCommunityById(@Param("communityId")Long communityId,@Param("name")String name,@Param("type")Integer type); + List> communityPersonnelTree(@Param("communityId")String communityId); + /** * 社区人员列表 * @return diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCustomersMapper.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCustomersMapper.java index 5fef93b9..07747202 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCustomersMapper.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCustomersMapper.java @@ -19,6 +19,9 @@ public interface XhpcCustomersMapper { */ Map getLandUser(@Param("userId") Long userId); + + List> tree(@Param("name") String name,@Param("operatorId") Long operatorId,@Param("tenantId") String tenantId); + /** * 大客户组树列表 * @@ -60,6 +63,9 @@ public interface XhpcCustomersMapper { */ int updateCustomers(XhpcCustomers xhpcCustomers); + List> customersPersonnelTree(@Param("customersId")String customersId); + + /** * 大客户人员列表 * @return diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommunityService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommunityService.java index b7fc2e4b..4fe8ffad 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommunityService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommunityService.java @@ -16,6 +16,15 @@ import java.util.Map; */ public interface IXhpcCommunityService { + + /** + * 社区组树列表 + * + * @param name 桩名称 + * @return + */ + List> userList(HttpServletRequest request, String name); + /** * 社区组树列表 * diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCustomersService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCustomersService.java index 1b805fb9..5fc57b6a 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCustomersService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCustomersService.java @@ -15,6 +15,9 @@ import java.util.Map; */ public interface IXhpcCustomersService { + + List> userList(HttpServletRequest request,String name); + /** * 大客户组列表 * diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java index c4d8def2..f891e8e8 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java @@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.ArrayList; @@ -33,15 +34,44 @@ import java.util.Map; @Service public class XhpcCommunityServiceImpl extends BaseService implements IXhpcCommunityService { - @Autowired - private XhpcCommunityMapper xhpcCommunityMapper; - @Autowired - private IMechanismService mechanismService; - @Autowired - private TokenService tokenService; + @Resource + XhpcCommunityMapper xhpcCommunityMapper; + @Resource + IMechanismService mechanismService; + @Resource + TokenService tokenService; private static final Logger logger = LoggerFactory.getLogger(XhpcCommunityServiceImpl.class); + + /** + * 社区组树列表 + * + * @param name 桩名称 + * @return + */ + @Override + public List> userList(HttpServletRequest request, String name){ + Long userId = SecurityUtils.getUserId(); + List> list =new ArrayList<>(); + LoginUser loginUser = tokenService.getLoginUser(request); + if(userId !=null){ + String userType = loginUser.getSysUser().getUserType(); + if(UserTypeUtil.SYS_USER_TYPE_ZERO.equals(userType)){ + list = xhpcCommunityMapper.tree(name, loginUser.getTenantId()); + } + } + + for (Map commMap: list){ + List> userMapList = xhpcCommunityMapper.communityPersonnelTree(commMap.get("id").toString().replaceAll("COMM_", "")); + if(userMapList.size() > 0){ + commMap.put("children", userMapList); + } + } + return list; + } + + @Override public List> list(HttpServletRequest request, String name) { Long userId = SecurityUtils.getUserId(); diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java index 6b97d869..4427a006 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java @@ -35,6 +35,29 @@ public class XhpcCustomersServiceImpl extends BaseService implements IXhpcCustom private IMechanismService mechanismService; @Autowired private TokenService tokenService; + + @Override + public List> userList(HttpServletRequest request,String name){ + List> list =new ArrayList<>(); + LoginUser loginUser = tokenService.getLoginUser(request); + String userType = loginUser.getSysUser().getUserType(); + if(UserTypeUtil.SYS_USER_TYPE_ZERO.equals(userType)){ + list = xhpcCustomersMapper.tree(name,null,loginUser.getTenantId()); + }else{ + list = xhpcCustomersMapper.tree(name,loginUser.getSysUser().getOperatorId(),loginUser.getTenantId()); + } + + for(Map cusMap: list){ + List> userList = xhpcCustomersMapper.customersPersonnelTree(cusMap.get("id").toString().replaceAll("CUS_", "")); + if (userList.size() > 0){ + cusMap.put("children", userList); + } + } + + return list; + } + + @Override public List> list(HttpServletRequest request,String name) { List> list =new ArrayList<>(); diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml index e81def17..f56616a6 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommunityMapper.xml @@ -30,6 +30,22 @@ select user_id as userId,user_type as userType,operator_id as operatorId from sys_user where user_id =#{userId} + + + + + + + + + + +