From 2376e2d4b76470973d1de29b661ff6f10d883ccd Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期四, 29 八月 2024 10:03:35 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
---
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java | 10
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java | 16 +-
pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/ByteArrayConverterConfig.java | 18 ++
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_66_Up.java | 2
pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1_0_0/ComSupportP206V1_0_0.java | 2
pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/RtuLogCtrl.java | 60 ++++++++
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java | 22 +-
pipIrr-platform/.gitignore | 1
pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/ByteArrayHttpMessageConverter.java | 40 +++++
pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java | 21 +-
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java | 102 ++++++++++++++
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/resource/ResourceUnit.java | 2
pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/RtuLogSupport.java | 68 +++++++++
13 files changed, 326 insertions(+), 38 deletions(-)
diff --git a/pipIrr-platform/.gitignore b/pipIrr-platform/.gitignore
index aa8d236..f54b775 100644
--- a/pipIrr-platform/.gitignore
+++ b/pipIrr-platform/.gitignore
@@ -1,3 +1,4 @@
target/
/pipIrr-platform.iml
+/pipIrr-parent.iml
/鏂囨。/~$pIrr鎺ュ彛.docx
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_66_Up.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_66_Up.java
index 2a5f5ae..26fd0f7 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_66_Up.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_66_Up.java
@@ -69,7 +69,7 @@
cdData.ip = ip1 + "." + ip2 + "." + ip3 + "." + ip4 ;
- String port = "" +ByteUtilUnsigned.bytes2Short_LE(bs, index++) ;
+ String port = "" +ByteUtilUnsigned.bytes2Short_BE(bs, index++) ;
cdData.port = Integer.parseInt(port) ;
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/resource/ResourceUnit.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/resource/ResourceUnit.java
index 9f440af..69699fe 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/resource/ResourceUnit.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/resource/ResourceUnit.java
@@ -123,7 +123,7 @@
/**
* 寰楀埌涓�涓棩蹇楁枃浠�
- * @param fileName 鏂囦欢鍚嶇О
+ * @param fileName 鏂囦欢鍚嶇О([rtuAddr].log)
*/
@SuppressWarnings("unused")
public File getLogFile(String fileName){
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java
index b8914a4..0dcd9cc 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java
@@ -1,5 +1,6 @@
package com.dy.rtuMw.web.com;
+import com.dy.rtuMw.resource.ResourceUnit;
import com.dy.rtuMw.server.ServerProperties;
import com.dy.rtuMw.server.forTcp.TcpSessionCache;
import com.dy.rtuMw.server.local.CommandInnerDeaLer;
@@ -10,9 +11,16 @@
import com.dy.common.mw.protocol.CommandType;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
+import jakarta.servlet.ServletOutputStream;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
/**
@@ -32,6 +40,100 @@
return BaseResponseUtils.buildSuccess("ok");
}
+ /**
+ * 涓嬭浇鎺у埗鍣紙RTU锛変笂涓嬭鏁版嵁鐨刲og鏃ュ織鏂囦欢
+ * @param rtuAddr
+ * @param req
+ * @param rep
+ */
+ @GetMapping("/rtuLogFile")
+ public void rtuLogFile(String rtuAddr, HttpServletRequest req, HttpServletResponse rep){
+ File logFile = ResourceUnit.getInstance().getLogFile(rtuAddr + ".log") ;
+ if(logFile != null && logFile.exists()){
+ //鍦⊿pring Boot涓紝application/octet-stream;charset=UTF-8閫氬父琛ㄧず鍝嶅簲鐨勫唴瀹规槸瀛楄妭娴侊紝
+ //骞朵笖瀛楃闆嗘槸UTF-8銆傚浜庤繖绉嶇被鍨嬬殑鍝嶅簲锛孲pring Boot榛樿浣跨敤ByteArrayHttpMessageConverter鏉ュ鐞嗭紝
+ //鍥犱负瀹冨彲浠ュ鐞嗘墍鏈塧pplication/octet-stream绫诲瀷鐨勫搷搴斻��
+ //鐒惰�岋紝ByteArrayHttpMessageConverter骞朵笉鐩存帴澶勭悊瀛楃闆嗭紙charset锛夈��
+ //瀛楃闆嗛�氬父鐢ㄤ簬鏂囨湰鍐呭锛岃�宎pplication/octet-stream閫氬父鐢ㄤ簬浜岃繘鍒跺唴瀹癸紝鍥犳鍦ㄨ繖绉嶆儏鍐典笅鎸囧畾瀛楃闆嗗彲鑳芥槸涓嶅悎閫傜殑銆�
+ //涓嶈繃锛屽鏋滀綘纭疄闇�瑕佸鐞嗗甫鏈夌壒瀹氬瓧绗﹂泦鐨刟pplication/octet-stream鍝嶅簲锛屼綘鍙兘闇�瑕佽嚜瀹氫箟HttpMessageConverter銆�
+ rep.addHeader("content-type", "application/octet-stream;charset=UTF-8");
+ rep.addHeader("Content-Disposition", "attachment;fileName=" + (rtuAddr + ".log")) ;
+ ServletOutputStream out = null;
+ FileInputStream in = null ;
+ try {
+ out = rep.getOutputStream() ;
+ } catch (Exception ee) {
+ out = null ;
+ }finally{
+ if(out != null){
+ byte[] bs = new byte[1024] ;
+ int len = -1 ;
+ try {
+ in = new FileInputStream(logFile);
+ len = in.read(bs) ;
+ while(len != -1){
+ out.write(bs, 0, len);
+ len = in.read(bs) ;
+ }
+ } catch (Exception eee) {
+ } finally {
+ if(out != null){
+ try{
+ out.flush();
+ out.close();
+ }catch(Exception e){
+ }finally{
+ if(in != null){
+ try{
+ in.close();
+ }catch(Exception e){
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ /**
+ * 涓嬭浇鎺у埗鍣紙RTU锛変笂涓嬭鏁版嵁鐨刲og鏃ュ織鏂囦欢
+ * @param rtuAddr
+ */
+ @GetMapping("/rtuLogText")
+ public BaseResponse<List<String>> rtuLogText(String rtuAddr){
+ List<String> list = new ArrayList() ;
+ File logFile = ResourceUnit.getInstance().getLogFile(rtuAddr + ".log") ;
+ if(logFile != null && logFile.exists()){
+ BufferedReader reader = null ;
+ try {
+ reader = new BufferedReader(new FileReader(logFile)) ;
+ String line ;
+ while((line = reader.readLine()) != null){
+ list.add(line) ;
+ }
+ return BaseResponseUtils.buildSuccess(list);
+ } catch (Exception e) {
+ list.add("璇诲彇鎺у埗鍣紙" + rtuAddr + "锛夌殑鏃ュ織鏂囦欢寮傚父锛�" + (e.getMessage() == null?"":("锛�" + e.getMessage()))) ;
+ return BaseResponseUtils.buildSuccess(list);
+ }finally{
+ if(reader != null){
+ try{
+ reader.close();
+ }catch(Exception e){
+ }
+ }
+ }
+ }else{
+ list.add("鏈緱鍒版帶鍒跺櫒锛�" + rtuAddr + "锛夌殑鏃ュ織鏂囦欢") ;
+ return BaseResponseUtils.buildSuccess(list);
+ }
+ }
+ /**
+ * 鎺ユ敹web绯荤粺鍙戞潵鐨勫懡浠�
+ * @param com
+ * @return
+ */
@PostMapping(path = "send", consumes = MediaType.APPLICATION_JSON_VALUE)
public BaseResponse<Command> send(@RequestBody Command com) {
log.info("鏀跺埌web绯荤粺鍙戞潵鐨勫懡浠わ細\n" + com.toString()) ;
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1_0_0/ComSupportP206V1_0_0.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1_0_0/ComSupportP206V1_0_0.java
index ae511a8..8063cb5 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1_0_0/ComSupportP206V1_0_0.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1_0_0/ComSupportP206V1_0_0.java
@@ -20,6 +20,8 @@
public class ComSupportP206V1_0_0 {
protected static String mwUrlTest = "http://127.0.0.1:8070/rtuMw/com/test" ;
protected static String mwUrlSendCom = "http://127.0.0.1:8070/rtuMw/com/send" ;
+ protected static String mwUrlRtuLogFile = "http://127.0.0.1:8070/rtuMw/com/rtuLogFile" ;
+ protected static String mwUrlRtuLogText = "http://127.0.0.1:8070/rtuMw/com/rtuLogText" ;
protected static String rtuAddr = "532328059995" ;
// protected static String mwUrlTest = "http://8.140.179.55:8071/rtuMw/com/test" ;
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/ByteArrayConverterConfig.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/ByteArrayConverterConfig.java
new file mode 100644
index 0000000..4adcc2d
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/ByteArrayConverterConfig.java
@@ -0,0 +1,18 @@
+package com.dy.pipIrrMwTestWeb.rtuLog;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.converter.HttpMessageConverter;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/8/28 16:02
+ * @Description
+ */
+@Configuration
+public class ByteArrayConverterConfig {
+ @Bean
+ public HttpMessageConverter<byte[]> logFileByteArrayHttpMessageConverter() {
+ return new ByteArrayHttpMessageConverter();
+ }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/ByteArrayHttpMessageConverter.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/ByteArrayHttpMessageConverter.java
new file mode 100644
index 0000000..5e6256e
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/ByteArrayHttpMessageConverter.java
@@ -0,0 +1,40 @@
+package com.dy.pipIrrMwTestWeb.rtuLog;
+
+import org.springframework.http.HttpInputMessage;
+import org.springframework.http.HttpOutputMessage;
+import org.springframework.http.MediaType;
+import org.springframework.http.converter.AbstractHttpMessageConverter;
+import org.springframework.http.converter.HttpMessageNotReadableException;
+import org.springframework.http.converter.HttpMessageNotWritableException;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/8/28 15:58
+ * @Description
+ */
+public class ByteArrayHttpMessageConverter extends AbstractHttpMessageConverter<byte[]> {
+
+ public ByteArrayHttpMessageConverter() {
+ super(MediaType.APPLICATION_OCTET_STREAM, new MediaType("application", "octet-stream", StandardCharsets.UTF_8));
+ }
+
+ @Override
+ protected boolean supports(Class<?> clazz) {
+ return byte[].class == clazz;
+ }
+
+ @Override
+ protected byte[] readInternal(Class<? extends byte[]> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
+ // Read the byte array from the input message
+ return org.springframework.util.StreamUtils.copyToByteArray(inputMessage.getBody());
+ }
+
+ @Override
+ protected void writeInternal(byte[] bytes, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
+ // Write the byte array to the output message
+ outputMessage.getBody().write(bytes);
+ }
+}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/RtuLogCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/RtuLogCtrl.java
new file mode 100644
index 0000000..e85fdaf
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/RtuLogCtrl.java
@@ -0,0 +1,60 @@
+package com.dy.pipIrrMwTestWeb.rtuLog;
+
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import jakarta.servlet.ServletOutputStream;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.net.URLEncoder;
+import java.util.List;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/8/28 14:55
+ * @Description
+ */
+@Slf4j
+@RestController
+@RequestMapping(path="rtuLog")
+public class RtuLogCtrl extends RtuLogSupport {
+
+ @GetMapping(path = "logFile")
+ public BaseResponse<List<String>> rtuLogFile(String rtuAddr, HttpServletRequest req, HttpServletResponse rep){
+ ServletOutputStream out = null ;
+ try{
+ byte[] bs = this.requestMw4File(rtuAddr, mwUrlRtuLogFile) ;
+ if(bs != null && bs.length > 0){
+ String fileReName = rtuAddr + ".log" ;
+ //URLEncoder.encode鍙互闃叉涓枃涔辩爜
+ fileReName = URLEncoder.encode(fileReName, "UTF-8").replaceAll("\\+", "%20");
+ rep.addHeader("content-type", "application/octet-stream;charset=UTF-8");
+ rep.addHeader("Content-Disposition", "attachment;fileName=" + fileReName);
+ out = rep.getOutputStream() ;
+ out.write(bs, 0, (bs==null?0:bs.length));
+ out.flush();
+ }else{
+ return BaseResponseUtils.buildError("鑾峰彇鏂囦欢澶辫触") ;
+ }
+ }catch (Exception e){
+ }finally {
+ if(out != null){
+ try{
+ out.close();
+ }catch(Exception e){
+ }
+ }
+ }
+ return null ;
+ }
+
+ @GetMapping(path="logText")
+ public BaseResponse<List<String>> rtuLogText(String rtuAddr){
+ BaseResponse<List<String>> response = this.requestMw4Text(rtuAddr, mwUrlRtuLogText) ;
+ return response ;
+ }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/RtuLogSupport.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/RtuLogSupport.java
new file mode 100644
index 0000000..162347c
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/RtuLogSupport.java
@@ -0,0 +1,68 @@
+package com.dy.pipIrrMwTestWeb.rtuLog;
+
+import com.dy.common.webUtil.BaseResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.*;
+import org.springframework.http.HttpRequest;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import java.util.List;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/8/28 14:58
+ * @Description
+ */
+public class RtuLogSupport {
+ protected static String mwUrlRtuLogFile = "http://127.0.0.1:8070/rtuMw/com/rtuLogFile" ;
+ protected static String mwUrlRtuLogText = "http://127.0.0.1:8070/rtuMw/com/rtuLogText" ;
+
+
+ @Autowired
+ private RestTemplate restTemplate;
+
+
+ /**
+ * 鍙戦�佸懡浠�
+ * @return
+ */
+ protected byte[] requestMw4File(String rtuAddr, String mwUrl) throws Exception{
+ String url = UriComponentsBuilder.fromUriString(mwUrl)
+ .build()
+ .toUriString();
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url)
+ //.queryParam("paramTest", "test")
+ .queryParam("rtuAddr", rtuAddr);
+ String fullUrl = builder.toUriString();
+ byte[] bs = restTemplate.getForObject(fullUrl, byte[].class);
+ return bs ;
+ }
+
+ /**
+ * 鍙戦�佸懡浠�
+ * @return
+ */
+ protected BaseResponse<List<String>> requestMw4Text(String rtuAddr, String mwUrl){
+ String url = UriComponentsBuilder.fromUriString(mwUrl)
+ .build()
+ .toUriString();
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url)
+ //.queryParam("paramTest", "test")
+ .queryParam("rtuAddr", rtuAddr);
+
+ String fullUrl = builder.toUriString();
+
+ HttpHeaders headers = new HttpHeaders();
+ HttpEntity<?> httpEntity = new HttpEntity<>(headers);
+ ResponseEntity<BaseResponse> response = null;
+ try {
+ // 閫氳繃Get鏂瑰紡璋冪敤鎺ュ彛
+ response = restTemplate.exchange(fullUrl, HttpMethod.GET, httpEntity, BaseResponse.class);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return response.getBody();
+ }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java
index bcbae33..e8a1df2 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java
@@ -102,7 +102,7 @@
try {
List<Map<String, Object>> list = Optional.ofNullable(controllerSv.getControllersByAddr(rtuAddr)).orElse(new ArrayList<>());
if (list.size() <= 0) {
- return BaseResponseUtils.buildFail(ProjectResultCode.NO_RECORDS.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.NO_RECORDS.getMessage());
}
return BaseResponseUtils.buildSuccess(list);
} catch (Exception e) {
@@ -133,7 +133,7 @@
//public BaseResponse<Boolean> add(@RequestBody @Valid DtoController po, BindingResult bindingResult){
public BaseResponse<Boolean> add(@RequestBody @Valid PrController po, BindingResult bindingResult) {
if (bindingResult != null && bindingResult.hasErrors()) {
- return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
//PrController prController = DtoToPojo.INSTANCT.po2vo(po);
@@ -151,7 +151,7 @@
}
Integer rec = Optional.ofNullable(controllerSv.addController(po)).orElse(0);
if (rec == 0) {
- return BaseResponseUtils.buildFail(ProjectResultCode.CONTROLLER_FAIL.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.CONTROLLER_FAIL.getMessage());
}
return BaseResponseUtils.buildSuccess(true);
}
@@ -175,13 +175,13 @@
@SsoAop()
public BaseResponse<Boolean> delete(@RequestBody Map map) {
if (map == null || map.size() <= 0) {
- return BaseResponseUtils.buildFail(ProjectResultCode.PLEASE_INPUT_CONTROLLER_ID.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.PLEASE_INPUT_CONTROLLER_ID.getMessage());
}
Long controllerId = Long.parseLong(map.get("controllerId").toString());
Integer recordCount = Optional.ofNullable(controllerSv.deleteControllerById(controllerId)).orElse(0);
if (recordCount == 0) {
- return BaseResponseUtils.buildFail(ProjectResultCode.DELETE_CONTROLLER_FAIL.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DELETE_CONTROLLER_FAIL.getMessage());
}
return BaseResponseUtils.buildSuccess(true);
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java
index 4619a22..3b1096a 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java
@@ -101,7 +101,7 @@
if(res != null) {
return BaseResponseUtils.buildSuccess(res);
}else {
- return BaseResponseUtils.buildFail(ProjectResultCode.NO_DIVIDES.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.NO_DIVIDES.getMessage());
}
} catch (Exception e) {
log.error("鏌ヨ鍐滄埛寮傚父", e);
@@ -129,7 +129,7 @@
@SsoAop()
public BaseResponse<Boolean> add(@RequestBody @Valid DtoDivide po, BindingResult bindingResult){
if(bindingResult != null && bindingResult.hasErrors()){
- return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
// 鎺ユ敹鏉戠紪鍙凤紙涓婚敭锛�
Long villageId = po.getVillageId();
@@ -142,7 +142,7 @@
*/
Map map_districts = Optional.ofNullable(divideSv.getDistrictsByVillageId(villageId)).orElse(new HashMap());
if(map_districts.size() <= 0) {
- return BaseResponseUtils.buildFail("鍖哄垝淇℃伅鏈夎");
+ return BaseResponseUtils.buildErrorMsg("鍖哄垝淇℃伅鏈夎");
}
Long countryId = Long.parseLong(map_districts.get("countryId").toString());
Long townId = Long.parseLong(map_districts.get("townId").toString());
@@ -155,7 +155,7 @@
prDivide.setDeleted((byte)0);
Integer rec = Optional.ofNullable(divideSv.addDivide(prDivide)).orElse(0);
if(rec == 0) {
- return BaseResponseUtils.buildFail(ProjectResultCode.DIVIDE_FAIL.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DIVIDE_FAIL.getMessage());
}
return BaseResponseUtils.buildSuccess(true) ;
}
@@ -186,7 +186,7 @@
try {
Integer res = Optional.ofNullable(divideSv.deleteDivideById(id)).orElse(0);
if(res == 0)
- return BaseResponseUtils.buildFail(ProjectResultCode.DELETE_DIVIDE_FAIL.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DELETE_DIVIDE_FAIL.getMessage());
return BaseResponseUtils.buildSuccess(true);
} catch (Exception e) {
@@ -215,7 +215,7 @@
@SsoAop()
public BaseResponse<Boolean> update(@RequestBody @Valid DtoDivide po, BindingResult bindingResult){
if(bindingResult != null && bindingResult.hasErrors()){
- return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
// 鎺ユ敹鏉戠紪鍙凤紙涓婚敭锛�
@@ -229,7 +229,7 @@
*/
Map map_districts = Optional.ofNullable(divideSv.getDistrictsByVillageId(villageId)).orElse(new HashMap());
if(map_districts.size() <= 0) {
- return BaseResponseUtils.buildFail("鍖哄垝淇℃伅鏈夎");
+ return BaseResponseUtils.buildErrorMsg("鍖哄垝淇℃伅鏈夎");
}
Long countryId = Long.parseLong(map_districts.get("countryId").toString());
Long townId = Long.parseLong(map_districts.get("townId").toString());
@@ -242,7 +242,7 @@
Integer rec = Optional.ofNullable(divideSv.updateByPrimaryKey(prDivide)).orElse(0);
if(rec == 0) {
- return BaseResponseUtils.buildFail("鍒嗘按鎴夸慨鏀瑰け璐�");
+ return BaseResponseUtils.buildErrorMsg("鍒嗘按鎴夸慨鏀瑰け璐�");
}
return BaseResponseUtils.buildSuccess(true) ;
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java
index 8fabaa3..44694c6 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intake/IntakeCtrl.java
@@ -78,7 +78,7 @@
try {
QueryResultVo<List<PrIntake>> res = this.intakeSv.selectAll();
if (res == null) {
- return BaseResponseUtils.buildFail(ProjectResultCode.NO_INTAKES.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.NO_INTAKES.getMessage());
} else {
return BaseResponseUtils.buildSuccess(res);
}
@@ -106,7 +106,7 @@
@SsoAop()
public BaseResponse<PrIntake> one(@PathVariable("id") Long id) {
if (this.intakeSv.selectById(id) == null) {
- return BaseResponseUtils.buildFail(ProjectResultCode.NO_INTAKES.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.NO_INTAKES.getMessage());
} else {
return BaseResponseUtils.buildSuccess(this.intakeSv.selectById(id));
}
@@ -127,7 +127,7 @@
try {
QueryResultVo<List<VoIntake>> res = intakeSv.getIntakes(vo);
if (res == null) {
- return BaseResponseUtils.buildFail(ProjectResultCode.NO_INTAKES.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.NO_INTAKES.getMessage());
}
return BaseResponseUtils.buildSuccess(res);
} catch (Exception e) {
@@ -151,17 +151,17 @@
public BaseResponse<Boolean> add(@RequestBody @Valid PrIntake po, @Parameter(hidden = true) BindingResult bindingResult) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
if (bindingResult != null && bindingResult.hasErrors()) {
- return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
List<Long> ids = intakeSv.getIntakeIdsByName(po.getName());
if (ids.size() > 0) {
- return BaseResponseUtils.buildFail(ProjectResultCode.INTAKE_NAME_EXIST.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.INTAKE_NAME_EXIST.getMessage());
}
po.setOperateDt(new Date());
po.setDeleted((byte) 0);
Integer rec = Optional.ofNullable(intakeSv.addIntake(po)).orElse(0);
if (rec == 0) {
- return BaseResponseUtils.buildFail(ProjectResultCode.ADD_INTAKE_FAIL.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.ADD_INTAKE_FAIL.getMessage());
}
return BaseResponseUtils.buildSuccess(true);
}
@@ -185,11 +185,11 @@
@SsoAop()
public BaseResponse<Boolean> update(@RequestBody @Parameter(description = "form琛ㄥ崟json鏁版嵁", required = true) @Valid PrIntake po, @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());
}
List<Long> ids = intakeSv.getIntakeIdByNameExcludeId(po.getId(), po.getName());
if (ids.size() > 0) {
- return BaseResponseUtils.buildFail(ProjectResultCode.INTAKE_NAME_EXIST.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.INTAKE_NAME_EXIST.getMessage());
}
int count;
po.setOperateDt(new Date());
@@ -200,7 +200,7 @@
return BaseResponseUtils.buildException(e.getMessage());
}
if (count <= 0) {
- return BaseResponseUtils.buildFail(ProjectResultCode.UPDATE_INTAKE.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.UPDATE_INTAKE.getMessage());
} else {
return BaseResponseUtils.buildSuccess(true);
}
@@ -225,14 +225,14 @@
@SsoAop()
public BaseResponse<Boolean> delete(@RequestBody Map map) {
if (map == null || map.size() <= 0) {
- return BaseResponseUtils.buildFail(ProjectResultCode.PLEASE_INPUT_INTAKE_ID.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.PLEASE_INPUT_INTAKE_ID.getMessage());
}
Long id = Long.parseLong(map.get("id").toString());
try {
//鍙栨按鍙D
Integer recordCount = Optional.ofNullable(intakeSv.delete(id)).orElse(0);
if (recordCount == 0) {
- return BaseResponseUtils.buildFail(ProjectResultCode.DELETE_INTAKE_FAIL.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DELETE_INTAKE_FAIL.getMessage());
} else {
return BaseResponseUtils.buildSuccess(true);
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java
index 47d2e2f..46fc4db 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java
@@ -100,18 +100,15 @@
@PostMapping(path = "loginJson", consumes = MediaType.APPLICATION_JSON_VALUE)
public BaseResponse<UserVo> loginJson(@RequestBody @Parameter(description = "鐧诲綍json鏁版嵁", required = true) @Valid LoginVo vo, @Parameter(hidden = true) BindingResult bindingResult) {
if(bindingResult != null && bindingResult.hasErrors()){
- return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
- }
- if(vo.phone == null || vo.phone.trim().length() == 0){
- return BaseResponseUtils.buildFail("鎵嬫満鍙蜂笉鑳戒负绌�");
+ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
if(!vo.phone.equals("admin")){
if(vo.phone.length() != 11){
- return BaseResponseUtils.buildFail("鎵嬫満鍙凤紙闀垮害涓嶆槸11浣嶏級涓嶆纭�");
+ return BaseResponseUtils.buildErrorMsg("鎵嬫満鍙凤紙闀垮害涓嶆槸11浣嶏級涓嶆纭�");
}
}
if(vo.orgTag == null || vo.orgTag.trim().length() == 0){
- return BaseResponseUtils.buildFail("鏈�夋嫨缁勭粐鍗曚綅");
+ return BaseResponseUtils.buildErrorMsg("鏈�夋嫨缁勭粐鍗曚綅");
}
//鎶婄粍缁囧崟浣嶆爣绛句綔涓烘暟鎹簮鍚嶇О
DataSourceContext.set(vo.orgTag);
@@ -119,7 +116,7 @@
//寰楀埌鎵�鏈夌敤鎴疯处鍙�
List<String> phones = sv.getPhones();
if(!phones.contains(vo.phone)){
- return BaseResponseUtils.buildFail("璐﹀彿涓嶅瓨鍦�");
+ return BaseResponseUtils.buildErrorMsg("璐﹀彿涓嶅瓨鍦�");
}
String uuid ;
@@ -145,7 +142,7 @@
uVo.token = uuid ;
return BaseResponseUtils.buildSuccess(uVo);
}else{
- return BaseResponseUtils.buildFail("瀵嗙爜閿欒");
+ return BaseResponseUtils.buildErrorMsg("瀵嗙爜閿欒");
}
}
@@ -166,10 +163,10 @@
@PostMapping(path = "loginForm", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public BaseResponse<UserVo> loginForm(@Parameter(description = "form琛ㄥ崟鏁版嵁", required = true) @Valid LoginVo 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.orgTag == null || vo.orgTag.trim().length() == 0){
- return BaseResponseUtils.buildFail("鏈�夋嫨缁勭粐鍗曚綅");
+ return BaseResponseUtils.buildErrorMsg("鏈�夋嫨缁勭粐鍗曚綅");
}
//鎶婄粍缁囧崟浣嶆爣绛句綔涓烘暟鎹簮鍚嶇О
DataSourceContext.set(vo.orgTag);
@@ -197,7 +194,7 @@
uVo.token = uuid ;
return BaseResponseUtils.buildSuccess(uVo);
}else{
- return BaseResponseUtils.buildFail("鐧诲綍澶辫触");
+ return BaseResponseUtils.buildErrorMsg("鐧诲綍澶辫触");
}
}
@@ -222,7 +219,7 @@
this.sv.logout(token) ;
return BaseResponseUtils.buildSuccess(true);
}else{
- return BaseResponseUtils.buildFail("鏈粠header涓緱鍒皌oken");
+ return BaseResponseUtils.buildErrorMsg("鏈粠header涓緱鍒皌oken");
}
}
--
Gitblit v1.8.0