From 91f6317d381bb399d31781c59cb4d21194d36517 Mon Sep 17 00:00:00 2001
From: Administrator <zhubaomin>
Date: 星期四, 20 六月 2024 17:45:51 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV

---
 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java |  140 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 97 insertions(+), 43 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java
index 3fa3861..d3fc309 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java
@@ -17,10 +17,12 @@
 import com.dy.pipIrrGlobal.command.ComSupport;
 import com.dy.pipIrrGlobal.daoSe.SeVirtualCardMapper;
 import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory;
+import com.dy.pipIrrGlobal.pojoSe.SeVirtualCard;
 import com.dy.pipIrrGlobal.voRm.VoUnclosedValve;
 import com.dy.pipIrrGlobal.voSe.VoVirtualCard;
 import com.dy.pipIrrWechat.command.dto.ValveClose;
 import com.dy.pipIrrWechat.command.dto.ValveOpen;
+import com.dy.pipIrrWechat.command.enums.LastOperateENUM;
 import com.dy.pipIrrWechat.result.WechatResultCode;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import jakarta.validation.Valid;
@@ -32,6 +34,7 @@
 import org.springframework.web.bind.annotation.*;
 
 import java.time.format.DateTimeFormatter;
+import java.util.Date;
 import java.util.List;
 import java.util.Objects;
 
@@ -65,7 +68,7 @@
     public BaseResponse<Boolean> open(@RequestBody @Valid ValveOpen valve, BindingResult bindingResult) {
         DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyMMddHHmmss");
         if(bindingResult != null && bindingResult.hasErrors()){
-            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+            return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
         }
 
         Long intakeId = valve.getIntakeId();
@@ -81,7 +84,7 @@
         if(vcId == null) {
             vcId = commandSv.getVcIdByIntakeId(intakeId);
             if(vcId == null) {
-                return BaseResponseUtils.buildFail(WechatResultCode.PLEASE_SELECT_A_VC.getMessage());
+                return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_VC.getMessage());
             }
         }
 
@@ -89,16 +92,14 @@
         if(!setuped) {
             setUp();
         }
-// 鍙栨按鍙D鎹㈠彇姘村彛瀵硅薄
-// 濡傛灉鍙栨按鍙d负鎵撳紑鐘舵�侊紝鍒欎笉鍏佽琚紑闃�
 
         // 铏氭嫙鍗D鎹㈣櫄鎷熷崱瀵硅薄
         VoVirtualCard vc = commandSv.getVcById(vcId);
         if(vc == null) {
-            return BaseResponseUtils.buildFail(WechatResultCode.PLEASE_SELECT_A_VC.getMessage());
+            return BaseResponseUtils.buildErrorMsg(WechatResultCode.PLEASE_SELECT_A_VC.getMessage());
         }
         if(vc.getInUse() == 1) {
-            return BaseResponseUtils.buildFail(WechatResultCode.IN_USE_VC_CANNOT_OPEN_VALVE.getMessage());
+            return BaseResponseUtils.buildErrorMsg(WechatResultCode.IN_USE_VC_CANNOT_OPEN_VALVE.getMessage());
         }
 
         // 鑾峰彇姘翠环
@@ -107,7 +108,7 @@
         // 鍙栨按鍙D鎹㈤榾鎺у櫒鍦板潃鍙婇�氳鍗忚
         JSONObject job_rtu = getRtu(intakeId, null);
         if(job_rtu == null) {
-            return BaseResponseUtils.buildError(WechatResultCode.RTU_NOT_EXIST.getMessage());
+            return BaseResponseUtils.buildErrorMsg(WechatResultCode.RTU_NOT_EXIST.getMessage());
         }
         String rtuAddr = job_rtu.getString("rtuAddr");
         String protocol = job_rtu.getString("protocol");
@@ -150,8 +151,8 @@
 
                 // 鍥炶皟澶辫触
                 if(!response_CallBack.getCode().equals("0001")) {
-                    return BaseResponseUtils.buildFail(response_CallBack.getMsg());
-                    //return BaseResponseUtils.buildFail(response_CallBack.getContent().toString());
+                    return BaseResponseUtils.buildErrorMsg(response_CallBack.getMsg());
+                    //return BaseResponseUtils.buildErrorMsg(response_CallBack.getContent().toString());
                 }
 
                 // 鍥炶皟鎴愬姛锛屽啀鍒ゆ柇鎵ц鏄惁鎴愬姛
