From 053d5042846ae96c9c7ba031bae9d9221745cd7f Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 29 十一月 2024 15:20:58 +0800
Subject: [PATCH] 向通信中间件请求,有参数时用post,无参数时用Get.

---
 pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java |   70 +++++++++++++++++++++++++---------
 1 files changed, 51 insertions(+), 19 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java
index ec86f88..a618170 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java
@@ -3,7 +3,6 @@
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.support.ExcelTypeEnum;
 import com.dy.common.aop.SsoAop;
-import com.dy.common.softUpgrade.state.UpgradeRtu;
 import com.dy.common.softUpgrade.state.UpgradeTaskVo;
 import com.dy.common.springUtil.SpringContextUtil;
 import com.dy.common.webUtil.BaseResponse;
@@ -12,8 +11,7 @@
 import com.dy.common.webUtil.ResultCodeMsg;
 import com.dy.pipIrrGlobal.pojoUg.UgRtuProgram;
 import com.dy.pipIrrGlobal.pojoUg.UgRtuTask;
-import com.dy.pipIrrGlobal.rtuMw.ToRtuMwCom;
-import com.dy.pipIrrGlobal.voPr.VoDivide;
+import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw;
 import com.dy.pipIrrGlobal.voUg.VoUgRtuResult;
 import com.dy.pipIrrGlobal.voUg.VoWatch;
 import io.swagger.v3.oas.annotations.Operation;
@@ -35,7 +33,6 @@
 
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
-import java.util.ArrayList;
 import java.util.Base64;
 import java.util.List;
 
@@ -48,7 +45,7 @@
 @Tag(name = "rtu杩滅▼鍗囩骇浠诲姟", description = "rtu杩滅▼鍗囩骇浠诲姟鐩稿叧鎿嶄綔")
 @RestController
 @RequestMapping(path = "rtuUpgrade")
