Forráskód Böngészése

故障诊断中调用智能问答接口

Rmengdi 1 hónapja
szülő
commit
7d32ce569b
2 módosított fájl, 106 hozzáadás és 8 törlés
  1. 3 3
      src/api/als/intelligentQA.js
  2. 103 5
      src/views/als/faultDiagnosis/index.vue

+ 3 - 3
src/api/als/intelligentQA.js

@@ -1,9 +1,9 @@
 import { get, post, deletes } from '@/http/index'
 
 // 问答接口
-// export const handlerAsk = async (data) => {
-//   return await post('/kgqa/ask/', data)
-// }
+export const handlerQAndA = async (data) => {
+  return await post('/kgqa/ask/', data)
+}
 // 问答接口
 export const handlerAsk = async (data) => {
   return await post('/als/algorithm/execute/qa', data)

+ 103 - 5
src/views/als/faultDiagnosis/index.vue

@@ -3,7 +3,7 @@
     <div class="view-dataSpecies-left">
       <MenuTree :currentNodeKey="currentNodeKey" nodeKey="id" :treedata="menuTreeData" @TreeNodeclick="treeNodeClick" v-bind="treeObj"> </MenuTree>
     </div>
-    <div class="view-dataSpecies-right">
+    <div class="view-dataSpecies-right" v-loading="loading">
       <div class="view-dataType-title">
         <div class="view-dataType-title-btn"></div>
         <div class="view-dataType-title-search">
@@ -30,23 +30,33 @@
             </div>
           </el-descriptions-item>
           <el-descriptions-item label="退化结果">
-            <el-tag style="margin-right: 20px" type="danger" v-for="(item, index) in diagnosisResult.degradation" :key="index">{{ item }}</el-tag>
+            <el-tag class="fault" style="margin-right: 20px" type="danger" v-for="(item, index) in diagnosisResult.degradation" :key="index" @click="handelQA(item)">{{ item }}</el-tag>
           </el-descriptions-item>
           <el-descriptions-item label="故障结果">
-            <el-tag style="margin-right: 20px" type="danger" v-for="(item, index) in diagnosisResult.fault" :key="index">{{ item }}</el-tag>
+            <el-tag class="fault" style="margin-right: 20px" type="danger" v-for="(item, index) in diagnosisResult.fault" :key="index" @click="handelQA(item)">{{ item }}</el-tag>
           </el-descriptions-item>
         </el-descriptions>
         <span slot="footer" class="dialog-footer">
           <el-button type="primary" @click="resultShowDialogClose">确 定</el-button>
         </span>
       </el-dialog>
+      <el-dialog title="问答结果" :visible.sync="QAVisible" width="1000px" :before-close="QADialogClose">
+        <div style="color: white; font-size: 20px; margin-bottom: 20px">
+          {{ QAData.graphAnswer.answer }}
+        </div>
+        <graphECharts :width="950" :height="400" :graphData="QAData.graphAnswer.graph"></graphECharts>
+
+        <span slot="footer" class="dialog-footer">
+          <el-button type="primary" @click="QAVisible = false">确 定</el-button>
+        </span>
+      </el-dialog>
     </div>
   </div>
 </template>
 
 <script>
+import store from '@/store'
 import { getDataImport } from '@/api/als/dataImport'
-import { getFaultDiagnosis } from '@/api/als/faultDiagnosis'
 import { getFaultDiagnosisResult } from '@/api/als/faultDiagnosisResult'
 import { getAircaftCatalogTree } from '@/api/als/sideTree'
 import { getAircaftCatalogAll } from '@/api/als/aircraft'
@@ -55,15 +65,20 @@ import { handleTree, flattenTree } from '../utils/common'
 import { getAirConfiguration } from '@/api/als/airConfiguration'
 import { executeFault } from '@/api/als/algorithm'
 import { getListByIdsApi } from '@/api/als/oss'
+import { handlerQAndA } from '@/api/als/intelligentQA'
+import graphECharts from '@/views/als/components/Charts/graph.vue'
 
 export default {
   name: 'FaultDiagnosis',
+  components: { graphECharts },
   data() {
     // 这里存放数据
     return {
+      loading: false,
       resultVisible: false,
       progressVisible: false,
       resultShowVisible: false,
+      QAVisible: false,
       keyWordData: '',
       aircaftModelIdList: [],
       currentNodeKey: '',
@@ -253,7 +268,11 @@ export default {
         fault: [],
         score: null
       },
-      changeScore: null
+      changeScore: null,
+      QAData: {
+        userId: '',
+        graphAnswer: {}
+      }
     }
   },
   watch: {
@@ -468,6 +487,82 @@ export default {
         this.progressVisible = false
         this.percentage = 0
       }
+    },
+
+    async handelQA(question) {
+      this.loading = true
+      const sendInput = {
+        question: question,
+        userId: String(store.state.user.userInfo.user.userId)
+      }
+      try {
+        if (question.trim() === '') {
+          return
+        }
+
+        // const { code, data } = await handlerQAndA(sendInput)
+        const { code, data } = {
+          code: 200,
+          msg: '',
+          data: {
+            userId: 'user',
+            graphAnswer: {
+              answer: '解决办法为:更换电池或遥控器',
+              fileName: '排故手册',
+              ossId: '227701077942149120', //pdf
+              // ossID: '227692224508796928', //word
+              filePage: 2,
+              graph: {
+                data: [
+                  { name: '202310150010', category: 'HMC' },
+                  { name: '电视', category: '成品' },
+                  { name: '电视遥控器失灵', category: '故障描述' },
+                  { name: '家用电器', category: '系统' },
+                  { name: '更换电池或遥控器', category: '维修策略' }
+                ],
+                links: [
+                  { source: '202310150010', target: '电视', value: '成品' },
+                  { source: '202310150010', target: '电视遥控器失灵', value: '故障描述' },
+                  { source: '202310150010', target: '家用电器', value: '系统' },
+                  { source: '202310150010', target: '更换电池或遥控器', value: '维修策略' }
+                ]
+              }
+            }
+          }
+        }
+        if (code == 200) {
+          // const newData = this.handleData(JSON.parse(data))
+          this.QAData = this.handleData(data)
+          this.loading = false
+          this.QAVisible = true
+        }
+      } catch (error) {}
+    },
+
+    handleData(data) {
+      if (data.graphAnswer?.graph) {
+        // const graphAnswer = eval('(' + data.graphAnswer.graph + ')')
+        // data.graphAnswer.graph = graphAnswer
+        const categories = []
+        data.graphAnswer.graph.data.forEach((node) => {
+          const flag = categories.find((item) => {
+            return item.name === node.category
+          })
+          if (!flag) {
+            categories.push({ name: node.category })
+          }
+        })
+        data.graphAnswer.graph.categories = categories
+      }
+      return data
+    },
+
+    QADialogClose() {
+      this.QAData = {
+        userId: '',
+        graphAnswer: {}
+      }
+      this.QAVisible = false
     }
   }
 }
@@ -475,4 +570,7 @@ export default {
 
 <style lang="scss" scoped>
 @import '../index.scss';
+.fault {
+  cursor: pointer;
+}
 </style>