@@ -161,7 +162,7 @@
                 System.out.println(job_subData);
                 Boolean dealResult = job_subData.getBoolean("success");
                 if(!dealResult) {
-                    return BaseResponseUtils.buildFail(response_CallBack.getContent().toString());
+                    return BaseResponseUtils.buildErrorMsg(response_CallBack.getContent().toString());
                 }
 
                 /**
@@ -181,7 +182,7 @@
             } else {
                 // 璇锋眰澶辫触
                 JSONObject job_param = response_SendCom.getJSONObject("content").getJSONObject("param");
-                return BaseResponseUtils.buildFail(job_param.getString("message"));
+                return BaseResponseUtils.buildErrorMsg(job_param.getString("message"));
             }
         } else if(protocol.equals("p206V1_0_1")) {
             // 鑾峰彇鍔熻兘鐮�
@@ -211,10 +212,36 @@
                 // 澶勭悊鍥炶皟
                 BaseResponse response_CallBack = dealWithCallBack(comId);
 
-                //鍥炶皟澶辫触
+                //鍥炶皟寮傚父
                 if(!response_CallBack.getCode().equals("0001")) {
-                    return BaseResponseUtils.buildFail(response_CallBack.getMsg());
-                    //return BaseResponseUtils.buildFail(response_CallBack.getContent().toString());
+                    // 鍛戒护鏃ュ織鎵ц缁撴灉鏀逛负澶辫触
+                    rmCommandHistory = new RmCommandHistory();
+                    rmCommandHistory.setId(comId);
+                    rmCommandHistory.setResult((byte)0);
+                    commandSv.update(rmCommandHistory);
+                    return BaseResponseUtils.buildErrorMsg(response_CallBack.getContent().toString());
+                }
+
+                // 鍥炶皟瓒呮椂
+                if(response_CallBack.getContent().toString().equals(WechatResultCode.GET_RESULT_IN_ONE_MINUTE.getMessage())) {
+                    /**
+                     * 鍥炶皟瓒呮椂锛屾殏鏃惰涓烘墽琛屽け璐�
+                     * 鍛戒护缃负澶辫触
+                     * 铏氭嫙鍗′緷鏃т繚鎸佷娇鐢ㄤ腑鐨勭姸鎬�
+                     */
+
+                    rmCommandHistory = new RmCommandHistory();
+                    rmCommandHistory.setId(comId);
+                    rmCommandHistory.setResult((byte)0);
+                    commandSv.update(rmCommandHistory);
+
+                    //SeVirtualCard virtualCard = new SeVirtualCard();
+                    //virtualCard.setId(vcId);
+                    //virtualCard.setInUse((byte) 1);
+                    //virtualCard.setLastOperate(LastOperateENUM.OPEN_VALVE.getCode());
+                    //virtualCard.setLastOperateTime(new Date());
+                    //seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard);
+                    return BaseResponseUtils.buildErrorMsg(WechatResultCode.GET_RESULT_IN_ONE_MINUTE.getMessage());
                 }
 
                 // 鍥炶皟鎴愬姛锛屽啀鍒ゆ柇鎵ц鏄惁鎴愬姛
@@ -224,19 +251,19 @@
                 System.out.println(job_subData);
                 Boolean dealResult = job_subData.getBoolean("success");
                 if(!dealResult) {
-                    return BaseResponseUtils.buildFail(response_CallBack.getContent().toString());
+                    return BaseResponseUtils.buildErrorMsg(response_CallBack.getContent().toString());
                 }
 
                 /**
                  * 鎵ц鎴愬姛
                  * 鏇存敼铏氭嫙鍗$姸鎬侊細鏄惁浣跨敤涓�佹渶鍚庢搷浣溿�佹渶鍚庢搷浣滄椂闂�
                  */
-                //SeVirtualCard virtualCard = new SeVirtualCard();
-                //virtualCard.setId(vcId);
-                //virtualCard.setInUse((byte) 1);
-                //virtualCard.setLastOperate(LastOperateENUM.OPEN_VALVE.getCode());
-                //virtualCard.setLastOperateTime(new Date());
-                //seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard);
+                SeVirtualCard virtualCard = new SeVirtualCard();
+                virtualCard.setId(vcId);
+                virtualCard.setInUse((byte) 1);
+                virtualCard.setLastOperate(LastOperateENUM.OPEN_VALVE.getCode());
+                virtualCard.setLastOperateTime(new Date());
+                seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard);
 
                 // 鍥炶皟杩斿洖鐨勫唴瀹�
                 Data myData = (Data)response_CallBack.getContent();
