index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <template>
  2. <div>
  3. <el-card class="box-card">
  4. <div class="seachBox">
  5. <div class="conditionOne">
  6. <span>测风塔:</span>
  7. <el-select v-model="cftId" filterable placeholder="请选择" @change="changeCft">
  8. <el-option
  9. v-for="item in startDateAndEndDate"
  10. :key="item.value"
  11. :label="item.label"
  12. :value="item.value">
  13. <span style="float: left;">{{ item.label }}</span>
  14. <span style="float: right; color: #8492a6; font-size: 13px">{{ item.date }}</span>
  15. </el-option>
  16. </el-select>
  17. </div>
  18. <div class="conditionTwo">
  19. <span>时间:</span>
  20. <el-date-picker
  21. v-model="dataTime"
  22. type="daterange"
  23. range-separator="至"
  24. start-placeholder="开始日期"
  25. end-placeholder="结束日期"
  26. >
  27. </el-date-picker>
  28. </div>
  29. <div class="conditionThree">
  30. <span>层高:</span>
  31. <el-select v-model="height" placeholder="请选择">
  32. <el-option
  33. v-for="item in options"
  34. :key="item.value"
  35. :label="item.label"
  36. :value="item.value">
  37. </el-option>
  38. </el-select>
  39. </div>
  40. <el-button class="seachBtu" type="primary" plain icon="el-icon-search" size="small" @click="seachWindRose" :loading="btuLoading">搜索
  41. </el-button>
  42. </div>
  43. <div class="mainBox">
  44. <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
  45. <el-tab-pane label="对比图" name="first">
  46. <div id="roseChart"/>
  47. <div id="powerChart"/>
  48. <div id="tunInRoseChart"/>
  49. </el-tab-pane>
  50. </el-tabs>
  51. </div>
  52. </el-card>
  53. </div>
  54. </template>
  55. <script>
  56. import {listWindRose, getWindEnergyDensity, getTurbulenceIntensity} from "@/api/biz/dataQuery/RealTimeDisplay";
  57. import {listAllInfo, listEquipmentIdAndDataTime} from "@/api/biz/dataQuery/windTowerStatusInfo";
  58. import defaultOption from "@/api/biz/dataQuery/defaultOption";
  59. import {startTimeAndEndTime} from "@/api/biz/dataQuery/RealTimeDisplay";
  60. export default {
  61. name: "index",
  62. data() {
  63. return {
  64. btuLoading:true,
  65. height: "",
  66. loading: false,
  67. activeName: 'first',
  68. roseChart: null,
  69. powerChart: null,
  70. tunInRoseChart: null,
  71. dataTime: [new Date(new Date().toLocaleDateString()).getTime() - 168 * 60 * 60 * 1000, new Date(new Date().toLocaleDateString()).getTime()],
  72. allOptions: [],
  73. options: [],
  74. cftId: '',
  75. startDateAndEndDate: [],
  76. pickerMinDate: '', //获取开始选择时间
  77. pickerMaxDate: '', //获取结束选择时间
  78. pickerOptions: {
  79. //时间范围选择控制
  80. onPick: ({maxDate, minDate}) => {
  81. if (minDate) {
  82. this.pickerMinDate = minDate.getTime()
  83. }
  84. if (maxDate) {
  85. this.pickerMinDate = ''
  86. this.pickerMaxDate = maxDate.getTime()
  87. }
  88. },
  89. disabledDate: time => {
  90. const day30 = 30 * 24 * 3600 * 1000
  91. if (this.pickerMinDate !== '') {
  92. let maxTime = this.pickerMinDate + day30
  93. if (maxTime >= new Date()) {
  94. maxTime = new Date()
  95. }
  96. return time.getTime() > maxTime
  97. }
  98. if (this.pickerMaxDate !== '' && !this.pickerMinDate) {
  99. let minTime = this.pickerMaxDate - day30
  100. return time.getTime() < minTime
  101. }
  102. return time.getTime() > Date.now()
  103. },
  104. }
  105. }
  106. },
  107. destroyed() {
  108. if (this.roseChart) {
  109. this.roseChart.dispose()
  110. this.roseChart = null
  111. }
  112. if (this.powerChart) {
  113. this.powerChart.dispose()
  114. this.powerChart = null
  115. }
  116. if (this.tunInRoseChart) {
  117. this.tunInRoseChart.dispose()
  118. this.tunInRoseChart = null
  119. }
  120. },
  121. mounted() {
  122. this.allOptions = defaultOption.allHeightOptions
  123. this.getTimeFrame()
  124. },
  125. methods: {
  126. /*查询三个玫瑰图*/
  127. seachWindRose() {
  128. this.btuLoading = true
  129. var param = {
  130. startTime: new Date(this.dataTime[0]).getTime(),
  131. endTime: new Date(this.dataTime[1]).getTime() - 1,
  132. equipmentId: this.cftId,
  133. height: this.height
  134. }
  135. this.getLoading()
  136. //风向玫瑰图
  137. this.listWindRose(param)
  138. //风功率玫瑰图
  139. this.getWindEnergyDensity(param)
  140. //湍流玫瑰图
  141. this.getTurbulenceIntensity(param)
  142. },
  143. /*玫瑰图数据*/
  144. listWindRose(param) {
  145. listWindRose(param).then(res => {
  146. // var data = [res.data[0].N, res.data[15].NNW, res.data[14].NW, res.data[13].WNW, res.data[12].W, res.data[11].WSW, res.data[10].SW, res.data[9].SSW, res.data[8].S, res.data[7].SSE, res.data[6].SE, res.data[5].ESE, res.data[4].E, res.data[3].ENE, res.data[2].NE, res.data[1].NNE]
  147. var data = [res.data[0].N, res.data[1].NNE, res.data[2].NE, res.data[3].ENE, res.data[4].E, res.data[5].ESE, res.data[6].SE, res.data[7].SSE, res.data[8].S, res.data[9].SSW, res.data[10].SW, res.data[11].WSW, res.data[12].W, res.data[13].WNW, res.data[14].NW, res.data[15].NNW]
  148. var max = Math.max.apply(null, data) == 0 ? 100 : Math.max.apply(null, data);
  149. this.drawRoseChart(data, max)
  150. }).catch(err => {
  151. this.roseChart.hideLoading();
  152. this.$message.error('查询风向玫瑰图异常')
  153. console.log("查询风向玫瑰图异常:" + err)
  154. })
  155. },
  156. /*风功率玫瑰图*/
  157. getWindEnergyDensity(param) {
  158. getWindEnergyDensity(param).then(res => {
  159. let data = []
  160. let max = 1
  161. if(res.data.length>0){
  162. data = [res.data[0].N, res.data[1].NNE, res.data[2].NE, res.data[3].ENE, res.data[4].E, res.data[5].ESE, res.data[6].SE, res.data[7].SSE, res.data[8].S, res.data[9].SSW, res.data[10].SW, res.data[11].WSW, res.data[12].W, res.data[13].WNW, res.data[14].NW, res.data[15].NNW]
  163. /*获取数组的最大值*/
  164. max = Math.max.apply(null, data) == 0 ? 100 : Math.max.apply(null, data);
  165. this.drawPowerChart(data, max)
  166. }
  167. this.drawPowerChart(data, max)
  168. }).catch(err => {
  169. this.powerChart.hideLoading();
  170. this.$message.error('查询风功率玫瑰图异常')
  171. console.log("查询风功率玫瑰图异常:" + err)
  172. })
  173. },
  174. /*湍流玫瑰图*/
  175. getTurbulenceIntensity(param) {
  176. getTurbulenceIntensity(param).then(res => {
  177. var data = [res.data[0].N, res.data[1].NNE, res.data[2].NE, res.data[3].ENE, res.data[4].E, res.data[5].ESE, res.data[6].SE, res.data[7].SSE, res.data[8].S, res.data[9].SSW, res.data[10].SW, res.data[11].WSW, res.data[12].W, res.data[13].WNW, res.data[14].NW, res.data[15].NNW]
  178. /*获取数组的最大值*/
  179. var max = Math.max.apply(null, data) == 0 ? 100 : Math.max.apply(null, data);
  180. this.drawTunInChart(data, max)
  181. }).catch(err => {
  182. this.tunInRoseChart.hideLoading();
  183. this.$message.error('查询湍流玫瑰图异常')
  184. console.log("查询湍流玫瑰图异常:" + err)
  185. })
  186. this.btuLoading = false
  187. },
  188. /*切换测风塔找到它对应的层高*/
  189. changeCft() {
  190. let data = this.startDateAndEndDate.find(w => w.value == this.cftId)
  191. this.getDataTime(this.cftId)
  192. this.changeHeight(data)
  193. },
  194. /*获取所有的测风塔*/
  195. getlistEquipmentIdAndDataTime() {
  196. listEquipmentIdAndDataTime().then(res => {
  197. this.startDateAndEndDate = res.data
  198. this.cftId = res.data[0].value
  199. this.getDataTime(this.cftId)
  200. this.changeHeight(res.data[0])
  201. this.seachWindRose()
  202. })
  203. },
  204. /*切换测风塔时改变层高option*/
  205. changeHeight(data) {
  206. if (data.heights != null) {
  207. var option = []
  208. let str = data.wdHeights.split(',')
  209. this.height = str[0]
  210. for (let i = 0; i < str.length; i++) {
  211. let filter = this.allOptions.find(w => w.value == str[i])
  212. option.push(filter)
  213. }
  214. this.options = option
  215. } else {
  216. this.height = "10"
  217. this.options = this.allOptions
  218. }
  219. },
  220. /*获取默认的时间段*/
  221. getTimeFrame() {
  222. startTimeAndEndTime().then(res => {
  223. this.defaultTimeData = res.data
  224. this.getlistEquipmentIdAndDataTime()
  225. }).catch(err => {
  226. this.getlistEquipmentIdAndDataTime()
  227. this.$message.error('获取时间范围异常')
  228. console.log('获取时间范围异常:' + err)
  229. })
  230. },
  231. /*设置时间范围默认值*/
  232. getDataTime(cftId) {
  233. this.dataTime = [new Date(new Date().toLocaleDateString()).getTime() - 168 * 60 * 60 * 1000, new Date(new Date().toLocaleDateString()).getTime()]
  234. if (cftId != null || cftId != undefined) {
  235. if (this.defaultTimeData.length > 0) {
  236. let filterData = this.defaultTimeData.find(w => w.equipmentId == cftId)
  237. if (JSON.stringify(filterData) != '{}') {
  238. this.dataTime = [filterData.startTime, filterData.endTime]
  239. }
  240. }
  241. }
  242. },
  243. drawRoseChart(data, max) {
  244. if (!this.roseChart) {
  245. this.roseChart = this.$echarts.init(document.getElementById('roseChart'))
  246. }
  247. // var option = {
  248. // title: {
  249. // text: '风向玫瑰图'
  250. // },
  251. // legend: {},
  252. // tooltip: {
  253. // position: ['50%', '30%'],
  254. // show: true
  255. // },
  256. // radar: {
  257. // center: ['40%', '50%'],
  258. // indicator: [
  259. // {name: 'N', max: max},
  260. // {name: 'NNW', max: max},
  261. // {name: 'NW', max: max},
  262. // {name: 'WNW', max: max},
  263. // {name: 'W', max: max},
  264. // {name: 'WSW', max: max},
  265. // {name: 'SW', max: max},
  266. // {name: 'SSW', max: max},
  267. // {name: 'S', max: max},
  268. // {name: 'SSE', max: max},
  269. // {name: 'SE', max: max},
  270. // {name: 'ESE', max: max},
  271. // {name: 'E', max: max},
  272. // {name: 'ENE', max: max},
  273. // {name: 'NE', max: max},
  274. // {name: 'NNE', max: max}
  275. // ]
  276. // },
  277. // series: [
  278. // {
  279. // name: '风向',
  280. // type: 'radar',
  281. // data: [{value: data}],
  282. // areaStyle: {
  283. // color: this.$echarts.graphic.RadialGradient(0.1, 0.6, 1, [
  284. // {
  285. // color: 'rgba(255, 145, 124, 0.1)',
  286. // offset: 0
  287. // },
  288. // {
  289. // color: 'rgba(255, 145, 124, 0.9)',
  290. // offset: 1
  291. // }
  292. // ])
  293. // }
  294. // }
  295. // ]
  296. // };
  297. let option = {
  298. title: {
  299. text: '风向玫瑰图'
  300. },
  301. polar: {
  302. radius: [0, '80%'],
  303. },
  304. tooltip: {
  305. show: true
  306. },
  307. radiusAxis: {
  308. // type: 'category',
  309. axisLine: {
  310. show: false,
  311. },
  312. interval: Math.ceil(max / 3)
  313. },
  314. angleAxis: {
  315. splitLine: {
  316. show: true
  317. },
  318. type: 'category',
  319. data: [
  320. 'N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW',
  321. 'WSW', 'W', 'WNW', 'NW', 'NNW'],
  322. startAngle: 100
  323. },
  324. series: {
  325. type: 'bar',
  326. data: data,
  327. coordinateSystem: 'polar',
  328. },
  329. animation: false
  330. };
  331. this.roseChart.setOption(option, true)
  332. this.roseChart.hideLoading();
  333. window.addEventListener('resize', () => {
  334. if (this.roseChart) {
  335. this.roseChart.resize()
  336. }
  337. })
  338. },
  339. drawPowerChart(data, max) {
  340. if (!this.powerChart) {
  341. this.powerChart = this.$echarts.init(document.getElementById('powerChart'))
  342. }
  343. // var option = {
  344. // title: {
  345. // text: '风功率玫瑰图'
  346. // },
  347. // legend: {},
  348. // tooltip: {
  349. // position: ['50%', '30%'],
  350. // show: true
  351. // },
  352. // radar: {
  353. // center: ['40%', '50%'],
  354. // indicator: [{name: 'N', max: max}, {name: 'NNW', max: max}, {name: 'NW', max: max}, {
  355. // name: 'WNW',
  356. // max: max
  357. // }, {name: 'W', max: max}, {name: 'WSW', max: max}, {name: 'SW', max: max}, {
  358. // name: 'SSW',
  359. // max: max
  360. // }, {name: 'S', max: max},
  361. // {name: 'SSE', max: max}, {name: 'SE', max: max}, {name: 'ESE', max: max}, {
  362. // name: 'E',
  363. // max: max
  364. // }, {name: 'ENE', max: max}, {name: 'NE', max: max}, {name: 'NNE', max: max}]
  365. // },
  366. // series: [
  367. // {
  368. // name: '风功率',
  369. // type: 'radar',
  370. // data: [{value: data,}],
  371. // areaStyle: {
  372. // color: this.$echarts.graphic.RadialGradient(0.1, 0.6, 1, [
  373. // {
  374. // color: 'rgba(255, 145, 124, 0.1)',
  375. // offset: 0
  376. // },
  377. // {
  378. // color: 'rgba(255, 145, 124, 0.9)',
  379. // offset: 1
  380. // }
  381. // ])
  382. // }
  383. // }
  384. // ]
  385. // };
  386. let option = {
  387. title: {
  388. text: '风功率玫瑰图'
  389. },
  390. polar: {
  391. radius: [0, '80%'],
  392. },
  393. tooltip: {
  394. show: true
  395. },
  396. radiusAxis: {
  397. // type: 'category',
  398. axisLine: {
  399. show: false,
  400. },
  401. interval: Math.ceil(max / 3)
  402. },
  403. angleAxis: {
  404. splitLine: {
  405. show: true
  406. },
  407. type: 'category',
  408. data: [
  409. 'N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW',
  410. 'WSW', 'W', 'WNW', 'NW', 'NNW'],
  411. startAngle: 100
  412. },
  413. series: {
  414. type: 'bar',
  415. data: data,
  416. coordinateSystem: 'polar',
  417. },
  418. animation: false
  419. };
  420. this.powerChart.setOption(option, true)
  421. this.powerChart.hideLoading();
  422. window.addEventListener('resize', () => {
  423. if (this.powerChart) {
  424. this.powerChart.resize()
  425. }
  426. })
  427. },
  428. drawTunInChart(data, max) {
  429. if (!this.tunInRoseChart) {
  430. this.tunInRoseChart = this.$echarts.init(document.getElementById('tunInRoseChart'))
  431. }
  432. // var option = {
  433. // title: {
  434. // text: '湍流玫瑰图'
  435. // },
  436. // legend: {},
  437. // tooltip: {
  438. // position: ['50%', '-5%'],
  439. // show: true
  440. // },
  441. // radar: {
  442. // center: ['40%', '50%'],
  443. // indicator: [
  444. // {name: 'N', max: max},
  445. // {name: 'NNW', max: max},
  446. // {name: 'NW', max: max},
  447. // {name: 'WNW', max: max},
  448. // {name: 'W', max: max},
  449. // {name: 'WSW', max: max},
  450. // {name: 'SW', max: max},
  451. // {name: 'SSW', max: max},
  452. // {name: 'S', max: max},
  453. // {name: 'SSE', max: max},
  454. // {name: 'SE', max: max},
  455. // {name: 'ESE', max: max},
  456. // {name: 'E', max: max},
  457. // {name: 'ENE', max: max},
  458. // {name: 'NE', max: max},
  459. // {name: 'NNE', max: max}
  460. // ]
  461. // },
  462. // series: [
  463. // {
  464. // name: '湍流',
  465. // type: 'radar',
  466. // data: [{value: data,}],
  467. // areaStyle: {
  468. // color: this.$echarts.graphic.RadialGradient(0.1, 0.6, 1, [
  469. // {
  470. // color: 'rgba(255, 145, 124, 0.1)',
  471. // offset: 0
  472. // },
  473. // {
  474. // color: 'rgba(255, 145, 124, 0.9)',
  475. // offset: 1
  476. // }
  477. // ])
  478. // }
  479. // }
  480. // ]
  481. // };
  482. let option = {
  483. title: {
  484. text: '湍流玫瑰图'
  485. },
  486. polar: {
  487. radius: [0, '80%'],
  488. },
  489. tooltip: {
  490. show: true
  491. },
  492. radiusAxis: {
  493. // type: 'category',
  494. axisLine: {
  495. show: false,
  496. },
  497. interval: Math.ceil(max / 3)
  498. },
  499. angleAxis: {
  500. splitLine: {
  501. show: true
  502. },
  503. type: 'category',
  504. data: [
  505. 'N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW',
  506. 'WSW', 'W', 'WNW', 'NW', 'NNW'],
  507. startAngle: 100
  508. },
  509. series: {
  510. type: 'bar',
  511. data: data,
  512. coordinateSystem: 'polar',
  513. },
  514. animation: false
  515. };
  516. this.tunInRoseChart.setOption(option, true)
  517. this.tunInRoseChart.hideLoading();
  518. window.addEventListener('resize', () => {
  519. if (this.tunInRoseChart) {
  520. this.tunInRoseChart.resize()
  521. }
  522. })
  523. },
  524. /*添加loading*/
  525. getLoading() {
  526. if (!this.roseChart) {
  527. this.roseChart = this.$echarts.init(document.getElementById('roseChart'))
  528. }
  529. this.roseChart.showLoading({
  530. text: 'loading',
  531. color: '#c23531',
  532. textColor: '#000',
  533. maskColor: 'rgba(255, 255, 255, 0.2)',
  534. zlevel: 0,
  535. });
  536. if (!this.powerChart) {
  537. this.powerChart = this.$echarts.init(document.getElementById('powerChart'))
  538. }
  539. this.powerChart.showLoading({
  540. text: 'loading',
  541. color: '#c23531',
  542. textColor: '#000',
  543. maskColor: 'rgba(255, 255, 255, 0.2)',
  544. zlevel: 0,
  545. });
  546. if (!this.tunInRoseChart) {
  547. this.tunInRoseChart = this.$echarts.init(document.getElementById('tunInRoseChart'))
  548. }
  549. this.tunInRoseChart.showLoading({
  550. text: 'loading',
  551. color: '#c23531',
  552. textColor: '#000',
  553. maskColor: 'rgba(255, 255, 255, 0.2)',
  554. zlevel: 0,
  555. });
  556. },
  557. handleClick(tab, event) {
  558. if (this.activeName == 'first') {
  559. this.roseChart = null
  560. this.roseChart.resize()
  561. this.powerChart = null
  562. this.powerChart.resize()
  563. this.tunInRoseChart = null
  564. this.tunInRoseChart.resize()
  565. }
  566. },
  567. }
  568. }
  569. </script>
  570. <style scoped>
  571. .seachBox {
  572. display: flex;
  573. margin: .5%;
  574. }
  575. .conditionOne, .conditionTwo, .conditionThree, .seachBtu {
  576. display: inline-block;
  577. }
  578. .conditionTwo, .conditionThree, .seachBtu {
  579. margin-left: .5%;
  580. }
  581. #roseChart, #powerChart, #tunInRoseChart, #shearChart {
  582. display: inline-block;
  583. width: 50%;
  584. height: calc(38vh - 10px);
  585. }
  586. </style>