src/main/java/org/springblade/modules/house/controller/HouseholdController.java
@@ -21,7 +21,9 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import liquibase.pro.packaged.S; import lombok.AllArgsConstructor; import org.springblade.common.node.TreeIntegerNode; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.excel.util.ExcelUtil; import org.springblade.core.mp.support.Condition; @@ -42,6 +44,7 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.util.List; import java.util.Map; /** * 住户 控制器 @@ -70,6 +73,7 @@ /** * 住户 自定义查询详情 * * @param household * @return */ @@ -78,6 +82,7 @@ public R getDetail(HouseholdEntity household) { return R.data(householdService.getDetail(household)); } /** * 住户 分页 */ @@ -108,6 +113,17 @@ @ApiOperation(value = "分页", notes = "传入household") public R<IPage<HouseholdVO>> getKeynotePersonnelPage(HouseholdVO household, Query query) { IPage<HouseholdVO> pages = householdService.getKeynotePersonnelPage(Condition.getPage(query), household); return R.data(pages); } /** * 住户标签统计 */ @GetMapping("/getlabelStatistics") @ApiOperationSupport(order = 3) @ApiOperation(value = "住户标签统计", notes = "传入household") public R<List<TreeIntegerNode>> getlabelStatistics(HouseholdVO household) { List<TreeIntegerNode> pages = householdService.getlabelStatistics(household); return R.data(pages); } @@ -155,6 +171,7 @@ /** * 住户 自定义新增或修改 * * @param household * @return */ @@ -213,6 +230,7 @@ /** * 住户对应物业,网格,公安负责人查询 * * @param household * @return */ @@ -225,6 +243,7 @@ /** * 用户信息统计 * * @param code * @param roleType * @return @@ -233,12 +252,13 @@ @ApiOperationSupport(order = 14) @ApiOperation(value = "用户信息统计", notes = " ") public R getHouseHoldStatistics(@RequestParam("code") String code, @RequestParam("roleType") String roleType) { return R.data(householdService.getHouseHoldStatistics(code,roleType)); return R.data(householdService.getHouseHoldStatistics(code, roleType)); } /** * 住户业主信息处理,将业主人员插入到用户表 * * @return */ @GetMapping("/userHandle") @@ -248,14 +268,13 @@ /** * 获取所有住户 * * @return */ @GetMapping("/getAllHouseHold") public R getAllHouseHold(HouseholdVO household) { return R.data(householdService.getAllHouseHold(household)); } } src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.java
@@ -18,7 +18,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import org.apache.ibatis.annotations.MapKey; import org.apache.ibatis.annotations.Param; import org.springblade.common.node.TreeIntegerNode; import org.springblade.common.node.TreeStringNode; import org.springblade.modules.house.entity.HouseholdEntity; import org.springblade.modules.house.excel.HouseHoldExcel; @@ -50,28 +52,32 @@ /** * 获取全部 * * @param household * @return */ List<HouseholdVO> getAllHouseHold(@Param("household")HouseholdVO household); List<HouseholdVO> getAllHouseHold(@Param("household") HouseholdVO household); /** * 查询房屋集合信息 * * @param userId * @return */ List<TreeStringNode> selectHouseNodeList(@Param("userId") Long userId); List<TreeStringNode> selectHouseNodeList(@Param("userId") Long userId); /** * 查询房屋人员情况 * * @param code * @return */ List<HouseholdVO> getHouseholdListByCode(@Param("code") String code); List<HouseholdVO> getHouseholdListByCode(@Param("code") String code); /** * 住户 自定义查询详情 * * @param household * @return */ @@ -79,22 +85,25 @@ /** * 导出 * * @param household * @return */ List<HouseHoldExcel> export(@Param("household") HouseholdVO household); Integer statistics(Long userId,String neiCode); Integer statistics(Long userId, String neiCode); /** * 查询物业 * * @param household * @return */ HouseholdOtherVO getProperty(@Param("household") HouseholdVO household); HouseholdOtherVO getProperty(@Param("household") HouseholdVO household); /** * 查询网格 * * @param household * @return */ @@ -102,17 +111,19 @@ /** * 查询公安信息 * * @param household * @return */ HouseholdOtherVO getSecurity(@Param("household") HouseholdVO household); List<Map<String, Object>> getHouseHoldStatistics(String code, Long userId,String roleType); List<Map<String, Object>> getHouseHoldStatistics(String code, Long userId, String roleType); List<Map<String, Object>> getHouseHoldStatisticsAge(String code, Long userId,String roleType); List<Map<String, Object>> getHouseHoldStatisticsAge(String code, Long userId, String roleType); /** * 查询所有未入库的业主信息 * * @return */ List<HouseholdEntity> getNotInsertUserHousehold(); @@ -129,8 +140,12 @@ /** * 根据人员标签编号集合查询对应的住户(按颜色区分近多少天没有发过任务的住户) * * @param list * @return */ List<HouseholdVO> getHouseholdListByParam(@Param("list") List<Integer> list); @MapKey(value = "id") Map<Integer, TreeIntegerNode> getlabelStatistics(@Param("household") HouseholdVO household); } src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.xml
@@ -177,7 +177,8 @@ LEFT JOIN jczz_grid jg on jg.grid_code = jhs.grid_code and jg.is_deleted = 0 <where> <if test="household.userId!=null"> AND jg.grid_code IN ( SELECT DISTINCT jgm.grid_code FROM jczz_gridman jgm WHERE jgm.user_id = #{household.userId} AND jg.grid_code IN ( SELECT DISTINCT jgm.grid_code FROM jczz_gridman jgm WHERE jgm.user_id = #{household.userId} ) </if> <if test="household.name!=null and household.name !=''"> @@ -286,7 +287,8 @@ where jh.is_deleted = 0 and jh.name != '' and jh.name is not null <if test="household.userId!=null"> AND jg.grid_code IN ( SELECT DISTINCT jgm.grid_code FROM jczz_gridman jgm WHERE jgm.user_id = #{household.userId} AND jg.grid_code IN ( SELECT DISTINCT jgm.grid_code FROM jczz_gridman jgm WHERE jgm.user_id = #{household.userId} ) </if> <if test="household.name!=null and household.name !=''"> @@ -543,7 +545,7 @@ jczz_doorplate_address jda LEFT JOIN jczz_community jc ON jc.CODE = jda.nei_code WHERE jc.res_police_user_id like concat('%',#{userId},'%')) jc.res_police_user_id like concat('%',#{userId},'%')) ) </if> ) a @@ -595,7 +597,7 @@ jczz_doorplate_address jda LEFT JOIN jczz_community jc ON jc.CODE = jda.nei_code WHERE jc.res_police_user_id like concat('%',#{userId},'%')) jc.res_police_user_id like concat('%',#{userId},'%')) ) </if> GROUP BY age @@ -670,7 +672,8 @@ LEFT JOIN jczz_user_house_label juhl on juhl.house_code = jda.address_code and lable_type=1 <where> <if test="household.userId!=null"> AND jg.grid_code IN ( SELECT DISTINCT jgm.grid_code FROM jczz_gridman jgm WHERE jgm.user_id = #{household.userId} AND jg.grid_code IN ( SELECT DISTINCT jgm.grid_code FROM jczz_gridman jgm WHERE jgm.user_id = #{household.userId} ) </if> <if test="household.name!=null and household.name !=''"> @@ -789,7 +792,8 @@ LEFT JOIN jczz_grid jg on jg.grid_code = jhs.grid_code and jg.is_deleted = 0 <where> <if test="household.userId!=null"> AND jg.grid_code IN ( SELECT DISTINCT jgm.grid_code FROM jczz_gridman jgm WHERE jgm.user_id = #{household.userId} AND jg.grid_code IN ( SELECT DISTINCT jgm.grid_code FROM jczz_gridman jgm WHERE jgm.user_id = #{household.userId} ) </if> <if test="household.name!=null and household.name !=''"> @@ -947,5 +951,85 @@ </choose> ) </select> <select id="getlabelStatistics" resultType="org.springblade.common.node.TreeIntegerNode"> SELECT jl.id AS id, jl.parent_id AS parentId, jl.label_name AS name, jl.sort, (SELECT count(juhl.household_id ) counts FROM jczz_user_house_label juhl LEFT JOIN jczz_household jh ON juhl.household_id = jh.id LEFT JOIN jczz_house jhs ON jh.house_code = jhs.house_code AND jhs.is_deleted = 0 LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jh.house_code LEFT JOIN jczz_grid jg ON jg.grid_code = jhs.grid_code AND jg.is_deleted = 0 <where> <if test="household.userId!=null"> AND jg.grid_code IN ( SELECT DISTINCT jgm.grid_code FROM jczz_gridman jgm WHERE jgm.user_id = #{household.userId} ) </if> <if test="household.name!=null and household.name !=''"> and jh.name like concat('%',#{household.name},'%') </if> <if test="household.houseCode!=null and household.houseCode !=''"> and jh.house_code = #{household.houseCode} </if> <if test="household.phoneNumber!=null and household.phoneNumber !=''"> and jh.phone_number like concat('%',#{household.phoneNumber},'%') </if> <if test="household.idCard!=null and household.idCard !=''"> and jh.id_card like concat('%',#{household.idCard},'%') </if> <if test="household.aoiName!=null and household.aoiName !=''"> and jhs.district_name like concat('%',#{household.aoiName},'%') </if> <if test="household.confirmFlag != null "> and jh.confirm_flag = #{household.confirmFlag} </if> <if test="household.townStreetName!=null and household.townStreetName!=''"> and jda.town_street_name like concat('%',#{household.townStreetName},'%') </if> <if test="household.neiName!=null and household.neiName!=''"> and jda.nei_name like concat('%',#{household.neiName},'%') </if> <if test="household.housingRentalId != null "> and jh.housing_rental_id = #{household.housingRentalId} </if> <if test="household.startTime != null and household.startTime != '' and household.endTime != null and household.endTime != '' "> AND jh.create_time BETWEEN #{household.startTime} and #{household.endTime} </if> <if test="household.regionCode!=null and household.regionCode!=''"> and jg.community_code like concat(#{household.regionCode},'%') </if> <if test="household.building!=null and household.building!=''"> and jhs.building like concat(#{household.building},'%') </if> <if test="household.unit!=null and household.unit!=''"> and jhs.unit like concat(#{household.unit},'%') </if> <if test="household.aoiCode!=null and household.aoiCode!=''"> and jhs.district_code = #{household.aoiCode} </if> <if test="household.labelId != null "> AND jl.id = #{household.labelId} </if> <if test="household.parentId != null "> AND jl.parent_id = #{household.parentId} </if> AND juhl.label_id IS NOT NULL and juhl.lable_type = 1 and jh.is_deleted = 0 AND juhl.label_id = jl.id </where> ) count FROM jczz_label jl where is_deleted = 0 and jl.id != '1002' and jl.id != '1001' and jl.parent_id != '1001' </select> </mapper> src/main/java/org/springblade/modules/house/service/IHouseholdService.java
@@ -18,6 +18,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import org.springblade.common.node.TreeIntegerNode; import org.springblade.common.node.TreeStringNode; import org.springblade.modules.house.entity.HouseholdEntity; import org.springblade.modules.house.excel.HouseHoldExcel; @@ -114,4 +115,6 @@ * @return */ List<HouseholdVO> getHouseholdListByParam(List<Integer> list); List<TreeIntegerNode> getlabelStatistics(HouseholdVO household); } src/main/java/org/springblade/modules/house/service/impl/HouseholdServiceImpl.java
@@ -22,7 +22,9 @@ import liquibase.repackaged.org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.util.Strings; import org.springblade.common.cache.SysCache; import org.springblade.common.node.TreeIntegerNode; import org.springblade.common.node.TreeStringNode; import org.springblade.common.utils.NodeTreeUtil; import org.springblade.core.mp.support.Condition; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.utils.BeanUtil; @@ -481,15 +483,15 @@ @Override public IPage<HouseholdVO> getKeynotePersonnelPage(IPage<HouseholdVO> page, HouseholdVO household) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); // Dept dept = deptService.getById(AuthUtil.getDeptId()); // if (null!=dept){ // household.setRegionCode(dept.getRegionCode()); // } // StopWatch stopWatch = new StopWatch(); // stopWatch.start(); // Dept dept = deptService.getById(AuthUtil.getDeptId()); // if (null!=dept){ // household.setRegionCode(dept.getRegionCode()); // } List<HouseholdVO> householdVOS = baseMapper.getKeynotePersonnelPage(page, household); stopWatch.stop(); System.out.println("selectHouseholdPage:" + stopWatch.getTotalTimeMillis()); // stopWatch.stop(); // System.out.println("selectHouseholdPage:" + stopWatch.getTotalTimeMillis()); return page.setRecords(householdVOS); } @@ -502,4 +504,20 @@ public List<HouseholdVO> getHouseholdListByParam(List<Integer> list) { return baseMapper.getHouseholdListByParam(list); } @Override public List<TreeIntegerNode> getlabelStatistics(HouseholdVO household) { Map<Integer, TreeIntegerNode> labelTreeList = baseMapper.getlabelStatistics(household); List<TreeIntegerNode> nodeTree = NodeTreeUtil.getNodeTree(labelTreeList); nodeTree.forEach(node -> recursion(node)); return nodeTree; } private void recursion(TreeIntegerNode node) { if (node.getChildren() != null && node.getChildren().size() > 0) { node.getChildren().forEach(node2 -> recursion(node2)); } else { node.setChildren(null); } } }