supervised.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. <template>
  2. <div class="decision-page-1">
  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
  9. v-model="chooseAlgorithm"
  10. @change="algorithmChange(chooseAlgorithm)"
  11. clearable
  12. placeholder="请选择"
  13. popper-class="select"
  14. >
  15. <el-option
  16. v-for="item in algorithm"
  17. :key="item.name"
  18. :value="item.name"
  19. :label="item.name"
  20. >
  21. </el-option>
  22. </el-select>
  23. </div>
  24. </div>
  25. <!-- <div v-for="(item, index) in chooseAlgorithm.parameters" :key="index">
  26. {{ item.name }}:
  27. <input
  28. v-model="item.value"
  29. type="number"
  30. @focus="inputChange(item)"
  31. @blur="inputChange(item)"
  32. />
  33. </div> -->
  34. </div>
  35. </div>
  36. <div class="actions mg-b-8">
  37. <button class="btn" @click="TypeClick('sjfl')">数据分类</button>
  38. <button class="btn" @click="TypeClick('mxjl')">模型记录</button>
  39. <button class="btn" @click="TypeClick('jcjl')">检测记录</button>
  40. <!-- <button class="btn" @click="handleTraining()">检测记录</button> -->
  41. </div>
  42. <el-row :type="'flex'" class="content">
  43. <el-col :span="16" class="pd-l-8">
  44. <panel :title="'训练记录'" :showLine="false">
  45. <div class="dataTitle">
  46. <div class="chooses">
  47. <el-date-picker
  48. class="picker"
  49. @change="changes"
  50. v-model="timeValue"
  51. type="datetimerange"
  52. range-separator="至"
  53. start-placeholder="开始日期"
  54. end-placeholder="结束日期"
  55. >
  56. </el-date-picker>
  57. <div class="contents">
  58. 风电场:
  59. <el-select
  60. v-model="selectValue"
  61. @change="search()"
  62. clearable
  63. placeholder="请选择"
  64. popper-class="select"
  65. style="width: 130px; margin-left: 20px"
  66. >
  67. <el-option
  68. v-for="item in options"
  69. :key="item.value"
  70. :value="item.value"
  71. :label="item.value"
  72. />
  73. </el-select>
  74. </div>
  75. <div class="contents">
  76. 机型:
  77. <el-select
  78. v-model="selectMoudle"
  79. @change="selectSearch()"
  80. clearable
  81. placeholder="全部"
  82. popper-class="select"
  83. style="width: 120px; margin-left: 20px"
  84. >
  85. <el-option
  86. v-for="item in moudleList"
  87. :key="item.value"
  88. :value="item.value"
  89. :label="item.label"
  90. />
  91. </el-select>
  92. </div>
  93. </div>
  94. <button class="btn" @click="getFaultList">查询</button>
  95. </div>
  96. <div class="bodys" v-if="dataList.length > 0">
  97. <div v-for="(item, index) in dataList" :key="index">
  98. <div class="faultTitle">{{ item.name }}:</div>
  99. <div class="fault">
  100. <div
  101. class="faultBlock"
  102. v-for="(val, indexs) in item.children"
  103. :key="indexs"
  104. >
  105. <div class="left">
  106. <div>{{ val.stationcn }}</div>
  107. <div>{{ val.windturbineid }}</div>
  108. <div>{{ val.model }}</div>
  109. <div style="font-size: 14px">{{ val.starttime }}</div>
  110. </div>
  111. <div class="right">
  112. <img class="imgs" src="./img/generator.png" alt="" />
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. <div v-else class="none">暂无数据</div>
  119. </panel>
  120. </el-col>
  121. <el-col :span="8" class="pd-l-8">
  122. <panel :title="'演示过程图'" :showLine="false">
  123. <div class="results" v-if="showTraining">
  124. <div class="progressTitle">
  125. <div v-if="!trainingFlag">数据获取中...</div>
  126. <div v-if="trainingFlag && width < 100">训练中...</div>
  127. <div v-if="trainingFlag && width === 100">训练完成</div>
  128. <div class="progressNum">
  129. 当前进度:{{ width >= 0 ? width : 0 }}%
  130. </div>
  131. </div>
  132. <div class="box">
  133. <div class="progress" :style="`width:${width}%;`"></div>
  134. <div class="line"></div>
  135. <div class="unprogress" :style="`width:${100 - width}%;`"></div>
  136. </div>
  137. </div>
  138. <LineChart v-if="lossList" id="loss" :dataList="lossList"></LineChart>
  139. <LineChart
  140. v-if="accuracyList"
  141. id="accuracy"
  142. :dataList="accuracyList"
  143. ></LineChart>
  144. <BarChart
  145. v-if="barList.length > 0"
  146. id="bar"
  147. :baseLine="ceshiList?.BaseLine"
  148. @click="showDetials"
  149. :barList="barList"
  150. ></BarChart>
  151. </panel>
  152. </el-col>
  153. </el-row>
  154. <SuperviseDataClassify
  155. ref="dataClass"
  156. @click-training="handleClick"
  157. @handleInterval="intervals"
  158. v-model="display"
  159. :allData="allData"
  160. :chooseAlgorithm="chooseAlgorithm"
  161. ></SuperviseDataClassify>
  162. <Records
  163. @results="recordResults"
  164. supervisedFlag="true"
  165. :recordList="showBarList"
  166. :accuracyList="accuracyList"
  167. v-model="recordsDisplay"
  168. ></Records>
  169. <ChartDetails
  170. v-model="detialsDisplay"
  171. :barList="ceshiList?.bar"
  172. :baseLine="ceshiList?.BaseLine"
  173. ></ChartDetails>
  174. <DetectionRecord
  175. v-model="detectionDisplay"
  176. :allData="allData"
  177. ></DetectionRecord>
  178. </div>
  179. </template>
  180. <script>
  181. import Panel from "../../components/coms/panel/panel.vue";
  182. import LineChart from "./components/lineChart.vue";
  183. import BarChart from "./components/barChart.vue";
  184. import SuperviseDataClassify from "./components/superviseDataClassify.vue";
  185. import Records from "./components/records.vue";
  186. import ChartDetails from "./components/chartDetails.vue";
  187. import DetectionRecord from "./components/detectionRecord.vue";
  188. export default {
  189. components: {
  190. Panel,
  191. LineChart,
  192. BarChart,
  193. SuperviseDataClassify,
  194. Records,
  195. ChartDetails,
  196. DetectionRecord,
  197. },
  198. created() {
  199. if (this.timeValue.length === 0) {
  200. let date = new Date();
  201. this.timeValue[0] = date.getTime() - 86400000;
  202. this.timeValue[1] = date.getTime();
  203. }
  204. let select = this.options.filter(
  205. (item) => item.value === this.selectValue
  206. )[0];
  207. this.selectMoudle = select.station[0].lable;
  208. this.moudleList = select.station;
  209. },
  210. data() {
  211. return {
  212. dataList: [],
  213. lossList: {},
  214. accuracyList: {},
  215. barList: [],
  216. algorithm: [], //算法
  217. chooseAlgorithm: '',
  218. timeValue: [],
  219. showBarList: [],
  220. moudleList: [],
  221. allData: [],
  222. ceshiList: [],
  223. detectionDisplay: false,
  224. showTraining: false,
  225. trainingFlag: false,
  226. lastTraining: false,
  227. display: false,
  228. recordsDisplay: false,
  229. detialsDisplay: false,
  230. width: 60,
  231. selectValue: "NSS_FDC",
  232. selectMoudle: "UP82",
  233. options: [
  234. {
  235. value: "NSS_FDC",
  236. station: [
  237. {
  238. lable: "UP82",
  239. value: "UP82",
  240. },
  241. ],
  242. },
  243. {
  244. value: "MHS_FDC",
  245. station: [
  246. {
  247. lable: "UP77",
  248. value: "UP77",
  249. },
  250. {
  251. lable: "UP105-2000-S",
  252. value: "UP105-2000-S",
  253. },
  254. ],
  255. },
  256. {
  257. value: "QS_FDC",
  258. station: [
  259. {
  260. lable: "CCWE-1500",
  261. value: "CCWE-1500",
  262. },
  263. {
  264. lable: "UP105-2000-S",
  265. value: "UP105-2000-S",
  266. },
  267. ],
  268. },
  269. {
  270. value: "SBQ_FDC",
  271. station: [
  272. {
  273. lable: "UP82",
  274. value: "UP82",
  275. },
  276. {
  277. lable: "UP97",
  278. value: "UP97",
  279. },
  280. {
  281. lable: "UP105-2000-S",
  282. value: "UP105-2000-S",
  283. },
  284. ],
  285. },
  286. {
  287. value: "XS_FDC",
  288. station: [
  289. {
  290. lable: "UP97",
  291. value: "UP97",
  292. },
  293. {
  294. lable: "UP105-2000-S",
  295. value: "UP105-2000-S",
  296. },
  297. ],
  298. },
  299. ],
  300. };
  301. },
  302. mounted() {
  303. let dataList = JSON.parse(
  304. '{"ducumentName":"NNS-1637028563000","loss":[1.0882383584976196,1.067789912223816,1.0520573854446411,1.0380222797393799,1.0230460166931152,1.0070627927780151,0.9899255037307739,0.9736341238021851,0.9547672271728516,0.9341660737991333,0.9082227945327759,0.8833365440368652,0.8581799268722534,0.8310791254043579,0.8011142611503601,0.7700659036636353,0.7383494973182678,0.7076452970504761,0.6731187105178833,0.6390867829322815],"accuracy":[0.3047619163990021,0.37142857909202576,0.3619047701358795,0.3619047701358795,0.380952388048172,0.5809524059295654,0.6571428775787354,0.6571428775787354,0.6666666865348816,0.6666666865348816,0.6666666865348816,0.6666666865348816,0.6666666865348816,0.6666666865348816,0.6666666865348816,0.6666666865348816,0.6761904954910278,0.6952381134033203,0.7333333492279053,0.7428571581840515],"val_loss":[1.0914311408996582,1.0727100372314453,1.0579898357391357,1.0469794273376465,1.0305122137069702,1.012723684310913,0.9997329115867615,0.9839586615562439,0.9610583782196045,0.9339884519577026,0.9096081256866455,0.8876619338989258,0.862886905670166,0.8299474120140076,0.793283998966217,0.7597811222076416,0.7229973673820496,0.6826366782188416,0.6449647545814514,0.6126752495765686],"val_accuracy":[0.2666666805744171,0.2666666805744171,0.2666666805744171,0.2666666805744171,0.4000000059604645,0.644444465637207,0.644444465637207,0.6666666865348816,0.6666666865348816,0.6666666865348816,0.6666666865348816,0.6666666865348816,0.6666666865348816,0.6666666865348816,0.6666666865348816,0.6666666865348816,0.6666666865348816,0.7333333492279053,0.7555555701255798,0.7333333492279053],"bar":[{"name":"邮箱温度","value":0.3},{"name":"风速","value":0.25},{"name":"变桨","value":0.25},{"name":"有高","value":0.2}]}'
  305. );
  306. this.ceshiList = dataList;
  307. this.lossList.loss = dataList.loss;
  308. this.lossList.val_loss = dataList.val_loss;
  309. this.accuracyList.accuracy = dataList.accuracy;
  310. this.accuracyList.val_accuracy = dataList.val_accuracy;
  311. this.barList = dataList.bar;
  312. this.getFaultList();
  313. this.getType();
  314. },
  315. methods: {
  316. getType() {
  317. let that = this;
  318. this.API.requestData({
  319. method: "GET",
  320. subUrl: "http://192.168.10.18:8080/api/coordinate/algorithm",
  321. data: {
  322. type: 1,
  323. },
  324. success(res) {
  325. if (res) {
  326. that.algorithm = res;
  327. that.value1 = res[0];
  328. that.chooseAlgorithm = res[0].name;
  329. }
  330. },
  331. });
  332. },
  333. TypeClick(btnType) {
  334. if (btnType === "sjfl") {
  335. this.display = true;
  336. } else if (btnType === "mxjl") {
  337. this.showBarList.push(this.ceshiList);
  338. this.recordsDisplay = true;
  339. } else if (btnType === "jcjl") {
  340. this.detectionDisplay = true;
  341. }
  342. },
  343. selectSearch() {
  344. this.allData.forEach((item) => {
  345. if (item.modelId.indexOf(this.selectMoudle) != -1) {
  346. this.dataList.push(item);
  347. }
  348. });
  349. },
  350. search() {
  351. let select = this.options.filter(
  352. (item) => item.value === this.selectValue
  353. )[0];
  354. this.selectMoudle = select.station[0].lable;
  355. this.moudleList = select.station;
  356. },
  357. showDetials() {
  358. this.detialsDisplay = true;
  359. },
  360. getFaultList() {
  361. this.dataList = [];
  362. let that = this;
  363. this.API.requestData({
  364. method: "GET",
  365. subUrl: "http://192.168.1.18:9002/case/fault/list",
  366. data: {
  367. station: this.selectValue,
  368. model: this.selectMoudle,
  369. st: new Date(this.timeValue[0]).formatDate("yyyy-MM-dd hh:mm:ss"),
  370. et: new Date(this.timeValue[1]).formatDate("yyyy-MM-dd hh:mm:ss"),
  371. },
  372. success(res) {
  373. if (res) {
  374. that.allData = res.data;
  375. res.data.forEach((item) => {
  376. let array = that.dataList.filter(
  377. (val) => val.code === item.faultcode
  378. );
  379. if (array.length > 0) {
  380. array[0].children.push(item);
  381. } else {
  382. let obj = {
  383. name: item.faulttype,
  384. code: item.faultcode,
  385. children: [],
  386. };
  387. obj.children.push(item);
  388. that.dataList.push(obj);
  389. }
  390. });
  391. }
  392. },
  393. });
  394. },
  395. handleClick() {
  396. this.lastTraining = false;
  397. this.barList = [];
  398. this.handleTraining();
  399. },
  400. handleTraining() {
  401. let that = this;
  402. that.resultList = [];
  403. this.API.requestData({
  404. method: "GET",
  405. subUrl: "http://192.168.10.18:8080/api/supervised/",
  406. success(res) {
  407. if (res.value.length > 0) {
  408. let arr = JSON.parse(res.value);
  409. that.ceshiList = arr;
  410. that.lossList.loss = arr.loss;
  411. that.lossList.val_loss = arr.val_loss;
  412. that.accuracyList.accuracy = arr.accuracy;
  413. that.accuracyList.val_accuracy = arr.val_accuracy;
  414. if (arr.bar) {
  415. arr.bar = JSON.parse(arr.bar);
  416. arr.bar?.sort(that.Compare("value"));
  417. that.barList = arr.bar?.slice(0, 5);
  418. }
  419. }
  420. },
  421. });
  422. this.API.requestData({
  423. method: "GET",
  424. subUrl: "http://192.168.10.18:8080/api/supervised/progress",
  425. success(res) {
  426. that.showTraining = true;
  427. if (res) {
  428. that.trainingFlag = res.value === -1 ? false : true;
  429. that.width = res.value === -1 ? 0 : (res.value * 100).toFixed(2);
  430. if (that.width < 100) {
  431. setTimeout(() => {
  432. that.handleTraining();
  433. }, 1000);
  434. } else {
  435. if (!that.lastTraining) {
  436. that.lastTraining = true;
  437. that.handleTraining();
  438. }
  439. }
  440. }
  441. },
  442. });
  443. },
  444. handleClose() {
  445. this.barList = this.ceshiList.bar.slice(0, 5);
  446. },
  447. algorithmChange(val) {
  448. this.chooseAlgorithm = this.algorithm.filter(
  449. (item) => item.name === val
  450. )[0].name;
  451. },
  452. // clear() {
  453. // this.chooseAlgorithm = '';
  454. // },
  455. Compare(property) {
  456. return function (a, b) {
  457. var value1 = a[property];
  458. var value2 = b[property];
  459. return value2 - value1;
  460. };
  461. },
  462. },
  463. };
  464. </script>
  465. <style lang="less" scoped>
  466. .dataTitle {
  467. display: flex;
  468. flex-direction: row;
  469. align-items: center;
  470. justify-content: space-between;
  471. margin-bottom: 20px;
  472. margin-top: 10px;
  473. .chooses {
  474. display: flex;
  475. flex-direction: row;
  476. align-items: center;
  477. }
  478. .timeInput {
  479. width: 30px;
  480. }
  481. .contents {
  482. display: flex;
  483. flex-direction: row;
  484. align-items: center;
  485. margin-left: 30px;
  486. }
  487. }
  488. .faultTitle {
  489. font-size: 18px;
  490. margin-bottom: 20px;
  491. }
  492. .fault {
  493. display: flex;
  494. flex-direction: row;
  495. align-items: center;
  496. flex-wrap: wrap;
  497. .faultBlock {
  498. width: 220px;
  499. height: 90px;
  500. border: 1px solid #05bb4c;
  501. display: flex;
  502. flex-direction: row;
  503. align-items: center;
  504. justify-content: space-between;
  505. margin-right: 20px;
  506. margin-bottom: 20px;
  507. .left {
  508. line-height: 19px;
  509. margin-left: 10px;
  510. font-size: 16px;
  511. }
  512. .right {
  513. display: flex;
  514. align-items: center;
  515. justify-content: center;
  516. height: 100%;
  517. border-left: 1px solid #05bb4c;
  518. .imgs {
  519. margin: 0px 10px;
  520. width: 40px;
  521. height: 40px;
  522. }
  523. }
  524. }
  525. }
  526. .bodys {
  527. display: flex;
  528. flex-direction: column;
  529. overflow-y: auto;
  530. height: 75vh;
  531. }
  532. .none {
  533. width: 100%;
  534. display: flex;
  535. justify-content: center;
  536. margin-top: 150px;
  537. color: #999999;
  538. }
  539. .results {
  540. margin-left: 35px;
  541. }
  542. .box {
  543. width: 80%;
  544. margin-top: 20px;
  545. height: 20px;
  546. display: flex;
  547. align-items: center;
  548. .progress {
  549. background: linear-gradient(to right, #0d692c, #6df0a0);
  550. height: 16px;
  551. z-index: 1;
  552. }
  553. .line {
  554. width: 1px;
  555. height: 70px;
  556. z-index: 2;
  557. background: linear-gradient(
  558. to bottom,
  559. rgba(158, 151, 151, 0) 0%,
  560. rgba(0, 0, 0, 0) 10%,
  561. rgba(255, 255, 255, 0.3) 20%,
  562. rgba(255, 255, 255, 0.6) 30%,
  563. rgba(255, 255, 255, 0.8) 40%,
  564. rgba(255, 255, 255, 1) 50%,
  565. rgba(255, 255, 255, 0.8) 60%,
  566. rgba(255, 255, 255, 0.6) 70%,
  567. rgba(255, 255, 255, 0.3) 80%,
  568. rgba(0, 0, 0, 0) 90%,
  569. rgba(0, 0, 0, 0) 100%
  570. );
  571. transition: width 0.2s linear;
  572. }
  573. .unprogress {
  574. background: linear-gradient(to right, #41acec, #003e7a);
  575. height: 16px;
  576. z-index: 1;
  577. }
  578. }
  579. </style>