From 7d05aad173c1e605419ea38ff598b9c7572c611d Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期四, 15 八月 2024 08:36:20 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
---
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/block/BlockCtrl.java | 157 ++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 120 insertions(+), 37 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/block/BlockCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/block/BlockCtrl.java
index 28aceb8..7f0ef55 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/block/BlockCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/block/BlockCtrl.java
@@ -1,14 +1,21 @@
package com.dy.pipIrrBase.block;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
import com.dy.common.aop.SsoAop;
+import com.dy.common.mybatis.envm.Deleted;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.common.webUtil.ResultCodeMsg;
+import com.dy.pipIrrBase.block.dto.Block;
+import com.dy.pipIrrBase.block.enums.graphTypeENUM;
+import com.dy.pipIrrBase.result.SystemResultCode;
import com.dy.pipIrrGlobal.pojoBa.BaBlock;
-import com.dy.pipIrrGlobal.pojoBa.BaBlock;
+import com.dy.pipIrrGlobal.pojoBa.BaMapCoordinates;
+import com.dy.pipIrrGlobal.pojoBa.BaMapGraph;
+import com.dy.pipIrrGlobal.voBa.VoBlock;
import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
@@ -18,11 +25,13 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
+import java.util.Optional;
@Slf4j
@Tag(name = "鐗囧尯绠$悊", description = "鐗囧尯澧炲垹鏀规煡绛夋搷浣�")
@@ -52,7 +61,7 @@
)
})
@GetMapping(path = "all")
- @SsoAop("-1")
+ @SsoAop()
public BaseResponse<QueryResultVo<List<BaBlock>>> all(){
try {
QueryResultVo<List<BaBlock>> res = this.sv.selectAll() ;
@@ -64,26 +73,37 @@
}
/**
- * 瀹㈡埛绔姹傚緱鍒版墍鏈夌墖鍖烘暟鎹�
+ * 瀹㈡埛绔姹傚緱鍒版墍鏈夌墖鍖烘暟鎹� 2024-08-14搴熷純
* @return 鎵�鏈夌墖鍖烘暟鎹�
*/
- @Operation(summary = "鑾峰緱涓�椤电墖鍖�", description = "杩斿洖涓�椤电墖鍖烘暟鎹�")
- @ApiResponses(value = {
- @ApiResponse(
- responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
- description = "杩斿洖涓�椤电墖鍖烘暟鎹紙BaseResponse.content:QueryResultVo[{}]锛�",
- content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
- schema = @Schema(implementation = BaBlock.class))}
- )
- })
- @PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE)
- @SsoAop("-1")
- public BaseResponse<QueryResultVo<List<BaBlock>>> some(@RequestBody @Parameter(description = "鏌ヨform琛ㄥ崟json鏁版嵁", required = true) QueryVo vo){
+ @PostMapping(path = "some2", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @SsoAop()
+ public BaseResponse<QueryResultVo<List<BaBlock>>> some(@RequestBody QueryVo vo){
try {
QueryResultVo<List<BaBlock>> res = this.sv.selectSome(vo) ;
return BaseResponseUtils.buildSuccess(res);
} catch (Exception e) {
log.error("鏌ヨ鐗囧尯寮傚父", e);
+ return BaseResponseUtils.buildException(e.getMessage()) ;
+ }
+ }
+
+ /**
+ * 鏍规嵁鎸囧畾鏉′欢鑾峰彇鐗囧尯锛�2024-08-14鏂板锛屾浛鎹㈠師鏉ョ殑鐗囧尯鍒嗛〉鏌ヨ
+ * @param qo
+ * @param bindingResult
+ * @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());
+ }
+ try {
+ return BaseResponseUtils.buildSuccess(this.sv.getBlocks(qo));
+ } catch (Exception e) {
+ log.error("鑾峰彇寮�鍗¤褰曞紓甯�", e);
return BaseResponseUtils.buildException(e.getMessage()) ;
}
}
@@ -101,9 +121,10 @@
schema = @Schema(implementation = BaBlock.class))}
)
})
- @GetMapping(path = "one", consumes = MediaType.TEXT_PLAIN_VALUE)
- @SsoAop("-1")
- public BaseResponse<BaBlock> one(@Parameter(description = "瀹炰綋id", required = true) Long id){
+ //@GetMapping(path = "one", consumes = MediaType.TEXT_PLAIN_VALUE)
+ @GetMapping(path = "one")
+ @SsoAop()
+ public BaseResponse<BaBlock> one(Long id){
return BaseResponseUtils.buildSuccess(this.sv.selectById(id));
}
@@ -122,24 +143,85 @@
)
})
@PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE)
- @SsoAop("-1")//@SsoAop(power = "-1")
- public BaseResponse<Boolean> save(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid BaBlock po, @Parameter(hidden = true) BindingResult bindingResult){
+ @Transactional(rollbackFor = Exception.class)
+ @SsoAop()
+ //public BaseResponse<Boolean> save(@RequestBody @Valid BaBlock po, BindingResult bindingResult){
+ public BaseResponse<Boolean> save(@RequestBody @Valid Block po, BindingResult bindingResult){
if(bindingResult != null && bindingResult.hasErrors()){
return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
- po.id = null ;
- int count;
- try {
- count = this.sv.save(po);
- } catch (Exception e) {
- log.error("淇濆瓨鐗囧尯寮傚父", e);
- return BaseResponseUtils.buildException(e.getMessage()) ;
+
+ // 娣诲姞鐗囧尯璁板綍
+ BaBlock baBlock = new BaBlock();
+ baBlock.setName(po.getName());
+ baBlock.setHeader(po.getHeader());
+ baBlock.setPhone(po.getPhone());
+ baBlock.setArea(po.getArea());
+ baBlock.setColor(po.getColor());
+ baBlock.setRemark(po.getRemark());
+ baBlock.deleted = Deleted.NO;
+ Long blockId = Optional.ofNullable(this.sv.save(baBlock)).orElse(0L);
+ if(blockId.equals(0)) {
+ return BaseResponseUtils.buildErrorMsg(SystemResultCode.SAVA_BLOCK_ERROR.getMessage());
}
- if(count <= 0){
- return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ;
- }else{
- return BaseResponseUtils.buildSuccess(true) ;
+
+ 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);
+
+ //po.id = null ;
+ //po.deleted = Deleted.NO;
+ //int count;
+ //try {
+ // count = this.sv.save(po);
+ //} catch (Exception e) {
+ // log.error("淇濆瓨鐗囧尯寮傚父", e);
+ // return BaseResponseUtils.buildException(e.getMessage()) ;
+ //}
+ //if(count <= 0){
+ // return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ;
+ //}else{
+ // return BaseResponseUtils.buildSuccess(true) ;
+ //}
}
/**
@@ -157,8 +239,8 @@
)
})
@PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
- @SsoAop("-1")//@SsoAop(power = "-1")
- public BaseResponse<Boolean> update(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid BaBlock po, @Parameter(hidden = true) BindingResult bindingResult){
+ @SsoAop()
+ public BaseResponse<Boolean> update(@RequestBody @Valid BaBlock po, BindingResult bindingResult){
if(bindingResult != null && bindingResult.hasErrors()){
return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
@@ -194,9 +276,10 @@
schema = @Schema(implementation = Boolean.class))}
)
})
- @GetMapping(path = "delete", consumes = MediaType.TEXT_PLAIN_VALUE)
- @SsoAop("-1")//@SsoAop(power = "-1")
- public BaseResponse<Boolean> delete(@Parameter(description = "瀹炰綋id", required = true) Long id){
+ //@GetMapping(path = "delete", consumes = MediaType.TEXT_PLAIN_VALUE)
+ @GetMapping(path = "delete")
+ @SsoAop()
+ public BaseResponse<Boolean> delete(Long id){
if(id == null){
return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖") ;
}
--
Gitblit v1.8.0