focusCard.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. console.log(thisKey)
  134. let array = []
  135. thisKey.forEach(item => { item.value ? array.push(item.value) : '' })
  136. let params = array.join(',')
  137. axios.get(process.env.VUE_APP_ADAPTERURL + `/ts/latest?keys=` + params)
  138. .then(res => {
  139. if (res) {
  140. console.log(res, this.dialogData.data, thisKey);
  141. for (let v in res.data) {
  142. thisKey.forEach(item => {
  143. let calc = item.calc ? item.calc : 1;
  144. if (item.value === v) {
  145. this.dialogData.data[item.tag] = {
  146. name: item.name,
  147. value: res.data[v].doubleValue ? res.data[v].doubleValue === 0 ? '0' : (res.data[v].doubleValue * calc).toFixed(2) : (res.data[v].booleanValue ? 1 : 0)
  148. }
  149. console.log(this.dialogData.data);
  150. }
  151. })
  152. }
  153. }
  154. })
  155. if (this.timeIndex == 0) {//一分钟执行一次
  156. var date = new Date()
  157. var endTs = date.getTime();
  158. var starTs = endTs - 28800000;
  159. const PowerSet = thisKey.find(ele => {
  160. return ele.tag == 'PowerSet'
  161. });
  162. const ActualPower = thisKey.find(ele => {
  163. return ele.tag == 'ActualPower'
  164. });
  165. var PowerSetData = [],
  166. ActualPowerData = [];
  167. axios.get(process.env.VUE_APP_ADAPTERURL + `/ts/history/snap?tagName=` + PowerSet.value + '&startTs=' +
  168. starTs +
  169. '&endTs=' + endTs).then(res1 => {
  170. axios.get(process.env.VUE_APP_ADAPTERURL + `/ts/history/snap?tagName=` + ActualPower.value +
  171. '&startTs=' + starTs + '&endTs=' + endTs).then(res2 => {
  172. res1.data.forEach(item => {
  173. PowerSetData.push({
  174. ts: item.ts,
  175. doubleValue: item.doubleValue * PowerSet.calc
  176. })
  177. })
  178. res2.data.forEach(item => {
  179. ActualPowerData.push({
  180. ts: item.ts,
  181. doubleValue: item.doubleValue * ActualPower.calc
  182. })
  183. })
  184. this.$refs.photo.initData(PowerSetData, ActualPowerData);
  185. });
  186. });
  187. } else if (this.timeIndex == 20) {
  188. this.timeIndex = -1;
  189. }
  190. this.timeIndex++;
  191. },
  192. },
  193. };
  194. </script>
  195. <style scoped>
  196. /* table {
  197. background-image: url("../../assets/img/RecommendedArea/background.png");
  198. text-align: center;
  199. font-size: 12px;
  200. background-size: 110px;
  201. margin-left: 10px;
  202. margin-top: 10px;
  203. padding-top: 10px;
  204. background-repeat: no-repeat;
  205. color: #ffffff;
  206. } */
  207. .imgs {
  208. /* width: 70px;
  209. height: 66px; */
  210. }
  211. .area {
  212. display: flex;
  213. flex-direction: column;
  214. font-size: 12px;
  215. color: #ffffff;
  216. width: 130px;
  217. align-items: center;
  218. margin-bottom: 10px;
  219. }
  220. .content {
  221. margin-top: -70px;
  222. width: 25px;
  223. height: 34px;
  224. margin-bottom: 20px;
  225. display: flex;
  226. align-items: center;
  227. }
  228. </style>