From 7aab004601e77890b158f19d1735594a8326feaa Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期四, 24 四月 2025 17:11:17 +0800 Subject: [PATCH] 数据库事务注解位置调整 --- pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/RtuLogSupport.java | 73 ++++++++++++++++++++++++++++++++++++ 1 files changed, 73 insertions(+), 0 deletions(-) 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..39a7040 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/rtuLog/RtuLogSupport.java @@ -0,0 +1,73 @@ +package com.dy.pipIrrMwTestWeb.rtuLog; + +import com.dy.common.webUtil.BaseResponse; +import com.dy.common.webUtil.BaseResponseUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.*; +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 BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父"); + } + if(response == null){ + return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父"); + }else{ + return response.getBody(); + } + } +} -- Gitblit v1.8.0