| | |
| | | * @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()) { |
| | |
| | | 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); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除片区 |
| | |
| | | |
| | | //@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) { |