focusCard.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /* 推荐区 */
  2. <template>
  3. <div style="display: flex;justify-content: flex-start;flex-wrap: wrap;">
  4. <!-- <table v-for="(vl , index) in values" :key="vl" @dblclick="sendMsg(vl,index)">
  5. <tr>{{vl.stationName}}</tr>
  6. <tr>{{vl.content}}</tr>
  7. <tr>{{vl.createTime}}</tr>
  8. </table> -->
  9. <div class="area" v-for="(vl , index) in values" :key="vl" @dblclick="sendMsg(vl,index)">
  10. <img class="imgs" src="../../assets/img/RecommendedArea/background.png" alt="">
  11. <div class="content">{{vl.content}}</div>
  12. <div class="">{{vl.stationName}}</div>
  13. <div class="">{{vl.createTime}}</div>
  14. </div>
  15. </div>
  16. <PhotoelectricDetailPages ref="photo" @closed="closed()" :data="dialogData.data"
  17. :stationName="dialogData.stationName" v-model="dialogVisible">
  18. </PhotoelectricDetailPages>
  19. </template>
  20. <script>
  21. import BackgroundData from "utils/BackgroundData"
  22. import { Photoelectric } from "utils/PhotoelectricDetailPages";
  23. import PhotoelectricDetailPages from "./PhotoelectricDetailPages.vue"
  24. import MessageBridge from 'utils/MessageBridge'
  25. import axios from 'axios';
  26. import dayjs from 'dayjs'
  27. export default {
  28. name: "RecommendedArea",
  29. props: ["datas"],
  30. data() {
  31. return {
  32. values: new Array(),
  33. dialogVisible: false,
  34. dialogData: {
  35. data: {
  36. PowerSet: '',
  37. AgcUp: '',
  38. AgcLower: '',
  39. ActualPower: '',
  40. TheoryPower: '',
  41. ForecastPower: '',
  42. AgcIn: '',
  43. AgcFar: '',
  44. SumLock: '',
  45. SubLock: '',
  46. }
  47. },
  48. dataMsg: [],
  49. interval: '',
  50. arrKey: [],
  51. timeIndex: 0
  52. };
  53. },
  54. components: {
  55. PhotoelectricDetailPages,
  56. },
  57. created() {
  58. this.datacontrol();
  59. this.initData();
  60. },
  61. methods: {
  62. datacontrol() {
  63. var mb = MessageBridge.getInstance();
  64. var vss = [{ key: "/topic/voice-control", action: this.windturbineMessage }];
  65. mb.register(vss);
  66. },
  67. windturbineMessage(msg) {
  68. var bd = BackgroundData.getInstance();
  69. let arr = []
  70. if (msg === 'CLOSE') {
  71. arr.push(msg)
  72. } else {
  73. arr = msg.split('-')
  74. }
  75. this.dialogVisible = false
  76. this.showSvg = false
  77. this.svgWeb = ''
  78. if (arr[0] === 'OPEN_AGC' && arr[1] !== 'GS') {
  79. let data = bd.Recommends
  80. for (let v in data) {
  81. if (arr[1] === data[v].stationID) {
  82. this.sendMsg(data[v])
  83. }
  84. }
  85. } else if (arr[0] === 'CLOSE') {
  86. this.dialogVisible = false
  87. }
  88. },
  89. closed() {
  90. clearInterval(this.interval);
  91. },
  92. initData() {
  93. setInterval(this.refreshData, 2000);
  94. },
  95. refreshData() {
  96. var bd = BackgroundData.getInstance();
  97. var list = new Array();
  98. var arr = [],
  99. thisKey = ''
  100. for (var v in bd.Recommends) {
  101. thisKey += v + ',';
  102. }
  103. axios.get(process.env.VUE_APP_ADAPTERURL + `/ts/latest?keys=` + thisKey)
  104. .then(msg => {
  105. for (let v in msg.data) {
  106. if (msg.data[v].doubleValue ? (msg.data[v].doubleValue > 0) : (msg.data[v].booleanValue)) {
  107. bd.Recommends[v].isActive = true
  108. }
  109. }
  110. for (let rec in bd.Recommends) {
  111. if (bd.Recommends[rec].isActive) {
  112. list.push(bd.Recommends[rec])
  113. }
  114. }
  115. list.forEach(item => {
  116. item.createTime = dayjs(item.createTime).format('YYYY-MM-DD HH:mm:ss')
  117. })
  118. this.values = list
  119. })
  120. },
  121. sendMsg: function (vl, index) {
  122. var that = this;
  123. that.timeIndex = 0;
  124. that.ajaxDetail(vl, index);
  125. that.interval = window.setInterval(function () {
  126. that.ajaxDetail(vl, index);
  127. }, 3000);
  128. that.dialogVisible = true;
  129. that.dialogData.stationName = vl.stationName;
  130. },
  131. ajaxDetail(data, index) {
  132. let thisKey = Photoelectric[data.values];
  133. let array = []
  134. thisKey.forEach(item => { item.value ? array.push(item.value) : '' })
  135. let params = array.join(',')
  136. axios.get(process.env.VUE_APP_ADAPTERURL + `/ts/latest?keys=` + params)
  137. .then(res => {
  138. if (res) {
  139. console.log(res, this.dialogData.data, thisKey);
  140. for (let v in res.data) {
  141. thisKey.forEach(item => {
  142. let calc = item.calc ? item.calc : 1;
  143. if (item.value === v) {
  144. this.dialogData.data[item.tag] = {
  145. name: item.name,
  146. value: res.data[v].doubleValue ? res.data[v].doubleValue === 0 ? '0' : (res.data[v].doubleValue * calc).toFixed(2) : (res.data[v].booleanValue ? 1 : 0)
  147. }
  148. console.log(this.dialogData.data);
  149. }
  150. })
  151. }
  152. }
  153. })
  154. if (this.timeIndex == 0) {//一分钟执行一次
  155. var date = new Date()
  156. var endTs = date.getTime();
  157. var starTs = endTs - 28800000;
  158. const PowerSet = thisKey.find(ele => {
  159. return ele.tag == 'PowerSet'
  160. });
  161. const ActualPower = thisKey.find(ele => {
  162. return ele.tag == 'ActualPower'
  163. });
  164. var PowerSetData = [],
  165. ActualPowerData = [];
  166. axios.get(process.env.VUE_APP_ADAPTERURL + `/ts/history/snap?tagName=` + PowerSet.value + '&startTs=' +
  167. starTs +
  168. '&endTs=' + endTs).then(res1 => {
  169. axios.get(process.env.VUE_APP_ADAPTERURL + `/ts/history/snap?tagName=` + ActualPower.value +
  170. '&startTs=' + starTs + '&endTs=' + endTs).then(res2 => {
  171. res1.data.forEach(item => {
  172. PowerSetData.push({
  173. ts: item.ts,
  174. doubleValue: item.doubleValue * PowerSet.calc
  175. })
  176. })
  177. res2.data.forEach(item => {
  178. ActualPowerData.push({
  179. ts: item.ts,
  180. doubleValue: item.doubleValue * ActualPower.calc
  181. })
  182. })
  183. this.$refs.photo.initData(PowerSetData, ActualPowerData);
  184. });
  185. });
  186. } else if (this.timeIndex == 20) {
  187. this.timeIndex = -1;
  188. }
  189. this.timeIndex++;
  190. },
  191. },
  192. };
  193. </script>
  194. <style scoped>
  195. /* table {
  196. background-image: url("../../assets/img/RecommendedArea/background.png");
  197. text-align: center;
  198. font-size: 12px;
  199. background-size: 110px;
  200. margin-left: 10px;
  201. margin-top: 10px;
  202. padding-top: 10px;
  203. background-repeat: no-repeat;
  204. color: #ffffff;
  205. } */
  206. .imgs {
  207. /* width: 70px;
  208. height: 66px; */
  209. }
  210. .area {
  211. display: flex;
  212. flex-direction: column;
  213. font-size: 12px;
  214. color: #ffffff;
  215. width: 130px;
  216. align-items: center;
  217. margin-bottom: 10px;
  218. }
  219. .content {
  220. margin-top: -70px;
  221. width: 25px;
  222. height: 34px;
  223. margin-bottom: 20px;
  224. display: flex;
  225. align-items: center;
  226. }
  227. </style>