From e83e9c56dcbec57b7bb8475d559e2169628e4ed9 Mon Sep 17 00:00:00 2001
From: jiminglei <836545853@qq.com>
Date: Tue, 11 Jul 2023 18:39:36 +0800
Subject: [PATCH] 11

---
 psdc-ui/src/api/control/manual.js          |   3 +
 psdc-ui/src/views/control/manual/index.vue | 115 +++++++++++++++------
 2 files changed, 86 insertions(+), 32 deletions(-)

diff --git a/psdc-ui/src/api/control/manual.js b/psdc-ui/src/api/control/manual.js
index cb71050..6b4a34a 100644
--- a/psdc-ui/src/api/control/manual.js
+++ b/psdc-ui/src/api/control/manual.js
@@ -31,4 +31,7 @@ export function getSenceControl(data) {
 /** 策略执行反馈*/
 export function ControlInfo(data) {
     return request.post('/analyse/nhdb/strategyRes?strategyCode='+data)
+}
+export function ControlResult() {
+    return request.post('/analyse/nhdb/newRunResScene')
 }
\ No newline at end of file
diff --git a/psdc-ui/src/views/control/manual/index.vue b/psdc-ui/src/views/control/manual/index.vue
index 2ed9442..2ab4e9e 100644
--- a/psdc-ui/src/views/control/manual/index.vue
+++ b/psdc-ui/src/views/control/manual/index.vue
@@ -1,6 +1,7 @@
 <template>
   <div class="app-container home">
-    <el-button type="primary" :icon="Download" @click="drawerIshow = true">策略导入</el-button>
+    <el-button type="primary" :icon="Download" @click="controlMsg">策略导入</el-button>
+    <el-button :type=data.type  plain>{{data.info}}:{{data.info1}}:{{data.result}}</el-button>
     <div class="dev_control_wrapper">
 
 
@@ -86,7 +87,7 @@
 <!--              </span>-->
 <!--            </div>-->
 <!--          </div>-->
-            <el-button type="primary" @click="controlMsg">执行结果</el-button>
+<!--            <el-button type="primary" @click="controlMsg">执行结果</el-button>-->
         </el-radio>
 
 
@@ -115,14 +116,59 @@
 import { Download } from '@element-plus/icons-vue'  //element字体图标
 import { ref,reactive,onMounted  } from 'vue'
 import { ElMessageBox,ElMessage, ElLoading} from 'element-plus'
-import { getDevice,getControlLogList,getStrategyList,getStartAndStop,getSetTemperature,getSenceControl,getControlDeviceList,ControlInfo } from '@/api/control/manual'
-
+import { getDevice,getControlLogList,getStrategyList,getStartAndStop,getSetTemperature,getSenceControl,getControlDeviceList,ControlInfo ,ControlResult} from '@/api/control/manual'
+const data = reactive({
+  strategyCode:'',
+  info:'',
+  result:'',
+  type:''
+})
 onMounted(()=>{
+  GetResult();
   getDeviceFun();
   getControlLogListFun();
   getStrategyListFun()
 })
-
+function GetResult(){
+  ControlResult().then((res)=>{
+    console.log(res)
+  if(!res.data){
+    radio.value=''
+    data.strategyCode=''
+    data.info='暂无执行策略'
+    data.info1=''
+    data.result=''
+    data.type='info'
+  }
+  else if(res.data){
+    var a =  res.data.strategyRunRes.substring(res.data.strategyRunRes.length-1)
+    if(a==0){
+      radio.value=res.data.strategyName
+      data.strategyCode=res.data.strategyCode
+      data.info=res.data.strategyName
+      data.info1=res.data.runSceneName
+      data.result='执行失败'
+      data.type='danger'
+    }
+    else if (a==1){
+      radio.value=res.data.strategyName
+      data.strategyCode=res.data.strategyCode
+      data.info=res.data.strategyName
+      data.info1=res.data.runSceneName
+      data.result='执行成功'
+      data.type='success'
+    }
+    else if(a==2){
+      radio.value=res.data.strategyName
+      data.strategyCode=res.data.strategyCode
+      data.info=res.data.strategyName
+      data.info1=res.data.runSceneName
+      data.result='执行中'
+      data.type='warning'
+    }
+  }
+  })
+}
 /** 获取所有设备*/
 const deviceArr = ref([])
 function getDeviceFun(){
@@ -472,35 +518,40 @@ function confirmClick() {
 }
 //执行结果
 function controlMsg() {
-  ControlInfo(celueItem.strategyCode).then((res)=>{
-    console.log('执行结果',res)
-    if(res.data){
-      //执行过程
-      function setFlowItem(i) {
-        if (i >= res.data.length) {
-          return; //递归终止条件
-        }
-        if(res.data[i]==1){
-          celueItem.scenesList[i].type = 'success';
-          celueItem.scenesList[i].icon = 'Check';
-        }
-        else if(res.data[i]==0){
-          celueItem.scenesList[i].type = 'danger';
-          celueItem.scenesList[i].icon = 'Close';
-        }else if(res.data[i]==2){
-          celueItem.scenesList[i].type = 'warning';
-          celueItem.scenesList[i].icon = 'loading';
+  drawerIshow.value = true
+  if(data.strategyCode!=null){
+    var a = data.strategyCode-1
+    celueItem = celueList.value[a]
+    ControlInfo(data.strategyCode).then((res)=>{
+      console.log('执行结果',res)
+      if(res.data){
+        //执行过程
+        function setFlowItem(i) {
+          if (i >= res.data.length) {
+            return; //递归终止条件
+          }
+          if(res.data[i]==1){
+            celueItem.scenesList[i].type = 'success';
+            celueItem.scenesList[i].icon = 'Check';
+          }
+          else if(res.data[i]==0){
+            celueItem.scenesList[i].type = 'danger';
+            celueItem.scenesList[i].icon = 'Close';
+          }else if(res.data[i]==2){
+            celueItem.scenesList[i].type = 'warning';
+            celueItem.scenesList[i].icon = 'loading';
+          }
+          setTimeout(function() {
+            setFlowItem(i + 1); //递归调用
+          }, 1000);
         }
-        setTimeout(function() {
-          setFlowItem(i + 1); //递归调用
-        }, 1000);
+        setFlowItem(0); //调用递归函数,从数组第一个元素开始赋值
+        getControlLogListFun()
+      }else{
+        getControlLogListFun()
       }
-      setFlowItem(0); //调用递归函数,从数组第一个元素开始赋值
-      getControlLogListFun()
-    }else{
-      getControlLogListFun()
-    }
-  })
+    })
+  }
 }
 /** 控制设备启停*/
 const loading = ref(false)