@@ -244,10 +271,10 @@
             } else {
                 // 璇锋眰澶辫触
                 JSONObject job_param = response_SendCom.getJSONObject("content").getJSONObject("param");
-                return BaseResponseUtils.buildFail(job_param.getString("message"));
+                return BaseResponseUtils.buildErrorMsg(job_param.getString("message"));
             }
         } else {
-            return BaseResponseUtils.buildFail("绯荤粺鏆備笉鏀寔璇ュ崗璁�");
+            return BaseResponseUtils.buildErrorMsg("绯荤粺鏆備笉鏀寔璇ュ崗璁�");
         }
     }
 
@@ -263,7 +290,7 @@
     public BaseResponse<Boolean> close(@RequestBody @Valid ValveClose valve, BindingResult bindingResult) {
         DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyMMddHHmmss");
         if(bindingResult != null && bindingResult.hasErrors()){
-            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+            return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
         }
 
         String rtuAddr = valve.getRtuAddr();
@@ -280,7 +307,7 @@
         // 闃�鎺у櫒鍦板潃鎹㈠彇姘村彛ID鍜岄�氳鍗忚
         JSONObject job_rtu = getRtu(null, rtuAddr);
         if(job_rtu == null) {
-            return BaseResponseUtils.buildError(WechatResultCode.RTU_NOT_EXIST.getMessage());
+            return BaseResponseUtils.buildErrorMsg(WechatResultCode.RTU_NOT_EXIST.getMessage());
         }
         Long intakeId = job_rtu.getLong("intakeId");
         String protocol = job_rtu.getString("protocol");
@@ -315,8 +342,8 @@
 
                 // 鍥炶皟澶辫触
                 if(!response_CallBack.getCode().equals("0001")) {
-                    return BaseResponseUtils.buildFail(response_CallBack.getMsg());
-                    //return BaseResponseUtils.buildError(WechatResultCode.GET_RESULT_ERROR.getMessage());
+                    return BaseResponseUtils.buildErrorMsg(response_CallBack.getMsg());
+                    //return BaseResponseUtils.buildErrorMsg(WechatResultCode.GET_RESULT_ERROR.getMessage());
                 }
 
                 // 鍥炶皟鎴愬姛锛屽啀鍒ゆ柇鎵ц鏄惁鎴愬姛
@@ -326,7 +353,7 @@
                 System.out.println(job_subData);
                 Boolean dealResult = job_subData.getBoolean("success");
                 if(!dealResult) {
-                    return BaseResponseUtils.buildFail(response_CallBack.getContent().toString());
+                    return BaseResponseUtils.buildErrorMsg(response_CallBack.getContent().toString());
                 }
 
                 /**
@@ -347,7 +374,7 @@
             } else {
                 // 璇锋眰澶辫触
                 JSONObject job_param = response_SendCom.getJSONObject("content").getJSONObject("param");
-                return BaseResponseUtils.buildFail(job_param.getString("message"));
+                return BaseResponseUtils.buildErrorMsg(job_param.getString("message"));
             }
         } else if(protocol.equals("p206V1_0_1")) {
             // 鑾峰彇鍔熻兘鐮�
@@ -375,10 +402,37 @@
                 // 澶勭悊鍥炶皟
                 BaseResponse response_CallBack = dealWithCallBack(comId);
 
-                // 鍥炶皟澶辫触
+                // 鍥炶皟寮傚父
                 if(!response_CallBack.getCode().equals("0001")) {
-                    return BaseResponseUtils.buildFail(response_CallBack.getMsg());
-                    //return BaseResponseUtils.buildError(WechatResultCode.GET_RESULT_ERROR.getMessage());
+                    // 鍛戒护鏃ュ織鎵ц缁撴灉鏀逛负澶辫触
+                    rmCommandHistory = new RmCommandHistory();
+                    rmCommandHistory.setId(comId);
+                    rmCommandHistory.setResult((byte)0);
+                    commandSv.update(rmCommandHistory);
+                    return BaseResponseUtils.buildErrorMsg(response_CallBack.getContent().toString());
+                }
+
+                // 鍥炶皟瓒呮椂
+                if(response_CallBack.getContent().toString().equals(WechatResultCode.GET_RESULT_IN_ONE_MINUTE.getMessage())) {
+                    /**
+                     * 鍥炶皟瓒呮椂锛屾殏鏃惰涓烘墽琛屽け璐�
+                     * 鍛戒护缃负澶辫触
+                     * 铏氭嫙鍗′緷鏃т繚鎸佷娇鐢ㄤ腑鐨勭姸鎬�
+                     */
+
+                    rmCommandHistory = new RmCommandHistory();
+                    rmCommandHistory.setId(comId);
+                    rmCommandHistory.setResult((byte)0);
+                    commandSv.update(rmCommandHistory);
+
+                    //Long vcId = seVirtualCardMapper.getVcIdByNum(vcNum);
+                    //SeVirtualCard virtualCard = new SeVirtualCard();
+                    //virtualCard.setId(vcId);
+                    //virtualCard.setInUse((byte) 0);
+                    //virtualCard.setLastOperate(LastOperateENUM.OPEN_VALVE.getCode());
+                    //virtualCard.setLastOperateTime(new Date());
+                    //seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard);
+                    return BaseResponseUtils.buildErrorMsg(WechatResultCode.GET_RESULT_IN_ONE_MINUTE.getMessage());
                 }
 
                 // 鍥炶皟鎴愬姛锛屽啀鍒ゆ柇鎵ц鏄惁鎴愬姛
