From 37d2aec0dbe914c8924d6514da7eca053eee4cf3 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期三, 26 三月 2025 17:26:35 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
---
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu3rd/src/main/java/com/dy/rtuMw3rd/http4Xjnk/HttpRq.java | 228 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V202404test/CommandP206V202404Ctrl.java | 4
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_92_A2_Down.java | 2
pipIrr-platform/pipIrr-mw/pom.xml | 1
4 files changed, 231 insertions(+), 4 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_92_A2_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_92_A2_Down.java
index c767292..a67201e 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_92_A2_Down.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_92_A2_Down.java
@@ -121,7 +121,7 @@
if(cvo.moneyRemain == null){
cvo.moneyRemain = 0.0 ;
}
- strTemp = "" + (Double.valueOf(cvo.moneyRemain * 100)).intValue() ;
+ strTemp = "" + (Double.valueOf(cvo.moneyRemain * 10000)).intValue() ;
bTemp = ByteUtil.string2BCD_LE(strTemp) ;
bTempLen = bTemp.length ;
count = 0 ;
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu3rd/src/main/java/com/dy/rtuMw3rd/http4Xjnk/HttpRq.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu3rd/src/main/java/com/dy/rtuMw3rd/http4Xjnk/HttpRq.java
new file mode 100644
index 0000000..0343a3f
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu3rd/src/main/java/com/dy/rtuMw3rd/http4Xjnk/HttpRq.java
@@ -0,0 +1,228 @@
+package com.dy.rtuMw3rd.http4Xjnk;
+
+import com.dy.common.util.HttpCallback;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.*;
+import org.springframework.http.converter.StringHttpMessageConverter;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2025/3/15 9:56
+ * @Description
+ */
+@Component()
+public class HttpRq {
+
+ private RestTemplate restTemplate ;
+
+ @Autowired
+ public void setRestTemplate(RestTemplate restTemplate){
+ this.restTemplate = restTemplate;
+ }
+
+ /**
+ * get璇锋眰锛岃繑鍥瀓son鍐呭
+ * 鍚屾
+ * @param httpBaseUrl
+ * @param params
+ * @param cb
+ * @throws Exception
+ */
+ public void get4JsonBySync(String httpBaseUrl, Map<String, String> params, HttpCallback cb) throws Exception {
+ String url = UriComponentsBuilder.fromUriString(httpBaseUrl)
+ .build()
+ .toUriString();
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url) ;
+ if(params != null && params.size() > 0){
+ Iterator<String> it = params.keySet().iterator() ;
+ String key ;
+ while (it.hasNext()){
+ key = it.next() ;
+ builder.queryParam(key, params.get(key)) ;
+ }
+ }
+ httpGetRequestSync(builder, cb);
+ }
+ /**
+ * get璇锋眰锛岃繑鍥瀓son鍐呭
+ * 寮傛
+ * @param httpBaseUrl
+ * @param params
+ * @param cb
+ * @throws Exception
+ */
+ public void get4JsonByAsync(String httpBaseUrl, Map<String, String> params, HttpCallback cb) throws Exception {
+ String url = UriComponentsBuilder.fromUriString(httpBaseUrl)
+ .build()
+ .toUriString();
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url) ;
+ if(params != null && params.size() > 0){
+ Iterator<String> it = params.keySet().iterator() ;
+ String key ;
+ while (it.hasNext()){
+ key = it.next() ;
+ builder.queryParam(key, params.get(key)) ;
+ }
+ }
+ httpGetRequestAsync(builder, cb);
+ }
+
+ /**
+ * get璇锋眰锛岃繑鍥瀓son鍐呭
+ * 鍚屾
+ * @param httpBaseUrl
+ * @param params
+ * @param cb
+ * @throws Exception
+ */
+ public void post4JsonBySync(String httpBaseUrl, Map<String, String> params, HttpCallback cb) throws Exception {
+ String url = UriComponentsBuilder.fromUriString(httpBaseUrl)
+ .build()
+ .toUriString();
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url) ;
+ httpPostRequestSync(builder, params, cb);
+ }
+ /**
+ * get璇锋眰锛岃繑鍥瀓son鍐呭
+ * 寮傛
+ * @param httpBaseUrl
+ * @param params
+ * @param cb
+ * @throws Exception
+ */
+ public void post4JsonByAsync(String httpBaseUrl, Map<String, String> params, HttpCallback cb) throws Exception {
+ String url = UriComponentsBuilder.fromUriString(httpBaseUrl)
+ .build()
+ .toUriString();
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url) ;
+ httpPostRequestAsync(builder, params, cb);
+ }
+
+ /**
+ * 鍙戣捣璇锋眰
+ * @param builder
+ * @param cb
+ * @return
+ */
+ private void httpGetRequestSync(UriComponentsBuilder builder, HttpCallback cb) {
+ HttpHeaders headers = new HttpHeaders() ;
+ headers.setContentType(MediaType.APPLICATION_JSON) ;
+ restTemplate.getMessageConverters().set(1,new StringHttpMessageConverter(StandardCharsets.UTF_8));
+ // 閫氳繃Get鏂瑰紡璋冪敤鎺ュ彛
+ ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(),
+ HttpMethod.GET,
+ new HttpEntity<>(headers),
+ String.class);
+
+ String contentType = response.getHeaders().getContentType().toString() ;
+ cb.call(response.getStatusCode().value() + "", contentType, response.getBody());
+ }
+
+
+ /**
+ * 鍙戣捣璇锋眰
+ * @param builder
+ * @param cb
+ * @return
+ */
+ private void httpGetRequestAsync(UriComponentsBuilder builder, HttpCallback cb) throws Exception {
+ HttpHeaders headers = new HttpHeaders() ;
+ headers.setContentType(MediaType.APPLICATION_JSON) ;
+ restTemplate.getMessageConverters().set(1,new StringHttpMessageConverter(StandardCharsets.UTF_8));
+ // 鍙戣捣寮傛 GET 璇锋眰
+ CompletableFuture<ResponseEntity<String>> future = CompletableFuture.supplyAsync(() ->
+ // 閫氳繃Get鏂瑰紡璋冪敤鎺ュ彛
+ restTemplate.exchange(builder.toUriString(),
+ HttpMethod.GET,
+ new HttpEntity<>(headers),
+ String.class)
+ );
+ future.thenAccept(response -> {
+ String contentType = response.getHeaders().getContentType().toString() ;
+ cb.call(response.getStatusCode().value() + "", contentType, response.getBody());
+ }) ;
+ /*
+ AtomicReference<Throwable> exeEx = new AtomicReference() ;
+ future.thenAccept(response -> {
+ String contentType = response.getHeaders().getContentType().toString() ;
+ cb.call(response.getStatusCode().value() + "", contentType, response.getBody());
+ }).exceptionally(ex -> {
+ exeEx.set(ex.getCause());
+ return null;
+ });
+ */
+ }
+
+ /**
+ * 鍙戣捣璇锋眰
+ * @param builder
+ * @param body
+ * @param cb
+ * @return
+ */
+ private void httpPostRequestSync(UriComponentsBuilder builder, Map<String, String> body, HttpCallback cb) {
+ HttpHeaders headers = new HttpHeaders() ;
+ headers.setContentType(MediaType.APPLICATION_JSON) ;
+ restTemplate.getMessageConverters().set(1,new StringHttpMessageConverter(StandardCharsets.UTF_8));
+ restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
+ HttpEntity<Map<String, String>> requestEntity = new HttpEntity<>(body, headers);
+ // 閫氳繃Get鏂瑰紡璋冪敤鎺ュ彛
+ ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(),
+ HttpMethod.POST,
+ requestEntity,
+ String.class);
+
+ String contentType = response.getHeaders().getContentType().toString() ;
+ cb.call(response.getStatusCode().value() + "", contentType, response.getBody());
+ }
+
+ /**
+ * 鍙戣捣璇锋眰
+ * @param builder
+ * @param body
+ * @param cb
+ * @return
+ */
+ private void httpPostRequestAsync(UriComponentsBuilder builder, Map<String, String> body, HttpCallback cb) throws Exception {
+ HttpHeaders headers = new HttpHeaders() ;
+ headers.setContentType(MediaType.APPLICATION_JSON) ;
+ restTemplate.getMessageConverters().set(1,new StringHttpMessageConverter(StandardCharsets.UTF_8));
+ restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
+ HttpEntity<Map<String, String>> requestEntity = new HttpEntity<>(body, headers);
+ // 鍙戣捣寮傛 GET 璇锋眰
+ CompletableFuture<ResponseEntity<String>> future = CompletableFuture.supplyAsync(() ->
+ // 閫氳繃Get鏂瑰紡璋冪敤鎺ュ彛
+ restTemplate.exchange(builder.toUriString(),
+ HttpMethod.POST,
+ requestEntity,
+ String.class)
+ );
+ future.thenAccept(response -> {
+ String contentType = response.getHeaders().getContentType().toString() ;
+ cb.call(response.getStatusCode().value() + "", contentType, response.getBody());
+ }) ;
+ /*
+ AtomicReference<Throwable> exeEx = new AtomicReference() ;
+ future.thenAccept(response -> {
+ String contentType = response.getHeaders().getContentType().toString() ;
+ cb.call(response.getStatusCode().value() + "", contentType, response.getBody());
+ }).exceptionally(ex -> {
+ exeEx.set(ex.getCause());
+ return null;
+ });
+ */
+ }
+}
diff --git a/pipIrr-platform/pipIrr-mw/pom.xml b/pipIrr-platform/pipIrr-mw/pom.xml
index 3e0de09..69e82be 100644
--- a/pipIrr-platform/pipIrr-mw/pom.xml
+++ b/pipIrr-platform/pipIrr-mw/pom.xml
@@ -21,7 +21,6 @@
<module>pipIrr-mw-simulate-rtu202404</module>
<module>pipIrr-mwTest-server</module>
<module>pipIrr-mwTest-client</module>
- <module>pipIrr-mw-rtu3rdTest</module>
</modules>
<dependencies>
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V202404test/CommandP206V202404Ctrl.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V202404test/CommandP206V202404Ctrl.java
index 28fa373..e6715af 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V202404test/CommandP206V202404Ctrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V202404test/CommandP206V202404Ctrl.java
@@ -218,8 +218,8 @@
comVo.projectNo = CommandP206V202404Ctrl.projectNo ;
//comVo.icCardAddr = Test.icCardAddr ;//IC鍗″湴鍧�(8浣嶆暟瀛楁垨瀛楁瘝)
comVo.icCardNo = CommandP206V202404Ctrl.icCardNo ;//鐢ㄦ埛鍗″簭鍒楀彿锛�17浣嶆暟瀛楋級锛�6瀛楄妭BCD锛�2瀛楄妭HEX锛�
- comVo.waterRemain = 123.45 ;//鍗曚綅:鍏� 2浣嶅皬鏁扮偣(鏈�澶у�� 99999999.99)
- comVo.moneyRemain = 234.56 ;//鍗曚綅:m3 2浣嶅皬鏁扮偣(鏈�澶у�� 99999999.99)
+ comVo.waterRemain = 123.45 ;//鍗曚綅:m3 2浣嶅皬鏁扮偣(鏈�澶у�� 99999999.99)
+ comVo.moneyRemain = 12345.67 ;//鍗曚綅:鍏� 2浣嶅皬鏁扮偣(鏈�澶у�� 99999999.99)
comVo.waterPrice = 0.8 ;//姘撮噺鍗曚环 鍗曚綅:鍏�, 2涓皬鏁扮偣
comVo.elePrice = 1.2 ;//鐢甸噺鍗曚环 鍗曚綅:鍏�, 2涓皬鏁扮偣
comVo.orderNo = "1234567890123456" ;//璁㈠崟鍙凤紙16浣嶆暟瀛楋級
--
Gitblit v1.8.0