src/main/java/org/springblade/common/cache/SysCache.java
@@ -156,25 +156,33 @@ /** * 获取子部门ID集合 * * @param deptId 主键 * @param deptIds 主键 * @return 子部门ID */ public static List<Long> getDeptChildIds(Long deptId) { if (deptId == null) { public static List<Long> getDeptChildIds(String deptIds) { if (Strings.isBlank(deptIds)) { return null; } List<Long> deptIdList = CacheUtil.get(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, List.class); if (deptIdList == null) { deptIdList = new ArrayList<>(); List<Dept> deptChild = getDeptChild(deptId); if (deptChild != null) { List<Long> collect = deptChild.stream().map(Dept::getId).collect(Collectors.toList()); deptIdList.addAll(collect); List<Long> list = new ArrayList<>(); List<String> deptIdList = new ArrayList<>(Arrays.asList(deptIds.split(","))); for (String deptId : deptIdList) { List<Long> deptIdLists = CacheUtil.get(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, List.class); if (deptIdLists == null) { deptIdLists = new ArrayList<>(); List<Dept> deptChild = getDeptChild(Long.parseLong(deptId)); if (deptChild != null) { List<Long> collect = deptChild.stream().map(Dept::getId).collect(Collectors.toList()); deptIdLists.addAll(collect); } deptIdLists.add(Long.parseLong(deptId)); CacheUtil.put(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, deptIdLists); } deptIdList.add(deptId); CacheUtil.put(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, deptIdList); list.addAll(deptIdLists); } return deptIdList; // 去重 List<Long> collect = list.stream().distinct().collect(Collectors.toList()); // 返回 return collect; } /** src/main/java/org/springblade/common/utils/SpringUtils.java
@@ -4,6 +4,10 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; /** * spring 工具类 @@ -22,6 +26,27 @@ } } public static HttpServletRequest getRequestHeaders(){ ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); // get the request HttpServletRequest request = requestAttributes.getRequest(); // 返回request 对象 return request; } /** * 获取角色别名 * @param key * @return */ public static String getRequestParam(String key){ // get the request HttpServletRequest requestHeaders = getRequestHeaders(); // 返回request 对象 return requestHeaders.getHeader(key); } public static ApplicationContext getApplicationContext() { return applicationContext; } src/main/java/org/springblade/modules/grid/service/IGridService.java
@@ -134,7 +134,7 @@ GridEntity getGridByNames(String gridName, String communityName); /** * 查询用户对应的网格 * 查询用户对应的网格编号集合 * @param userId * @return */ src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -136,7 +136,7 @@ @ApiOperationSupport(order = 3) @ApiOperation(value = "搜索用户", notes = "传入name") @PreAuth(RoleConstant.HAS_ROLE_ADMIN) public R<List<UserVO>> searchUser(@ApiIgnore User user, Query query, Long deptId, BladeUser bladeUser) { public R<List<UserVO>> searchUser(@ApiIgnore User user, Query query, String deptId, BladeUser bladeUser) { IPage<User> pages = userService.selectUserPage(Condition.getPage(query), user, deptId, (bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? StringPool.EMPTY : bladeUser.getTenantId())); return R.data(UserWrapper.build().listVO(pages.getRecords())); } @@ -161,7 +161,7 @@ @ApiOperationSupport(order = 3) @ApiOperation(value = "列表", notes = "传入account和realName") // @PreAuth(RoleConstant.HAS_ROLE_ADMIN) public R<IPage<UserVO>> page(@ApiIgnore User user, Query query, Long deptId, BladeUser bladeUser) { public R<IPage<UserVO>> page(@ApiIgnore User user, Query query, String deptId, BladeUser bladeUser) { IPage<User> pages = userService.selectUserPage(Condition.getPage(query), user, deptId, (bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? StringPool.EMPTY : bladeUser.getTenantId())); return R.data(UserWrapper.build().pageVO(pages)); } src/main/java/org/springblade/modules/system/service/IUserService.java
@@ -73,7 +73,7 @@ * @param tenantId * @return */ IPage<User> selectUserPage(IPage<User> page, User user, Long deptId, String tenantId); IPage<User> selectUserPage(IPage<User> page, User user, String deptId, String tenantId); /** * 自定义分页 src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -212,9 +212,9 @@ } @Override public IPage<User> selectUserPage(IPage<User> page, User user, Long deptId, String tenantId) { public IPage<User> selectUserPage(IPage<User> page, User user, String deptId, String tenantId) { if (null == deptId && !AuthUtil.isAdministrator()) { deptId = Long.parseLong(AuthUtil.getDeptId()); deptId = AuthUtil.getDeptId(); } List<Long> deptIdList = SysCache.getDeptChildIds(deptId); return page.setRecords(baseMapper.selectUserPage(page, user, deptIdList, tenantId)); src/main/java/org/springblade/modules/task/mapper/TaskMapper.java
@@ -42,7 +42,8 @@ List<TaskVO> selectTaskPage(IPage page, @Param("task") TaskVO task, @Param("regionChildCodesList") List<String> regionChildCodesList, @Param("isAdministrator") Integer isAdministrator); @Param("isAdministrator") Integer isAdministrator, @Param("gridCodeList") List<String> gridCodeList); List<TaskVO> selectTaskPageBy(IPage page, @Param("task") TaskVO task, @@ -53,4 +54,18 @@ List<TaskVO> getBailReportingPage(IPage<TaskVO> page, TaskVO task); /** * 查询取保候审任务列表(人房相关) * @param page * @param task * @param regionChildCodesList * @param isAdministrator * @return */ List<TaskVO> selectTaskPageByPerson(IPage<TaskVO> page, @Param("task") TaskVO task, @Param("regionChildCodesList") List<String> regionChildCodesList, @Param("isAdministrator") Integer isAdministrator, @Param("gridCodeList") List<String> gridCodeList); } src/main/java/org/springblade/modules/task/mapper/TaskMapper.xml
@@ -20,14 +20,13 @@ <result column="report_type" property="reportType"/> </resultMap> <!--查询非取保候审任务列表(场所相关)--> <select id="selectTaskPage" resultMap="taskResultMap"> SELECT IFNULL( jda.address_name, jp.location ) AS address_name, IFNULL( jgr.district_code, ' ' ) aoiCode, jda.region_code, jg.community_code neiCode, jc.street_code streetCode, jp.location AS address_name, br.district_code regionCode, br.village_code neiCode, br.town_code streetCode, jp.principal as realName, jp.principal_phone as phone, jt.id, @@ -46,75 +45,207 @@ jt.report_type FROM jczz_task jt LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jt.house_code LEFT JOIN jczz_place jp ON locate(jt.house_code,jp.house_code)>0 and jp.is_deleted = 0 LEFT JOIN jczz_place jp ON jt.house_code=jp.house_code and jp.is_deleted = 0 LEFT JOIN blade_user bu on bu.id = jt.create_user and bu.is_deleted = 0 LEFT JOIN jczz_grid jg on jg.grid_code = jp.grid_code and jg.is_deleted = 0 LEFT JOIN blade_region br on br.code = jg.community_code LEFT JOIN jczz_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0 <where> <if test="task.roleName != null and task.roleName != ''"> <if test="task.roleName=='wgy'"> <if test="isAdministrator==2"> <choose> <when test="regionChildCodesList !=null and regionChildCodesList.size()>0"> and jp.grid_code in <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=","> #{code} </foreach> </when> <otherwise> and jp.grid_code in ('') </otherwise> </choose> </if> </if> <if test="task.roleName=='mj'"> <if test="isAdministrator==2"> <choose> <when test="regionChildCodesList !=null and regionChildCodesList.size()>0"> and jpag.community_code in <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=","> #{code} </foreach> </when> <otherwise> and jpag.community_code in ('') </otherwise> </choose> </if> </if> </if> <if test="isAdministrator==2"> <choose> <when test="regionChildCodesList !=null and regionChildCodesList.size()>0"> and ( jg.grid_code in <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=","> #{code} </foreach> or br.village_code in <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=","> #{code} </foreach> ) </when> <otherwise> and ( jg.grid_code in ('') or br.village_code in ('') ) </otherwise> </choose> </if> <if test="task.status != null and task.status != null"> and jt.status = #{task.status} </if> <if test="task.neiCode != null and task.neiCode != null"> and jg.community_code = #{task.neiCode} </if> <if test="task.communityCode != null and task.communityCode != null"> and jg.community_code = #{task.communityCode} </if> <if test="task.communityName != null and task.communityName != null"> and br.name like concat('%', #{task.communityName}, '%') </if> <if test="task.streetCode != null and task.streetCode != null"> and br.town_code = #{task.streetCode} </if> <if test="task.realName != null and task.realName != null"> and bu.name like concat('%', #{task.realName}, '%') </if> <if test="task.phone != null and task.phone != null"> and bu.phone like concat('%', #{task.phone}, '%') </if> <if test="task.frequency != null and task.frequency != ''"> and jt.frequency = #{task.frequency} </if> <if test="task.name != null and task.name != ''"> and jt.name like concat('%', #{task.name}, '%') </if> <if test="task.id != null ">and jt.id = #{task.id}</if> <if test="task.type != null ">and jt.type = #{task.type}</if> <if test="task.remark != null and task.remark != ''">and jt.remark = #{task.remark}</if> <if test="task.createTime != null ">and jt.create_time = #{task.createTime}</if> <if test="task.createUser != null ">and jt.create_user = #{task.createUser}</if> <if test="task.updateTime != null ">and jt.update_time = #{task.updateTime}</if> <if test="task.updateUser != null ">and jt.update_user = #{task.updateUser}</if> <if test="task.isDeleted != null ">and jt.is_deleted = #{task.isDeleted}</if> <if test="task.houseCode != null and task.houseCode != ''">and jt.house_code = #{task.houseCode}</if> <if test="task.startTime != null and task.startTime != '' and task.endTime != null and task.endTime != '' "> AND jt.create_time BETWEEN #{task.startTime} and #{task.endTime} </if> <!-- 场所店铺 --> <if test="task.reportType != null and task.reportType == 2 "> and jt.report_type in (2,3,4,5,6,7,8) </if> <if test="task.reportType == null"> and jt.report_type in (2,3,4,5,6,7,8) </if> and jt.is_deleted = 0 and jt.house_code is not null order by jt.create_time desc </where> </select> <!--查询取保候审任务列表(人房相关)--> <select id="selectTaskPageByPerson" resultType="org.springblade.modules.task.vo.TaskVO"> SELECT jh.address AS address_name, jh.district_code AS aoiCode, br.district_code regionCode, br.village_code neiCode, br.town_code streetCode, jt.id, jt.NAME, jt.type, jt.frequency, jt.remark, jt.create_time, jt.create_user, jt.update_time, jt.update_user, jt.STATUS, jt.source, jt.is_deleted, jt.house_code, jt.report_type FROM jczz_task jt LEFT JOIN jczz_house jh ON jt.house_code=jh.house_code and jh.is_deleted = 0 LEFT JOIN blade_user bu on bu.id = jt.create_user and bu.is_deleted = 0 LEFT JOIN jczz_grid_range jgr on jgr.house_code= jt.house_code LEFT JOIN jczz_grid jg on jg.id = jgr.grid_id and jg.is_deleted = 0 LEFT JOIN jczz_community jc on jc.`code`= jg.community_code and jc.is_deleted = 0 LEFT JOIN blade_region br on br.code = jg.community_code <where> <if test="task.userId != null and task.userId != ''"> AND jt.house_code IN ( SELECT jgr.house_code FROM jczz_grid_range jgr LEFT JOIN jczz_grid jg ON jg.id = jgr.grid_id LEFT JOIN jczz_gridman jgm ON jg.id = jgm.grid_id WHERE jg.is_deleted = 0 <if test="isAdministrator==2"> <if test="task.roleName != null and task.roleName != ''"> <if test="task.roleName=='wgy'"> <if test="isAdministrator==2"> <choose> <when test="regionChildCodesList !=null and regionChildCodesList.size()>0"> and jh.grid_code in <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=","> #{code} </foreach> </when> <otherwise> and jh.grid_code in ('') </otherwise> </choose> </if> </if> <if test="task.roleName=='mj' and isAdministrator==2"> <choose> <when test="regionChildCodesList !=null and regionChildCodesList.size()>0"> and jg.community_code in and br.village_code in <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=","> #{code} </foreach> </when> <otherwise> and jg.community_code in ('') and br.village_code in ('') </otherwise> </choose> </if> AND jgm.user_id = #{task.userId} ) </if> <if test="task.status != null and task.status != null"> and jt.status = #{task.status} </if> <if test="task.aoiCode != null and task.aoiCode != null"> and jgr.district_code = #{task.aoiCode} and jh.district_code = #{task.aoiCode} </if> <if test="task.neiCode != null and task.neiCode != null"> and jg.community_code = #{task.neiCode} </if> <if test="task.communityCode != null and task.communityCode != null"> and jg.community_code = #{task.communityCode} </if> <if test="task.communityName != null and task.communityName != null"> and jc.name like concat('%', #{task.communityName}, '%') and br.name like concat('%', #{task.communityName}, '%') </if> <if test="task.streetCode != null and task.streetCode != null"> and jc.street_code = #{task.streetCode} and br.town_code = #{task.streetCode} </if> <if test="task.realName != null and task.realName != null"> and bu.name like concat('%', #{task.realName}, '%') </if> <if test="task.phone != null and task.phone != null"> and bu.phone like concat('%', #{task.phone}, '%') </if> <if test="task.communityName != null and task.communityName != null"> and jc.name like concat('%', #{task.communityName}, '%') </if> <if test="task.districtName != null and task.districtName != null"> and jgr.district_name like concat('%', #{task.districtName}, '%') and jh.district_name like concat('%', #{task.districtName}, '%') </if> <if test="task.frequency != null and task.frequency != ''"> and jt.frequency = #{task.frequency} </if> @@ -136,13 +267,6 @@ <!-- 取保候审 或 报事报修 --> <if test="task.reportType != null and task.reportType != 2 "> and jt.report_type = #{task.reportType} </if> <!-- 场所店铺 --> <if test="task.reportType != null and task.reportType == 2 "> and jt.report_type in (2,3,4,5,6,7,8) </if> <if test="task.reportType == null"> and jt.report_type in (2,3,4,5,6,7,8) </if> and jt.is_deleted = 0 and jt.house_code is not null src/main/java/org/springblade/modules/task/service/impl/TaskServiceImpl.java
@@ -25,10 +25,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import liquibase.pro.packaged.W; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.util.Strings; import org.springblade.common.cache.SysCache; import org.springblade.common.constant.DictConstant; import org.springblade.common.utils.SpringUtils; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.utils.SpringUtil; import org.springblade.modules.category.entity.CategoryEntity; import org.springblade.modules.category.service.ICategoryService; import org.springblade.modules.grid.entity.GridEntity; @@ -44,8 +46,10 @@ import org.springblade.modules.place.service.IPlaceExtService; import org.springblade.modules.place.service.IPlaceService; import org.springblade.modules.place.vo.PlaceVO; import org.springblade.modules.police.service.IPoliceAffairsGridService; import org.springblade.modules.system.entity.Dept; import org.springblade.modules.system.service.IDeptService; import org.springblade.modules.system.service.IRegionService; import org.springblade.modules.task.entity.*; import org.springblade.modules.task.mapper.TaskMapper; import org.springblade.modules.task.service.*; @@ -53,7 +57,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; import java.util.*; import java.util.stream.Collectors; @@ -92,24 +99,37 @@ @Override public IPage<TaskVO> selectTaskPage(IPage<TaskVO> page, TaskVO task) { String roleName = SpringUtils.getRequestParam("roleName"); String communityCode = SpringUtils.getRequestParam("communityCode"); if (!Strings.isBlank(communityCode)){ // 校验社区编号是否合规 if(null!=SpringUtils.getBean(IRegionService.class).getById(communityCode)) { task.setCommunityCode(communityCode); } } List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId()); Integer isAdministrator = AuthUtil.isAdministrator()==true?1:2; // 网格编号集合 List<String> gridCodeList = new ArrayList<>(); // 民警角色 if (AuthUtil.getUserRole().equals("mj")) { task.setUserId(AuthUtil.getUserId()); return page.setRecords(baseMapper.selectTaskPageBy(page, task,regionChildCodesList,isAdministrator)); } else { if (AuthUtil.getUserAccount().equals("18879306957")) { task.setCommunityCode("361102003027"); task.setUserId(null); if (!Strings.isBlank(roleName)){ task.setRoleName(roleName); if(roleName.equals("mj")) { regionChildCodesList = SpringUtil.getBean(IPoliceAffairsGridService.class).getCommunityCodeListByUserId(AuthUtil.getUserId()); } if (AuthUtil.getUserRole().equals("wgy")) { task.setUserId(AuthUtil.getUserId()); if (roleName.equals("wgy")) { gridCodeList = SpringUtil.getBean(IGridService.class).getGridListByUserId(AuthUtil.getUserId()); } // 非民警角色 List<TaskVO> taskVOS = baseMapper.selectTaskPage(page, task,regionChildCodesList,isAdministrator); return page.setRecords(taskVOS); } if (AuthUtil.getUserAccount().equals("18879306957")) { task.setCommunityCode("361102003027"); } if (null!=task.getReportType() && task.getReportType()==1){ // 查询取保候审任务列表(人房相关) return page.setRecords(baseMapper.selectTaskPageByPerson(page, task,regionChildCodesList,isAdministrator,gridCodeList)); } // 查询非取保候审任务列表(场所相关) return page.setRecords(baseMapper.selectTaskPage(page, task,regionChildCodesList,isAdministrator,gridCodeList)); } @Override src/main/java/org/springblade/modules/task/vo/TaskVO.java
@@ -61,4 +61,9 @@ @ApiModelProperty("结束时间") private String endTime; /** * 角色别名 */ private String roleName; } src/main/java/org/springblade/modules/taskPlaceRectification/mapper/TaskPlaceRectificationMapper.xml
@@ -283,7 +283,7 @@ #{code} </foreach> or jpag.community_code in br.village_code in <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=","> #{code} </foreach> @@ -292,7 +292,7 @@ <otherwise> and ( jg.grid_code in ('') or jpag.community_code in ('') jg.grid_code in ('') or br.village_code in ('') ) </otherwise> </choose>