From feb98a932adc9dab19fa538dbad743c63af0e621 Mon Sep 17 00:00:00 2001 From: 张天森 <1292933220@qq.com> Date: 星期二, 19 七月 2022 17:24:17 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/huacheng_zts' into huacheng_zZ --- springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java | 165 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 138 insertions(+), 27 deletions(-) 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 38eea50..004a6bb 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; @@ -3602,38 +3603,81 @@ return R.ok(); } @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() { @@ -3643,7 +3687,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); @@ -3846,6 +3890,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); + } } -- Gitblit v1.7.1