index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. <template>
  2. <div class="view-table-content">
  3. <div class="view-dataSpecies-left">
  4. <MenuTree :currentNodeKey="currentNodeKey" nodeKey="id" :treedata="menuTreeData" @TreeNodeclick="treeNodeClick" v-bind="treeObj"> </MenuTree>
  5. </div>
  6. <div class="view-dataSpecies-right">
  7. <div class="view-dataType-title">
  8. <div class="view-dataType-title-btn"></div>
  9. <div class="view-dataType-title-search">
  10. <el-input placeholder="请输入架次号" v-model="keyWordData" class="input1">
  11. <el-button slot="append" icon="el-icon-search" @click="searchClick"></el-button>
  12. </el-input>
  13. </div>
  14. </div>
  15. <div class="view-dataType-table">
  16. <LTable ref="table" @selection-change="selection" :defaultFetch="false" :fetch="fetch" :columns="columns" :dataSource="tableData" :options="options" :pagination="tableRequset"></LTable>
  17. </div>
  18. <!-- 警告列表对话框 -->
  19. <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" :before-close="handleClose" width="1200px">
  20. <el-form ref="form" :inline="true" :model="form" label-width="80px" disabled>
  21. <el-form-item label="编目" prop="aircraftId">
  22. <el-select v-model="form.aircraftId">
  23. <el-option v-for="item in aircaftCatalogAll" :key="item.aircaftCatalogId" :label="item.aircaftCatalogCode" :value="item.aircaftCatalogId"> </el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="架次" prop="sortieNo">
  27. <el-input v-model="form.sortieNo" />
  28. </el-form-item>
  29. <!-- <el-form-item label="飞行时间" prop="flightDate">
  30. <el-input v-model="form.flightDate" />
  31. </el-form-item> -->
  32. </el-form>
  33. <LTable ref="warningTable" @selection-change="selection" :defaultFetch="false" :showColumnSetting="false" :columns="warningColumns" :dataSource="warningTableData" :options="warningOptions" :pagination="warningTableRequset"></LTable>
  34. <el-dialog width="80%" title="飞参数据曲线" :visible.sync="innerVisible" :before-close="innerDialogClose" append-to-body>
  35. <PlayBackChart @data-zoom="handleDataZoom" :chartData="chartData" />
  36. <div style="margin-top: 20px">
  37. <span style="color: #fff; margin-left: 30px">请选择时间区间:</span>
  38. <el-time-picker is-range v-model="mathTime" placement="bottom-start" value-format="HH:mm:ss.SSS" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" @change="handleMathTime" :clearable="false"></el-time-picker>
  39. <el-button class="refresh" @click="resetTime">重 置</el-button>
  40. <el-button type="success" @click="getExecuteMathAPI" style="margin-left: 15px">确 定</el-button>
  41. <LTable ref="mathTable" style="margin-top: 20px" :showColumnSetting="false" :defaultFetch="false" :columns="mathColumns" :dataSource="mathTableData" :options="mathOptions"></LTable>
  42. </div>
  43. <div style="width: 100%; color: #fff; text-align: center">
  44. <el-radio-group class="isFalseAlarm" v-model="isFalseAlarm" size="small">
  45. <el-radio-button label="0">实警</el-radio-button>
  46. <el-radio-button label="1">虚警</el-radio-button>
  47. </el-radio-group>
  48. </div>
  49. <span slot="footer" class="dialog-footer">
  50. <el-button @click="innerDialogClose">取 消</el-button>
  51. <el-button type="primary" @click="submit">确 定</el-button>
  52. </span>
  53. </el-dialog>
  54. </el-dialog>
  55. <el-dialog title="执行进度" :visible.sync="progressVisible" width="800px">
  56. <el-progress :text-inside="true" :stroke-width="24" :percentage="percentage" status="success"></el-progress>
  57. </el-dialog>
  58. </div>
  59. </div>
  60. </template>
  61. <script>
  62. import { getDataImport } from '@/api/als/dataImport'
  63. import { getCurveData, getWarning, updateWarning } from '@/api/als/warning'
  64. import { getAircaftCatalogTree } from '@/api/als/sideTree'
  65. import { getAircaftCatalogAll } from '@/api/als/aircraft'
  66. import PlayBackChart from '@/views/als/components/Charts/playBackChart.vue'
  67. import { deepClone, debounce } from '@/utils/index'
  68. import { executeFalseAlarm, getOssIdDataAPI, executeMath } from '@/api/als/algorithm'
  69. import { getWarningResult, updateWarningResult } from '@/api/als/falseAlarmResult'
  70. export default {
  71. name: 'FalseAlarm',
  72. components: { PlayBackChart },
  73. data() {
  74. // 这里存放数据
  75. return {
  76. dialogTitle: '新增',
  77. dialogVisible: false,
  78. innerVisible: false,
  79. progressVisible: false,
  80. keyWordData: '',
  81. aircaftModelIdList: [],
  82. currentNodeKey: '',
  83. currentNode: {},
  84. menuTreeData: [],
  85. treeObj: {
  86. title: '所属机种',
  87. activityheight: '275px',
  88. searchIcon: false,
  89. configure: {
  90. children: 'children',
  91. label: 'label'
  92. }
  93. },
  94. typeTree: {
  95. children: 'children',
  96. label: 'label'
  97. },
  98. searchValue: '',
  99. columns: [
  100. {
  101. prop: 'aircraftId',
  102. label: '编目',
  103. render: (h, params) => {
  104. const matchedItem = this.aircaftCatalogAll.find((item) => params.row.aircraftId.trim() === item.aircaftCatalogId.trim())
  105. if (matchedItem) {
  106. return h('span', matchedItem.aircaftCatalogCode)
  107. } else {
  108. return h('span', {}, '')
  109. }
  110. }
  111. },
  112. {
  113. prop: 'sortieNo',
  114. label: '架次号'
  115. },
  116. {
  117. prop: 'dataStatus',
  118. label: '状态',
  119. // 1 未处理,2 已处理
  120. render: (h, params) => {
  121. if (params.row.dataStatus == '1') {
  122. return h('span', '未处理')
  123. } else if (params.row.dataStatus == '2') {
  124. return h('span', { class: 'success-state' }, '已处理')
  125. } else {
  126. return h('span', { class: 'warning-state' }, '异常')
  127. }
  128. }
  129. },
  130. {
  131. // 算法执行时间
  132. prop: 'createTime',
  133. label: '创建时间'
  134. },
  135. {
  136. button: true,
  137. label: '操作',
  138. width: '240px',
  139. group: [
  140. {
  141. name: '虚警判断',
  142. type: 'text',
  143. // statusKey: 'dataStatus',
  144. // disableKey: '2',
  145. round: false,
  146. plain: false,
  147. onClick: (row, index, scope) => {
  148. this.beginExecute(row)
  149. }
  150. },
  151. {
  152. name: '查看',
  153. type: 'text',
  154. statusKey: 'dataStatus',
  155. unDisableKey: '2',
  156. round: false,
  157. plain: false,
  158. onClick: (row, index, scope) => {
  159. this.checkResultList(row)
  160. }
  161. }
  162. ]
  163. }
  164. ],
  165. options: {
  166. stripe: false, // 斑马纹
  167. mutiSelect: true, // 多选框
  168. index: false, // 显示序号, 多选则 mutiSelect
  169. loading: false, // 表格动画
  170. initTable: false, // 是否一挂载就加载数据
  171. border: true,
  172. height: 'calc(100vh - 300px)'
  173. },
  174. tableCheckItems: [],
  175. tableData: [],
  176. tableRequset: {
  177. total: 0,
  178. pageIndex: 1,
  179. pageSize: 20,
  180. searchValue: ''
  181. },
  182. warningColumns: [
  183. {
  184. prop: 'name',
  185. label: '故障名称'
  186. },
  187. {
  188. prop: 'code',
  189. label: 'HMC码'
  190. },
  191. {
  192. prop: 'attribute1',
  193. label: '判据名称',
  194. // render: (h, params) => {
  195. // return h('span', { class: 'warning-state' }, params.row.attribute1)
  196. // },
  197. onClick: (row, index, scope) => {
  198. this.$router.push({ name: 'JudgeFaultLogic' })
  199. }
  200. },
  201. {
  202. prop: 'resultContent',
  203. label: '判断结果',
  204. render: (h, params) => {
  205. if (params.row.resultContent == '0') {
  206. return h('span', { class: 'warning-state' }, '实警')
  207. } else if (params.row.resultContent == '1') {
  208. return h('span', { class: 'success-state' }, '虚警')
  209. } else if (params.row.resultContent == '2') {
  210. return h('span', '判故公式参数不匹配')
  211. } else if (params.row.resultContent == '3') {
  212. return h('span', '该HMC码无判据公式')
  213. }
  214. }
  215. },
  216. {
  217. button: true,
  218. label: '操作',
  219. width: '240px',
  220. group: [
  221. {
  222. name: '查看',
  223. type: 'text',
  224. round: false,
  225. plain: false,
  226. onClick: (row, index, scope) => {
  227. this.checkCurve(row)
  228. }
  229. }
  230. ]
  231. }
  232. ],
  233. warningOptions: {
  234. stripe: false, // 斑马纹
  235. mutiSelect: false, // 多选框
  236. index: true, // 显示序号, 多选则 mutiSelect
  237. loading: false, // 表格动画
  238. initTable: false, // 是否一挂载就加载数据
  239. border: true,
  240. height: 'calc(100vh - 600px)'
  241. },
  242. warningTableCheckItems: [],
  243. warningTableData: [],
  244. warningTableRequset: {
  245. total: 0,
  246. pageIndex: 1,
  247. pageSize: 10,
  248. searchValue: ''
  249. },
  250. mathColumns: [
  251. {
  252. prop: 'params',
  253. label: '参数'
  254. },
  255. {
  256. prop: 'mean',
  257. label: '算数平均数'
  258. },
  259. {
  260. prop: 'variance',
  261. label: '方差'
  262. },
  263. {
  264. prop: 'populationVariance',
  265. label: '总体方差'
  266. },
  267. {
  268. prop: 'sum',
  269. label: '和'
  270. },
  271. {
  272. prop: 'max',
  273. label: '最大值'
  274. },
  275. {
  276. prop: 'min',
  277. label: '最小值'
  278. },
  279. {
  280. prop: 'mode',
  281. label: '众数'
  282. },
  283. {
  284. prop: 'geometricMean',
  285. label: '几何平均数'
  286. },
  287. {
  288. prop: 'sumSq',
  289. label: '平方和'
  290. }
  291. ],
  292. mathOptions: {
  293. stripe: false, // 斑马纹
  294. mutiSelect: false, // 多选框
  295. index: false, // 显示序号, 多选则 mutiSelect
  296. loading: false, // 表格动画
  297. initTable: false, // 是否一挂载就加载数据
  298. border: true,
  299. height: '300px'
  300. },
  301. mathTableData: [],
  302. debounceFn: debounce(this.fetch, 500),
  303. aircaftCatalogAll: [],
  304. chartData: {
  305. title: '',
  306. legendData: [],
  307. xAxisData: [],
  308. yAxisData: [],
  309. seriesData: []
  310. },
  311. form: {
  312. id: '',
  313. sortieNo: '',
  314. aircraftId: '',
  315. ossId: '',
  316. dataStatus: '',
  317. flightDate: ''
  318. },
  319. warningForm: {
  320. id: null,
  321. resultContent: ''
  322. },
  323. isFalseAlarm: '0',
  324. currentSortieNo: '',
  325. percentage: 0,
  326. mathTime: [],
  327. mathParams: {
  328. code: '',
  329. sortieNo: '',
  330. beginTime: '',
  331. endTime: ''
  332. },
  333. backupsTime: []
  334. // startTime:'',
  335. // endTime:'',
  336. }
  337. },
  338. watch: {
  339. keyWord() {
  340. this.tableRequset.pageIndex = 1
  341. this.debounceFn()
  342. }
  343. },
  344. mounted() {
  345. this.getAircaftCatalogTreeAPI()
  346. },
  347. methods: {
  348. async getAircaftCatalogTreeAPI(params) {
  349. try {
  350. const { data } = await getAircaftCatalogTree(params)
  351. this.menuTreeData = data
  352. const getAircaftCatalogAllParams = {
  353. keyWord: '',
  354. aircaftModelIdList: []
  355. }
  356. const { data: data2 } = await getAircaftCatalogAll(getAircaftCatalogAllParams)
  357. this.aircaftCatalogAll = data2
  358. if (data.length) {
  359. this.currentNodeKey = data[0].id
  360. this.currentNode = data[0]
  361. this.aircaftModelIdList = this.getTreeLeafData(data[0]?.children)
  362. .map((e) => e.id)
  363. .toString()
  364. this.getDataImportAPI({ aircraftId: this.aircaftModelIdList })
  365. }
  366. } catch (error) {}
  367. },
  368. getTreeLeafData(list) {
  369. const newArr = []
  370. function getLeaf(data, arr) {
  371. data.forEach((e) => {
  372. if (e.type === 2) {
  373. arr.push(e)
  374. }
  375. if (e.children.length) {
  376. getLeaf(e.children, arr)
  377. }
  378. })
  379. }
  380. getLeaf(list, newArr)
  381. return newArr
  382. },
  383. async getDataImportAPI(params) {
  384. if (this.$refs.table) this.$refs.table.clearSelection()
  385. const { keyWord } = this
  386. const { pageSize, pageIndex } = this.tableRequset
  387. const {
  388. data: { list, total }
  389. } = await getDataImport({ pageSize, pageNum: pageIndex, ...params, source: 1 })
  390. this.tableData = list
  391. this.tableRequset.total = total
  392. },
  393. fetch() {
  394. this.getDataImportAPI({ aircraftId: this.aircaftModelIdList })
  395. },
  396. async searchClick() {
  397. this.getDataImportAPI({ aircraftId: this.aircaftModelIdList, sortieNo: this.keyWordData })
  398. },
  399. treeNodeClick(data) {
  400. this.$refs.table.clearSelection()
  401. this.currentNodeKey = data.id
  402. this.currentNode = data
  403. this.aircaftModelIdList = this.getTreeLeafData(data.children.length ? data.children : [data])
  404. .map((e) => e.id)
  405. .toString()
  406. if (!this.aircaftModelIdList) {
  407. this.aircaftModelIdList = '#'
  408. }
  409. this.getDataImportAPI({ aircraftId: this.aircaftModelIdList })
  410. },
  411. openDialog() {
  412. this.dialogTitle = '虚警抑制结果'
  413. this.dialogVisible = true
  414. },
  415. handleClose() {
  416. this.dialogVisible = false
  417. this.warningTableData = []
  418. this.currentSortieNo = ''
  419. this.form = {
  420. id: '',
  421. sortieNo: '',
  422. aircraftId: '',
  423. ossId: '',
  424. dataStatus: '',
  425. flightDate: ''
  426. }
  427. },
  428. innerDialogClose() {
  429. this.innerVisible = false
  430. this.chartData = {
  431. title: '',
  432. legendData: [],
  433. xAxisData: [],
  434. yAxisData: [],
  435. seriesData: []
  436. }
  437. this.warningForm = {
  438. id: null,
  439. resultContent: ''
  440. }
  441. this.mathParams = {
  442. code: '',
  443. sortieNo: '',
  444. beginTime: '',
  445. endTime: ''
  446. }
  447. this.mathTableData = []
  448. this.isFalseAlarm = false
  449. },
  450. submit() {
  451. this.warningForm.resultContent = this.isFalseAlarm
  452. this.updateWarningResultAPI()
  453. },
  454. async updateWarningResultAPI() {
  455. try {
  456. const { code } = await updateWarningResult({ ...this.warningForm })
  457. if (code === 200) {
  458. this.$message({
  459. type: 'success',
  460. message: '操作成功!'
  461. })
  462. this.innerDialogClose()
  463. this.getWarningResultAPI({ sortieNo: this.currentSortieNo })
  464. }
  465. } catch (error) {}
  466. },
  467. selection(val) {
  468. this.tableCheckItems = val
  469. },
  470. checkResultList(row) {
  471. this.currentSortieNo = this.form.sortieNo = row.sortieNo
  472. this.form.aircraftId = row.aircraftId
  473. this.form.flightDate = row.flightDate
  474. this.getWarningResultAPI({ sortieNo: row.sortieNo })
  475. this.openDialog()
  476. },
  477. async getWarningResultAPI(params) {
  478. if (this.$refs.warningTable) this.$refs.warningTable.clearSelection()
  479. const { pageSize, pageIndex } = this.warningTableRequset
  480. this.warningTableData = []
  481. const {
  482. data: { list, total }
  483. } = await getWarningResult({ pageSize, pageNum: pageIndex, ...params })
  484. this.warningTableData = list
  485. this.warningTableRequset.total = total
  486. },
  487. async getWarningAPI(params) {
  488. if (this.$refs.warningTable) this.$refs.warningTable.clearSelection()
  489. const { pageSize, pageIndex } = this.warningTableRequset
  490. const {
  491. data: { list, total }
  492. } = await getWarning({ pageSize, pageNum: pageIndex, ...params })
  493. this.warningTableData = list
  494. this.warningTableRequset.total = total
  495. },
  496. async checkCurve(row) {
  497. this.isFalseAlarm = row.resultContent
  498. this.warningForm = deepClone(row)
  499. this.mathParams.code = row.code
  500. this.mathParams.sortieNo = row.sortieNo
  501. try {
  502. const { code, data } = await getCurveData(row.code, row.sortieNo)
  503. if (code === 200) {
  504. if (data) {
  505. this.getExecuteMathAPI()
  506. this.getResultData(data)
  507. } else {
  508. this.$message({
  509. type: 'warning',
  510. message: '无飞参数据!'
  511. })
  512. }
  513. }
  514. } catch (error) {}
  515. },
  516. handleMathTime(time) {
  517. this.mathParams.beginTime = time[0]
  518. this.mathParams.endTime = time[1]
  519. },
  520. resetTime() {
  521. this.mathTime = this.backupsTime
  522. this.handleMathTime(this.mathTime)
  523. this.getExecuteMathAPI()
  524. },
  525. // 获取数学数据
  526. async getExecuteMathAPI() {
  527. this.mathOptions.loading = true
  528. try {
  529. const { data, code } = await executeMath(this.mathParams)
  530. if (code === 200) {
  531. this.mathTableData = []
  532. this.mathOptions.loading = false
  533. Object.keys(data).forEach((item) => {
  534. this.mathTableData.push({
  535. params: item,
  536. ...data[item]
  537. })
  538. })
  539. }
  540. } catch (error) {}
  541. },
  542. getResultData(data) {
  543. this.chartData = {
  544. title: '',
  545. legendData: [],
  546. xAxisData: [],
  547. yAxisData: [],
  548. seriesData: []
  549. }
  550. // const { contentData, headData } = this.handleResultData(JSON.parse(data))
  551. const contentData = JSON.parse(data)
  552. const headData = Object.keys(contentData)
  553. this.chartData.legendData = headData
  554. for (var key in contentData) {
  555. if (key === '时间') {
  556. const timeList = contentData['时间']
  557. const time = [timeList[0], timeList[timeList.length - 1]]
  558. this.mathTime = this.backupsTime = time
  559. this.chartData.xAxisData = timeList
  560. } else {
  561. this.chartData.seriesData.push({
  562. name: key,
  563. type: 'line',
  564. data: contentData[key],
  565. connectNulls: true
  566. })
  567. }
  568. }
  569. this.innerVisible = true
  570. },
  571. handleResultData(resultData) {
  572. const headData = Object.keys(resultData)
  573. const contentData = {}
  574. headData.forEach((headItem) => {
  575. contentData[headItem] = []
  576. })
  577. resultData.forEach((item) => {
  578. for (var key in item) {
  579. contentData[key].push(item[key])
  580. }
  581. })
  582. return { contentData, headData }
  583. },
  584. async beginExecute(row) {
  585. this.form = deepClone(row)
  586. this.progressVisible = true
  587. let myTimer = setInterval(() => {
  588. if (this.percentage < 100) {
  589. if (this.percentage === 99) {
  590. this.percentage = 99
  591. } else {
  592. this.percentage += 1
  593. }
  594. }
  595. }, 30)
  596. try {
  597. this.form.dataId = row.id
  598. const res = await executeFalseAlarm(this.form)
  599. clearInterval(myTimer)
  600. if (res?.code === 200) {
  601. this.handleClose()
  602. this.$message({
  603. type: 'success',
  604. message: '执行成功!'
  605. })
  606. // const res = await getWarningResult({ falseAlarmId: row.sortieNo })
  607. // const { data } = await getListByIdsApi(JSON.parse(res.data).ossId)
  608. // this.resultShowData.url = data[0].url
  609. this.checkResultList(row)
  610. this.dialogVisible = true
  611. this.getDataImportAPI({ aircraftId: this.aircaftModelIdList })
  612. }
  613. } catch (error) {
  614. clearInterval(myTimer)
  615. } finally {
  616. this.progressVisible = false
  617. this.percentage = 0
  618. }
  619. },
  620. handleDataZoom(val) {
  621. if (val[0] && val[0]) {
  622. this.mathTime = val
  623. } else {
  624. this.mathTime = this.backupsTime
  625. // this.getExecuteMathAPI()
  626. }
  627. this.handleMathTime(this.mathTime)
  628. this.getExecuteMathAPI()
  629. }
  630. }
  631. }
  632. </script>
  633. <style lang="scss" scoped>
  634. @import '../index.scss';
  635. .isFalseAlarm {
  636. // position: absolute;
  637. // right: 20px;
  638. margin-top: 20px;
  639. color: #fff;
  640. z-index: 9999;
  641. }
  642. .refresh {
  643. margin-left: 10px;
  644. }
  645. </style>