@@ -388,20 +442,20 @@
                 System.out.println(job_subData);
                 Boolean dealResult = job_subData.getBoolean("success");
                 if(!dealResult) {
-                    return BaseResponseUtils.buildFail(response_CallBack.getContent().toString());
+                    return BaseResponseUtils.buildErrorMsg(response_CallBack.getContent().toString());
                 }
 
                 /**
                  * 鎵ц鎴愬姛
                  * 鏇存敼铏氭嫙鍗$姸鎬侊細鏄惁浣跨敤涓�佹渶鍚庢搷浣溿�佹渶鍚庢搷浣滄椂闂�
                  */
-                //Long vcId = seVirtualCardMapper.getVcIdByNum(vcNum);
-                //SeVirtualCard virtualCard = new SeVirtualCard();
-                //virtualCard.setId(vcId);
-                //virtualCard.setInUse((byte) 0);
-                //virtualCard.setLastOperate(LastOperateENUM.OPEN_VALVE.getCode());
-                //virtualCard.setLastOperateTime(new Date());
-                //seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard);
+                Long vcId = seVirtualCardMapper.getVcIdByNum(vcNum);
+                SeVirtualCard virtualCard = new SeVirtualCard();
+                virtualCard.setId(vcId);
+                virtualCard.setInUse((byte) 0);
+                virtualCard.setLastOperate(LastOperateENUM.OPEN_VALVE.getCode());
+                virtualCard.setLastOperateTime(new Date());
+                seVirtualCardMapper.updateByPrimaryKeySelective(virtualCard);
 
                 // 鍥炶皟杩斿洖鐨勫唴瀹�
                 Data myData = (Data)response_CallBack.getContent();
@@ -409,10 +463,10 @@
             } else {
                 // 璇锋眰澶辫触
                 JSONObject job_param = response_SendCom.getJSONObject("content").getJSONObject("param");
-                return BaseResponseUtils.buildFail(job_param.getString("message"));
+                return BaseResponseUtils.buildErrorMsg(job_param.getString("message"));
             }
         } else {
-            return BaseResponseUtils.buildFail("绯荤粺鏆備笉鏀寔璇ュ崗璁�");
+            return BaseResponseUtils.buildErrorMsg("绯荤粺鏆備笉鏀寔璇ュ崗璁�");
         }
     }
 
@@ -422,7 +476,7 @@
      * @return
      */
     @GetMapping(path = "/get")
-    @SsoAop()
+    //@SsoAop()
     public BaseResponse<List<VoUnclosedValve>> getUnclosedValves(@RequestParam Long operator){
         try {
             List<VoUnclosedValve> res = commandSv.getUnclosedValves(operator);

--
Gitblit v1.8.0