From c6beb89b7170115eada78526f87406381c931229 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期四, 03 四月 2025 10:37:51 +0800
Subject: [PATCH] 灌溉计划发布时仅发布灌溉时长大于0的
---
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/program/UgRtuProgramCtrl.java | 52 ++++++++++++++++++++++++++++++++++------------------
1 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/program/UgRtuProgramCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/program/UgRtuProgramCtrl.java
index 23a04a4..9cadf12 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/program/UgRtuProgramCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/rtuUpgrade/program/UgRtuProgramCtrl.java
@@ -4,13 +4,13 @@
import com.dy.common.aop.SsoAop;
import com.dy.common.softUpgrade.parse.HexFileParse;
import com.dy.common.softUpgrade.parse.HexFileVo;
-import com.dy.common.util.DateTime;
+import com.dy.common.util.ByteUtil;
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.pipIrrGlobal.pojoRm.UgRtuProgram;
-import com.dy.pipIrrGlobal.voRm.VoRtuProgram;
+import com.dy.pipIrrGlobal.pojoUg.UgRtuProgram;
+import com.dy.pipIrrGlobal.voUg.VoRtuProgram;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
@@ -75,7 +75,7 @@
}
return BaseResponseUtils.buildSuccess(po);
}else{
- return BaseResponseUtils.buildException("鏈煡璇㈠埌瀵瑰簲鐨勮褰�") ;
+ return BaseResponseUtils.buildErrorMsg("鏈煡璇㈠埌瀵瑰簲鐨勮褰�") ;
}
}
/**
@@ -99,7 +99,7 @@
return BaseResponseUtils.buildSuccess(res);
} catch (Exception e) {
log.error("鏌ヨRTU鍗囩骇绋嬪簭寮傚父", e);
- return BaseResponseUtils.buildException(e.getMessage()) ;
+ return BaseResponseUtils.buildErrorMsg(e.getMessage()) ;
}
}
@@ -124,7 +124,7 @@
return BaseResponseUtils.buildSuccess(res);
} catch (Exception e) {
log.error("鏌ヨRTU鍗囩骇绋嬪簭寮傚父", e);
- return BaseResponseUtils.buildException(e.getMessage()) ;
+ return BaseResponseUtils.buildErrorMsg(e.getMessage()) ;
}
}
@@ -142,14 +142,30 @@
schema = @Schema(implementation = Boolean.class))}
)
})
- @PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @PostMapping(path = "save", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@SsoAop()
- public BaseResponse<Boolean> save(@RequestBody @Valid VoRtuProgram vo, @Parameter(hidden = true) BindingResult bindingResult){
+ public BaseResponse<Boolean> save(@Parameter(description = "form琛ㄥ崟鏁版嵁", required = true) @Valid VoRtuProgram vo, @Parameter(hidden = true) BindingResult bindingResult){
if(bindingResult != null && bindingResult.hasErrors()){
- return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ if(vo.storeRamAddr == null
+ || vo.storeRamAddr.trim().equals("")
+ || vo.storeRamAddr.length() != 8
+ || !HexUtil.isHexNumber(vo.storeRamAddr)){
+ return BaseResponseUtils.buildErrorMsg("鍗囩骇绋嬪簭瀛樻斁鍦板潃(4瀛楄妭锛�8浣嶅崄鍏繘鍒舵暟)涓嶆纭�") ;
+ }
+ if(vo.startRamAddr == null
+ || vo.startRamAddr.trim().equals("")
+ || vo.startRamAddr.length() != 8
+ || !HexUtil.isHexNumber(vo.startRamAddr)){
+ return BaseResponseUtils.buildErrorMsg("绋嬪簭瑕嗙洊璧峰鍦板潃(4瀛楄妭锛�8浣嶅崄鍏繘鍒舵暟)涓嶆纭�") ;
}
if(vo.file == null){
- return BaseResponseUtils.buildFail("RTU绋嬪簭鏂囦欢蹇呴』涓婁紶") ;
+ return BaseResponseUtils.buildErrorMsg("RTU绋嬪簭鏂囦欢蹇呴』涓婁紶") ;
+ }
+ String fileName = vo.file.getOriginalFilename() ;
+ if(this.sv.existFileName(fileName)){
+ return BaseResponseUtils.buildErrorMsg("RTU绋嬪簭鏂囦欢鍚嶅凡瀛樺湪") ;
}
HexFileVo fileVo = null ;
@@ -162,11 +178,11 @@
}
}catch (Exception e){
fileVo = null ;
- return BaseResponseUtils.buildFail("瑙f瀽RTU绋嬪簭鏂囦欢寮傚父锛�" + e.getMessage()) ;
+ return BaseResponseUtils.buildErrorMsg("瑙f瀽RTU绋嬪簭鏂囦欢寮傚父锛�" + e.getMessage()) ;
}
if(fileVo != null){
UgRtuProgram po = new UgRtuProgram();
- po.hexFileName = vo.file.getOriginalFilename() ;
+ po.hexFileName = fileName ;
po.programCalculateBytes = (int)fileVo.calculateBytes ;
po.programCrc16 = fileVo.bytesCrc16 ;
po.programBytes = fileVo.bytes;
@@ -181,15 +197,15 @@
count = this.sv.save(po);
} catch (Exception e) {
log.error("淇濆瓨RTU鍗囩骇绋嬪簭寮傚父", e);
- return BaseResponseUtils.buildException(e.getMessage()) ;
+ return BaseResponseUtils.buildErrorMsg(e.getMessage()) ;
}
if(count <= 0){
- return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ;
+ return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撳瓨鍌ㄥけ璐�") ;
}else{
return BaseResponseUtils.buildSuccess(true) ;
}
}else{
- return BaseResponseUtils.buildFail("瑙f瀽RTU绋嬪簭鏂囦欢寮傚父") ;
+ return BaseResponseUtils.buildErrorMsg("瑙f瀽RTU绋嬪簭鏂囦欢寮傚父") ;
}
}
/**
@@ -229,17 +245,17 @@
@SsoAop()
public BaseResponse<Boolean> delete(Long id){
if(id == null){
- return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖") ;
+ return BaseResponseUtils.buildErrorMsg("id涓嶈兘涓虹┖") ;
}
int count;
try {
count = this.sv.delete(id);
} catch (Exception e) {
log.error("鍒犻櫎RTU鍗囩骇绋嬪簭寮傚父", e);
- return BaseResponseUtils.buildException(e.getMessage()) ;
+ return BaseResponseUtils.buildErrorMsg(e.getMessage()) ;
}
if(count <= 0){
- return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ;
+ return BaseResponseUtils.buildErrorMsg("鏁版嵁搴撳瓨鍌ㄥけ璐�") ;
}else{
return BaseResponseUtils.buildSuccess(true) ;
}
--
Gitblit v1.8.0