alarm-center-1.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. <template>
  2. <div class="alarm-center-1">
  3. <div class="action-bar">
  4. <div class="query mg-b-16">
  5. <div class="query-items">
  6. <div class="query-item">
  7. <div class="lable">风场:</div>
  8. <div class="search-input">
  9. <el-select
  10. v-model="wpvalue"
  11. clearable
  12. placeholder="请选择"
  13. popper-class="select"
  14. >
  15. <el-option
  16. v-for="item in wpoptions"
  17. :key="item.id"
  18. :label="item.name"
  19. :value="item.id"
  20. >
  21. </el-option>
  22. </el-select>
  23. </div>
  24. </div>
  25. <div class="query-item">
  26. <div class="lable">开始日期:</div>
  27. <div class="search-input">
  28. <el-date-picker
  29. v-model="startdate"
  30. type="date"
  31. placeholder="选择日期"
  32. popper-class="date-select"
  33. >
  34. </el-date-picker>
  35. </div>
  36. </div>
  37. <div class="query-item">
  38. <div class="lable">结束日期:</div>
  39. <div class="search-input">
  40. <el-date-picker
  41. v-model="enddate"
  42. type="date"
  43. placeholder="选择日期"
  44. popper-class="date-select"
  45. >
  46. </el-date-picker>
  47. </div>
  48. </div>
  49. <div class="query-item">
  50. <div class="lable">规则:</div>
  51. <el-cascader
  52. style="width: 240px"
  53. size="mini"
  54. popper-class="search-select"
  55. :options="cascaderOptions"
  56. :props="cascaderProps"
  57. v-model="cascaderSel"
  58. collapse-tags
  59. :clearable="true"
  60. ></el-cascader>
  61. </div>
  62. </div>
  63. <div class="query-actions">
  64. <button class="btn green" @click="searchData">搜索</button>
  65. <button class="btn green" @click="searchTree">筛选</button>
  66. <!-- <button class="btn green" @click="fx">分析</button> -->
  67. </div>
  68. </div>
  69. </div>
  70. <panel-3 class="table-panel">
  71. <table-3 :data="tableData" :height="'85vh'">
  72. <template v-for="(item, i) in column" :key="i" #[item]="scope">
  73. <div class="bar" @click="showChart(scope)">
  74. <div
  75. class="bar-percent"
  76. :style="{ width: scope?.data?.countStyle }"
  77. ></div>
  78. <span class="value">{{ scope?.data?.count }} 次数</span>
  79. </div>
  80. <div class="bar" @click="showChart(scope)">
  81. <div
  82. class="bar-percent"
  83. :style="{ width: scope?.data?.timeStyle }"
  84. ></div>
  85. <span class="value">{{ scope?.data?.time }} 分钟</span>
  86. </div>
  87. </template>
  88. </table-3>
  89. </panel-3>
  90. <el-dialog
  91. :title="dialogTitle"
  92. v-model="dialogVisible"
  93. width="70%"
  94. top="10vh"
  95. custom-class="modal"
  96. :close-on-click-modal="false"
  97. >
  98. <div class="searchForm">
  99. <div class="choose">
  100. <button class="btn green">等间隔</button>
  101. <!-- <button :class="chooseStatus?'btn green':'btn'" @click="switchChange(1,'original')">原始数据</button> -->
  102. </div>
  103. <el-select
  104. v-if="!chooseStatus"
  105. @change="switchChange(selectValue)"
  106. class="inputs"
  107. v-model="selectValue"
  108. placeholder="请选择"
  109. >
  110. <el-option
  111. v-for="item in timeoptions"
  112. :key="item.value"
  113. :label="item.label"
  114. :value="item.value"
  115. >
  116. </el-option>
  117. </el-select>
  118. </div>
  119. <multiple-y-line-chart-normal
  120. height="500px"
  121. :list="Analysis"
  122. :yAxises="AnalysisYAxises"
  123. :showLegend="true"
  124. />
  125. </el-dialog>
  126. <el-dialog
  127. :title="dialogTitleFX"
  128. v-model="dialogVisibleFX"
  129. width="70%"
  130. top="10vh"
  131. custom-class="modal"
  132. :close-on-click-modal="false"
  133. :destroy-on-close="true"
  134. >
  135. <FX :date="startdate" :wpid="wpvalue" />
  136. </el-dialog>
  137. </div>
  138. </template>
  139. <script>
  140. import Panel3 from "../../components/coms/panel/panel3.vue";
  141. import Table3 from "../../components/coms/table/table3.vue";
  142. import MultipleYLineChartNormal from "./multiple-y-line-chart-normal.vue";
  143. import FX from "./alarm-center-yjfx.vue";
  144. import BASE from "@tools/basicTool.js";
  145. export default {
  146. components: {
  147. Panel3,
  148. Table3,
  149. MultipleYLineChartNormal,
  150. FX,
  151. },
  152. data() {
  153. return {
  154. dialogTitleFX: "",
  155. dialogVisibleFX: false,
  156. dialogTitle: "",
  157. chooseStatus: false,
  158. dialogVisible: false,
  159. chooseTime: [],
  160. wpvalue: "",
  161. wpid: "",
  162. wtId: "",
  163. descName: "",
  164. AnalysisName: "",
  165. AnalysisUnit: "",
  166. Analysis: [
  167. {
  168. title: "",
  169. yAxisIndex: 0, // 使用单位
  170. value: [],
  171. },
  172. ],
  173. AnalysisYAxises: [
  174. {
  175. name: "",
  176. min: "",
  177. max: "",
  178. unit: "",
  179. position: "left",
  180. },
  181. {
  182. name: "",
  183. min: "",
  184. max: "",
  185. unit: "",
  186. position: "right",
  187. },
  188. ],
  189. selectValue: "60",
  190. timeoptions: [
  191. {
  192. value: "60",
  193. label: "一分钟",
  194. },
  195. {
  196. value: "300",
  197. label: "五分钟",
  198. },
  199. {
  200. value: "600",
  201. label: "十分钟",
  202. },
  203. {
  204. value: "1800",
  205. label: "三十分钟",
  206. },
  207. {
  208. value: "3600",
  209. label: "一小时",
  210. },
  211. {
  212. value: "86400",
  213. label: "一天",
  214. },
  215. ],
  216. wpoptions: "",
  217. options: [],
  218. cascaderOptions: [],
  219. cascaderSel: [],
  220. cascaderProps: {
  221. multiple: true,
  222. },
  223. column: [
  224. "风机偏航过程震动",
  225. "齿轮箱轴承温升超过40度",
  226. "三相电流不平衡",
  227. "断轴或联轴器打滑",
  228. "风速突变",
  229. ],
  230. columnObj: [
  231. {
  232. name: "风机编号",
  233. field: "name",
  234. width: "100px",
  235. minWidth: "100px",
  236. },
  237. {
  238. name: "风机偏航过程震动",
  239. field: "风机偏航过程震动",
  240. align: "left",
  241. slot: true,
  242. sortable: true,
  243. minWidth: "200px",
  244. },
  245. {
  246. name: "齿轮箱轴承温升超过40度",
  247. field: "齿轮箱轴承温升超过40度",
  248. align: "left",
  249. slot: true,
  250. sortable: true,
  251. minWidth: "200px",
  252. },
  253. {
  254. name: "三相电流不平衡",
  255. field: "三相电流不平衡",
  256. align: "left",
  257. slot: true,
  258. sortable: true,
  259. minWidth: "200px",
  260. },
  261. {
  262. name: "断轴或联轴器打滑",
  263. field: "断轴或联轴器打滑",
  264. align: "left",
  265. slot: true,
  266. sortable: true,
  267. minWidth: "200px",
  268. },
  269. {
  270. name: "风速突变",
  271. align: "left",
  272. field: "风速突变",
  273. slot: true,
  274. sortable: true,
  275. minWidth: "200px",
  276. },
  277. ],
  278. startdate: new Date(
  279. new Date(new Date().setDate(new Date().getDate() - 1))
  280. ).formatDate("yyyy-MM-dd"),
  281. enddate: new Date(new Date()).formatDate("yyyy-MM-dd"),
  282. tableData: {
  283. column: [
  284. {
  285. name: "风机编号",
  286. field: "name",
  287. },
  288. {
  289. name: "主轴温度温差大于8度",
  290. field: "v1",
  291. align: "left",
  292. slot: true,
  293. },
  294. {
  295. name: "浆叶角过小",
  296. field: "v2",
  297. align: "left",
  298. slot: true,
  299. },
  300. ],
  301. data: [
  302. {
  303. name: "MG01_01",
  304. v1: {
  305. count: 12,
  306. time: 0,
  307. },
  308. },
  309. ],
  310. },
  311. };
  312. },
  313. created() {
  314. this.$nextTick(() => {
  315. this.search();
  316. });
  317. },
  318. methods: {
  319. //对比
  320. showChart(column) {
  321. let that = this;
  322. that.dialogTitle = column.column.name + ` (${column.row.name})`;
  323. that.wtId = column.row.name;
  324. that.descName = column.column.name;
  325. that.requestDetailData(
  326. that.wpvalue,
  327. that.startdate,
  328. that.enddate,
  329. 60,
  330. column.row.name,
  331. column.column.name
  332. );
  333. },
  334. requestDetailData(station, startTs, endTs, interval, wtId, name) {
  335. let that = this;
  336. BASE.showLoading();
  337. that.API.requestData({
  338. method: "GET",
  339. subUrl: "/analysis/detail",
  340. data: {
  341. // station: that.wpvalue,
  342. // startTs: new Date(that.startdate).getTime(),
  343. // endTs: new Date(that.enddate).getTime(),
  344. // // interval: 360,
  345. // interval:1,
  346. // wtId: column.row.name,
  347. // name: column.column.name,
  348. station: station,
  349. startTs: new Date(
  350. new Date(startTs).formatDate("yyyy/MM/dd")
  351. ).getTime(),
  352. endTs: new Date(new Date(endTs).formatDate("yyyy/MM/dd")).getTime(),
  353. interval: interval,
  354. wtId: wtId,
  355. name: name,
  356. },
  357. success(res) {
  358. if (res.data.length == 1) {
  359. that.dialogVisible = true;
  360. BASE.closeLoading();
  361. let yaxises = [
  362. {
  363. name: "",
  364. min: 0,
  365. max: null,
  366. unit: "",
  367. position: "left",
  368. },
  369. ];
  370. // yaxises.name = res.data[0].name;
  371. yaxises.unit = res.data[0].unit;
  372. that.AnalysisYAxises = yaxises;
  373. let aKey1 = ["doubleValue"];
  374. let aList1 = [
  375. {
  376. title: "",
  377. // yAxisIndex:"",
  378. smooth: true,
  379. value: [],
  380. },
  381. ];
  382. aKey1.forEach((keyEle, keyIndex) => {
  383. aList1[keyIndex].title = res.data[keyIndex].name;
  384. aList1[keyIndex].yAxisIndex = keyIndex
  385. res.data[keyIndex].data.forEach((rEle) => {
  386. aList1[keyIndex].value.push({
  387. text: new Date(rEle.ts).formatDate("hh:mm"),
  388. value: rEle.doubleValue,
  389. });
  390. });
  391. });
  392. that.Analysis = aList1;
  393. } else if (res.data.length == 2) {
  394. that.dialogVisible = true;
  395. BASE.closeLoading();
  396. let aKey2 = ["doubleValue", "doubleValue"];
  397. let aList2 = [
  398. {
  399. title: "",
  400. yAxisIndex:0,
  401. smooth: true,
  402. value: [],
  403. },
  404. {
  405. title: "",
  406. yAxisIndex:1,
  407. smooth: true,
  408. value: [],
  409. },
  410. ];
  411. let yaxises1 = [
  412. {
  413. name: "",
  414. min: 0,
  415. max: null,
  416. unit: "",
  417. position: "left",
  418. },
  419. {
  420. name: "",
  421. min: 0,
  422. max: null,
  423. unit: "",
  424. position: "right",
  425. },
  426. ];
  427. res.data.forEach((aEle, keyIndex) => {
  428. // res.data.forEach((rEle) => {
  429. // yaxises1[aIndex].name = aEle.name;
  430. yaxises1[keyIndex].unit = aEle.unit;
  431. // aEle.unit = rEle.unit;
  432. // });
  433. aList2[keyIndex].title = res.data[keyIndex].name;
  434. aList2[keyIndex].yAxisIndex = keyIndex
  435. res.data[keyIndex].data.forEach((rEle) => {
  436. aList2[keyIndex].value.push({
  437. text: new Date(rEle.ts).formatDate("hh:mm"),
  438. value: rEle.doubleValue,
  439. });
  440. });
  441. });
  442. that.AnalysisYAxises = yaxises1;
  443. that.Analysis = aList2;
  444. } else if (res.data.length >=3) {
  445. that.dialogVisible = true;
  446. BASE.closeLoading();
  447. let aList4 = []
  448. let yaxises2 = []
  449. res.data.forEach((aEle, keyIndex) => {
  450. yaxises2.push( {
  451. name: "",
  452. min: 0,
  453. max: null,
  454. unit: aEle.unit,
  455. position: keyIndex %2 === 0 ? 'left' : 'right'
  456. })
  457. aList4.push({
  458. title: aEle.name,
  459. yAxisIndex: keyIndex,
  460. smooth: true,
  461. value: aEle.data.map(o => {
  462. return {
  463. text: new Date(o.ts).formatDate("hh:mm"),
  464. value: o.doubleValue,
  465. }
  466. }),
  467. })
  468. });
  469. console.log(aList4)
  470. that.AnalysisYAxises = yaxises2;
  471. that.Analysis = aList4;
  472. } else if (res.data.length == 0) {
  473. that.dialogVisible = false;
  474. BASE.closeLoading();
  475. that.BASE.showMsg({
  476. type: "warning",
  477. msg: "暂无数据",
  478. });
  479. }
  480. },
  481. });
  482. },
  483. //切换数据类型
  484. switchChange(interval, status) {
  485. if (status === "interval") {
  486. this.chooseStatus = false;
  487. this.selectValue = "60";
  488. } else if (status === "original") {
  489. this.chooseStatus = true;
  490. }
  491. this.requestDetailData(
  492. this.wpvalue,
  493. this.startdate,
  494. this.enddate,
  495. interval,
  496. this.wtId,
  497. this.descName
  498. );
  499. },
  500. async search() {
  501. const { data } = await this.API.requestData({
  502. subUrl: "powercompare/windfarmAjax",
  503. });
  504. this.wpoptions = data.data;
  505. this.wpvalue = data.data[0].id;
  506. this.searchData();
  507. },
  508. async searchTree() {
  509. let arr = [];
  510. let columnObj = [
  511. {
  512. name: "风机编号",
  513. field: "name",
  514. minWidth: "100px",
  515. },
  516. ];
  517. this.cascaderSel.forEach((e) => {
  518. let obj = {
  519. name: e[1],
  520. field: e[1],
  521. align: "left",
  522. slot: true,
  523. sortable: true,
  524. minWidth: "200px",
  525. };
  526. columnObj.push(obj);
  527. arr.push(e[1]);
  528. });
  529. this.columnObj = columnObj;
  530. this.column = arr;
  531. this.searchData();
  532. },
  533. async searchData() {
  534. let enddate = new Date(
  535. Date.parse(new Date(this.enddate)) + 24 * 3600 * 1000
  536. ).formatDate("yyyy-MM-dd");
  537. const { data } = await this.API.requestData({
  538. showLoading: true,
  539. baseURL: "http://192.168.1.82:8075/",
  540. subUrl: "alarm/count/query/new2",
  541. data: {
  542. stationid: this.wpvalue,
  543. startdate: new Date(this.startdate).formatDate("yyyy-MM-dd"),
  544. enddate: enddate,
  545. },
  546. });
  547. ////////
  548. this.tableData = [];
  549. const resData = data.data;
  550. // const resData =this.resdata;
  551. const column = this.columnObj;
  552. let dataAll = []; // 总数据集合
  553. resData.forEach((e) => {
  554. let obj = {
  555. name: Object.keys(e)[0],
  556. };
  557. let wpid = Object.keys(e)[0];
  558. this.wpid = wpid;
  559. e[wpid].forEach((k) => {
  560. column.forEach((c) => {
  561. if (k.alertText == c.name) {
  562. const countStyle = k.count / (k.count + k.time);
  563. const timeStyle = k.time / (k.count + k.time);
  564. let obj1 = {
  565. count: k.count,
  566. countStyle: countStyle ? countStyle * 100 + "px" : "0",
  567. time: k.time,
  568. timeStyle: timeStyle ? timeStyle * 100 + "px" : "0",
  569. };
  570. obj[k.alertText] = obj1;
  571. }
  572. });
  573. });
  574. dataAll.push(obj);
  575. });
  576. this.tableData.column = column;
  577. this.tableData.data = dataAll;
  578. ///////////////////// 获取规则list
  579. const map = {};
  580. var windNum = [];
  581. for (let i in resData) {
  582. for (let k in resData[i]) {
  583. map[k] = resData[i][k];
  584. }
  585. }
  586. // nmap为新的map 整理数据结构
  587. const nmap = {};
  588. for (let kv in map) {
  589. var nchildMap = {};
  590. var childrenMap = map[kv];
  591. for (var ckv in childrenMap) {
  592. var cckey = childrenMap[ckv].alertText;
  593. var ccvalue = childrenMap[ckv];
  594. nchildMap[cckey] = ccvalue;
  595. }
  596. nmap[kv] = nchildMap;
  597. }
  598. windNum = Object.keys(nmap);
  599. var cascaderOptions = [];
  600. var root = {}; // 原始根节点
  601. var clumnsOnes = nmap[windNum[0]];
  602. for (let k in clumnsOnes) {
  603. let f = clumnsOnes[k].relatePartsText
  604. ? clumnsOnes[k].relatePartsText
  605. : "其他";
  606. let fvalue = clumnsOnes[k].relateParts ? clumnsOnes[k].relateParts : "";
  607. if (root[f]) {
  608. // 已经存在此子节点
  609. if (!root[f].children[k]) {
  610. // 不存在子节点
  611. root[f].children[k] = {};
  612. root[f].children[k].value = root[f].children[k].label = k;
  613. root[f].fobj.children.push(root[f].children[k]);
  614. }
  615. } else {
  616. // 不存在子节点
  617. root[f] = {};
  618. // root[f].value = fvalue;
  619. // root[f].label = f;
  620. root[f].children = {};
  621. root[f].children[k] = {};
  622. root[f].children[k].value = root[f].children[k].label = k;
  623. // 将对象放入 cascaderOptions
  624. let childrenArray = [];
  625. childrenArray.push(root[f].children[k]);
  626. let fobj = {};
  627. fobj.value = fvalue;
  628. fobj.label = f;
  629. fobj.children = childrenArray;
  630. cascaderOptions.push(fobj);
  631. root[f].fobj = fobj;
  632. }
  633. }
  634. this.cascaderOptions = cascaderOptions;
  635. },
  636. fx() {
  637. this.startdate = new Date(this.startdate).formatDate("yyyy-MM-dd");
  638. this.dialogTitleFX = "预警分析";
  639. this.dialogVisibleFX = true;
  640. },
  641. },
  642. };
  643. </script>
  644. <style lang="less">
  645. .alarm-center-1 {
  646. .action-bar {
  647. display: flex;
  648. .query {
  649. justify-content: flex-start;
  650. }
  651. }
  652. .table-panel {
  653. width: 100%;
  654. background: transparent;
  655. padding: 0;
  656. .bar {
  657. display: flex;
  658. align-items: center;
  659. height: 16px;
  660. margin: 8px 0;
  661. .bar-percent {
  662. height: 100%;
  663. background: @green;
  664. margin-right: 8px;
  665. }
  666. }
  667. }
  668. .searchForm {
  669. display: flex;
  670. margin-left: 36px;
  671. flex-direction: row-reverse;
  672. .inputs {
  673. width: 15%;
  674. margin-right: 18px;
  675. }
  676. }
  677. }
  678. </style>