diagnose.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <div>
  3. <div class="query mg-b-8">
  4. <div class="query-items">
  5. <div class="query-item">
  6. <div class="lable">场站:</div>
  7. <div class="search-input">
  8. <el-select v-model="station" placeholder="请选择" popper-class="select" @change="stationChange">
  9. <el-option v-for="item in stations" :key="item.id" :value="item.id" :label="item.name">
  10. </el-option>
  11. </el-select>
  12. </div>
  13. </div>
  14. <div class="query-item">
  15. <div class="lable">日期:</div>
  16. <div class="search-input">
  17. <el-date-picker v-model="date" type="datetimerange" range-separator="至" start-placeholder="开始日期"
  18. end-placeholder="结束日期">
  19. </el-date-picker>
  20. </div>
  21. </div>
  22. <div class="query-item">
  23. <div class="lable">风机:</div>
  24. <div class="search-input">
  25. <el-select v-model="fj" collapse-tags placeholder="请选择" popper-class="select">
  26. <el-option v-for="item in fjArr" :key="item.id" :value="item.id" :label="item.name">
  27. </el-option>
  28. </el-select>
  29. </div>
  30. </div>
  31. <div class="query-item">
  32. <div class="lable">风机型号:</div>
  33. <div class="lable">
  34. {{modelid}}
  35. </div>
  36. </div>
  37. <div class="query-actions">
  38. <button class="btn green" @click="query(false)">查询</button>
  39. <button class="btn green" @click="reset">实时更新</button>
  40. </div>
  41. </div>
  42. </div>
  43. <el-row type="flex">
  44. <el-col :span="12">
  45. <el-row type="flex">
  46. <el-col :span="12">
  47. <panel title="残差 【模型记录】" :showLine="false">
  48. <div class="timeLine">
  49. <div class="body" v-for="(item, index) in ccS" :key="index">
  50. <div class="left">
  51. <div class="round_on"></div>
  52. <div class="line"></div>
  53. </div>
  54. <div class="right">
  55. <div>{{ item.time }}</div>
  56. <div class="content">
  57. <div class="names">
  58. {{ item.faultIds }}
  59. </div>
  60. <button class="btn" @click="deleteDate(item.name)">
  61. 删除
  62. </button>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </panel>
  68. </el-col>
  69. <el-col :span="12">
  70. <panel title="油温 【模型记录】" :showLine="false">
  71. <div class="timeLine">
  72. <div class="body" v-for="(item, index) in ywS" :key="index">
  73. <div class="left">
  74. <div class="round_on"></div>
  75. <div class="line"></div>
  76. </div>
  77. <div class="right">
  78. <div>{{ item.time }}</div>
  79. <div class="content">
  80. <div class="names">
  81. {{ item.faultIds }}
  82. </div>
  83. <button class="btn" @click="deleteDate(item.name)">
  84. 删除
  85. </button>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </panel>
  91. </el-col>
  92. </el-row>
  93. </el-col>
  94. <el-col :span="12">
  95. <panel title="残差 【预测记录】" :showLine="false">
  96. <double-line-chart height="25vh" :list='ccChart' />
  97. <double-line-chart height="20vh" :list='ccLineChart' />
  98. <div class="green text">
  99. 依据当前的模型,{{forekonw?'油温误差大于0.1,预计在'+forekonw+',齿轮箱会发生油温异常':'没有油温误差大于0.1的齿轮箱油温异常'}}。
  100. </div>
  101. </panel>
  102. <panel title="油温 【预测记录】" :showLine="false">
  103. <double-line-chart height="25vh" :list='ywChart' />
  104. <div class="green text">
  105. 预计未来10分钟的油温走势,当前时间为{{new Date(endTs).formatDate("yyyy-MM-dd hh:mm")}},当前油温: {{ywChartHtml[0]}}
  106. ℃,未来10分钟油温:{{ywChartHtml[1]}} ℃ 。
  107. </div>
  108. </panel>
  109. </el-col>
  110. </el-row>
  111. </div>
  112. </template>
  113. <script>
  114. import Panel from "@/components/coms/panel/panel.vue";
  115. import DoubleLineChart from "@/components/chart/line/double-line-chart.vue";
  116. import axios from "axios";
  117. export default {
  118. components: {
  119. Panel,
  120. DoubleLineChart
  121. },
  122. data() {
  123. return {
  124. stations: [],
  125. station: '',
  126. model: [],
  127. fjArr: [], //风机
  128. fj: '',
  129. ywChart: [{
  130. title: "实时油温",
  131. smooth: true,
  132. value: []
  133. }, {
  134. title: "未来10分钟油温",
  135. smooth: true,
  136. value: []
  137. }],
  138. ywChartHtml: [],
  139. ccChart: [{
  140. title: "实时油温",
  141. smooth: true,
  142. value: []
  143. }, {
  144. title: "理论油温",
  145. smooth: true,
  146. value: []
  147. }],
  148. ccLineChart:[{
  149. title: "油温残差",
  150. smooth: true,
  151. value: []
  152. }],
  153. startTs: '',
  154. endTs: '',
  155. date: [],
  156. uniformCodes: ['CI0671', 'AI041','YWCH','LLYW'],
  157. interval: null,
  158. flag: 1,
  159. ccS: [],
  160. ywS: [],
  161. modelid:'',
  162. forekonw:0
  163. };
  164. },
  165. created() {
  166. this.resetDate();
  167. this.startAjax();
  168. },
  169. methods: {
  170. resetDate(){//重置时间
  171. let end = new Date().valueOf();
  172. this.startTs = new Date(new Date().getTime() - (3600 * 1000 * 2)).valueOf();
  173. this.endTs = end;
  174. this.date = [this.startTs, this.endTs];
  175. },
  176. async history(thingId, uniformCode) { //油温chart历史
  177. let that = this;
  178. let items = [];
  179. const {
  180. data
  181. } = await axios.get(
  182. `http://192.168.10.18:8011/ts/history/snap?thingType=windturbine&uniformCode=${uniformCode}&thingId=${thingId}&startTs=${that.startTs}&endTs=${that.endTs}&interval=60`
  183. );
  184. data.forEach(ele => {
  185. items.push({
  186. text: new Date(ele.ts).formatDate("yyyy-MM-dd hh:mm"),
  187. value: ele.value.toFixed(2)
  188. })
  189. })
  190. if (uniformCode === 'AI041') {
  191. that.ywChart[0].value = items;
  192. that.ccChart[0].value = items;
  193. }
  194. if (uniformCode === 'CI0671') {
  195. that.ywChart[1].value = items;
  196. }
  197. if (uniformCode === 'YWCH') {
  198. that.ccLineChart[0].value = items;
  199. if(items.pop().value >= 0.1){
  200. that.forekonw = item.value;
  201. }
  202. }
  203. if (uniformCode === 'LLYW') {
  204. that.ccChart[1].value = items;
  205. }
  206. },
  207. async list(thingId) { //一分钟一次
  208. let that = this;
  209. const {
  210. data
  211. } = await axios.get(
  212. `http://192.168.10.18:8011/ts/latest?thingType=windturbine&uniformCodes=YWCH,CI0671,LLYW,AI041&thingId=${thingId}`
  213. );
  214. let AI041 = {
  215. text: new Date(data.AI041.ts).formatDate("yyyy-MM-dd hh:mm"),
  216. value: data.AI041.value.toFixed(2)
  217. }
  218. that.ywChart[0].value.push(AI041)
  219. that.ywChart[1].value.push({
  220. text: new Date(data.CI0671.ts).formatDate("yyyy-MM-dd hh:mm"),
  221. value: data.CI0671.value.toFixed(2)
  222. })
  223. that.ywChartHtml = [data.AI041.value.toFixed(2), data.CI0671.value.toFixed(2)];
  224. that.ccChart[0].value.push(AI041);
  225. },
  226. async startAjax() { //场站
  227. var that = this;
  228. await that.API.requestData({
  229. method: "GET",
  230. baseURL: "http://192.168.1.18:9002/",
  231. subUrl: "basic/station/all",
  232. success(res) {
  233. that.stations = res.data;
  234. that.station = res.data[1].id;
  235. },
  236. });
  237. },
  238. query(a) {
  239. this.ywYc(a);
  240. this.mxjl();
  241. },
  242. reset(){
  243. this.resetDate();
  244. this.query(true);//传个true,重置,开启每秒执行,else停
  245. },
  246. ywYc(a) { //油温预测记录
  247. this.ccChart[0].value = [];
  248. this.ccChart[1].value = [];
  249. this.ccLineChart[0].value = [];
  250. this.ywChart[0].value = [];
  251. this.ywChart[1].value = [];
  252. this.stopInterval();
  253. this.uniformCodes.forEach(ele => {
  254. this.history(this.fj, ele);
  255. })
  256. this.list(this.fj);
  257. if(a){//实时更新
  258. this.interval = setInterval(() => {
  259. this.uniformCodes.forEach(ele => {
  260. this.history(this.fj, ele);
  261. })
  262. this.list(this.fj)
  263. }, 60000);
  264. }
  265. },
  266. mxjl() { //模型记录
  267. let that = this;
  268. that.API.requestData({ //风机
  269. method: "GET",
  270. baseURL: "http://10.155.32.14:9002/",
  271. subUrl: "api/gearbox-diagnosis/history",
  272. success(res) {
  273. let cc = [],
  274. yw = [];
  275. res.forEach(ele => {
  276. let data = {
  277. name: ele.name,
  278. time: ele.name.split('_')[1],
  279. faultIds: ele.faultIds ? ele.faultIds : '暂无数据'
  280. };
  281. ele.name.split('_')[0] === '残差' ? cc.push(data) : yw.push(data);
  282. })
  283. that.ccS = cc;
  284. that.ywS = yw;
  285. },
  286. });
  287. },
  288. deleteDate(val) {
  289. let that = this;
  290. that.API.requestData({
  291. method: "GET",
  292. baseURL: "http://10.155.32.14:9002/",
  293. subUrl: "api/gearbox-diagnosis/history/remove",
  294. data: {
  295. names: val,
  296. },
  297. success(res) {
  298. if (res == 'success') {
  299. that.mxjl();
  300. that.BASE.showMsg({
  301. type: "success",
  302. msg: '已删除'
  303. });
  304. }
  305. },
  306. });
  307. },
  308. stopInterval(){
  309. clearInterval(this.interval);
  310. this.interval = null;
  311. }
  312. },
  313. unmounted() {
  314. this.stopInterval();
  315. },
  316. watch: {
  317. // YWCH 油温残差
  318. // LLYW 理论油温
  319. // CI0671 未来10分钟油温
  320. // AI041 实时油温
  321. station(e) {
  322. let that = this;
  323. that.API.requestData({ //风机
  324. method: "GET",
  325. baseURL: "http://10.155.32.4:9001/",
  326. subUrl: "benchmarking/wtList",
  327. data: {
  328. wpid: e,
  329. },
  330. success(res) {
  331. that.fjArr = res.data;
  332. that.fj = res.data[0].id;
  333. if (that.flag === 1) {
  334. that.query(true);
  335. }
  336. that.flag = 2;
  337. },
  338. });
  339. },
  340. date(e) {
  341. this.startTs = e[0].valueOf();
  342. this.endTs = e[1].valueOf();
  343. },
  344. fj(e){
  345. let that = this;
  346. that.API.requestData({ //风机型号
  347. method: "GET",
  348. subUrl: "windturbine/getWindturbine",
  349. data: {
  350. windturbineid: e,
  351. },
  352. success(res) {
  353. that.modelid = res.data.modelid;
  354. }
  355. });
  356. }
  357. }
  358. };
  359. </script>
  360. <style lang="less" scoped>
  361. .body {
  362. display: flex;
  363. flex-direction: row;
  364. height: 75px;
  365. width: 100%;
  366. .left {
  367. display: flex;
  368. flex-direction: column;
  369. justify-content: center;
  370. align-items: center;
  371. width: 30px;
  372. margin-left: 30px;
  373. .round_on {
  374. width: 20px;
  375. height: 27px;
  376. border-radius: 50%;
  377. background-color: rgb(30, 209, 45);
  378. }
  379. .round {
  380. width: 20px;
  381. height: 27px;
  382. border-radius: 50%;
  383. background-color: crimson;
  384. }
  385. .line {
  386. width: 2px;
  387. height: 100%;
  388. background-color: #ffffff;
  389. }
  390. }
  391. .right {
  392. width: 100%;
  393. margin-left: 20px;
  394. .content {
  395. display: flex;
  396. flex-direction: row;
  397. justify-content: space-between;
  398. align-items: center;
  399. margin-top: 10px;
  400. .btn {
  401. margin-right: 20px;
  402. }
  403. }
  404. }
  405. }
  406. .timeLine {
  407. height: 80vh;
  408. overflow-y: auto;
  409. margin-top: 30px;
  410. }
  411. .text {
  412. font-size: 2vh;
  413. margin: 1vh 0;
  414. }
  415. </style>
  416. <style lang="less">
  417. .el-date-editor--daterange {
  418. border: 1px solid rgba(96, 103, 105, 0.2);
  419. height: 33px;
  420. width: 100% !important;
  421. input {
  422. background-color: transparent;
  423. color: white;
  424. }
  425. .el-range-separator {
  426. color: white;
  427. }
  428. }
  429. </style>