index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  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. timeFlag: null,
  312. timeFlagPos: null,
  313. form: {
  314. id: '',
  315. sortieNo: '',
  316. aircraftId: '',
  317. ossId: '',
  318. dataStatus: '',
  319. flightDate: ''
  320. },
  321. warningForm: {
  322. id: null,
  323. resultContent: ''
  324. },
  325. isFalseAlarm: '0',
  326. currentSortieNo: '',
  327. percentage: 0,
  328. mathTime: [],
  329. mathParams: {
  330. code: '',
  331. sortieNo: '',
  332. beginTime: '',
  333. endTime: ''
  334. },
  335. backupsTime: []
  336. // startTime:'',
  337. // endTime:'',
  338. }
  339. },
  340. watch: {
  341. keyWord() {
  342. this.tableRequset.pageIndex = 1
  343. this.debounceFn()
  344. }
  345. },
  346. mounted() {
  347. this.getAircaftCatalogTreeAPI()
  348. },
  349. methods: {
  350. async getAircaftCatalogTreeAPI(params) {
  351. try {
  352. const { data } = await getAircaftCatalogTree(params)
  353. this.menuTreeData = data
  354. const getAircaftCatalogAllParams = {
  355. keyWord: '',
  356. aircaftModelIdList: []
  357. }
  358. const { data: data2 } = await getAircaftCatalogAll(getAircaftCatalogAllParams)
  359. this.aircaftCatalogAll = data2
  360. if (data.length) {
  361. this.currentNodeKey = data[0].id
  362. this.currentNode = data[0]
  363. this.aircaftModelIdList = this.getTreeLeafData(data[0]?.children)
  364. .map((e) => e.id)
  365. .toString()
  366. this.getDataImportAPI({ aircraftId: this.aircaftModelIdList })
  367. }
  368. } catch (error) {}
  369. },
  370. getTreeLeafData(list) {
  371. const newArr = []
  372. function getLeaf(data, arr) {
  373. data.forEach((e) => {
  374. if (e.type === 2) {
  375. arr.push(e)
  376. }
  377. if (e.children.length) {
  378. getLeaf(e.children, arr)
  379. }
  380. })
  381. }
  382. getLeaf(list, newArr)
  383. return newArr
  384. },
  385. async getDataImportAPI(params) {
  386. if (this.$refs.table) this.$refs.table.clearSelection()
  387. const { keyWord } = this
  388. const { pageSize, pageIndex } = this.tableRequset
  389. const {
  390. data: { list, total }
  391. } = await getDataImport({ pageSize, pageNum: pageIndex, ...params, source: 1 })
  392. this.tableData = list
  393. this.tableRequset.total = total
  394. },
  395. fetch() {
  396. this.getDataImportAPI({ aircraftId: this.aircaftModelIdList })
  397. },
  398. async searchClick() {
  399. this.getDataImportAPI({ aircraftId: this.aircaftModelIdList, sortieNo: this.keyWordData })
  400. },
  401. treeNodeClick(data) {
  402. this.$refs.table.clearSelection()
  403. this.currentNodeKey = data.id
  404. this.currentNode = data
  405. this.aircaftModelIdList = this.getTreeLeafData(data.children.length ? data.children : [data])
  406. .map((e) => e.id)
  407. .toString()
  408. if (!this.aircaftModelIdList) {
  409. this.aircaftModelIdList = '#'
  410. }
  411. this.getDataImportAPI({ aircraftId: this.aircaftModelIdList })
  412. },
  413. openDialog() {
  414. this.dialogTitle = '虚警抑制结果'
  415. this.dialogVisible = true
  416. },
  417. handleClose() {
  418. this.dialogVisible = false
  419. this.warningTableData = []
  420. this.currentSortieNo = ''
  421. this.form = {
  422. id: '',
  423. sortieNo: '',
  424. aircraftId: '',
  425. ossId: '',
  426. dataStatus: '',
  427. flightDate: ''
  428. }
  429. },
  430. innerDialogClose() {
  431. this.innerVisible = false
  432. this.chartData = {
  433. title: '',
  434. legendData: [],
  435. xAxisData: [],
  436. yAxisData: [],
  437. seriesData: []
  438. }
  439. this.warningForm = {
  440. id: null,
  441. resultContent: ''
  442. }
  443. this.mathParams = {
  444. code: '',
  445. sortieNo: '',
  446. beginTime: '',
  447. endTime: ''
  448. }
  449. this.mathTableData = []
  450. this.isFalseAlarm = false
  451. },
  452. submit() {
  453. this.warningForm.resultContent = this.isFalseAlarm
  454. this.updateWarningResultAPI()
  455. },
  456. async updateWarningResultAPI() {
  457. try {
  458. const { code } = await updateWarningResult({ ...this.warningForm })
  459. if (code === 200) {
  460. this.$message({
  461. type: 'success',
  462. message: '操作成功!'
  463. })
  464. this.innerDialogClose()
  465. this.getWarningResultAPI({ sortieNo: this.currentSortieNo })
  466. }
  467. } catch (error) {}
  468. },
  469. selection(val) {
  470. this.tableCheckItems = val
  471. },
  472. checkResultList(row) {
  473. this.currentSortieNo = this.form.sortieNo = row.sortieNo
  474. this.form.aircraftId = row.aircraftId
  475. this.form.flightDate = row.flightDate
  476. this.getWarningResultAPI({ sortieNo: row.sortieNo })
  477. this.openDialog()
  478. },
  479. async getWarningResultAPI(params) {
  480. if (this.$refs.warningTable) this.$refs.warningTable.clearSelection()
  481. const { pageSize, pageIndex } = this.warningTableRequset
  482. this.warningTableData = []
  483. const {
  484. data: { list, total }
  485. } = await getWarningResult({ pageSize, pageNum: pageIndex, ...params })
  486. this.warningTableData = list
  487. this.warningTableRequset.total = total
  488. },
  489. async getWarningAPI(params) {
  490. if (this.$refs.warningTable) this.$refs.warningTable.clearSelection()
  491. const { pageSize, pageIndex } = this.warningTableRequset
  492. const {
  493. data: { list, total }
  494. } = await getWarning({ pageSize, pageNum: pageIndex, ...params })
  495. this.warningTableData = list
  496. this.warningTableRequset.total = total
  497. },
  498. async checkCurve(row) {
  499. this.isFalseAlarm = row.resultContent
  500. this.warningForm = deepClone(row)
  501. this.mathParams.code = row.code
  502. this.mathParams.sortieNo = row.sortieNo
  503. this.timeFlag = row.attribute2
  504. try {
  505. const { code, data } = await getCurveData(row.code, row.sortieNo)
  506. if (code === 200) {
  507. if (data) {
  508. this.getExecuteMathAPI()
  509. this.getResultData(data)
  510. } else {
  511. this.$message({
  512. type: 'warning',
  513. message: '无飞参数据!'
  514. })
  515. }
  516. }
  517. } catch (error) {}
  518. },
  519. handleMathTime(time) {
  520. this.mathParams.beginTime = time[0]
  521. this.mathParams.endTime = time[1]
  522. },
  523. resetTime() {
  524. // chart.dispatchAction({
  525. // type: 'dataZoom',
  526. // start: 0, // 起始位置
  527. // end: 100, // 终止位置
  528. // });
  529. this.mathTime = this.backupsTime
  530. this.handleMathTime(this.mathTime)
  531. this.getExecuteMathAPI()
  532. },
  533. // 获取数学数据
  534. async getExecuteMathAPI() {
  535. this.mathOptions.loading = true
  536. try {
  537. const { data, code } = await executeMath(this.mathParams)
  538. if (code === 200) {
  539. this.mathTableData = []
  540. this.mathOptions.loading = false
  541. Object.keys(data).forEach((item) => {
  542. this.mathTableData.push({
  543. params: item,
  544. ...data[item]
  545. })
  546. })
  547. }
  548. } catch (error) {}
  549. },
  550. getResultData(data) {
  551. this.chartData = {
  552. title: '',
  553. legendData: [],
  554. xAxisData: [],
  555. yAxisData: [],
  556. seriesData: []
  557. }
  558. // const { contentData, headData } = this.handleResultData(JSON.parse(data))
  559. const contentData = JSON.parse(data)
  560. const headData = Object.keys(contentData)
  561. this.chartData.legendData = headData
  562. const timeList = contentData['时间']
  563. this.timeFlagPos = timeList.findIndex((item) => {
  564. return item == this.timeFlag
  565. })
  566. for (var key in contentData) {
  567. if (key === '时间') {
  568. const time = [timeList[0], timeList[timeList.length - 1]]
  569. this.mathTime = this.backupsTime = time
  570. this.chartData.xAxisData = timeList
  571. } else {
  572. this.chartData.seriesData.push({
  573. name: key,
  574. type: 'line',
  575. markLine: {
  576. symbol: 'none',
  577. data: [{ xAxis: this.timeFlagPos }],
  578. lineStyle: {
  579. color: '#f00'
  580. },
  581. label: {
  582. formatter: this.timeFlag,
  583. color: '#f00'
  584. }
  585. },
  586. data: contentData[key],
  587. connectNulls: true
  588. })
  589. }
  590. }
  591. this.innerVisible = true
  592. },
  593. handleResultData(resultData) {
  594. const headData = Object.keys(resultData)
  595. const contentData = {}
  596. headData.forEach((headItem) => {
  597. contentData[headItem] = []
  598. })
  599. resultData.forEach((item) => {
  600. for (var key in item) {
  601. contentData[key].push(item[key])
  602. }
  603. })
  604. return { contentData, headData }
  605. },
  606. async beginExecute(row) {
  607. this.form = deepClone(row)
  608. this.progressVisible = true
  609. let myTimer = setInterval(() => {
  610. if (this.percentage < 100) {
  611. if (this.percentage === 99) {
  612. this.percentage = 99
  613. } else {
  614. this.percentage += 1
  615. }
  616. }
  617. }, 30)
  618. try {
  619. this.form.dataId = row.id
  620. const res = await executeFalseAlarm(this.form)
  621. clearInterval(myTimer)
  622. if (res?.code === 200) {
  623. this.handleClose()
  624. this.$message({
  625. type: 'success',
  626. message: '执行成功!'
  627. })
  628. // const res = await getWarningResult({ falseAlarmId: row.sortieNo })
  629. // const { data } = await getListByIdsApi(JSON.parse(res.data).ossId)
  630. // this.resultShowData.url = data[0].url
  631. this.checkResultList(row)
  632. this.dialogVisible = true
  633. this.getDataImportAPI({ aircraftId: this.aircaftModelIdList })
  634. }
  635. } catch (error) {
  636. clearInterval(myTimer)
  637. } finally {
  638. this.progressVisible = false
  639. this.percentage = 0
  640. }
  641. },
  642. handleDataZoom(val) {
  643. if (val[0] && val[0]) {
  644. this.mathTime = val
  645. } else {
  646. this.mathTime = this.backupsTime
  647. // this.getExecuteMathAPI()
  648. }
  649. this.handleMathTime(this.mathTime)
  650. this.getExecuteMathAPI()
  651. }
  652. }
  653. }
  654. </script>
  655. <style lang="scss" scoped>
  656. @import '../index.scss';
  657. .isFalseAlarm {
  658. // position: absolute;
  659. // right: 20px;
  660. margin-top: 20px;
  661. color: #fff;
  662. z-index: 9999;
  663. }
  664. .refresh {
  665. margin-left: 10px;
  666. }
  667. </style>