DecisionConvert.java 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. package com.gyee.impala.common.spring;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  4. import com.gyee.impala.mapper.decision.CollectorwireprojectMapper;
  5. import com.gyee.impala.mapper.decision.EnumMenuItemMapper;
  6. import com.gyee.impala.mapper.decision.WindplantprojectMapper;
  7. import com.gyee.impala.mapper.decision.WturMapper;
  8. import com.gyee.impala.mapper.master.WindturbineMapper;
  9. import com.gyee.impala.mapper.slave.LineMapper;
  10. import com.gyee.impala.mapper.slave.ProjectMapper;
  11. import com.gyee.impala.model.decision.Collectorwireproject;
  12. import com.gyee.impala.model.decision.EnumMenuItem;
  13. import com.gyee.impala.model.decision.Windplantproject;
  14. import com.gyee.impala.model.decision.Wtur;
  15. import com.gyee.impala.model.master.Windturbine;
  16. import com.gyee.impala.model.slave.Line;
  17. import com.gyee.impala.model.slave.Project;
  18. import org.springframework.stereotype.Service;
  19. import javax.annotation.Resource;
  20. import java.util.HashMap;
  21. import java.util.List;
  22. import java.util.Map;
  23. import java.util.stream.Collectors;
  24. @Service
  25. public class DecisionConvert {
  26. @Resource
  27. private WindplantprojectMapper windplantprojectMapper;
  28. @Resource
  29. private CollectorwireprojectMapper collectorwireprojectMapper;
  30. @Resource
  31. private WturMapper wturMapper;
  32. @Resource
  33. private WindturbineMapper windturbineMapper;
  34. @Resource
  35. private ProjectMapper projectMapper;
  36. @Resource
  37. private LineMapper lineMapper;
  38. @Resource
  39. private EnumMenuItemMapper enumMenuItemMapper;
  40. //网源id,英文名称
  41. private Map<Short, String> stationIdMap;
  42. //网源id,汉字名称
  43. private Map<Short, String> stationNameMap;
  44. private Map<Short, String> projectIdMap;
  45. private Map<Short, String> projectNameMap;
  46. private Map<Short, String> lineIdMap;
  47. private Map<Short, String> lineNameMap;
  48. private Map<Short, String> windturbineIdMap;
  49. private Map<Short, String> windturbineNameMap;
  50. //超短期模型
  51. private Map<Integer, String> spModelNameMap;
  52. //短期模型
  53. private Map<Integer, String> modelNameMap;
  54. private List<Collectorwireproject> collectorwireprojects;
  55. private List<Windplantproject> windplantprojects;
  56. public Map<Integer, String> getSpModelNameMap() {
  57. if (spModelNameMap == null) {
  58. QueryWrapper<EnumMenuItem> wrapper = new QueryWrapper<>();
  59. wrapper.eq("MENU_NO", 123);
  60. spModelNameMap = enumMenuItemMapper.selectList(wrapper).stream().collect(Collectors.toMap(EnumMenuItem::getItemNo, EnumMenuItem::getItemName));
  61. }
  62. return spModelNameMap;
  63. }
  64. public Map<Integer, String> getModelNameMap() {
  65. if (modelNameMap == null) {
  66. QueryWrapper<EnumMenuItem> wrapper = new QueryWrapper<>();
  67. wrapper.eq("MENU_NO", 120);
  68. modelNameMap = enumMenuItemMapper.selectList(wrapper).stream().collect(Collectors.toMap(EnumMenuItem::getItemNo, EnumMenuItem::getItemName));
  69. }
  70. return modelNameMap;
  71. }
  72. public Map<Short, String> getStationIdMap() {
  73. if (stationIdMap == null) {
  74. stationIdMap = new HashMap<>();
  75. stationIdMap.put((short) 1, "NSS_FDC");
  76. stationIdMap.put((short) 2, "QS_FDC");
  77. stationIdMap.put((short) 3, "SBQ_FDC");
  78. stationIdMap.put((short) 4, "XS_FDC");
  79. stationIdMap.put((short) 5, "MHS_FDC");
  80. }
  81. return stationIdMap;
  82. }
  83. public Map<Short, String> getStationNameMap() {
  84. if (stationNameMap == null) {
  85. stationNameMap = new HashMap<>();
  86. stationNameMap.put((short) 1, "牛首山风电场");
  87. stationNameMap.put((short) 2, "青山风电场");
  88. stationNameMap.put((short) 3, "石板泉风电场");
  89. stationNameMap.put((short) 4, "香山风电场");
  90. stationNameMap.put((short) 5, "麻黄山风电场");
  91. }
  92. return stationNameMap;
  93. }
  94. public Map<Short, String> getProjectIdMap() {
  95. if (projectNameMap == null) {
  96. Map<String, String> pm = projectMapper.selectList(Wrappers.emptyWrapper()).stream().collect(
  97. Collectors.toMap(Project::getName, Project::getId));
  98. getProjectNameMap();
  99. projectNameMap = new HashMap<>();
  100. projectIdMap.forEach((wyid, wyname) -> projectNameMap.put(wyid, pm.get(wyname)));
  101. }
  102. return projectNameMap;
  103. }
  104. public Map<Short, String> getProjectNameMap() {
  105. if (projectIdMap == null) {
  106. getWindplantprojects();
  107. projectIdMap = windplantprojects.stream().collect(Collectors.toMap(Windplantproject::getProjectNo, Windplantproject::getProjectName));
  108. }
  109. return projectIdMap;
  110. }
  111. public Map<Short, String> getLineIdMap() {
  112. if (lineNameMap == null) {
  113. Map<String, String> lm = lineMapper.selectList(Wrappers.emptyWrapper()).stream().collect(
  114. Collectors.toMap(Line::getName, Line::getId));
  115. getLineNameMap();
  116. lineNameMap = new HashMap<>();
  117. lineIdMap.forEach((wyid, wynm) -> lineNameMap.put(wyid, lm.get(wynm)));
  118. }
  119. return lineNameMap;
  120. }
  121. public Map<Short, String> getLineNameMap() {
  122. if (lineIdMap == null) {
  123. getCollectorwireprojects();
  124. lineIdMap = collectorwireprojects.stream().collect(Collectors.toMap(Collectorwireproject::getCollectorwireNo, Collectorwireproject::getWireName));
  125. }
  126. return lineIdMap;
  127. }
  128. public Map<Short, String> getWindturbineIdMap() {
  129. if (windturbineIdMap == null) {
  130. QueryWrapper<Wtur> wrapper = new QueryWrapper();
  131. wrapper.lt("WINDPLANT_NO", 6).lt("WTG_TYPE", 15);
  132. List<Wtur> wturs = wturMapper.selectList(wrapper);
  133. wturs.forEach(wtur -> wtur.setName(wtur.getName().replaceFirst("G", "G01_")));
  134. windturbineIdMap = wturs.stream().collect(Collectors.toMap(Wtur::getWturNo, Wtur::getName));
  135. }
  136. return windturbineIdMap;
  137. }
  138. public Map<Short, String> getWindturbineNameMap() {
  139. if (windturbineNameMap == null) {
  140. Map<String, String> wm = windturbineMapper.selectList(Wrappers.emptyWrapper()).stream().collect(
  141. Collectors.toMap(Windturbine::getId, Windturbine::getName));
  142. getWindturbineIdMap();
  143. windturbineNameMap = new HashMap<>();
  144. windturbineIdMap.forEach((wyid, fjid) -> windturbineNameMap.put(wyid, wm.get("fjid")));
  145. }
  146. return windturbineNameMap;
  147. }
  148. public List<Collectorwireproject> getCollectorwireprojects() {
  149. if (collectorwireprojects == null) {
  150. QueryWrapper<Collectorwireproject> wrapper = new QueryWrapper();
  151. wrapper.lt("WP_NO", 6);
  152. collectorwireprojects = collectorwireprojectMapper.selectList(wrapper);
  153. }
  154. return collectorwireprojects;
  155. }
  156. public List<Windplantproject> getWindplantprojects() {
  157. if (windplantprojects == null) {
  158. QueryWrapper<Windplantproject> wrapper = new QueryWrapper();
  159. wrapper.gt("PROJECT_NO", 0);
  160. windplantprojects = windplantprojectMapper.selectList(wrapper);
  161. }
  162. return windplantprojects;
  163. }
  164. }