From 00d54db361d697cf8fdf2f15940f4650b21b3185 Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期一, 21 四月 2025 15:05:35 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V202404test/ComSupportP206V202404.java | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 116 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V202404test/ComSupportP206V202404.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V202404test/ComSupportP206V202404.java new file mode 100644 index 0000000..a4321b4 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/p206V202404test/ComSupportP206V202404.java @@ -0,0 +1,116 @@ +package com.dy.pipIrrMwTestWeb.p206V202404test; + +import com.dy.common.mw.protocol.Command; +import com.dy.common.mw.protocol.CommandType; +import com.dy.common.mw.protocol.p206V202404.ProtocolConstantV206V202404; +import com.dy.common.mw.protocol.p206V202404.downVos.ComCdXyVo; +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/5/14 17:32 + * @Description + */ +public class ComSupportP206V202404 { + //protected static final String mwIp = "romq9311819.vicp.fun" ; //http://romq9311819.vicp.fun:16583 + //protected static final String mwPort = "16583" ; + protected static final String mwIp = "127.0.0.1" ; + protected static final String mwPort = "65533" ; + + protected static String mwUrlTest = "http://" + mwIp + ":" + mwPort + "/rtuMw/com/test" ; + protected static String mwUrlSendCom = "http://" + mwIp + ":" + mwPort + "/rtuMw/com/send" ; + + protected static String rtuAddr = "37142501020100229" ; + protected static String rtuResultSendWebUrl = "http://127.0.0.1:65535/test/comRes/receive" ; + + protected static String controllerType = "02" ;//鎺у埗鍣ㄧ被鍨� 57姘存车锛�02闃�闂� + protected static Integer projectNo = 10 ;//椤圭洰缂栫爜 + + protected static String icCardAddr = "04BEA5BB" ;//IC鍗″湴鍧� + protected static String icCardNo = "37142501020500001" ;//IC鍗$紪鍙凤紙鐢ㄦ埛鍗″簭鍒楀彿锛� + + + @Autowired + private RestTemplate restTemplate; + + + protected ComCdXyVo comCdXyVo(){ + ComCdXyVo comVo = new ComCdXyVo() ; + comVo.controllerType = controllerType ; + comVo.projectNo = projectNo ; + return comVo ; + } + + protected Command command(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 = ProtocolConstantV206V202404.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(); + } + } + +} -- Gitblit v1.8.0