From f84d149459b73928c864eb5aebf764cf58105c73 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 07 五月 2025 16:11:24 +0800
Subject: [PATCH] 命令生成器修改注释、代码优化。
---
pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1/ComSupportP206V1.java | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 120 insertions(+), 0 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1/ComSupportP206V1.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1/ComSupportP206V1.java
new file mode 100644
index 0000000..7c82e02
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V1/ComSupportP206V1.java
@@ -0,0 +1,120 @@
+package com.dy.pipIrrMwTestWeb.p206V1;
+
+import com.dy.common.mw.protocol.Command;
+import com.dy.common.mw.protocol.CommandType;
+import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.util.UriComponentsBuilder;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/6/29 6:47
+ * @Description
+ */
+public class ComSupportP206V1 {
+ 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" ;
+// protected static String mwUrlSendCom = "http://8.140.179.55:8071/rtuMw/com/send" ;
+// protected static String rtuAddr = "620202000066" ;
+
+ protected static String rtuResultSendWebUrl = "http://127.0.0.1:65535/test/comRes/receive" ;
+ protected static String vsIcCardNo = "61181622830147822" ;//铏氭嫙IC鍗$紪鍙凤紙鐢ㄦ埛铏氭嫙鍗″簭鍒楀彿锛�
+
+
+ @Autowired
+ private RestTemplate restTemplate;
+
+
+ protected Command commandLocal(String code, Object param, String comId){
+ Command com = new Command() ;
+ com.id = comId==null?Command.defaultId:(comId.trim().equals("")?Command.defaultId:comId) ;//瀹為檯搴旂敤涓紝鏇挎崲鎴愭暟鎹簱璁板綍id
+ com.protocol = ProtocolConstantV206V1.protocolName ;
+ com.code = code ;
+ com.rtuAddr = rtuAddr ;
+ com.type = CommandType.innerCommand ;
+ com.rtuResultSendWebUrl = rtuResultSendWebUrl ;
+
+ com.param = param ;
+
+ return com ;
+ }
+
+
+ protected Command commandOuter(String code, Object param, String comId){
+ Command com = new Command() ;
+ com.id = comId==null?Command.defaultId:(comId.trim().equals("")?Command.defaultId:comId) ;//瀹為檯搴旂敤涓紝鏇挎崲鎴愭暟鎹簱璁板綍id
+ com.protocol = ProtocolConstantV206V1.protocolName ;
+ com.code = code ;
+ com.rtuAddr = rtuAddr ;
+ com.type = CommandType.outerCommand ;
+ com.rtuResultSendWebUrl = rtuResultSendWebUrl ;
+
+ com.param = param ;
+
+ return com ;
+ }
+
+
+ /**
+ * 杩炴帴閫氫俊涓棿浠舵祴璇�
+ * @return
+ */
+ protected BaseResponse sendTest(){
+ String url = UriComponentsBuilder.fromUriString(mwUrlTest)
+ .build()
+ .toUriString();
+ HttpHeaders headers = new HttpHeaders();
+ HttpEntity<?> httpEntity = new HttpEntity<>(headers);
+ ResponseEntity<BaseResponse> response = null;
+ try {
+ // 閫氳繃Get鏂瑰紡璋冪敤鎺ュ彛
+ response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, BaseResponse.class);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父");
+ }
+ if(response == null){
+ return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父");
+ }else{
+ return response.getBody();
+ }
+ }
+
+ /**
+ * 鍙戦�佸懡浠�
+ * @return
+ */
+ protected BaseResponse sendCom2Mw(Command com){
+ String url = UriComponentsBuilder.fromUriString(mwUrlSendCom)
+ .build()
+ .toUriString();
+ HttpHeaders headers = new HttpHeaders();
+ HttpEntity<Command> httpEntity = new HttpEntity<>(com, headers);
+ ResponseEntity<BaseResponse> response = null;
+ try {
+ // 閫氳繃Post鏂瑰紡璋冪敤鎺ュ彛
+ response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父");
+ }
+ if(response == null){
+ return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父");
+ }else{
+ return response.getBody();
+ }
+ }
+
+}
\ No newline at end of file
--
Gitblit v1.8.0