linwei
2024-01-31 b3b566ebdfed4005aaa513da3d5d2fd3924903cc
src/main/java/org/springblade/modules/place/service/impl/PlaceServiceImpl.java
@@ -178,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 {
         // 一对一,暂时不处理,后续考虑需加绑定关系表
      }
   }
   /**
@@ -382,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);
         }
      }
   }