-public class RtuUpgradeCtrl extends ToRtuMwCom {
+public class RtuUpgradeCtrl extends Web2RtuMw {
     @Autowired
     private RtuUpgradeSv sv ;
 
@@ -79,28 +76,28 @@
     @SsoAop()
     public BaseResponse<Boolean> issuedTask(String id){
         if(id == null || id.trim().equals("")){
-            return BaseResponseUtils.buildError("浠诲姟id涓嶈兘涓虹┖") ;
+            return BaseResponseUtils.buildErrorMsg("浠诲姟id涓嶈兘涓虹┖") ;
         }
         UgRtuTask tpo = this.sv.selectTaskById(id) ;
         if(tpo == null){
-            return BaseResponseUtils.buildError("浠诲姟涓嶅瓨鍦�") ;
+            return BaseResponseUtils.buildErrorMsg("浠诲姟涓嶅瓨鍦�") ;
         }
         if(tpo.isExecute == 1){
-            return BaseResponseUtils.buildError("浠诲姟宸蹭笅鍙戯紝涓嶈兘閲嶅涓嬪彂浠诲姟") ;
+            return BaseResponseUtils.buildErrorMsg("浠诲姟宸蹭笅鍙戯紝涓嶈兘閲嶅涓嬪彂浠诲姟") ;
         }
         UgRtuProgram ppo = this.sv.selectProgramById(tpo.programId) ;
         if(ppo == null){
-            return BaseResponseUtils.buildError("浠诲姟瀵瑰簲鐨勭▼搴忎笉瀛樺湪") ;
+            return BaseResponseUtils.buildErrorMsg("浠诲姟瀵瑰簲鐨勭▼搴忎笉瀛樺湪") ;
         }
 
         List<String> taskRtuAddrs = this.sv.selectAllRtuAddrByTask(id) ;
         if(taskRtuAddrs == null || taskRtuAddrs.size() == 0){
-            return BaseResponseUtils.buildError("浠诲姟鎵�娑夊強鐨勬帶鍒跺櫒杩樻湭璁剧疆") ;
+            return BaseResponseUtils.buildErrorMsg("浠诲姟鎵�娑夊強鐨勬帶鍒跺櫒杩樻湭璁剧疆") ;
         }
 
         String ugCallbackUrl_rm = env.getProperty("mw.ugCallbackUrl_rm" );
         if(ugCallbackUrl_rm == null || ugCallbackUrl_rm.trim().equals("")){
-            return BaseResponseUtils.buildError("鏈厤缃崌绾т换鍔″洖璋冪綉鍧�") ;
+            return BaseResponseUtils.buildErrorMsg("鏈厤缃崌绾т换鍔″洖璋冪綉鍧�") ;
         }
 
         UpgradeTaskVo vo = new UpgradeTaskVo() ;
@@ -108,8 +105,8 @@
         vo.rtuAddrList = taskRtuAddrs ;
         vo.callbackWebUrl = ugCallbackUrl_rm ;
 
-        String ugSendUrl = this.getToMwUgUrl(this.env) ;
-        BaseResponse res = sendUpgradeTask2Mw(restTemplate, ugSendUrl, vo) ;
+        String rqUrl = this.get2MwRequestUrl(this.env, ContextUgTaskSend) ;
+        BaseResponse res = sendPostRequest2Mw(restTemplate, rqUrl, vo) ;
         if(res != null){
             if(res.isSuccess()){
                 this.sv.setUpgradeTaskExecuted(id);
@@ -119,14 +116,49 @@
                 if(msg == null){
                     msg = res.getMsg() ;
                 }
-                log.error("閫氫俊涓棿浠舵墽琛屼笅鍙戝崌绾т换鍔″け璐�" + msg) ;
-                return BaseResponseUtils.buildFail("閫氫俊涓棿浠舵墽琛屽け璐�" + msg) ;
+                log.error("閫氫俊涓棿浠舵墽琛屼笅鍙戝崌绾т换鍔″け璐ワ紝" + msg) ;
+                return BaseResponseUtils.buildErrorMsg("閫氫俊涓棿浠舵墽琛屽け璐ワ紝" + msg) ;
             }
         }else{
             log.error("閫氫俊涓棿浠惰繑鍥炵粨鏋滀负null") ;
-            return BaseResponseUtils.buildFail("閫氫俊涓棿浠惰繑鍥炵粨鏋滀负null") ;
+            return BaseResponseUtils.buildErrorMsg("閫氫俊涓棿浠惰繑鍥炵粨鏋滀负null") ;
         }
     }
+    /**
+     * 涓嬪彂寮哄埗缁撴潫褰撳墠rtu杩滅▼鍗囩骇浠诲姟
+     * @return 鎿嶄綔缁撴灉
+     */
+    @Operation(summary = "涓嬪彂寮哄埗缁撴潫褰撳墠rtu杩滅▼鍗囩骇浠诲姟", description = "涓嬪彂寮哄埗缁撴潫褰撳墠rtu杩滅▼鍗囩骇浠诲姟")
+    @ApiResponses(value = {
+            @ApiResponse(
+                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+                    description = "杩斿洖鎿嶄綔鎴愬姛涓庡惁鏁版嵁锛圔aseResponse.content:Boolean锛�",
+                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+                            schema = @Schema(implementation = String.class))}
+            )
+    })
+    @GetMapping(path = "/forceOver")
+    @SsoAop()
+    public BaseResponse<String> forceOver() {
+        String rqUrl = this.get2MwRequestUrl(this.env, ContextUgForceOver) ;
+        BaseResponse res = sendGetRequest2Mw(restTemplate, rqUrl) ;
+        if(res != null){
+            if(res.isSuccess()){
+                return BaseResponseUtils.buildSuccess(true) ;
+            }else{
+                String msg = res.getContent()==null?null:(String)res.getContent() ;
+                if(msg == null){
+                    msg = res.getMsg() ;
+                }
+                log.error("閫氫俊涓棿浠舵墽琛屼笅鍙戝己鍒剁粨鏉熷綋鍓峳tu杩滅▼鍗囩骇浠诲姟澶辫触锛�" + msg) ;
+                return BaseResponseUtils.buildErrorMsg("閫氫俊涓棿浠舵墽琛屽己鍒剁粨鏉熷綋鍓峳tu杩滅▼鍗囩骇浠诲姟澶辫触锛�" + msg) ;
+            }
+        }else{
+            log.error("閫氫俊涓棿浠惰繑鍥炵粨鏋滀负null") ;
+            return BaseResponseUtils.buildErrorMsg("閫氫俊涓棿浠惰繑鍥炵粨鏋滀负null") ;
+        }
+    }
+
 
     private void valueFromPo(UpgradeTaskVo vo, UgRtuTask tpo, UgRtuProgram ppo){
         vo.id = "" + tpo.id ;
@@ -180,10 +212,10 @@
             qvo.pageSize = 49 ;
         }
         if(RtuUpgradeStateReceiverCtrl.cache == null){
-            //return BaseResponseUtils.buildError("褰撳墠娌℃湁鍗囩骇浠诲姟") ;
+            return BaseResponseUtils.buildErrorMsg("褰撳墠娌℃湁鍗囩骇浠诲姟") ;
             //姝e紡杩愯鏃讹紝涓嬮潰涓よ鍘绘帀锛屼笂闈竴琛屾墦寮�
-            RtuUpgradeStateReceiverCtrl ctrl = SpringContextUtil.getBean(RtuUpgradeStateReceiverCtrl.class);
-            ctrl.demo();
+            //RtuUpgradeStateReceiverCtrl ctrl = SpringContextUtil.getBean(RtuUpgradeStateReceiverCtrl.class);
+            //ctrl.demo();
         }
         QueryResultVo<VoWatch> rsVo = this.resSv.curUpgradeState(qvo) ;
         return BaseResponseUtils.buildSuccess(rsVo) ;

--
Gitblit v1.8.0