RealtimeSpeedPowerService.java 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. package com.gyee.generation.service;
  2. import com.gyee.common.contant.Contant;
  3. import com.gyee.common.model.PointData;
  4. import com.gyee.common.util.DateUtils;
  5. import com.gyee.generation.init.CacheContext;
  6. import com.gyee.generation.model.auto.*;
  7. import com.gyee.generation.util.realtimesource.IEdosUtil;
  8. import org.springframework.stereotype.Service;
  9. import javax.annotation.Resource;
  10. import java.util.ArrayList;
  11. import java.util.Date;
  12. import java.util.List;
  13. import java.util.Map;
  14. import java.util.concurrent.atomic.AtomicReference;
  15. /**
  16. * @ClassName : RealtimeSpeedPowerService
  17. * @Author : xieshengjie
  18. * @Date: 2022/4/24 8:49
  19. * @Description : 场站实时风速,实时功率
  20. */
  21. @Service
  22. public class RealtimeSpeedPowerService {
  23. @Resource
  24. private IEdosUtil edosUtil;
  25. private List<Windpowerstation> wpls;
  26. private Map<String, List<Project>> wppromap;
  27. private Map<String, List<Line>> prolinemap;
  28. private Map<String, List<Inverter>> linewtmap;
  29. private Date currentDate;
  30. private Map<String, Map<String, Windpowerstationpointnew>> wppointmap;
  31. private Map<String, Map<String, Windpowerstationpointnew>> linepointmap;
  32. private Map<String, Map<String, Windpowerstationpointnew>> propointmap;
  33. private Map<String, Map<String, Photovoltaictestingpointnew>> wtpAimap;
  34. private void init(){
  35. wpls = CacheContext.wpls;
  36. wppromap = CacheContext.wppromap;
  37. prolinemap = CacheContext.prolinemap;
  38. linewtmap = CacheContext.linewtmap;
  39. wppointmap = CacheContext.wppointmap;
  40. linepointmap = CacheContext.linepointmap;
  41. propointmap = CacheContext.propointmap;
  42. wtpAimap = CacheContext.wtpAimap;
  43. currentDate = DateUtils.getCurrentDate();
  44. }
  45. /**
  46. * 计算场站实时风速功率
  47. */
  48. public void calculateRealtimeSpeedPower() throws Exception {
  49. init();
  50. List<PointData> resultList = new ArrayList<>();
  51. wpls.stream().forEach(wp->{
  52. AtomicReference<Double> wpPower = new AtomicReference<>(0.0);
  53. Map<String, Windpowerstationpointnew> wppointnewMap = wppointmap.get(wp.getId());
  54. Windpowerstationpointnew wppowerpointnew = wppointnewMap.get(Contant.SSZGL);
  55. AtomicReference<Double> wpcount = new AtomicReference<>(0.0);
  56. wppromap.get(wp.getId()).stream().forEach(project -> {
  57. AtomicReference<Double> projectPower = new AtomicReference<>(0.0);
  58. Map<String, Windpowerstationpointnew> propointnewMap = propointmap.get(project.getId());
  59. Windpowerstationpointnew propowerpointnew = propointnewMap.get(Contant.SSZGL);
  60. AtomicReference<Double> procount = new AtomicReference<>(0.0);
  61. prolinemap.get(project.getId()).stream().forEach(line->{
  62. AtomicReference<Double> linePower = new AtomicReference<>(0.0);
  63. Map<String, Windpowerstationpointnew> linepointnewMap = linepointmap.get(line.getId());
  64. Windpowerstationpointnew linepowerpointnew = linepointnewMap.get(Contant.SSZGL);
  65. AtomicReference<Double> count = new AtomicReference<>(0.0);
  66. if ( linewtmap.containsKey(line.getId())) {
  67. List<Inverter> inverters = linewtmap.get(line.getId());
  68. inverters.stream().forEach(wt -> {
  69. Map<String, Photovoltaictestingpointnew> windturbinetestingpointnewMap = wtpAimap.get(wt.getId());
  70. Photovoltaictestingpointnew powerpoint = windturbinetestingpointnewMap.get(Contant.AIG013);
  71. Photovoltaictestingpointnew ztpoint = windturbinetestingpointnewMap.get(Contant.ZTMX);
  72. Boolean isOffline = false;
  73. try {
  74. Double ztvalue = edosUtil.getRealData(ztpoint).getPointValueInDouble();
  75. if (ztvalue == 12.0) {
  76. isOffline = true;
  77. }
  78. if (!isOffline) {
  79. count.getAndSet(count.get() + 1);
  80. procount.getAndSet(procount.get() + 1);
  81. wpcount.getAndSet(wpcount.get() + 1);
  82. Double wtpower = 0.0;
  83. try {
  84. wtpower = edosUtil.getRealData(powerpoint).getPointValueInDouble();
  85. Double finalWtpower = wtpower;
  86. linePower.updateAndGet(v -> new Double((double) (v + finalWtpower)));
  87. projectPower.updateAndGet(v -> new Double((double) (v + finalWtpower)));
  88. wpPower.updateAndGet(v -> new Double((double) (v + finalWtpower)));
  89. } catch (Exception e) {
  90. e.printStackTrace();
  91. }
  92. }
  93. } catch (Exception e) {
  94. e.printStackTrace();
  95. }
  96. });
  97. }else {
  98. }
  99. PointData linepowerPointData = createWpPointData(linepowerpointnew, linePower.get());
  100. resultList.add(linepowerPointData);
  101. });
  102. PointData projectpowerPointData = createWpPointData(propowerpointnew, projectPower.get());
  103. resultList.add(projectpowerPointData);
  104. });
  105. PointData wppowerPointData = createWpPointData(wppowerpointnew, wpPower.get());
  106. resultList.add(wppowerPointData);
  107. });
  108. edosUtil.sendMultiPoint(resultList);
  109. }
  110. private PointData createWpPointData(Windpowerstationpointnew linepointnew, double linespeed) {
  111. PointData pointData = new PointData();
  112. pointData.setEdnaId(linepointnew.getCode());
  113. pointData.setPointTime(currentDate.getTime());
  114. pointData.setPointName(linepointnew.getName());
  115. pointData.setPointValue(String.valueOf(linespeed));
  116. pointData.setPointValueInDouble(linespeed);
  117. return pointData;
  118. }
  119. }