From a3b6ac86de21d83dcda6e523b28895dc13468d8c Mon Sep 17 00:00:00 2001 From: 张天森 <1292933220@qq.com> Date: 星期二, 19 七月 2022 16:54:22 +0800 Subject: [PATCH] 防疫后台数据隔离 --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActAcidRecordMapper.xml | 107 ++++++++++++-- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java | 24 +++ springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java | 165 +++++++++++++++++++--- springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/resources/mapper/UserDao.xml | 26 +++ springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/IndexApi.java | 30 ---- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ComActAcidRecordApi.java | 4 springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComActAcidRecordApi.java | 19 +- springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/acid/ComActAcidRecordDTO.java | 4 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java | 2 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActAcidRecordDao.java | 2 springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/UserDao.java | 12 + springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/api/UserApi.java | 4 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/user/UserService.java | 2 springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/UserService.java | 2 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComActAcidRecordService.java | 2 15 files changed, 306 insertions(+), 99 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/acid/ComActAcidRecordDTO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/acid/ComActAcidRecordDTO.java index 5d2a6f5..55c7bbc 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/acid/ComActAcidRecordDTO.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/community/acid/ComActAcidRecordDTO.java @@ -1,6 +1,7 @@ package com.panzhihua.common.model.dtos.community.acid; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; @@ -61,6 +62,7 @@ private String checkStatus; @ApiModelProperty("id数组") private String ids; - @ApiModelProperty("是否根据社区/村落隔离") + @ApiModelProperty("登录的账号名") + private String loginAccount; private Integer type; } diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java index 6d3884c..052251f 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java @@ -9675,7 +9675,7 @@ * @return */ @GetMapping("/comActAcidRecord/fiveCountPlus") - R comActAcidRecordFiveCountPlus(@RequestParam("date")String date,@RequestParam("localCity")String localCity); + R comActAcidRecordFiveCountPlus(@RequestParam("date")String date,@RequestParam("localCity")String localCity,@RequestParam("loginAccount")String loginAccount); @GetMapping("/comActAcidRecord/statics") R comActAcidRecordStatics(@RequestParam("date")String date); diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/user/UserService.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/user/UserService.java index 66b247a..e120fcc 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/user/UserService.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/user/UserService.java @@ -1268,5 +1268,5 @@ R uuPush(@RequestParam("washPhone")String washPhone,@RequestParam("phone")String phone,@RequestParam("washName")String washName,@RequestParam("orderStatus")Integer orderStatus); @GetMapping("/communityList") - R communityList(@RequestParam("type") Integer type); + R communityList(@RequestParam("name") String name, @RequestParam("id") Long id); } diff --git a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComActAcidRecordApi.java b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComActAcidRecordApi.java index bbdf210..d7888df 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComActAcidRecordApi.java +++ b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ComActAcidRecordApi.java @@ -1,6 +1,7 @@ package com.panzhihua.community_backstage.api; +import cn.hutool.core.util.ArrayUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.write.metadata.WriteSheet; @@ -88,16 +89,14 @@ comActAcidRecordDTO.setLocalCity(this.getLoginUserInfo().getName()); } else { - if(!comActAcidRecordDTO.getLocalCity().contains(",")&&this.getLoginUserInfo().getType()==9){ - comActAcidRecordDTO.setLocalCity(this.getLoginUserInfo().getName()+","+comActAcidRecordDTO.getLocalCity()); - } + String[] area={"东区","西区","仁和区","米易县","盐边县","钒钛新区"}; + if(!ArrayUtil.contains(area,comActAcidRecordDTO.getLocalCity())){ + if(!comActAcidRecordDTO.getLocalCity().contains(",")&&this.getLoginUserInfo().getType()==9){ + comActAcidRecordDTO.setLocalCity(this.getLoginUserInfo().getName()+","+comActAcidRecordDTO.getLocalCity()); + }} } LoginUserInfoVO loginUserInfo = this.getLoginUserInfo(); - if (StringUtils.equals("pandashujuzhongxin", loginUserInfo.getAccount())){ - comActAcidRecordDTO.setType(1); - }else if (StringUtils.equals("pannongyenongcunju", loginUserInfo.getAccount())){ - comActAcidRecordDTO.setType(2); - } + comActAcidRecordDTO.setLoginAccount(loginUserInfo.getAccount()); return this.communityService.selectAllComActAcidRecord(comActAcidRecordDTO); } @@ -285,9 +284,9 @@ @GetMapping("fiveCountPlus") public R fiveCountPlus(@RequestParam("date")String date,@RequestParam(value = "localCity",required = false)String localCity){ if(StringUtils.isNotEmpty(localCity)){ - return this.communityService.comActAcidRecordFiveCountPlus(date,localCity); + return this.communityService.comActAcidRecordFiveCountPlus(date,localCity,this.getLoginUserInfo().getAccount()); } - return this.communityService.comActAcidRecordFiveCountPlus(date,this.getLoginUserInfo().getName()); + return this.communityService.comActAcidRecordFiveCountPlus(date,this.getLoginUserInfo().getName(),this.getLoginUserInfo().getAccount()); } diff --git a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/IndexApi.java b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/IndexApi.java index 4b32815..7da6508 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/IndexApi.java +++ b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/IndexApi.java @@ -88,35 +88,7 @@ @GetMapping("/communityList") @ApiOperation(value = "获取当前账号下的社区/村落列表",response = StreetVO.class) public R communityList(){ - //获取当前登录用户的信息 - RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); - // 从获取RequestAttributes中获取HttpServletRequest的信息 - HttpServletRequest request = - (HttpServletRequest)requestAttributes.resolveReference(RequestAttributes.REFERENCE_REQUEST); - // 登录对象信息 - String userInfo = request.getHeader(TokenConstant.TOKEN_USERINFO); - boolean empty = ObjectUtils.isEmpty(userInfo); - if (empty) { - log.error("获取登录用户信息失败【{}】"); - } - byte[] bytes = AES.parseHexStr2Byte(userInfo); - byte[] decrypt = AES.decrypt(bytes, Constants.AES_KEY); - userInfo = new String(decrypt); - LoginUserInfoVO loginUserInfoVO = JSONObject.parseObject(userInfo, LoginUserInfoVO.class); -// //截取社区名 -// if (StringUtils.isEmpty(loginUserInfoVO.getCommunityName())) { -// R<LoginUserInfoVO> userInfoByUserId = userService.getUserInfoByUserId(loginUserInfoVO.getUserId().toString()); -// loginUserInfoVO = userInfoByUserId.getData(); -// } - Integer type=3; -// if (loginUserInfoVO.getAccount().equals("pannongyenongcunju")){ -// type=2; -// }else if (loginUserInfoVO.getAccount().equals("pandashujuzhongxin")){ -// type=1; -// }else if (loginUserInfoVO.getAccount().equals("fangyipingtai")){ -// type=3; -// } - return userService.communityList(type); + return userService.communityList(this.getLoginUserInfo().getAccount(),this.getUserId()); } } \ No newline at end of file diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ComActAcidRecordApi.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ComActAcidRecordApi.java index cf025fe..463d2b0 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ComActAcidRecordApi.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/ComActAcidRecordApi.java @@ -139,8 +139,8 @@ * @return */ @GetMapping("fiveCountPlus") - public R fiveCountPlus(@RequestParam("date")String date,@RequestParam("localCity")String localCity){ - return this.comActAcidRecordService.fiveCountPlus(date,localCity); + public R fiveCountPlus(@RequestParam("date")String date,@RequestParam("localCity")String localCity,@RequestParam("loginAccount")String loginAccount){ + return this.comActAcidRecordService.fiveCountPlus(date,localCity,loginAccount); } /** diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActAcidRecordDao.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActAcidRecordDao.java index 3932daa..e561f34 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActAcidRecordDao.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActAcidRecordDao.java @@ -66,7 +66,7 @@ * @param localCity * @return */ - FiveCount fiveCountPlus(@Param("date") String date,@Param("localCity") String localCity); + FiveCount fiveCountPlus(@Param("date") String date,@Param("localCity") String localCity,@Param("type") Integer type); /** * 统计查询 diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComActAcidRecordService.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComActAcidRecordService.java index 85618c0..6ffd8fb 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComActAcidRecordService.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComActAcidRecordService.java @@ -56,7 +56,7 @@ * 5项统计 * @return */ - R fiveCountPlus(String date,String localCity); + R fiveCountPlus(String date,String localCity,String loginAccount); /** * 图标统计 diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java index 41057a6..ba36654 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java @@ -69,6 +69,10 @@ @Override public R pageList(ComActAcidRecordDTO comActAcidRecordDTO) { + //是否需要筛选 + comActAcidRecordDTO.setType(isVilliage(comActAcidRecordDTO.getLoginAccount())); + log.info("搜索条件=========="+comActAcidRecordDTO); + //获取当前登录账号的社区名 return R.ok(this.baseMapper.pageList(new Page<>(comActAcidRecordDTO.getPage(), comActAcidRecordDTO.getSize()),comActAcidRecordDTO)); } @@ -259,8 +263,10 @@ return R.ok(this.baseMapper.fiveCount(localCity)); } @Override - public R fiveCountPlus(String date,String localCity) { - return R.ok(this.baseMapper.fiveCountPlus(date,localCity)); + public R fiveCountPlus(String date,String localCity,String loginAccount) { + Integer type = isVilliage(loginAccount); + log.info("type===="+type); + return R.ok(this.baseMapper.fiveCountPlus(date,localCity,type)); } @Override @@ -566,4 +572,18 @@ case "盐边县": comStreetDO.setAreaCode(510422); break; } } + + /** + * 是否需要区分村落/社区 + * */ + private Integer isVilliage(String name){ + if ("fangyipingtai".equals(name)){ + return 3; + }else if ("pandashujuzhongxin".equals(name)){ + return 1; + }else if ("pannongyenongcunju".equals(name)){ + return 2; + } + return 3; + } } diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActAcidRecordMapper.xml b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActAcidRecordMapper.xml index bf31102..dae8ac3 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActAcidRecordMapper.xml +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/resources/mapper/ComActAcidRecordMapper.xml @@ -59,6 +59,12 @@ <if test="commonPage.travelCard !=null and commonPage.travelCard !=''"> and travel_card like concat('%',#{commonPage.travelCard},'%') </if> + <if test="commonPage.type == 1"> + and local_city like concat('%','社区') + </if> + <if test="commonPage.type == 2"> + and local_city like concat('%','村') + </if> </where> order by check_status asc,create_time desc </select> @@ -222,53 +228,116 @@ <select id="fiveCountPlus" resultType="com.panzhihua.common.model.vos.community.reserve.FiveCount"> select (select count(*) from com_act_acid_record where 1=1 and is_del=0 + <if test="type == 1"> + and local_city like + concat('%','社区') + </if> + <if test="type == 2"> + and local_city like + concat('%','村') + </if> <if test="date!=null and date!=''">and create_time between concat(#{date},' 00:00:00') and concat(#{date},' 23:23:59') </if> <if test="localCity!=null and localCity!='' and localCity !='panzhihua'">and local_city like - concat('%',#{localCity},'%')</if>) allCount, + concat('%',#{localCity},'%') + <if test="type == 1"> + and local_city like + concat('%','社区') + </if> + <if test="type == 2"> + and local_city like + concat('%','村') + </if></if>) allCount, (select count(*) from com_act_acid_record where danger_area = '是' and is_del=0 - <if - test="date!=null and date!=''">and create_time between concat(#{date},' 00:00:00') and concat(#{date},' + <if test="date!=null and date!=''">and create_time between concat(#{date},' 00:00:00') and concat(#{date},' 23:23:59') </if> + <if test="type == 1"> + and local_city like + concat('%','社区') + </if> + <if test="type == 2"> + and local_city like + concat('%','村') + </if> <if test="localCity!=null and localCity!='' and localCity !='panzhihua'">and local_city like - concat('%',#{localCity},'%')</if>) dangerCount, + concat('%',#{localCity},'%') + </if>) dangerCount, (select count(*) from com_act_acid_record where color_mark = '绿码' and is_del=0 - <if - test="date!=null and date!=''">and create_time between concat(#{date},' 00:00:00') and concat(#{date},' + <if test="date!=null and date!=''">and create_time between concat(#{date},' 00:00:00') and concat(#{date},' 23:23:59') </if> <if test="localCity!=null and localCity!='' and localCity !='panzhihua'">and local_city like - concat('%',#{localCity},'%')</if>) greenMark, + concat('%',#{localCity},'%')</if> + <if test="type == 1"> + and local_city like + concat('%','社区') + </if> + <if test="type == 2"> + and local_city like + concat('%','村') + </if>) greenMark, (select count(*) from com_act_acid_record where color_mark = '红码' and is_del=0 - <if - test="date!=null and date!=''">and create_time between concat(#{date},' 00:00:00') and concat(#{date},' + <if test="date!=null and date!=''">and create_time between concat(#{date},' 00:00:00') and concat(#{date},' 23:23:59') </if> + <if test="type == 1"> + and local_city like + concat('%','社区') + </if> + <if test="type == 2"> + and local_city like + concat('%','村') + </if> <if test="localCity!=null and localCity!='' and localCity !='panzhihua'">and local_city like - concat('%',#{localCity},'%')</if>) redMark, + concat('%',#{localCity},'%') + </if>) redMark, (select count(*) from com_act_acid_record where color_mark = '黄码' and is_del=0 - <if - test="date!=null and date!=''">and create_time between concat(#{date},' 00:00:00') and concat(#{date},' + <if test="type == 1"> + and local_city like + concat('%','社区') + </if> + <if test="type == 2"> + and local_city like + concat('%','村') + </if> + <if test="date!=null and date!=''">and create_time between concat(#{date},' 00:00:00') and concat(#{date},' 23:23:59') </if> <if test="localCity!=null and localCity!='' and localCity !='panzhihua'">and local_city like - concat('%',#{localCity},'%')</if>) yellowMark, + concat('%',#{localCity},'%') + </if>) yellowMark, (select count(*) from com_act_acid_record where travel_card = '是' and is_del=0 - <if - test="date!=null and date!=''">and create_time between concat(#{date},' 00:00:00') and concat(#{date},' + <if test="type == 1"> + and local_city like + concat('%','社区') + </if> + <if test="type == 2"> + and local_city like + concat('%','村') + </if> + <if test="date!=null and date!=''">and create_time between concat(#{date},' 00:00:00') and concat(#{date},' 23:23:59') </if> <if test="localCity!=null and localCity!='' and localCity !='panzhihua'">and local_city like - concat('%',#{localCity},'%')</if>) travelCount, + concat('%',#{localCity},'%') + </if>) travelCount, (select count(*) from com_act_acid_record where outside_city = '是' and is_del=0 - <if - test="date!=null and date!=''">and create_time between concat(#{date},' 00:00:00') and concat(#{date},' + <if test="type == 1"> + and local_city like + concat('%','社区') + </if> + <if test="type == 2"> + and local_city like + concat('%','村') + </if> + <if test="date!=null and date!=''">and create_time between concat(#{date},' 00:00:00') and concat(#{date},' 23:23:59') </if> <if test="localCity!=null and localCity!='' and localCity !='panzhihua'">and local_city like - concat('%',#{localCity},'%')</if>) outsideCount + concat('%',#{localCity},'%') + </if>) outsideCount </select> <select id="pushStatics" resultType="com.panzhihua.common.model.vos.community.reserve.FiveCount"> diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/api/UserApi.java b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/api/UserApi.java index 90b324b..3d0a161 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/api/UserApi.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/api/UserApi.java @@ -1420,8 +1420,8 @@ } @GetMapping("/communityList") - public R getCommunityList(@RequestParam(value = "type") Integer type){ - return userService.getCommunityList(type); + public R getCommunityList(@RequestParam("name") String name, @RequestParam(value = "id",required = false) Long id){ + return userService.getCommunityList(name,id); } } diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/UserDao.java b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/UserDao.java index f147273..dd013f9 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/UserDao.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/UserDao.java @@ -310,7 +310,9 @@ Map<String,Long> getDailyAddAndActive(@Param("date") Date date,@Param("id") Long streetId,@Param("areaCode") Long areaCode); - List<StreetVO> selectStreetByAreaCode(Integer code); + List<StreetVOS> selectStreetByAreaCode(Integer code); + + List<StreetVO> selectStreetsByAreaCode(Integer code); ComActAcidCheckRecordVO selectComActAcidCheckRecordById(Long id); @@ -328,4 +330,12 @@ * */ List<CommunityVO> selectCommunityByStreetId(@Param("id") Integer streetId,@Param("type") Integer type); + /** + * 获取账户id + * */ + List<Integer> selectIdsByAccount(@Param("array") String[] streetList); + + List<CommunityVO> selectCommunityByStreetName(String name); + + StreetVOS selectStreetByName(String name); } diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/UserService.java b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/UserService.java index e233ba4..8bc9e2f 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/UserService.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/UserService.java @@ -903,5 +903,5 @@ /** * 获取城镇或村落列表 * */ - R getCommunityList(Integer type); + R getCommunityList(String name,Long id); } diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java index 3753f8e..571a0b2 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java @@ -18,6 +18,7 @@ import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.NumberUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; @@ -3604,38 +3605,81 @@ } @Override - public R getCommunityList(Integer type) { - List<Integer> areaList = areaCodeList(); - List<AreaVOS> areaVOList=new ArrayList<>(); - for (Integer code : areaList) { - AreaVOS areaVO=new AreaVOS(); - areaVO.setId(code); - areaVO.setName(areaCodeToName(code.longValue())); - List<StreetVO> streetVOS = userDao.selectStreetByAreaCode(code); - Iterator<StreetVO> iterator = streetVOS.listIterator(); - while (iterator.hasNext()){ - StreetVO vo = iterator.next(); - List<CommunityVO> communityVOS = userDao.selectCommunityByStreetId(vo.getId(), type); - vo.setCommunityList(communityVOS); - if (type!=3){ - if (communityVOS==null || communityVOS.size()==0){ - iterator.remove(); + public R getCommunityList(String name,Long id) { + //区级账号名 + String[] streetList={"bingcaogangjiedao","donghuajiedao","nongnongpingjiedao","dadukoujiedaojiedao","guazipingjiedao", + "yinjiangzhen","qingxiangpingjiedao","yuquanjiedao","hemenkoujiedao","dabaodingjiedao","taojiadujiedao","gelipinzhen","dahezhonglujiedao", + "jingjiangzhen","renhezhen","pingdizhen","datianzhen","tongdezhen","futianzhen","qianjinzhen","panlianzhen","binguzhen","baimazhen", + "salianzhen","puweizhen","deshizhen","wanqiuyizuxiang","caochangzhen","xinshanlisuzuxiang","tongzilinzhen","yongxingzhen","yumenzhen", + "honggezhen","hongguoyizuxiang"}; + List<Integer> ids = userDao.selectIdsByAccount(streetList); + //村或社区账号 + Integer type=isVilliage(name); + //是否为市级账号 + Boolean cityAccount = isCityAccount(name); + if (cityAccount){ + List<Integer> areaList=areaCodeList(); + List<AreaVOS> areaVOList=new ArrayList<>(); + for (Integer code : areaList) { + AreaVOS areaVO=new AreaVOS(); + areaVO.setId(code); + areaVO.setName(areaCodeToName(code.longValue())); + List<StreetVOS> streetVOS = userDao.selectStreetByAreaCode(code); + Iterator<StreetVOS> iterator = streetVOS.listIterator(); + while (iterator.hasNext()){ + StreetVOS vo = iterator.next(); + List<CommunityVO> communityVOS = userDao.selectCommunityByStreetId(vo.getId(), type); + vo.setChildList(communityVOS); + if (type!=3){ + if (communityVOS==null || communityVOS.size()==0){ + iterator.remove(); + } } } + areaVO.setChildList(streetVOS); + areaVOList.add(areaVO); } - List<StreetVOS> list=new ArrayList<>(); - for (StreetVO streetVO : streetVOS) { - StreetVOS vo=new StreetVOS(); - vo.setId(streetVO.getId()); - vo.setName(streetVO.getName()); - vo.setChildList(streetVO.getCommunityList()); - list.add(vo); + return R.ok(areaVOList); + }else{ + Boolean areaAccount = isAreaAccount(name); + if (areaAccount){ + Integer areaCode = accountToCode(name); + List<Integer> areaList=new ArrayList<>(); + areaList.add(areaCode); + List<AreaVOS> areaVOList=new ArrayList<>(); + for (Integer code : areaList) { + AreaVOS areaVO=new AreaVOS(); + areaVO.setId(code); + areaVO.setName(areaCodeToName(code.longValue())); + List<StreetVOS> streetVOS = userDao.selectStreetByAreaCode(code); + Iterator<StreetVOS> iterator = streetVOS.listIterator(); + while (iterator.hasNext()){ + StreetVOS vo = iterator.next(); + List<CommunityVO> communityVOS = userDao.selectCommunityByStreetId(vo.getId(), type); + vo.setChildList(communityVOS); + } + areaVO.setChildList(streetVOS); + areaVOList.add(areaVO); + } + return R.ok(areaVOList); + }else{ + //非区县账号,只看街道下属社区 + if (ArrayUtil.contains(streetList, name)){ + List<StreetVOS> list=new ArrayList<>(); + //只看当前街道下属社区 + StreetVOS streetVOS = userDao.selectStreetByName(name); + List<CommunityVO> communityVOS = userDao.selectCommunityByStreetName(name); + if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(streetVOS)) { + streetVOS.setChildList(communityVOS); + } + list.add(streetVOS); + return R.ok(list); + } } - areaVO.setChildList(list); - areaVOList.add(areaVO); } - return R.ok(areaVOList); + return R.ok(null); } + @Override public R getAreaAndStreet() { @@ -3645,7 +3689,7 @@ AreaVO vo=new AreaVO(); vo.setId(code); vo.setName(areaCodeToName(code.longValue())); - vo.setStreetList(userDao.selectStreetByAreaCode(code)); + vo.setStreetList(userDao.selectStreetsByAreaCode(code)); areaVOList.add(vo); } return R.ok(areaVOList); @@ -3847,6 +3891,73 @@ return null; } + /** + * 是否需要区分村落/社区 + * */ + private Integer isVilliage(String name){ + if ("fangyipingtai".equals(name)){ + return 3; + }else if ("pandashujuzhongxin".equals(name)){ + return 1; + }else if ("pannongyenongcunju".equals(name)){ + return 2; + } + return 3; + } + /** + * 是否为市级账号 + * */ + private Boolean isCityAccount(String name){ + if(("fangyipingtai").equals(name) || ("pandashujuzhongxin").equals(name) || ("pannongyenongcunju").equals(name)){ + return true; + } + return false; + } + + /** + * 是否为区级账号 + * */ + private Boolean isAreaAccount(String name){ + Boolean flag=false; + switch (name){ + case "dongqu": + case "xiqu": + case "renhequ": + case "miyixian": + case "yanbianxian": + flag=true; + break; + } + return flag; + } + + /** + * account转区areaCode + * */ + private Integer accountToCode(String code){ + String name="100000"; + switch (code){ + case "xiqu" : + name= "510423"; + break; + case "dongqu": + name="510402"; + break; + case "renhequ": + name="510411"; + break; + case "miyixian": + name="510421"; + break; + case "yanbianxian": + name="510422"; + break; + case "fantaixinqu": + name="510424"; + break; + } + return Integer.parseInt(name); + } } diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/resources/mapper/UserDao.xml b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/resources/mapper/UserDao.xml index 73e2987..df229ac 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/resources/mapper/UserDao.xml +++ b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/resources/mapper/UserDao.xml @@ -678,7 +678,10 @@ </if> </select> - <select id="selectStreetByAreaCode" resultType="com.panzhihua.common.model.vos.user.StreetVO"> + <select id="selectStreetByAreaCode" resultType="com.panzhihua.common.model.vos.user.StreetVOS"> + select street_id as id,name as name from com_street where area_code=#{code} + </select> + <select id="selectStreetsByAreaCode" resultType="com.panzhihua.common.model.vos.user.StreetVO"> select street_id as id,name as name from com_street where area_code=#{code} </select> <select id="selectComActAcidCheckRecordById" @@ -716,4 +719,25 @@ and name like concat('%','村') </if> </select> + + <select id="selectIdsByAccount" resultType="java.lang.Integer"> + select user_id from sys_user where account in + <foreach collection="array" item="name" separator="," open="(" close=")" > + #{name} + </foreach> + </select> + <select id="selectCommunityByStreetName" resultType="com.panzhihua.common.model.vos.user.CommunityVO"> + select ca.community_id as id,ca.name as name + from sys_user as su + left join com_street as cs on cs.name=su.name + left join com_act as ca on ca.street_id=cs.street_id + where su.account=#{name} + </select> + <select id="selectStreetByName" resultType="com.panzhihua.common.model.vos.user.StreetVOS"> + select cs.street_id as id,cs.name as name + from sys_user as su + left join com_street as cs on su.name=cs.name + where su.account=#{name} + limit 1 + </select> </mapper> -- Gitblit v1.7.1