zhongrj
2024-01-30 e4eb59f43880294103f74311f10e92f8cb99b736
场所标签为空设置
1 files modified
134 ■■■■ changed files
src/main/java/org/springblade/modules/place/service/impl/PlaceServiceImpl.java 134 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/place/service/impl/PlaceServiceImpl.java
@@ -417,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);
            }
        }
    }