zhubaomin
2024-08-21 c0a1e58617d69fa78cceebb27376e57e324a562e
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/block/BlockCtrl.java
@@ -94,15 +94,12 @@
     * 根据指定条件获取片区,2024-08-14新增,替换原来的片区分页查询
     *
     * @param qo
     * @param bindingResult
     * @param
     * @return
     */
    @GetMapping(path = "/some")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoBlock>>> getBlocks(@Valid QueryVo qo, BindingResult bindingResult) {
        if (bindingResult != null && bindingResult.hasErrors()) {
            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
    public BaseResponse<QueryResultVo<List<VoBlock>>> getBlocks(QueryVo qo) {
        try {
            return BaseResponseUtils.buildSuccess(this.sv.getBlocks(qo));
        } catch (Exception e) {
@@ -266,6 +263,7 @@
     * @return
     */
    @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    public BaseResponse<Boolean> update(@RequestBody @Valid Block po, BindingResult bindingResult) {
        if (bindingResult != null && bindingResult.hasErrors()) {
@@ -298,14 +296,55 @@
            return BaseResponseUtils.buildFail("数据库存储失败");
        }
        // 删除片区关联的地图图形
        this.sv.deleteMapGraph(blockId);
        // 删除地图图形坐标
        this.sv.deleteMapCoordinates(blockId);
        // 删除片区关联的地图图形
        this.sv.deleteMapGraph(blockId);
        JSONArray graphs = po.getGraphs();
        for (int i = 0; i < graphs.size(); i++) {
            JSONObject graph = graphs.getJSONObject(i);
            // 添加地图图形记录
            BaMapGraph baMapGraph = new BaMapGraph();
            baMapGraph.setBlockId(blockId);
            switch (graph.getString("type")) {
                case "CircleMarker":
                    baMapGraph.setGraphType(graphTypeENUM.CIRCLE_MARKER.getCode());
                    break;
                case "Polygon":
                    baMapGraph.setGraphType(graphTypeENUM.POLYGON.getCode());
                    break;
                case "Polyline":
                    baMapGraph.setGraphType(graphTypeENUM.POLYLINE.getCode());
                    break;
            }
            Long graphId = Optional.ofNullable(this.sv.addMapGraph(baMapGraph)).orElse(0L);
            if (graphId.equals(0)) {
                return BaseResponseUtils.buildErrorMsg(SystemResultCode.SAVA_BLOCK_ERROR.getMessage());
            }
            // 添加地图图形坐标记录
            JSONArray coordinates = graph.getJSONArray("coordinates");
            for (int j = 0; j < coordinates.size(); j++) {
                JSONArray coordinate = coordinates.getJSONArray(j);
                for (int k = 0; k < coordinate.size(); k++) {
                    JSONObject point = coordinate.getJSONObject(k);
                    BaMapCoordinates mapCoordinates = new BaMapCoordinates();
                    mapCoordinates.setGraphId(graphId);
                    mapCoordinates.setLat(point.getBigDecimal("lat"));
                    mapCoordinates.setLng(point.getBigDecimal("lng"));
                    Long coordinateId = Optional.ofNullable(this.sv.addMapCoordinate(mapCoordinates)).orElse(0L);
                    if (coordinateId.equals(0)) {
                        return BaseResponseUtils.buildErrorMsg(SystemResultCode.SAVA_BLOCK_ERROR.getMessage());
                    }
                }
            }
        }
        return BaseResponseUtils.buildSuccess(true);
    }
    /**
     * 删除片区
@@ -325,6 +364,7 @@
    //@GetMapping(path = "delete", consumes = MediaType.TEXT_PLAIN_VALUE)
    @GetMapping(path = "delete")
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    public BaseResponse<Boolean> delete(Long id) {
        if (id == null) {
@@ -341,10 +381,10 @@
            return BaseResponseUtils.buildFail("数据库存储失败");
        }
        // 删除片区关联的地图图形
        this.sv.deleteMapGraph(id);
        // 删除地图图形坐标
        this.sv.deleteMapCoordinates(id);
        // 删除片区关联的地图图形
        this.sv.deleteMapGraph(id);
        return BaseResponseUtils.buildSuccess(true);
    }