From 780598ee03fdb76ac6d060a23a8235bef935c4f3 Mon Sep 17 00:00:00 2001 From: TS-QD1 Date: Fri, 9 Jun 2023 09:27:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4KAFKA=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=85=A8=E9=87=8F=E7=BB=9F=E8=AE=A1=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/area/user/AreaUserController.java | 5 ++ .../UserExpandResourceController.java | 43 ++++++++++++++++ .../kafka/KafKaSyncTableConsumer.java | 50 +++++++++++++------ .../service/area/user/IAreaUserService.java | 5 +- .../area/user/impl/AreaUserServiceImpl.java | 2 + .../impl/GridPointSaveAfterHandlerImpl.java | 5 +- .../GridRelationSaveAfterHandlerImpl.java | 18 +++++++ .../impl/RoleUserSaveAfterHandlerImpl.java | 35 +++++++++++++ .../userexpand/IUserExpandService.java | 8 +++ .../impl/UserExpandServiceImpl.java | 34 +++++++++++++ .../mapper/user-expand/user-expand-mapper.xml | 29 +++++++++++ .../static/assets/js/area/user/area-user.js | 2 +- 12 files changed, 216 insertions(+), 20 deletions(-) diff --git a/src/main/java/cn/com/tenlion/usercenter/controller/api/area/user/AreaUserController.java b/src/main/java/cn/com/tenlion/usercenter/controller/api/area/user/AreaUserController.java index acc4389..3a86eb1 100644 --- a/src/main/java/cn/com/tenlion/usercenter/controller/api/area/user/AreaUserController.java +++ b/src/main/java/cn/com/tenlion/usercenter/controller/api/area/user/AreaUserController.java @@ -120,4 +120,9 @@ public class AreaUserController extends DefaultBaseController { return areaUserService.listPageAreaUser(page); } + // 当前区域下的所有网格员总数 + + + // 当前网格下的网格员总数 + } diff --git a/src/main/java/cn/com/tenlion/usercenter/controller/resource/userexpand/UserExpandResourceController.java b/src/main/java/cn/com/tenlion/usercenter/controller/resource/userexpand/UserExpandResourceController.java index 78d1338..d205755 100644 --- a/src/main/java/cn/com/tenlion/usercenter/controller/resource/userexpand/UserExpandResourceController.java +++ b/src/main/java/cn/com/tenlion/usercenter/controller/resource/userexpand/UserExpandResourceController.java @@ -12,6 +12,7 @@ import ink.wgink.interfaces.consts.ISystemConstant; import ink.wgink.pojo.ListPage; import ink.wgink.pojo.result.ErrorResult; import ink.wgink.pojo.result.SuccessResult; +import ink.wgink.pojo.result.SuccessResultData; import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.pojo.vos.IdsVO; import io.swagger.annotations.*; @@ -40,6 +41,7 @@ public class UserExpandResourceController extends DefaultBaseController { @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户ID", paramType = "path") }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @PutMapping("update/{userId}") @CheckRequestBodyAnnotation @@ -105,4 +107,45 @@ public class UserExpandResourceController extends DefaultBaseController { return userExpandService.listPageByRoleIdAndAreaCode(roleId, areaCode, page); } + @ApiOperation(value = "通过角色和区域编码获取拓展属性完整分页列表", notes = "通过角色和区域编码获取拓展属性完整分页列表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path", required = true), + @ApiImplicitParam(name = "areaCode", value = "地区编码", paramType = "path", required = true) + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("listpage/role-id/{roleId}/area-code-like/{areaCodeLike}") + public SuccessResultList> listPageByRoleIdAndAreaCodeLike(@PathVariable("roleId") String roleId, + @PathVariable("areaCodeLike") String areaCodeLike, + ListPage page) { + Map params = requestParams(); + page.setParams(params); + return userExpandService.listPageByRoleIdAndAreaCodeLike(roleId, areaCodeLike, page); + } + + @ApiOperation(value = "通过角色ID和区域编码统计用户", notes = "通过角色ID和区域编码统计用户") + @ApiImplicitParams({ + @ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path", required = true), + @ApiImplicitParam(name = "areaCode", value = "地区编码", paramType = "path", required = true) + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("count/role-id/{roleId}/area-code-like/{areaCodeLike}") + public SuccessResultData countByRoleIdAndAreaCode(@PathVariable("roleId") String roleId, + @PathVariable("areaCodeLike") String areaCodeLike) { + Integer count = userExpandService.countByRoleIdAndAreaCode(roleId, areaCodeLike); + return new SuccessResultData<>(count); + } + + @ApiOperation(value = "通过网格编码和角色查询", notes = "通过网格编码和角色查询用户") + @ApiImplicitParams({ + @ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path", required = true), + @ApiImplicitParam(name = "gridCode", value = "网格编码", paramType = "path", required = true), + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("count/role-id/{roleId}/grid-code/{gridCode}") + public SuccessResultData countByRoleIdAndGridCode(@PathVariable("roleId") String roleId, + @PathVariable("gridCode") String gridCode) { + Integer count = userExpandService.countByRoleIdAndGridCode(roleId, gridCode); + return new SuccessResultData<>(count); + } + } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/usercenter/kafka/KafKaSyncTableConsumer.java b/src/main/java/cn/com/tenlion/usercenter/kafka/KafKaSyncTableConsumer.java index 07d40c0..aa60b34 100644 --- a/src/main/java/cn/com/tenlion/usercenter/kafka/KafKaSyncTableConsumer.java +++ b/src/main/java/cn/com/tenlion/usercenter/kafka/KafKaSyncTableConsumer.java @@ -3,6 +3,9 @@ package cn.com.tenlion.usercenter.kafka; import cn.com.tenlion.usercenter.config.ParamsConfigProperties; import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts; import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO; +import cn.com.tenlion.usercenter.pojo.pos.area.user.GridUserPO; +import cn.com.tenlion.usercenter.service.area.user.IAreaUserService; +import cn.com.tenlion.usercenter.service.userexpand.IUserExpandService; import com.alibaba.fastjson.JSON; import ink.wgink.interfaces.department.IDepartmentDeleteAfterHandler; import ink.wgink.interfaces.department.IDepartmentSaveAfterHandler; @@ -13,9 +16,11 @@ import ink.wgink.interfaces.role.IRoleUserSaveAfterHandler; import ink.wgink.interfaces.user.IUserUpdateAfterHandler; import ink.wgink.module.map.pojo.dtos.grid.GridDTO; import ink.wgink.module.map.pojo.dtos.grid.GridRelationDTO; +import ink.wgink.module.map.pojo.dtos.grid.GridUserDTO; import ink.wgink.module.map.service.grid.IGridPointService; import ink.wgink.module.map.service.grid.IGridRelationService; import ink.wgink.module.map.service.grid.IGridService; +import ink.wgink.module.map.service.grid.IGridUserService; import ink.wgink.pojo.dtos.user.UserDTO; import ink.wgink.pojo.pos.DepartmentPO; import ink.wgink.service.department.service.IDepartmentService; @@ -24,6 +29,7 @@ import ink.wgink.service.user.service.IUserService; import ink.wgink.util.ArrayListUtil; import org.apache.commons.lang3.StringUtils; import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.checkerframework.checker.units.qual.A; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -36,6 +42,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; /** * @ClassName: KafKaPublishConsumer @@ -89,6 +96,12 @@ public class KafKaSyncTableConsumer implements ApplicationEventPublisherAware { private IRoleUserService roleUserService; @Autowired private ParamsConfigProperties paramsConfigProperties; + @Autowired + private IUserExpandService userExpandService; + @Autowired + private IAreaUserService areaUserService; + @Autowired + private IGridUserService gridUserService; public KafKaSyncTableConsumer() { @@ -137,13 +150,14 @@ public class KafKaSyncTableConsumer implements ApplicationEventPublisherAware { @KafkaListener(id = ISmartCityUserCenterConsts.KAFKA_TABLE_SYNC_GRID_RELATION + "FullSync", topics = ISmartCityUserCenterConsts.KAFKA_TABLE_SYNC_GRID_RELATION + "FullSync") public void gridRelationFullSync(ConsumerRecord record) { Map params = new HashMap<>(); - List gridRelationDTOs = gridRelationService.list(params); - if (gridRelationDTOs.isEmpty()) { - LOG.error("Grid Relation Full Sync(" + ISmartCityUserCenterConsts.KAFKA_TABLE_SYNC_GRID_RELATION + "FullSync) error, gridRelationDTOs is empty"); + List userDTOS = gridUserService.listUser(params); + if (userDTOS.isEmpty()) { + LOG.error("Grid Relation Full Sync(" + ISmartCityUserCenterConsts.KAFKA_TABLE_SYNC_GRID_RELATION + "FullSync) error, userDTOS is empty"); return; } - List relationIds = ArrayListUtil.listBeanStringIdValue(gridRelationDTOs, "relationId", GridRelationDTO.class); - gridRelationSaveAfterHandler.handle(relationIds); + userDTOS.forEach(userDTO -> { + gridRelationSaveAfterHandler.handle(userDTO); + }); } /** @@ -251,9 +265,9 @@ public class KafKaSyncTableConsumer implements ApplicationEventPublisherAware { LOG.error("Grid Point Full Sync(" + ISmartCityUserCenterConsts.KAFKA_TABLE_SYNC_GRID_POINT + "FullSync) error, gridDTOs is empty"); return; } - gridDTOs.forEach(gridDTO -> { - gridPointSaveAfterHandler.handle(gridDTO.getGridId()); - }); + for(GridDTO gridDTO : gridDTOs) { + gridPointSaveAfterHandler.handle(gridDTO.getGridId()); + } } /** @@ -368,12 +382,14 @@ public class KafKaSyncTableConsumer implements ApplicationEventPublisherAware { */ @KafkaListener(id = ISmartCityUserCenterConsts.KAFKA_TABLE_SYNC_SPECIALIZED_PERSON + "FullSync", topics = ISmartCityUserCenterConsts.KAFKA_TABLE_SYNC_SPECIALIZED_PERSON + "FullSync") public void specializedPersonFullSync(ConsumerRecord record) { - List userIds = roleUserService.listUserId(paramsConfigProperties.getRoleSpecializedPerson()); - if (userIds.isEmpty()) { - LOG.error("Specialized Person Full Sync(" + ISmartCityUserCenterConsts.KAFKA_TABLE_SYNC_SPECIALIZED_PERSON + "FullSync) error, userIds is empty"); + List userDTOS = roleUserService.listUserByRoleId(paramsConfigProperties.getRoleSpecializedPerson()); + if (userDTOS.isEmpty()) { + LOG.error("Specialized Person Full Sync(" + ISmartCityUserCenterConsts.KAFKA_TABLE_SYNC_SPECIALIZED_PERSON + "FullSync) error, userDTOS is empty"); return; } - roleUserSaveAfterHandler.handle(paramsConfigProperties.getRoleSpecializedPerson(), userIds); + userDTOS.forEach(userDTO -> { + roleUserSaveAfterHandler.handle(paramsConfigProperties.getRoleSpecializedPerson(), userDTO); + }); } @@ -411,12 +427,14 @@ public class KafKaSyncTableConsumer implements ApplicationEventPublisherAware { */ @KafkaListener(id = ISmartCityUserCenterConsts.KAFKA_TABLE_SYNC_GRID_MEMBER + "FullSync", topics = ISmartCityUserCenterConsts.KAFKA_TABLE_SYNC_GRID_MEMBER + "FullSync") public void gridMemberFullSync(ConsumerRecord record) { - List userIds = roleUserService.listUserId(paramsConfigProperties.getRoleGridMember()); - if (userIds.isEmpty()) { - LOG.error("Grid Member Full Sync(" + ISmartCityUserCenterConsts.KAFKA_TABLE_SYNC_GRID_MEMBER + "FullSync) error, userIds is empty"); + List userDTOS = roleUserService.listUserByRoleId(paramsConfigProperties.getRoleGridMember()); + if (userDTOS.isEmpty()) { + LOG.error("Grid Member Full Sync(" + ISmartCityUserCenterConsts.KAFKA_TABLE_SYNC_GRID_MEMBER + "FullSync) error, userDTOS is empty"); return; } - roleUserSaveAfterHandler.handle(paramsConfigProperties.getRoleGridMember(), userIds); + userDTOS.forEach(userDTO -> { + roleUserSaveAfterHandler.handle(paramsConfigProperties.getRoleGridMember(), userDTO); + }); } private SyncDataDTO> getSyncData(String msg) { diff --git a/src/main/java/cn/com/tenlion/usercenter/service/area/user/IAreaUserService.java b/src/main/java/cn/com/tenlion/usercenter/service/area/user/IAreaUserService.java index 18d9141..460bf52 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/area/user/IAreaUserService.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/area/user/IAreaUserService.java @@ -2,14 +2,18 @@ package cn.com.tenlion.usercenter.service.area.user; import cn.com.tenlion.usercenter.pojo.dtos.area.user.AreaUserCountDTO; import cn.com.tenlion.usercenter.pojo.dtos.area.user.AreaUserDTO; +import cn.com.tenlion.usercenter.pojo.dtos.userexpand.UserExpandDTO; import cn.com.tenlion.usercenter.pojo.vos.area.user.AreaUserVO; import ink.wgink.module.dictionary.pojo.dtos.AreaDTO; import ink.wgink.pojo.ListPage; import ink.wgink.pojo.dtos.department.DepartmentDTO; +import ink.wgink.pojo.dtos.user.UserDTO; +import ink.wgink.pojo.result.SuccessResultData; import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.service.core.pojo.vos.manage.CoreManageUserVO; import java.util.List; +import java.util.Map; public interface IAreaUserService { @@ -36,5 +40,4 @@ public interface IAreaUserService { SuccessResultList> listPageAreaUser(ListPage page); - } diff --git a/src/main/java/cn/com/tenlion/usercenter/service/area/user/impl/AreaUserServiceImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/area/user/impl/AreaUserServiceImpl.java index 6187684..e062c6f 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/area/user/impl/AreaUserServiceImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/area/user/impl/AreaUserServiceImpl.java @@ -19,6 +19,7 @@ import ink.wgink.interfaces.user.mongo.IMongoLoginUserService; import ink.wgink.module.dictionary.pojo.dtos.AreaDTO; import ink.wgink.module.dictionary.service.IAreaService; import ink.wgink.module.map.pojo.dtos.grid.GridDTO; +import ink.wgink.module.map.pojo.dtos.grid.GridUserDTO; import ink.wgink.module.map.service.grid.IGridRelationService; import ink.wgink.module.map.service.grid.IGridService; import ink.wgink.pojo.ListPage; @@ -31,6 +32,7 @@ import ink.wgink.pojo.pos.DepartmentPO; import ink.wgink.pojo.pos.GroupPO; import ink.wgink.pojo.pos.PositionPO; import ink.wgink.pojo.pos.RolePO; +import ink.wgink.pojo.result.SuccessResultData; import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.service.department.service.IDepartmentService; import ink.wgink.service.department.service.IDepartmentUserService; diff --git a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridPointSaveAfterHandlerImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridPointSaveAfterHandlerImpl.java index 3d8d4b0..d01a407 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridPointSaveAfterHandlerImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridPointSaveAfterHandlerImpl.java @@ -17,6 +17,7 @@ import org.springframework.stereotype.Service; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; /** * @ClassName: GridPointSaveAfterHandlerImpl @@ -44,7 +45,7 @@ public class GridPointSaveAfterHandlerImpl implements IGridPointSaveAfterHandler return; } List gridPointDTOs = gridPointService.list(gridId); - gridPointDTOs.forEach(gridPointDTO -> { + for (GridPointDTO gridPointDTO : gridPointDTOs) { Map data = new HashMap<>(6); data.put("grid_id", gridId); data.put("lng", gridPointDTO.getLng()); @@ -55,7 +56,7 @@ public class GridPointSaveAfterHandlerImpl implements IGridPointSaveAfterHandler syncDataDTO.setData(data); syncDataDTO.setTableNumber(ISmartCityUserCenterConsts.KAFKA_TABLE_SYNC_GRID_POINT); kafkaTemplate.send(ISmartCityUserCenterConsts.KAFKA_TOPIC_TABLE_SYNC, JSONObject.toJSONString(syncDataDTO)); - }); + } } diff --git a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridRelationSaveAfterHandlerImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridRelationSaveAfterHandlerImpl.java index 2ca89f2..55de76d 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridRelationSaveAfterHandlerImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/GridRelationSaveAfterHandlerImpl.java @@ -3,6 +3,9 @@ package cn.com.tenlion.usercenter.service.kafka.impl; import cn.com.tenlion.usercenter.config.ParamsConfigProperties; import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts; import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO; +import cn.com.tenlion.usercenter.pojo.dtos.userexpand.UserExpandDTO; +import cn.com.tenlion.usercenter.pojo.pos.userexpand.UserExpandPO; +import cn.com.tenlion.usercenter.service.userexpand.IUserExpandService; import com.alibaba.fastjson.JSONObject; import ink.wgink.exceptions.base.SystemException; import ink.wgink.interfaces.map.IGridRelationSaveAfterHandler; @@ -38,6 +41,8 @@ public class GridRelationSaveAfterHandlerImpl implements IGridRelationSaveAfterH private IGridService gridService; @Autowired private ParamsConfigProperties paramsConfigProperties; + @Autowired + private IUserExpandService userExpandService; @Override public void handle(List relationIds) throws SystemException { @@ -62,6 +67,7 @@ public class GridRelationSaveAfterHandlerImpl implements IGridRelationSaveAfterH if (!paramsConfigProperties.getKafkaActive()) { return; } + List gridDTOs = gridService.listByRelationId(userDTO.getUserId()); if (gridDTOs.isEmpty()) { return; @@ -75,9 +81,21 @@ public class GridRelationSaveAfterHandlerImpl implements IGridRelationSaveAfterH }); Map data = new HashMap<>(); + data.put("user_id", userDTO.getUserId()); + data.put("user_username", userDTO.getUserUsername()); + data.put("user_avatar", userDTO.getUserAvatar()); + data.put("user_name", userDTO.getUserName()); + data.put("user_phone", userDTO.getUserPhone()); + data.put("user_email", userDTO.getUserEmail()); data.put("grid_code", WStringUtil.listToStr(gridCodes, ",")); data.put("grid_name", WStringUtil.listToStr(gridNames, ",")); + UserExpandPO userExpandPO = userExpandService.getPO(userDTO.getUserId()); + if(userExpandPO != null) { + data.put("area_code", userExpandPO.getAreaCode()); + data.put("area_name", userExpandPO.getAreaName()); + } + SyncDataDTO syncDataDTO = new SyncDataDTO<>(); syncDataDTO.setUid(userDTO.getUserId()); syncDataDTO.setData(data); diff --git a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/RoleUserSaveAfterHandlerImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/RoleUserSaveAfterHandlerImpl.java index 83e8a86..388ef73 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/RoleUserSaveAfterHandlerImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/kafka/impl/RoleUserSaveAfterHandlerImpl.java @@ -4,10 +4,12 @@ import cn.com.tenlion.usercenter.config.ParamsConfigProperties; import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts; import cn.com.tenlion.usercenter.pojo.dtos.kafka.SyncDataDTO; import cn.com.tenlion.usercenter.pojo.dtos.userexpand.UserExpandDTO; +import cn.com.tenlion.usercenter.pojo.pos.userexpand.UserExpandPO; import cn.com.tenlion.usercenter.service.userexpand.IUserExpandService; import com.alibaba.fastjson.JSONObject; import ink.wgink.exceptions.base.SystemException; import ink.wgink.interfaces.role.IRoleUserSaveAfterHandler; +import ink.wgink.pojo.dtos.user.UserDTO; import ink.wgink.service.role.service.IRoleUserService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -81,4 +83,37 @@ public class RoleUserSaveAfterHandlerImpl implements IRoleUserSaveAfterHandler { } } + @Override + public void handle(String roleId, UserDTO userDTO) throws SystemException { + if (!paramsConfigProperties.getKafkaActive()) { + return; + } + String tableNumber; + if (StringUtils.equals(paramsConfigProperties.getRoleSpecializedPerson(), roleId)) { + // 专管员 + tableNumber = ISmartCityUserCenterConsts.KAFKA_TABLE_SYNC_SPECIALIZED_PERSON; + } else if (StringUtils.equals(paramsConfigProperties.getRoleGridMember(), roleId)) { + // 网格员 + tableNumber = ISmartCityUserCenterConsts.KAFKA_TABLE_SYNC_GRID_MEMBER; + } else { + return; + } + UserExpandPO userExpandPO = userExpandService.getPO(userDTO.getUserId()); + SyncDataDTO syncDataDTO = new SyncDataDTO<>(); + syncDataDTO.setAction(ISmartCityUserCenterConsts.KAFKA_DATA_SAVE); + syncDataDTO.setTableNumber(tableNumber); + Map dataMap = new HashMap<>(); + syncDataDTO.setUid(userDTO.getUserId()); + dataMap.put("user_name", userDTO.getUserName()); + dataMap.put("user_username", userDTO.getUserUsername()); + dataMap.put("user_phone", userDTO.getUserPhone()); + dataMap.put("user_avatar", userDTO.getUserAvatar()); + if (userExpandPO != null) { + dataMap.put("area_name", userExpandPO.getAreaName()); + dataMap.put("area_code", userExpandPO.getAreaCode()); + } + syncDataDTO.setData(dataMap); + kafkaTemplate.send(ISmartCityUserCenterConsts.KAFKA_TOPIC_TABLE_SYNC, JSONObject.toJSONString(syncDataDTO)); + } + } diff --git a/src/main/java/cn/com/tenlion/usercenter/service/userexpand/IUserExpandService.java b/src/main/java/cn/com/tenlion/usercenter/service/userexpand/IUserExpandService.java index 26363ba..99dfb72 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/userexpand/IUserExpandService.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/userexpand/IUserExpandService.java @@ -9,6 +9,7 @@ import cn.com.tenlion.usercenter.pojo.vos.userexpand.UserExpandVO; import ink.wgink.interfaces.user.IUserExpandBaseService; import ink.wgink.pojo.ListPage; import ink.wgink.pojo.dtos.user.UserDTO; +import ink.wgink.pojo.result.SuccessResultData; import ink.wgink.pojo.result.SuccessResultList; import java.util.List; @@ -109,5 +110,12 @@ public interface IUserExpandService extends IUserExpandBaseService> listPageByRoleIdAndAreaCode(String roleId, String areaCode, ListPage page); + SuccessResultList> listPageByRoleIdAndAreaCodeLike(String roleId, String areaCodeLike, ListPage page); + Integer countByAreaCode(String areaCode, boolean isLike); + + Integer countByRoleIdAndAreaCode(String roleId, String areaCodeLike); + + Integer countByRoleIdAndGridCode(String roleId, String gridCode); + } diff --git a/src/main/java/cn/com/tenlion/usercenter/service/userexpand/impl/UserExpandServiceImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/userexpand/impl/UserExpandServiceImpl.java index d46cd22..c4efecf 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/userexpand/impl/UserExpandServiceImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/userexpand/impl/UserExpandServiceImpl.java @@ -31,6 +31,7 @@ import ink.wgink.pojo.dtos.department.DepartmentDTO; import ink.wgink.pojo.dtos.department.DepartmentUserDTO; import ink.wgink.pojo.dtos.user.UserDTO; import ink.wgink.pojo.pos.DepartmentPO; +import ink.wgink.pojo.result.SuccessResultData; import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.pojo.session.WebSocketSession; import ink.wgink.service.user.pojo.pos.UserPO; @@ -441,6 +442,21 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx return new SuccessResultList<>(userExpandDTOS, pageInfo.getPageNum(), pageInfo.getTotal()); } + @Override + public SuccessResultList> listPageByRoleIdAndAreaCodeLike(String roleId, String areaCodeLike, ListPage page) { + page.getParams().put("roleId", roleId); + page.getParams().put("areaCodeLike", areaCodeLike); + PageHelper.startPage(page.getPage(), page.getRows()); + List userExpandDTOS = userExpandDao.list(page.getParams()); + if (userExpandDTOS.size() > 0) { + List userIds = userExpandDTOS.stream().map(UserExpandDTO::getUserId).collect(Collectors.toList()); + List userDTOs = userService.listByUserIds(userIds); + setUser(userDTOs, userExpandDTOS); + } + PageInfo pageInfo = new PageInfo<>(userExpandDTOS); + return new SuccessResultList<>(userExpandDTOS, pageInfo.getPageNum(), pageInfo.getTotal()); + } + @Override public Integer countByAreaCode(String areaCode, boolean isLike) { Map params = getHashMap(2); @@ -453,6 +469,24 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx return count == null ? 0 : count; } + @Override + public Integer countByRoleIdAndAreaCode(String roleId, String areaCodeLike) { + Map params = getHashMap(2); + params.put("roleId", roleId); + params.put("areaCodeLike", areaCodeLike); + Integer count = userExpandDao.count(params); + return count == null ? 0 : count; + } + + @Override + public Integer countByRoleIdAndGridCode(String roleId, String gridCode) { + Map params = getHashMap(2); + params.put("roleId", roleId); + params.put("gridCode", gridCode); + Integer count = userExpandDao.count(params); + return count == null ? 0 : count; + } + /** * 设置用户 * diff --git a/src/main/resources/mybatis/mapper/user-expand/user-expand-mapper.xml b/src/main/resources/mybatis/mapper/user-expand/user-expand-mapper.xml index cc82dc4..b75d810 100644 --- a/src/main/resources/mybatis/mapper/user-expand/user-expand-mapper.xml +++ b/src/main/resources/mybatis/mapper/user-expand/user-expand-mapper.xml @@ -335,6 +335,35 @@ AND area_code LIKE CONCAT(#{areaCodeLike}, '%') + + AND + su.user_id IN ( + SELECT + sru.user_id + FROM + sys_role_user sru + WHERE + sru.role_id = #{roleId} + ) + + + AND + su.user_id IN ( + SELECT + mgr.relation_id + FROM + map_grid_relation mgr + WHERE + mgr.grid_id IN ( + SELECT + mg.grid_id + FROM + map_grid mg + WHERE + mg.grid_code = #{gridCode} + ) + ) + diff --git a/src/main/resources/static/assets/js/area/user/area-user.js b/src/main/resources/static/assets/js/area/user/area-user.js index 8ee30bd..0ba493e 100644 --- a/src/main/resources/static/assets/js/area/user/area-user.js +++ b/src/main/resources/static/assets/js/area/user/area-user.js @@ -205,7 +205,7 @@ function initMultiSelectInputTree($, treeselect) { top.dialog.dialogData.oldSelectedGridList = oldGrids; top.dialog.open({ title: '选择网格', - url: top.restAjax.path('route/grid/list-select?selectType=checkbox&areaCode={areaCode}', [areaCode]), + url: top.restAjax.path('route/grid/list-select?selectType=checkbox', []), width: '800px', height: '80%', onClose: function() {