alarm-center-1.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  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. res.data[keyIndex].data.forEach((rEle) => {
  385. aList1[keyIndex].value.push({
  386. text: new Date(rEle.ts).formatDate("hh:mm"),
  387. value: rEle.doubleValue,
  388. });
  389. });
  390. });
  391. that.Analysis = aList1;
  392. } else if (res.data.length == 2) {
  393. that.dialogVisible = true;
  394. BASE.closeLoading();
  395. let aKey2 = ["doubleValue", "doubleValue"];
  396. let aList2 = [
  397. {
  398. title: "",
  399. // yAxisIndex:"",
  400. smooth: true,
  401. value: [],
  402. },
  403. {
  404. title: "",
  405. // yAxisIndex:"",
  406. smooth: true,
  407. value: [],
  408. },
  409. ];
  410. let yaxises1 = [
  411. {
  412. name: "",
  413. min: 0,
  414. max: null,
  415. unit: "",
  416. position: "left",
  417. },
  418. {
  419. name: "",
  420. min: 0,
  421. max: null,
  422. unit: "",
  423. position: "right",
  424. },
  425. ];
  426. yaxises1.forEach((aEle, aIndex) => {
  427. res.data.forEach((rEle) => {
  428. // aEle.name = rEle.name;
  429. aEle.unit = rEle.unit;
  430. });
  431. });
  432. that.AnalysisYAxises = yaxises1;
  433. aKey2.forEach((keyEle, keyIndex) => {
  434. aList2[keyIndex].title = res.data[keyIndex].name;
  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. // res.data.forEach((rEle,rIndex)=>{
  443. // })
  444. // aKey2.forEach((keyEle, keyIndex) => {
  445. // res.data.forEach((rEle) => {
  446. // // alist2[keyIndex].yAxisIndex = keyIndex;
  447. // aList2[keyIndex].title = res.data[keyIndex].name;
  448. // rEle.data.forEach((tEle,tIndex) => {
  449. // aList2[keyIndex].value.push({
  450. // text: new Date(tEle.ts).formatDate("hh:mm"),
  451. // // value: tEle[keyEle],
  452. // // value:res.data[keyIndex].data[tIndex].doubleValue
  453. // });
  454. // });
  455. // });
  456. // });
  457. that.Analysis = aList2;
  458. } else if (res.data.length >=3) {
  459. that.dialogVisible = true;
  460. BASE.closeLoading();
  461. let aList4 = []
  462. let yaxises2 = [
  463. {
  464. name: "",
  465. min: 0,
  466. max: null,
  467. unit: '',
  468. position: 'left'
  469. },
  470. {
  471. name: "",
  472. min: 0,
  473. max: null,
  474. unit: '',
  475. position: 'right'
  476. }
  477. ]
  478. res.data.forEach((aEle, keyIndex) => {
  479. yaxises2[0].unit = aEle.unit
  480. yaxises2[1].unit = aEle.unit
  481. aList4.push({
  482. title: aEle.name,
  483. yAxisIndex: 0,
  484. smooth: true,
  485. value: aEle.data.map(o => {
  486. return {
  487. text: new Date(o.ts).formatDate("hh:mm"),
  488. value: o.doubleValue,
  489. }
  490. }),
  491. })
  492. });
  493. that.AnalysisYAxises = yaxises2;
  494. that.Analysis = aList4;
  495. } else if (res.data.length == 0) {
  496. that.dialogVisible = false;
  497. BASE.closeLoading();
  498. that.BASE.showMsg({
  499. type: "warning",
  500. msg: "暂无数据",
  501. });
  502. }
  503. },
  504. });
  505. },
  506. //切换数据类型
  507. switchChange(interval, status) {
  508. if (status === "interval") {
  509. this.chooseStatus = false;
  510. this.selectValue = "60";
  511. } else if (status === "original") {
  512. this.chooseStatus = true;
  513. }
  514. this.requestDetailData(
  515. this.wpvalue,
  516. this.startdate,
  517. this.enddate,
  518. interval,
  519. this.wtId,
  520. this.descName
  521. );
  522. },
  523. async search() {
  524. const { data } = await this.API.requestData({
  525. subUrl: "powercompare/windfarmAjax",
  526. });
  527. this.wpoptions = data.data;
  528. this.wpvalue = data.data[0].id;
  529. this.searchData();
  530. },
  531. async searchTree() {
  532. let arr = [];
  533. let columnObj = [
  534. {
  535. name: "风机编号",
  536. field: "name",
  537. minWidth: "100px",
  538. },
  539. ];
  540. this.cascaderSel.forEach((e) => {
  541. let obj = {
  542. name: e[1],
  543. field: e[1],
  544. align: "left",
  545. slot: true,
  546. sortable: true,
  547. minWidth: "200px",
  548. };
  549. columnObj.push(obj);
  550. arr.push(e[1]);
  551. });
  552. this.columnObj = columnObj;
  553. this.column = arr;
  554. this.searchData();
  555. },
  556. async searchData() {
  557. let enddate = new Date(
  558. Date.parse(new Date(this.enddate)) + 24 * 3600 * 1000
  559. ).formatDate("yyyy-MM-dd");
  560. const { data } = await this.API.requestData({
  561. showLoading: true,
  562. baseURL: "http://192.168.1.18:8075/",
  563. subUrl: "alarm/count/query/new2",
  564. data: {
  565. stationid: this.wpvalue,
  566. startdate: new Date(this.startdate).formatDate("yyyy-MM-dd"),
  567. enddate: enddate,
  568. },
  569. });
  570. ////////
  571. this.tableData = [];
  572. const resData = data.data;
  573. // const resData =this.resdata;
  574. const column = this.columnObj;
  575. let dataAll = []; // 总数据集合
  576. resData.forEach((e) => {
  577. let obj = {
  578. name: Object.keys(e)[0],
  579. };
  580. let wpid = Object.keys(e)[0];
  581. this.wpid = wpid;
  582. e[wpid].forEach((k) => {
  583. column.forEach((c) => {
  584. if (k.alertText == c.name) {
  585. const countStyle = k.count / (k.count + k.time);
  586. const timeStyle = k.time / (k.count + k.time);
  587. let obj1 = {
  588. count: k.count,
  589. countStyle: countStyle ? countStyle * 100 + "px" : "0",
  590. time: k.time,
  591. timeStyle: timeStyle ? timeStyle * 100 + "px" : "0",
  592. };
  593. obj[k.alertText] = obj1;
  594. }
  595. });
  596. });
  597. dataAll.push(obj);
  598. });
  599. this.tableData.column = column;
  600. this.tableData.data = dataAll;
  601. ///////////////////// 获取规则list
  602. const map = {};
  603. var windNum = [];
  604. for (let i in resData) {
  605. for (let k in resData[i]) {
  606. map[k] = resData[i][k];
  607. }
  608. }
  609. // nmap为新的map 整理数据结构
  610. const nmap = {};
  611. for (let kv in map) {
  612. var nchildMap = {};
  613. var childrenMap = map[kv];
  614. for (var ckv in childrenMap) {
  615. var cckey = childrenMap[ckv].alertText;
  616. var ccvalue = childrenMap[ckv];
  617. nchildMap[cckey] = ccvalue;
  618. }
  619. nmap[kv] = nchildMap;
  620. }
  621. windNum = Object.keys(nmap);
  622. var cascaderOptions = [];
  623. var root = {}; // 原始根节点
  624. var clumnsOnes = nmap[windNum[0]];
  625. for (let k in clumnsOnes) {
  626. let f = clumnsOnes[k].relatePartsText
  627. ? clumnsOnes[k].relatePartsText
  628. : "其他";
  629. let fvalue = clumnsOnes[k].relateParts ? clumnsOnes[k].relateParts : "";
  630. if (root[f]) {
  631. // 已经存在此子节点
  632. if (!root[f].children[k]) {
  633. // 不存在子节点
  634. root[f].children[k] = {};
  635. root[f].children[k].value = root[f].children[k].label = k;
  636. root[f].fobj.children.push(root[f].children[k]);
  637. }
  638. } else {
  639. // 不存在子节点
  640. root[f] = {};
  641. // root[f].value = fvalue;
  642. // root[f].label = f;
  643. root[f].children = {};
  644. root[f].children[k] = {};
  645. root[f].children[k].value = root[f].children[k].label = k;
  646. // 将对象放入 cascaderOptions
  647. let childrenArray = [];
  648. childrenArray.push(root[f].children[k]);
  649. let fobj = {};
  650. fobj.value = fvalue;
  651. fobj.label = f;
  652. fobj.children = childrenArray;
  653. cascaderOptions.push(fobj);
  654. root[f].fobj = fobj;
  655. }
  656. }
  657. this.cascaderOptions = cascaderOptions;
  658. },
  659. fx() {
  660. this.startdate = new Date(this.startdate).formatDate("yyyy-MM-dd");
  661. this.dialogTitleFX = "预警分析";
  662. this.dialogVisibleFX = true;
  663. },
  664. },
  665. };
  666. </script>
  667. <style lang="less">
  668. .alarm-center-1 {
  669. .action-bar {
  670. display: flex;
  671. .query {
  672. justify-content: flex-start;
  673. }
  674. }
  675. .table-panel {
  676. width: 100%;
  677. background: transparent;
  678. padding: 0;
  679. .bar {
  680. display: flex;
  681. align-items: center;
  682. height: 16px;
  683. margin: 8px 0;
  684. .bar-percent {
  685. height: 100%;
  686. background: @green;
  687. margin-right: 8px;
  688. }
  689. }
  690. }
  691. .searchForm {
  692. display: flex;
  693. margin-left: 36px;
  694. flex-direction: row-reverse;
  695. .inputs {
  696. width: 15%;
  697. margin-right: 18px;
  698. }
  699. }
  700. }
  701. </style>