linwei
2024-01-31 b3b566ebdfed4005aaa513da3d5d2fd3924903cc
src/main/java/org/springblade/modules/place/service/impl/PlaceServiceImpl.java
@@ -107,7 +107,14 @@
   public IPage<PlaceVO> selectPlacePage(IPage<PlaceVO> page, PlaceVO place) {
      List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId());
      Integer isAdministrator = AuthUtil.isAdministrator()==true?1:2;
      List<PlaceVO> placeVOS = baseMapper.selectPlacePage(page, place,regionChildCodesList,isAdministrator);
      List<String> list = new ArrayList<>();
      if (null!=place.getRoleName() && !place.getRoleName().equals("")){
         if (place.getRoleName().equals("网格员")){
            // 查询对应的房屋地址code
            list = gridService.getAddressCodeListByUserId(AuthUtil.getUserId());
         }
      }
      List<PlaceVO> placeVOS = baseMapper.selectPlacePage(page, place,list,regionChildCodesList,isAdministrator);
      // 返回
      return page.setRecords(placeVOS);
   }
@@ -171,8 +178,43 @@
      gridBind(placeVO);
      // 网格编号绑定场所-新
      gridCodeBind(placeVO);
      // 房屋编号绑定
//      houseCodeBind(placeVO);
      // 返回结果
      return flag;
   }
   /**
    * 房屋绑定
    * @param placeVO
    */
   public void houseCodeBind(PlaceVO placeVO) {
      String houseCode = placeVO.getHouseCode();
      List<String> list = Arrays.asList(houseCode.split(","));
      if (list.size()>1){
         // 处理对应的绑定房屋数据
         List<Long> longs = new ArrayList<>();
         // 把其他单个的场所数据删除
         for (String code : list) {
            // 先查询对应的场所id
            QueryWrapper<PlaceEntity> wrapper = new QueryWrapper<>();
            wrapper.eq("house_code",code).eq("is_deleted",0);
            PlaceEntity one = getOne(wrapper);
            if (null!=one){
               longs.add(one.getId());
               // 删除对应的单个编号的场所
               removeById(one.getId());
            }
         }
         if (longs.size()>0) {
            // 删除对应的详情
            removePlaceExt(longs);
            // 删除对应的标签绑定信息
            removePlaceLabel(longs);
         }
      }else {
         // 一对一,暂时不处理,后续考虑需加绑定关系表
      }
   }
   /**
@@ -375,81 +417,83 @@
    * @param placeVO
    */
   public void savePlaceLabel(PlaceVO placeVO) {
      // 批量新增
      List<String> labelList = Arrays.asList(placeVO.getLabel().split(","));
      if (labelList.size()>1){
         // 只处理小类
         // 遍历
         labelList.forEach(labelId -> {
      if (!Strings.isBlank(placeVO.getLabel())) {
         // 批量新增
         List<String> labelList = Arrays.asList(placeVO.getLabel().split(","));
         if (labelList.size() > 1) {
            // 只处理小类
            // 遍历
            labelList.forEach(labelId -> {
               // 处理小类
               if (labelId.length() > 4) {
                  // 切割成三个,分别是大类,中类,小类
                  String bigString = labelId.substring(0, 2);
                  String midString = labelId.substring(0, 4);
                  // 大类
                  PlacePoiLabel big = new PlacePoiLabel();
                  big.setPlaceId(placeVO.getId());
                  big.setPoiCode(Integer.parseInt(bigString));
                  big.setType(1);
                  if (!Strings.isBlank(placeVO.getColor())) {
                     big.setColor(placeVO.getColor());
                  }
                  placePoiLabelService.save(big);
                  // 中类
                  PlacePoiLabel mid = new PlacePoiLabel();
                  mid.setPlaceId(placeVO.getId());
                  mid.setPoiCode(Integer.parseInt(midString));
                  mid.setType(2);
                  if (!Strings.isBlank(placeVO.getColor())) {
                     mid.setColor(placeVO.getColor());
                  }
                  placePoiLabelService.save(mid);
                  // 小类
                  PlacePoiLabel min = new PlacePoiLabel();
                  min.setPlaceId(placeVO.getId());
                  min.setPoiCode(Integer.parseInt(labelId));
                  min.setType(3);
                  if (!Strings.isBlank(placeVO.getColor())) {
                     min.setColor(placeVO.getColor());
                  }
                  placePoiLabelService.save(min);
               }
            });
         } else {
            // 处理单个
            String labelCode = labelList.get(0);
            // 切割成三个,分别是大类,中类,小类
            String bigString = labelCode.substring(0, 2);
            String midString = labelCode.substring(0, 4);
            // 大类
            PlacePoiLabel big = new PlacePoiLabel();
            big.setPlaceId(placeVO.getId());
            big.setPoiCode(Integer.parseInt(bigString));
            big.setType(1);
            if (!Strings.isBlank(placeVO.getColor())) {
               big.setColor(placeVO.getColor());
            }
            placePoiLabelService.save(big);
            // 中类
            PlacePoiLabel mid = new PlacePoiLabel();
            mid.setPlaceId(placeVO.getId());
            mid.setPoiCode(Integer.parseInt(midString));
            mid.setType(2);
            if (!Strings.isBlank(placeVO.getColor())) {
               mid.setColor(placeVO.getColor());
            }
            placePoiLabelService.save(mid);
            // 处理小类
            if (labelId.length()>4) {
               // 切割成三个,分别是大类,中类,小类
               String bigString = labelId.substring(0,2);
               String midString = labelId.substring(0,4);
               // 大类
               PlacePoiLabel big = new PlacePoiLabel();
               big.setPlaceId(placeVO.getId());
               big.setPoiCode(Integer.parseInt(bigString));
               big.setType(1);
               if (!Strings.isBlank(placeVO.getColor())){
                  big.setColor(placeVO.getColor());
               }
               placePoiLabelService.save(big);
               // 中类
               PlacePoiLabel mid = new PlacePoiLabel();
               mid.setPlaceId(placeVO.getId());
               mid.setPoiCode(Integer.parseInt(midString));
               mid.setType(2);
               if (!Strings.isBlank(placeVO.getColor())){
                  mid.setColor(placeVO.getColor());
               }
               placePoiLabelService.save(mid);
            if (labelCode.length() > 4) {
               // 小类
               PlacePoiLabel min = new PlacePoiLabel();
               min.setPlaceId(placeVO.getId());
               min.setPoiCode(Integer.parseInt(labelId));
               min.setPoiCode(Integer.parseInt(labelCode));
               min.setType(3);
               if (!Strings.isBlank(placeVO.getColor())){
               if (!Strings.isBlank(placeVO.getColor())) {
                  min.setColor(placeVO.getColor());
               }
               placePoiLabelService.save(min);
            }
         });
      }else {
         // 处理单个
         String labelCode = labelList.get(0);
         // 切割成三个,分别是大类,中类,小类
         String bigString = labelCode.substring(0, 2);
         String midString = labelCode.substring(0, 4);
         // 大类
         PlacePoiLabel big = new PlacePoiLabel();
         big.setPlaceId(placeVO.getId());
         big.setPoiCode(Integer.parseInt(bigString));
         big.setType(1);
         if (!Strings.isBlank(placeVO.getColor())){
            big.setColor(placeVO.getColor());
         }
         placePoiLabelService.save(big);
         // 中类
         PlacePoiLabel mid = new PlacePoiLabel();
         mid.setPlaceId(placeVO.getId());
         mid.setPoiCode(Integer.parseInt(midString));
         mid.setType(2);
         if (!Strings.isBlank(placeVO.getColor())){
            mid.setColor(placeVO.getColor());
         }
         placePoiLabelService.save(mid);
         // 处理小类
         if (labelCode.length() > 4) {
            // 小类
            PlacePoiLabel min = new PlacePoiLabel();
            min.setPlaceId(placeVO.getId());
            min.setPoiCode(Integer.parseInt(labelCode));
            min.setType(3);
            if (!Strings.isBlank(placeVO.getColor())){
               min.setColor(placeVO.getColor());
            }
            placePoiLabelService.save(min);
         }
      }
   }
@@ -592,36 +636,36 @@
      // 查询场所信息
      PlaceVO placeVO = baseMapper.getDetail(place);
      // 门牌信息
      if (null!= place.getAddressType() && place.getAddressType()==4){
         if (null != placeVO) {
      if (null != placeVO) {
         if (null != place.getAddressType() && place.getAddressType() == 4) {
            // 查询地址编码信息(社区派出所相关信息)
            DoorplateAddressEntity addressEntity = placeRelService.getDoorplateAddressEntity(placeVO);
            placeVO.setDoorplateAddressEntity(addressEntity);
            // 查询网格信息--商超
            placeVO.setGrid(gridService.getGridDetailByParam(placeVO));
         }
      }else {
         // 管理后台查询赋值颜色
         if (placeVO.getPlacePoiLabelVOList().size()>0){
            PlacePoiLabelVO placePoiLabelVO = placeVO.getPlacePoiLabelVOList().get(0);
            if (!Strings.isBlank(placePoiLabelVO.getColor())){
               placeVO.setColor(placePoiLabelVO.getColor());
         } else {
            // 管理后台查询赋值颜色
            if (placeVO.getPlacePoiLabelVOList().size() > 0) {
               PlacePoiLabelVO placePoiLabelVO = placeVO.getPlacePoiLabelVOList().get(0);
               if (!Strings.isBlank(placePoiLabelVO.getColor())) {
                  placeVO.setColor(placePoiLabelVO.getColor());
               }
            }
            // 查询地址门牌信息
            QueryWrapper<DoorplateAddressEntity> wrapper = new QueryWrapper<>();
            wrapper.eq("address_code", placeVO.getHouseCode());
            List<DoorplateAddressEntity> list = doorplateAddressService.list(wrapper);
            if (list.size() > 0) {
               placeVO.setDoorplateAddressEntity(list.get(0));
               placeVO.setNeiCode(list.get(0).getNeiCode());
            }
            // 查询场所对应的网格数据
            placeVO.setGrid(gridService.getPlaceGridDetailByHouseCode(placeVO.getHouseCode()));
            // 设置详情信息
            QueryWrapper<PlaceExtEntity> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("is_deleted", 0).eq("place_id", placeVO.getId());
            placeVO.setPlaceExtEntity(placeExtService.getOne(queryWrapper));
         }
         // 查询地址门牌信息
         QueryWrapper<DoorplateAddressEntity> wrapper = new QueryWrapper<>();
         wrapper.eq("address_code", placeVO.getHouseCode());
         List<DoorplateAddressEntity> list = doorplateAddressService.list(wrapper);
         if (list.size() > 0) {
            placeVO.setDoorplateAddressEntity(list.get(0));
            placeVO.setNeiCode(list.get(0).getNeiCode());
         }
         // 查询场所对应的网格数据
         placeVO.setGrid(gridService.getPlaceGridDetailByHouseCode(placeVO.getHouseCode()));
         // 设置详情信息
         QueryWrapper<PlaceExtEntity> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("is_deleted",0).eq("place_id",placeVO.getId());
         placeVO.setPlaceExtEntity(placeExtService.getOne(queryWrapper));
      }
      // 返回
      return placeVO;