focusCard.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /* 推荐区 */
  2. <template>
  3. <div style="display: flex; justify-content: flex-start; flex-wrap: wrap">
  4. <div
  5. class="area"
  6. v-for="(vl, index) in values"
  7. :key="vl"
  8. @dblclick="sendMsg(vl, flase, index)"
  9. >
  10. <img
  11. class="imgs"
  12. src="../../assets/img/RecommendedArea/background.png"
  13. alt=""
  14. />
  15. <div class="content">{{ vl.showType }}</div>
  16. <div class="">{{ vl.name }}</div>
  17. <div class="">{{ vl.createTime }}</div>
  18. </div>
  19. </div>
  20. <PhotoelectricDetailPages
  21. ref="photo"
  22. @closed="closed()"
  23. :data="dialogData.data"
  24. :stationName="dialogData.stationName"
  25. v-model="dialogVisible"
  26. >
  27. </PhotoelectricDetailPages>
  28. <WindturbineDetailPages
  29. v-model="windVisible"
  30. :windturbine="currentWindturbine"
  31. @close="close"
  32. >
  33. </WindturbineDetailPages>
  34. <StationSvgDetailPages
  35. v-model="svgVisible"
  36. :svgWeb="svgWeb"
  37. @close="close"
  38. >
  39. </StationSvgDetailPages>
  40. </template>
  41. <script>
  42. import PhotoelectricDetailPages from "./PhotoelectricDetailPages.vue";
  43. import MessageBridge from "utils/MessageBridge";
  44. import StationSvgDetailPages from "../stationSvgDetailPages.vue";
  45. import WindturbineDetailPages from "../WindturbineDetailPages.vue";
  46. import api from "api/index";
  47. import dayjs from "dayjs";
  48. export default {
  49. name: "RecommendedArea",
  50. props: ["datas"],
  51. data() {
  52. return {
  53. values: [],
  54. currentWindturbine: {},
  55. dialogVisible: false,
  56. svgVisible: false,
  57. windVisible: false,
  58. svgWeb: "",
  59. station: [],
  60. dialogData: {
  61. data: {
  62. PowerSet: "",
  63. AgcUp: "",
  64. AgcLower: "",
  65. ActualPower: "",
  66. TheoryPower: "",
  67. ForecastPower: "",
  68. AgcIn: "",
  69. AgcFar: "",
  70. SumLock: "",
  71. SubLock: "",
  72. },
  73. },
  74. interval: "",
  75. intervalTimer: "",
  76. timeIndex: 0,
  77. };
  78. },
  79. components: {
  80. PhotoelectricDetailPages,
  81. StationSvgDetailPages,
  82. WindturbineDetailPages,
  83. },
  84. created() {
  85. this.datacontrol();
  86. this.getAGCStation();
  87. },
  88. methods: {
  89. getAGCStation() {
  90. api.getAGCStation().then((res) => {
  91. this.station = res.data;
  92. });
  93. },
  94. datacontrol() {
  95. let mb = MessageBridge.getInstance();
  96. let attention = [{ key: "/topic/attention", action: this.attention }];
  97. mb.register(attention);
  98. },
  99. attention(msg) {
  100. let list = JSON.parse(msg);
  101. let types = {
  102. ElectricityRestrictions: "限电",
  103. Offline: "离线",
  104. Accident: "故障",
  105. LowCurveFollowingRate: "跟随率低",
  106. };
  107. list.forEach((item) => {
  108. item.createTime = dayjs(item.time).format("YYYY-MM-DD HH:mm:ss");
  109. item.showType = types[item.type];
  110. });
  111. this.values = list;
  112. },
  113. closed() {
  114. clearInterval(this.intervalTimer);
  115. this.intervalTimer = null
  116. },
  117. close() {
  118. this.svgVisible = false;
  119. },
  120. sendMsg: function (vl, types, index) {
  121. if (vl.attentionType === "Station" && vl.type === "Accident") {
  122. this.svgVisible = true;
  123. this.svgWeb = vl.stationId;
  124. } else if (
  125. (vl.attentionType === "Station" &&
  126. vl.type === "ElectricityRestrictions") ||
  127. types
  128. ) {
  129. let that = this;
  130. that.timeIndex = 0;
  131. that.ajaxDetail(vl, index);
  132. that.intervalTimer = window.setInterval(function () {
  133. that.ajaxDetail(vl, index);
  134. }, 3000);
  135. that.dialogVisible = true;
  136. that.dialogData.stationName = this.station.filter(
  137. (item) => item.id === vl.id
  138. )[0].name;
  139. } else if (vl.attentionType === "WindTurbine") {
  140. this.windVisible = true;
  141. this.currentWindturbine = this.$store.state.windturbinelist[vl.id];
  142. }
  143. },
  144. ajaxDetail(data, index) {
  145. let thisKey = this.station.filter((item) => item.id === data.id)[0].tags;
  146. let array = [];
  147. thisKey.forEach((item) => {
  148. item.value ? array.push(item.value) : "";
  149. });
  150. let params = array.join(",");
  151. api.getLatest(params).then((res) => {
  152. if (res) {
  153. for (let v in res.data) {
  154. thisKey.forEach((item) => {
  155. let calc = item.calc ? item.calc : 1;
  156. if (item.value === v) {
  157. this.dialogData.data[item.tag] = {
  158. name: item.name,
  159. value: res.data[v].doubleValue
  160. ? res.data[v].doubleValue === 0? 0 : Number((res.data[v].doubleValue * calc).toFixed(2))
  161. : res.data[v].booleanValue? 1: 0,
  162. };
  163. }
  164. });
  165. }
  166. }
  167. });
  168. if (this.timeIndex == 0) {
  169. //一分钟执行一次
  170. let date = new Date();
  171. let endTs = date.getTime();
  172. let starTs = endTs - 28800000;
  173. const PowerSet = thisKey.find((ele) => {
  174. return ele.tag == "PowerSet";
  175. });
  176. const ActualPower = thisKey.find((ele) => {
  177. return ele.tag == "ActualPower";
  178. });
  179. let PowerSetData = [],
  180. ActualPowerData = [];
  181. api
  182. .getPower({
  183. tagName: PowerSet.value,
  184. startTs: starTs,
  185. endTs: endTs,
  186. interval: 60,
  187. })
  188. .then((res1) => {
  189. api
  190. .getPower({
  191. tagName: ActualPower.value,
  192. startTs: starTs,
  193. endTs: endTs,
  194. interval: 60,
  195. })
  196. .then((res2) => {
  197. res1.data.forEach((item) => {
  198. PowerSetData.push({
  199. ts: item.ts,
  200. doubleValue: item.doubleValue * PowerSet.calc,
  201. });
  202. });
  203. res2.data.forEach((item) => {
  204. ActualPowerData.push({
  205. ts: item.ts,
  206. doubleValue: item.doubleValue * ActualPower.calc,
  207. });
  208. });
  209. this.$refs.photo.initData(PowerSetData, ActualPowerData);
  210. });
  211. });
  212. } else if (this.timeIndex == 20) {
  213. this.timeIndex = -1;
  214. }
  215. this.timeIndex++;
  216. },
  217. },
  218. };
  219. </script>
  220. <style scoped>
  221. .area {
  222. display: flex;
  223. flex-direction: column;
  224. font-size: 12px;
  225. color: #ffffff;
  226. width: 130px;
  227. align-items: center;
  228. margin-bottom: 10px;
  229. }
  230. .content {
  231. margin-top: -70px;
  232. width: 25px;
  233. height: 34px;
  234. margin-bottom: 20px;
  235. display: flex;
  236. align-items: center;
  237. }
  238. </style>