HomePageServiceImpl.java 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  1. package com.jiayue.biz.service.impl;
  2. import cn.hutool.core.date.DateTime;
  3. import cn.hutool.core.util.ObjectUtil;
  4. import cn.hutool.db.Entity;
  5. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  6. import com.jiayue.biz.domain.*;
  7. import com.jiayue.biz.dto.EquipmentDto;
  8. import com.jiayue.biz.dto.ProjectEvolveDto;
  9. import com.jiayue.biz.dto.ProjectInfoDto;
  10. import com.jiayue.biz.dto.SelectLabForVal;
  11. import com.jiayue.biz.eunms.WindDirectionEnum;
  12. import com.jiayue.biz.mapper.ProphaseAnemometryDataMapper;
  13. import com.jiayue.biz.mapper.ProphaseWeatherDataMapper;
  14. import com.jiayue.biz.mapper.WindTowerDataParentTableMapper;
  15. import com.jiayue.biz.service.*;
  16. import com.jiayue.biz.util.CalculationUtil;
  17. import com.jiayue.biz.util.DateTimeUtil;
  18. import com.jiayue.common.core.redis.RedisCache;
  19. import com.jiayue.common.utils.DateUtil;
  20. import com.jiayue.common.utils.spring.SpringUtils;
  21. import com.sun.corba.se.spi.ior.ObjectKey;
  22. import lombok.AllArgsConstructor;
  23. import org.springframework.beans.factory.annotation.Autowired;
  24. import org.springframework.stereotype.Service;
  25. import java.math.BigDecimal;
  26. import java.math.RoundingMode;
  27. import java.sql.Timestamp;
  28. import java.text.ParseException;
  29. import java.text.SimpleDateFormat;
  30. import java.util.*;
  31. import java.util.stream.Collectors;
  32. /**
  33. * 首页Service业务层处理
  34. *
  35. * @author L.ym
  36. * @date 2022-05-11
  37. */
  38. @Service
  39. @AllArgsConstructor
  40. public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMapper, WindTowerDataParentTable> implements HomePageService {
  41. private final WindTowerInfoService windTowerInfoService;
  42. private final EquipmentAttributeService equipmentAttributeService;
  43. private final WindTowerCalculationDataServiceImpl windTowerCalculationDataService;
  44. private final WindTowerDataParentTableService windTowerDataParentTableService;
  45. private final StatisticsSituationService iStatisticsSituationService;
  46. private final ProjectService projectService;
  47. private final ElectricStationService electricStationService;
  48. private final ProvincialEnergyStationsService provincialEnergyStationsService;
  49. private final ProjectInfoService projectInfoService;
  50. private final StationInfoService stationInfoService;
  51. private final ProjectProgressService proProjectInfoService;
  52. private final TotalityInfoService totalityInfoService;
  53. private final FanModelDataService fanModelDataService;
  54. private final ProphaseAnemometryDataMapper prophaseAnemometryDataMapper;
  55. private final ProphaseWeatherDataMapper prophaseWeatherDataMapper;
  56. private final OtherStationInfoService otherStationInfoService;
  57. private final BigDecimal threeParameterOne = new BigDecimal("1.146");
  58. private final BigDecimal threeParameterTow = new BigDecimal("77.42");
  59. private final BigDecimal threeParameterThree = new BigDecimal("1672");
  60. private final BigDecimal threeParameterFour = new BigDecimal("5251");
  61. private final Double e = 10.0;
  62. /**
  63. * 风速 风功率 柱状图
  64. *
  65. * @param equipmentId 设备编号
  66. * @return Map<String, Object>
  67. */
  68. public Map<String, Object> getWsAndWpdForHeight(String equipmentId, String month) {
  69. List<WindTowerInfo> windTowerInfoList = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, equipmentId).list();
  70. String[] heights = windTowerInfoList.get(0).getHeights().split(",");
  71. //风速数据
  72. List<ProphaseAnemometryData> prophaseAnemometryDataList = new ArrayList<>();
  73. //空气密度
  74. List<ProphaseWeatherData> weatherDataList = new ArrayList<>();
  75. if (!month.equals("")) {
  76. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
  77. try {
  78. Date startDate = sdf.parse(month);
  79. Date endDate = DateTimeUtil.endOfMonth(startDate);
  80. prophaseAnemometryDataList = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
  81. weatherDataList = prophaseWeatherDataMapper.selectAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
  82. } catch (ParseException e) {
  83. e.printStackTrace();
  84. }
  85. } else {
  86. // 最新一天数据
  87. List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
  88. Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
  89. DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
  90. prophaseAnemometryDataList = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
  91. weatherDataList = prophaseWeatherDataMapper.selectAir(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
  92. }
  93. //时间和空气密度map
  94. Map<Timestamp, Float> timeAndAirMap = weatherDataList.stream().collect(Collectors.toMap(ProphaseWeatherData::getTs, ProphaseWeatherData::getAirDensity));
  95. HashMap<String, Object> dataMap = new HashMap<>();
  96. ArrayList<BigDecimal> wpdList = new ArrayList<>();
  97. ArrayList<BigDecimal> wsList = new ArrayList<>();
  98. ArrayList<String> heightList = new ArrayList<>();
  99. for (String height : heights) {
  100. //根据层高获取时间和风速map
  101. Map<Timestamp, Float> timeAndWsMap = prophaseAnemometryDataList.stream().filter(p -> p.getLayerHeight().equals(height)).collect(Collectors.toMap(ProphaseAnemometryData::getTs, ProphaseAnemometryData::getWsAve));
  102. if (!timeAndWsMap.isEmpty() && !timeAndAirMap.isEmpty()) {
  103. ArrayList<BigDecimal> wsSumList = new ArrayList<>();
  104. ArrayList<BigDecimal> wpdSumList = new ArrayList<>();
  105. //遍历空气密度
  106. for (Map.Entry<Timestamp, Float> airAndTime : timeAndAirMap.entrySet()) {
  107. //过滤风速map
  108. Map<Timestamp, Float> map = timeAndWsMap.entrySet().stream().filter(t -> t.getKey().getTime() == airAndTime.getKey().getTime()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
  109. if (!map.isEmpty()) {
  110. BigDecimal wpdCalculate = CalculationUtil.getWpdCalculate(BigDecimal.valueOf(map.get(airAndTime.getKey())), BigDecimal.valueOf(airAndTime.getValue()));
  111. wpdSumList.add(wpdCalculate);
  112. wsSumList.add(BigDecimal.valueOf(map.get(airAndTime.getKey())));
  113. }
  114. }
  115. if (wsSumList.size() > 0) {
  116. BigDecimal wpdAve = BigDecimal.valueOf(wsSumList.stream().collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
  117. wsList.add(wpdAve);
  118. }
  119. if (wpdSumList.size() > 0) {
  120. BigDecimal wpdAve = BigDecimal.valueOf(wpdSumList.stream().collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
  121. wpdList.add(wpdAve);
  122. }
  123. heightList.add(height + "m");
  124. }
  125. }
  126. dataMap.put("ws", wsList);
  127. dataMap.put("wpd", wpdList);
  128. dataMap.put("height", heightList);
  129. return dataMap;
  130. }
  131. /*首页地图 测风塔信息*/
  132. public List<Map<String, Object>> homePageMap() {
  133. List<Map<String, Object>> list = new ArrayList<>();
  134. try {
  135. SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  136. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  137. Date startDay = DateTimeUtil.getDayStartTime(new Date().getTime() - 1000 * 60 * 60 * 24);
  138. Date endDay = DateTimeUtil.getDayLastTime(new Date().getTime() - 1000 * 60 * 60 * 24);
  139. /*测风塔设备*/
  140. List<WindTowerInfo> windTowerInfoList = windTowerInfoService.list();
  141. List<StatisticsSituation> statisticsSituationList = iStatisticsSituationService.list();
  142. /*系统昨日的时间戳*/
  143. long date = DateTimeUtil.getDayStartTime(new Date().getTime()).getTime() - 86400000;
  144. for (WindTowerInfo windTowerInfo : windTowerInfoList) {
  145. Map<String, Object> map = new HashMap();
  146. // 状态
  147. Boolean status = true;
  148. /*判断此塔是否停机状态 若运行状态 计算是否10天内没接入数据*/
  149. if (windTowerInfo.getStatus() == null || windTowerInfo.getStatus().equals("1")) {
  150. /*根据设备编号获取该塔的最后一条数据*/
  151. WindTowerDataParentTable lastData = windTowerDataParentTableService.getLastData(windTowerInfo.getEquipmentNo());
  152. /*获取该塔接入的时间*/
  153. long startTime = DateTimeUtil.getDayStartTime(lastData.getTime().getTime()).getTime();
  154. /*测风塔最新接入时间 - 今日系统时间 = 差值 差值代表此塔几天没有接入数据,若差值>=10 将此塔状态设置为异常*/
  155. long differenceDays = date - startTime;
  156. if ((differenceDays / 86400000) >= 10) {
  157. status = false;
  158. } else {
  159. status = true;
  160. }
  161. }
  162. // 缺失的数据条数
  163. BigDecimal defectCount = new BigDecimal(144);
  164. /*昨日数据条数*/
  165. List<Map<String, Object>> maps = windTowerDataParentTableService.countDataIntegrity(windTowerInfo.getEquipmentNo(), sdfTime.format(startDay), sdfTime.format(endDay));
  166. List<StatisticsSituation> statisticsSituations = statisticsSituationList.stream().filter(w -> w.getEquipmentId().equals(windTowerInfo.getEquipmentNo())).collect(Collectors.toList());
  167. String info = "";
  168. if (!statisticsSituations.isEmpty()) {
  169. StatisticsSituation statisticsSituation = statisticsSituations.get(0);
  170. String[] split = statisticsSituation.getStartTimeAndEndTime().split(",");
  171. info = info + "数据起止时间:" + sdf.format(new Date(Long.parseLong(split[0]))) + " - " + sdf.format(new Date(Long.parseLong(split[1])));
  172. // if (statisticsSituation.getWsAve140() != null)
  173. // info = info + ";140米风速:" + statisticsSituation.getWsAve140().setScale(2, RoundingMode.HALF_UP);
  174. // if (statisticsSituation.getWsAve120() != null)
  175. // info = info + ";120米风速:" + statisticsSituation.getWsAve120().setScale(2, RoundingMode.HALF_UP);
  176. // if (statisticsSituation.getWsAve100() != null)
  177. // info = info + ";100米风速:" + statisticsSituation.getWsAve100().setScale(2, RoundingMode.HALF_UP);
  178. // if (statisticsSituation.getWsAve80() != null)
  179. // info = info + ";80米风速:" + statisticsSituation.getWsAve80().setScale(2, RoundingMode.HALF_UP);
  180. // if (statisticsSituation.getWsAve70() != null)
  181. // info = info + ";70米风速:" + statisticsSituation.getWsAve70().setScale(2, RoundingMode.HALF_UP);
  182. // if (statisticsSituation.getWsAve50() != null)
  183. // info = info + ";50米风速:" + statisticsSituation.getWsAve50().setScale(2, RoundingMode.HALF_UP);
  184. // if (statisticsSituation.getWsAve30() != null)
  185. // info = info + ";30米风速:" + statisticsSituation.getWsAve30().setScale(2, RoundingMode.HALF_UP);
  186. // if (statisticsSituation.getWsAve10() != null)
  187. // info = info + ";10米风速:" + statisticsSituation.getWsAve10().setScale(2, RoundingMode.HALF_UP);
  188. }
  189. if (!maps.isEmpty()) {
  190. defectCount = new BigDecimal(maps.get(0).get("num").toString()).subtract(new BigDecimal(144));
  191. }
  192. map.put("name", windTowerInfo.getName());
  193. map.put("equipmentNo", windTowerInfo.getEquipmentNo());
  194. map.put("lon", windTowerInfo.getLongitude());
  195. map.put("lat", windTowerInfo.getLatitude());
  196. map.put("defectCount", defectCount);
  197. map.put("status", status);
  198. map.put("info", info);
  199. list.add(map);
  200. }
  201. } catch (Exception e) {
  202. e.printStackTrace();
  203. }
  204. return list;
  205. }/*首页地图 测风塔信息*/
  206. public List<Map<String, Object>> homePageAllWindMap() {
  207. List<Map<String, Object>> list = new ArrayList<>();
  208. try {
  209. /*项目信息*/
  210. List<Project> projectList = projectService.list();
  211. /*场站信息*/
  212. List<ElectricStation> electricStationList = electricStationService.list();
  213. /*测风塔设备*/
  214. // List<WindTowerInfo> windTowerInfoList = windTowerInfoService.list();
  215. List<WindTowerInfo> windTowerInfoList = windTowerInfoService.lambdaQuery().list();
  216. /*项目塔信息*/
  217. List<Map<String, Object>> projectTowerList = projectTowerMap(projectList, windTowerInfoList);
  218. list.addAll(projectTowerList);
  219. /*场站塔信息*/
  220. List<Map<String, Object>> electricStationTowerList = electricStationTowerMap(electricStationList, windTowerInfoList);
  221. list.addAll(electricStationTowerList);
  222. } catch (Exception e) {
  223. e.printStackTrace();
  224. }
  225. return list;
  226. }
  227. /*首页地图项目塔*/
  228. public List<Map<String, Object>> projectTowerMap(List<Project> projectList, List<WindTowerInfo> windTowerInfoList) {
  229. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  230. List<Map<String, Object>> list = new ArrayList<>();
  231. /*统计概述*/
  232. List<StatisticsSituation> statisticsSituationList = iStatisticsSituationService.list();
  233. /*系统昨日的时间戳*/
  234. long date = DateTimeUtil.getDayStartTime(new Date().getTime()).getTime() - 86400000;
  235. /*项目塔*/
  236. for (Project project : projectList) {
  237. /*项目关联的塔*/
  238. String[] strings = project.getRelationEquipment().split(",");
  239. if (strings.length > 0) {
  240. for (String equipmentNo : strings) {
  241. Map<String, Object> map = new HashMap();
  242. map.put("type", "emailWind");
  243. map.put("projectId", project.getId());
  244. List<WindTowerInfo> windTowerInfos = windTowerInfoList.stream().filter(w -> w.getEquipmentNo().equals(equipmentNo)).collect(Collectors.toList());
  245. WindTowerInfo windTowerInfo = windTowerInfos.get(0);
  246. // 状态
  247. Boolean status = true;
  248. /*判断此塔是否停机状态 若运行状态 计算是否10天内没接入数据*/
  249. if (windTowerInfo.getStatus() == null || windTowerInfo.getStatus().equals("1")) {
  250. /*根据设备编号获取该塔的最后一条数据*/
  251. WindTowerDataParentTable lastData = windTowerDataParentTableService.getLastData(windTowerInfo.getEquipmentNo());
  252. /*获取该塔接入的时间*/
  253. long startTime = DateTimeUtil.getDayStartTime(lastData.getTime().getTime()).getTime();
  254. /*测风塔最新接入时间 - 今日系统时间 = 差值 差值代表此塔几天没有接入数据,若差值>=10 将此塔状态设置为异常*/
  255. long differenceDays = date - startTime;
  256. if ((differenceDays / 86400000) >= 10) {
  257. status = false;
  258. } else {
  259. status = true;
  260. }
  261. }
  262. /*获取数据的起止时间*/
  263. List<StatisticsSituation> statisticsSituations = statisticsSituationList.stream().filter(w -> w.getEquipmentId().equals(windTowerInfo.getEquipmentNo())).collect(Collectors.toList());
  264. String info = "";
  265. if (!statisticsSituations.isEmpty()) {
  266. StatisticsSituation statisticsSituation = statisticsSituations.get(0);
  267. String[] split = statisticsSituation.getStartTimeAndEndTime().split(",");
  268. info = info + "数据起止时间:" + sdf.format(new Date(Long.parseLong(split[0]))) + " - " + sdf.format(new Date(Long.parseLong(split[1])));
  269. }
  270. map.put("name", windTowerInfo.getName());
  271. map.put("equipmentNo", windTowerInfo.getEquipmentNo());
  272. map.put("lon", windTowerInfo.getLongitude());
  273. map.put("lat", windTowerInfo.getLatitude());
  274. map.put("status", status);
  275. map.put("info", info);
  276. list.add(map);
  277. }
  278. }
  279. }
  280. return list;
  281. }
  282. /*首页地图实时塔*/
  283. public List<Map<String, Object>> electricStationTowerMap(List<ElectricStation> electricStationList, List<WindTowerInfo> windTowerInfoList) {
  284. List<Map<String, Object>> list = new ArrayList<>();
  285. /*实时塔*/
  286. for (ElectricStation electricStation : electricStationList) {
  287. /*风场站关联的塔*/
  288. String[] strings = electricStation.getRelationEquipment().split(",");
  289. if (strings.length > 0) {
  290. for (String equipmentNo : strings) {
  291. Map<String, Object> map = new HashMap();
  292. map.put("type", "realWind");
  293. map.put("electricStationId", electricStation.getId());
  294. List<WindTowerInfo> windTowerInfos = windTowerInfoList.stream().filter(w -> w.getEquipmentNo().equals(equipmentNo)).collect(Collectors.toList());
  295. if (!windTowerInfos.isEmpty()) {
  296. WindTowerInfo windTowerInfo = windTowerInfos.get(0);
  297. // 状态
  298. Boolean status = windTowerInfo.getStatus() == null || windTowerInfo.getStatus().equals("1") ? true : false;
  299. map.put("name", windTowerInfo.getName());
  300. map.put("equipmentNo", windTowerInfo.getEquipmentNo());
  301. map.put("lon", windTowerInfo.getLongitude());
  302. map.put("lat", windTowerInfo.getLatitude());
  303. map.put("status", status);
  304. list.add(map);
  305. }
  306. }
  307. }
  308. }
  309. return list;
  310. }
  311. /**
  312. * 首页查询最新一天的风向玫瑰图
  313. *
  314. * @param equipmentId 设备编号
  315. * @param height 层高
  316. * @return List<Map < String, Object>>
  317. */
  318. @Override
  319. public HashMap<String, Object> homePageRose(String equipmentId, String height, String month) {
  320. List<ProphaseAnemometryData> anemometryData = new ArrayList<>();
  321. if (!month.equals("")) {
  322. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
  323. try {
  324. Date startDate = sdf.parse(month);
  325. Date endDate = DateTimeUtil.endOfMonth(startDate);
  326. anemometryData = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()), height);
  327. } catch (ParseException e) {
  328. e.printStackTrace();
  329. }
  330. } else {
  331. // 最新一天数据
  332. List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
  333. Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
  334. DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
  335. anemometryData = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, new Timestamp(startTime.getTime()), timeEnd, height);
  336. }
  337. HashMap<String, Integer> hashMap = new HashMap<>();
  338. BigDecimal total = BigDecimal.ZERO;
  339. Map<String, BigDecimal> map = new HashMap<>();
  340. Map<String, BigDecimal> windPowerMap = new HashMap<>();
  341. for (WindDirectionEnum value : WindDirectionEnum.values()) {
  342. //根据设备属性风向获取数据
  343. List<ProphaseAnemometryData> heightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(anemometryData, value);
  344. BigDecimal wsAve = BigDecimal.ZERO;
  345. if (heightAndWindDirectionEnum.size() > 0) {
  346. wsAve = BigDecimal.valueOf(heightAndWindDirectionEnum.stream().map(h -> {
  347. return BigDecimal.valueOf(h.getWsAve());
  348. }).collect(Collectors.averagingDouble(BigDecimal::doubleValue)));
  349. }
  350. hashMap.put(value.name(), heightAndWindDirectionEnum.size());
  351. total = total.add(BigDecimal.valueOf(heightAndWindDirectionEnum.size()));
  352. if (anemometryData.size() > 0) {
  353. //风向频率
  354. BigDecimal wdF = BigDecimal.valueOf(heightAndWindDirectionEnum.size()).divide(BigDecimal.valueOf(anemometryData.size()), 2, RoundingMode.HALF_UP);
  355. map.put(value.name(), BigDecimal.valueOf(100).multiply(wdF));
  356. // 风能:风向频率 * 平均风速的立方
  357. windPowerMap.put(value.name(), wsAve.multiply(wsAve).multiply(wsAve).multiply(wdF).setScale(2, RoundingMode.HALF_UP));
  358. } else {
  359. map.put(value.name(), BigDecimal.ZERO);
  360. windPowerMap.put(value.name(), BigDecimal.ZERO);
  361. }
  362. }
  363. ArrayList<Map.Entry<String, BigDecimal>> entries = new ArrayList<>(map.entrySet());
  364. entries.sort((o1, o2) -> {
  365. return o2.getValue().compareTo(o1.getValue());
  366. });
  367. List<Map.Entry<String, BigDecimal>> entries1 = entries.subList(0, 3);
  368. HashMap<String, Object> everyMap = new HashMap<>();
  369. everyMap.put("echars", map);
  370. everyMap.put("windPowerEchars", windPowerMap);
  371. everyMap.put("proportion", entries1);
  372. return everyMap;
  373. }
  374. /**
  375. * @param equipmentId 设备编号
  376. * @param height 层高
  377. * @return Map<String, Object>
  378. */
  379. public Map<String, Object> getHeightForAveWs(String equipmentId, String height) {
  380. // 最新一天数据
  381. List<Map<String, Object>> mapList = windTowerDataParentTableService.getStartTimeAndEndTimeForData(equipmentId);
  382. List<BigDecimal> wsForHeight = CalculationUtil.getWsForHeight(mapList, height);
  383. //本层高风速总和
  384. BigDecimal aveWs = wsForHeight.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
  385. HashMap<String, Long> hashMap = new HashMap<>();
  386. //层高所有条数
  387. long total = 0;
  388. for (int i = 0; i < 11; i = i + 2) {
  389. long count;
  390. int finalI = i;
  391. String iStr = "";
  392. if (i >= 10) {
  393. count = wsForHeight.stream().filter(w -> w.compareTo(BigDecimal.valueOf(finalI)) > 0).count();
  394. iStr = ">" + finalI + "m/s";
  395. } else {
  396. count = wsForHeight.stream().filter(w -> w.compareTo(BigDecimal.valueOf(finalI)) > 0 && w.compareTo(BigDecimal.valueOf(finalI + 2)) < 0).count();
  397. iStr = finalI + "~" + (finalI + 2) + "m/s";
  398. }
  399. total += count;
  400. if (count > 0) {
  401. hashMap.put(iStr, count);
  402. }
  403. }
  404. HashMap<String, Object> dataMap = new HashMap<>();
  405. if (total > 0) {
  406. dataMap.put("wsAve", aveWs.divide(BigDecimal.valueOf(total), 2, RoundingMode.HALF_UP));
  407. } else {
  408. dataMap.put("wsAve", BigDecimal.ZERO);
  409. }
  410. dataMap.put("proportion", hashMap);
  411. return dataMap;
  412. }
  413. /**
  414. * 首页查询最新一天的平均风速
  415. *
  416. * @param equipmentId 设备编号
  417. * @return
  418. */
  419. public Map<String, Object> homePageCharts(String equipmentId, String month) {
  420. List<ProphaseAnemometryData> mapList = new ArrayList<>();
  421. if (!month.equals("")) {
  422. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
  423. try {
  424. Date startDate = sdf.parse(month);
  425. Date endDate = DateTimeUtil.endOfMonth(startDate);
  426. mapList = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
  427. } catch (ParseException e) {
  428. e.printStackTrace();
  429. }
  430. } else {
  431. // 最新一天数据
  432. List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
  433. Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
  434. DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
  435. mapList = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
  436. }
  437. HashMap<String, Object> everyMap = new HashMap();
  438. //获取风速层高
  439. List<WindTowerInfo> windTowerInfos = windTowerInfoService.getByEquipmentNo(equipmentId);
  440. String height = windTowerInfos.get(0).getHeights();
  441. String[] heightAll = height.split(",");
  442. // 时间list
  443. ArrayList<String> timeList = new ArrayList();
  444. ArrayList<Object> everyData = new ArrayList<>();
  445. for (String h : heightAll) {
  446. timeList = new ArrayList();
  447. ArrayList<Object> hList = new ArrayList();
  448. HashMap<String, Object> hMap = new HashMap();
  449. //根据层高过滤时间和风速
  450. TreeMap<Long, Float> heightForTimeAndWs = new TreeMap<>(mapList.stream().filter(p -> p.getLayerHeight().equals(h)).collect(Collectors.toMap(prophaseAnemometryData -> prophaseAnemometryData != null ? prophaseAnemometryData.getTs().getTime() : null, prophaseAnemometryData1 -> prophaseAnemometryData1 != null ? prophaseAnemometryData1.getWsAve() : null)));
  451. for (Map.Entry<Long, Float> entry : heightForTimeAndWs.entrySet()) {
  452. String time = DateUtil.format(new Date(entry.getKey()), "yyyy-MM-dd HH:mm:ss");
  453. timeList.add(time);
  454. hList.add(entry.getValue());
  455. }
  456. hMap.put("height", h);
  457. hMap.put("value", hList);
  458. everyData.add(hMap);
  459. }
  460. everyMap.put("chart", everyData);
  461. everyMap.put("time", timeList);
  462. return everyMap;
  463. }
  464. /**
  465. * 首页空气密度和温度 折线图
  466. *
  467. * @param equipmentId 场站编号
  468. * @return List<WindTowerDataAirAndT>
  469. */
  470. public Map<String, List<Object>> selectTForAir(String equipmentId) {
  471. //获取最新一天的数据
  472. List<Map<String, Object>> mapList = windTowerDataParentTableService.getStartTimeAndEndTimeForData(equipmentId);
  473. ArrayList<Object> tList = new ArrayList<>();
  474. ArrayList<Object> airList = new ArrayList<>();
  475. ArrayList<Object> timeList = new ArrayList<>();
  476. HashMap<String, List<Object>> hashMap1 = new HashMap<>();
  477. for (Map<String, Object> map : mapList) {
  478. BigDecimal tAve = BigDecimal.ZERO;
  479. BigDecimal airDensity = BigDecimal.ZERO;
  480. String abnormal_type = "";
  481. //过滤异常值
  482. if (map.get("abnormal_type") != null) {
  483. abnormal_type = map.get("abnormal_type").toString();
  484. }
  485. if (map.get("t_ave") != null && !map.get("t_ave").equals("") && (!abnormal_type.contains("t_ave"))) {
  486. tAve = CalculationUtil.getBigDecimal(map.get("t_ave"));
  487. }
  488. if (map.get("air_density") != null && !map.get("air_density").equals("") && (!abnormal_type.contains("air_density"))) {
  489. airDensity = CalculationUtil.getBigDecimal(map.get("air_density"));
  490. }
  491. tList.add(tAve);
  492. airList.add(airDensity);
  493. String time = DateUtil.format(new Date(Long.parseLong(map.get("time").toString())), "yyyy-MM-dd HH:mm:ss");
  494. timeList.add(time);
  495. }
  496. hashMap1.put("t", tList);
  497. hashMap1.put("air", airList);
  498. hashMap1.put("time", timeList);
  499. return hashMap1;
  500. }
  501. /**
  502. * 首页空气密度、温度、压强平均值 湍流 风切变
  503. *
  504. * @param equipmentId 场站编号
  505. * @return Map<String, BigDecimal>
  506. */
  507. public Map<String, Object> getAirAndPaAndT(String equipmentId, String month) {
  508. List<ProphaseWeatherData> weatherDataList = new ArrayList<>();
  509. List<ProphaseAnemometryData> anemometryDataList = new ArrayList<>();
  510. if (!month.equals("")) {
  511. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
  512. try {
  513. Date startDate = sdf.parse(month);
  514. Date endDate = DateTimeUtil.endOfMonth(startDate);
  515. weatherDataList = prophaseWeatherDataMapper.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
  516. anemometryDataList = prophaseAnemometryDataMapper.selectAveAndSta(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
  517. } catch (ParseException e) {
  518. e.printStackTrace();
  519. }
  520. } else {
  521. List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
  522. Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
  523. DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
  524. // 最新一天数据
  525. weatherDataList = prophaseWeatherDataMapper.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
  526. anemometryDataList = prophaseAnemometryDataMapper.selectAveAndSta(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
  527. }
  528. WindTowerInfo windTowerInfo = windTowerInfoService.getByEquipmentNo(equipmentId).get(0);
  529. String height;
  530. String[] strings = windTowerInfo.getHeights().split(",");
  531. height = CalculationUtil.getNumberFromString(strings[0]);
  532. String minHeight = CalculationUtil.getNumberFromString(strings[strings.length - 1]); //最底层
  533. if (windTowerInfo.getDisplayHeight() != null && !windTowerInfo.getDisplayHeight().equals("")) {
  534. height = windTowerInfo.getDisplayHeight();
  535. }
  536. HashMap<String, Object> dataMap = new HashMap<>();
  537. BigDecimal tAve = BigDecimal.ZERO;
  538. BigDecimal airDensity = BigDecimal.ZERO;
  539. BigDecimal pa = BigDecimal.ZERO;
  540. // 风速集合
  541. String finalHeight = height;
  542. List<BigDecimal> wsForHeight = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(finalHeight)).map(h -> {
  543. return BigDecimal.valueOf(h.getWsAve());
  544. }).collect(Collectors.toList());
  545. List<BigDecimal> minWsForHeight = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(minHeight)).map(h -> {
  546. return BigDecimal.valueOf(h.getWsAve());
  547. }).collect(Collectors.toList());
  548. // 风速标准差集合
  549. List<BigDecimal> wsStaForHeight = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(minHeight)).map(h -> {
  550. return BigDecimal.valueOf(h.getWsSta());
  551. }).collect(Collectors.toList());
  552. BigDecimal avgWs = CalculationUtil.getAvgWind(wsForHeight); // 风速平均值
  553. BigDecimal avgMinWs = CalculationUtil.getAvgWind(minWsForHeight); // 最小风速平均值
  554. BigDecimal avgWsSta = CalculationUtil.getAvgWind(wsStaForHeight);// 风速标准差平均值
  555. BigDecimal turbulence = CalculationUtil.caTurbulenceIntensity(avgWsSta, avgWs); // 湍流
  556. BigDecimal windShear = BigDecimal.ZERO;
  557. if (avgWs.compareTo(BigDecimal.ZERO) != 0) {
  558. windShear = CalculationUtil.caWindShear(avgWs, avgMinWs, new BigDecimal(height), new BigDecimal(minHeight));// 风切变
  559. }
  560. if(!weatherDataList.isEmpty()){
  561. airDensity = BigDecimal.valueOf(weatherDataList.stream().map(w -> {
  562. return BigDecimal.valueOf(w.getAirDensity());
  563. }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2,RoundingMode.HALF_UP);
  564. tAve = BigDecimal.valueOf(weatherDataList.stream().map(w -> {
  565. return BigDecimal.valueOf(w.getTAve());
  566. }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2,RoundingMode.HALF_UP);
  567. pa = BigDecimal.valueOf(weatherDataList.stream().map(w -> {
  568. return BigDecimal.valueOf(w.getPaAve());
  569. }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2,RoundingMode.HALF_UP);
  570. }
  571. BigDecimal batterySum = BigDecimal.ZERO;
  572. for (BigDecimal ws : wsForHeight) {
  573. // 日发电量 = 风速*功率*塔个数*频率 累加至24小时
  574. BigDecimal battery = CalculationUtil.getBattery(ws);
  575. batterySum = batterySum.add(battery);
  576. }
  577. //日发电量
  578. batterySum = batterySum.divide(BigDecimal.valueOf(6 * 1000), 2, RoundingMode.HALF_UP);
  579. //满发小时数
  580. BigDecimal hourMax = batterySum.divide(BigDecimal.valueOf(6.25), 2, RoundingMode.HALF_UP);
  581. dataMap.put("battery", batterySum);
  582. dataMap.put("hour", hourMax);
  583. dataMap.put("t", tAve);
  584. dataMap.put("air", airDensity);
  585. dataMap.put("pa", pa);
  586. dataMap.put("turbulence", turbulence);
  587. dataMap.put("windShear", windShear);
  588. dataMap.put("height", height);
  589. return dataMap;
  590. }
  591. /**
  592. * 根据时间范围和设备id查询数据
  593. *
  594. * @param startTime 开始时间
  595. * @param endTime 结束时间
  596. * @param equipmentId 设备id
  597. * @return List<Map < String, Object>>
  598. */
  599. public List<Map<String, Object>> selectDataByBetweenTimeAndEquipmetId(Date startTime, Date endTime, String equipmentId) {
  600. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
  601. String key = "homepageWindDataSelect" + sdf.format(startTime) + equipmentId;
  602. Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(key);
  603. if (ObjectUtil.isNotNull(cacheObj)) {
  604. return (List<Map<String, Object>>) cacheObj;
  605. }
  606. List<Map<String, Object>> mapList = windTowerDataParentTableService.selectDataByBetweenTimeAndEquipmetId(startTime, endTime, equipmentId);
  607. SpringUtils.getBean(RedisCache.class).setCacheObject(key, mapList);
  608. return mapList;
  609. }
  610. //首页全省资源概述
  611. public HashMap<String, String> getResourcesOverview() {
  612. ProvincialEnergyStations provincialEnergyStations = provincialEnergyStationsService.getProvincialEnergyStations();
  613. HashMap<String, String> hashMap = new HashMap<>();
  614. hashMap.put("resourcesOverview", provincialEnergyStations.getResourcesOverview());
  615. return hashMap;
  616. }
  617. //获取华电以及全省资源概况
  618. public ProvincialEnergyStations getProvincialEnergyStations() {
  619. return provincialEnergyStationsService.getProvincialEnergyStations();
  620. }
  621. //获取项目类别以及项目概况
  622. public HashMap<String, Object> getProjectSort() {
  623. HashMap<String, Object> dataMap = new HashMap<>();
  624. List<TotalityInfo> totalityInfos = totalityInfoService.selectTotalityInfoList();
  625. List<ProjectInfo> projectInfoList = projectInfoService.getProjectInfoList();
  626. //根据类别分组
  627. Map<String, List<ProjectInfo>> four = projectInfoList.stream()
  628. .filter(p -> !p.getProjectBasicInfo().getProjectSort().equals("four"))
  629. .collect(Collectors.groupingBy((ProjectInfo pro) -> {
  630. return pro.getProjectBasicInfo().getProjectSort();
  631. }));
  632. //循环数据 存放Id和项目名称
  633. for (Map.Entry<String, List<ProjectInfo>> entry : four.entrySet()) {
  634. ArrayList<ProjectInfoDto> projectInfoDtoList = new ArrayList<>();
  635. for (ProjectInfo projectInfo : entry.getValue()) {
  636. ProjectInfoDto projectInfoDto = new ProjectInfoDto();
  637. projectInfoDto.setId(projectInfo.getId());
  638. projectInfoDto.setProjectSort(projectInfo.getProjectBasicInfo().getProjectName());
  639. projectInfoDtoList.add(projectInfoDto);
  640. }
  641. dataMap.put(entry.getKey(), projectInfoDtoList);
  642. }
  643. //项目基本信息
  644. dataMap.put("pInfo", totalityInfos.get(0).getPInfo());
  645. return dataMap;
  646. }
  647. //查询项目概况
  648. public HashMap<String, Object> projectMapInfo(String projectId) {
  649. HashMap<String, Object> dataMap = new HashMap<>();
  650. //获取项目信息
  651. List<ProjectInfo> projectInfoList = projectInfoService.getProjectInfoList();
  652. //根据项目ID过滤指定数据
  653. List<ProjectInfo> collect = projectInfoList.stream().filter(p -> p.getId().equals(projectId)).collect(Collectors.toList());
  654. //获取对应项目概述
  655. if (!collect.isEmpty()) {
  656. for (ProjectInfo projectInfo : collect) {
  657. dataMap.put("projectOverview", projectInfo.getProjectBasicInfo().getProjectOverview());
  658. dataMap.put("resourcesOverview", projectInfo.getProjectBasicInfo().getResourcesOverview());
  659. if (projectInfo.getEquipment() != null && projectInfo.getEquipment().size() > 0) {
  660. dataMap.put("longitude", projectInfo.getEquipment().get(0).getLongitude());
  661. dataMap.put("latitude", projectInfo.getEquipment().get(0).getLatitude());
  662. }
  663. }
  664. }
  665. return dataMap;
  666. }
  667. //地图点位坐标 (风机、测风塔、拐点)
  668. public HashMap<String, Object> getPointMap() {
  669. HashMap<String, Object> dataMap = new HashMap<>();
  670. //获取项目信息
  671. List<ProjectInfo> projectInfoList = projectInfoService.getProjectInfoList();
  672. //获取场站数据
  673. List<StationInfo> stationInfoList = stationInfoService.selectStationInfo();
  674. //循环所有项目于信息
  675. //测风塔List
  676. ArrayList<Map<String, Object>> towerList = new ArrayList<>();
  677. //拐点坐标List
  678. ArrayList<List<Coordinates>> coordinateList = new ArrayList<>();
  679. //风机List
  680. ArrayList<FanTower> fanList = new ArrayList<>();
  681. for (ProjectInfo projectInfo : projectInfoList) {
  682. //拐点坐标
  683. coordinateList.add(projectInfo.getCoordinates());
  684. if (projectInfo.getEquipment() != null && projectInfo.getEquipment().size() > 0) {
  685. //循环测风塔信息
  686. for (Equipment equipment : projectInfo.getEquipment()) {
  687. HashMap<String, Object> map = new HashMap<>();
  688. map.put("longitude", equipment.getLongitude());
  689. map.put("latitude", equipment.getLatitude());
  690. map.put("towerName", equipment.getName());
  691. map.put("projectName", projectInfo.getProjectBasicInfo().getProjectNameEasy());
  692. towerList.add(map);
  693. }
  694. }
  695. }
  696. dataMap.put("towerList", towerList);
  697. dataMap.put("coordinatesList", coordinateList);
  698. for (StationInfo stationInfo : stationInfoList) {
  699. if (stationInfo.getEquipment() != null && stationInfo.getEquipment().size() > 0) {
  700. //循环测风塔信息
  701. ArrayList<Map<String, Object>> arrayList = new ArrayList<>();
  702. for (Equipment equipment : stationInfo.getEquipment()) {
  703. HashMap<String, Object> map = new HashMap<>();
  704. map.put("longitude", equipment.getLongitude());
  705. map.put("latitude", equipment.getLatitude());
  706. map.put("towerName", equipment.getName());
  707. map.put("stationName", stationInfo.getStationBasicInfo().getStationName());
  708. arrayList.add(map);
  709. }
  710. towerList.addAll(arrayList);
  711. }
  712. fanList.addAll(stationInfo.getFanTowerList());
  713. }
  714. dataMap.put("fan", fanList);
  715. return dataMap;
  716. }
  717. /**
  718. * 项目测风塔下拉框
  719. *
  720. * @return List<SelectLabForVal>
  721. */
  722. public List<SelectLabForVal> projectSelect() {
  723. List<ProjectInfo> projectInfoList = projectInfoService.getProjectInfoList();
  724. ArrayList<SelectLabForVal> selectList = new ArrayList<>();
  725. if (projectInfoList.size() > 0) {
  726. //循环数据 放入项目id和项目名称
  727. for (ProjectInfo projectInfo : projectInfoList) {
  728. SelectLabForVal selectLabForVal = new SelectLabForVal();
  729. selectLabForVal.setLabel(projectInfo.getProjectBasicInfo().getProjectNameEasy());
  730. selectLabForVal.setValue(projectInfo.getId());
  731. if (projectInfo.getEquipment().size() > 0) {
  732. ArrayList<EquipmentDto> equipmentDtoList = new ArrayList<>();
  733. //循环数据 放入测风塔id和测风塔名称
  734. for (Equipment equipment : projectInfo.getEquipment()) {
  735. EquipmentDto equipmentDto = new EquipmentDto();
  736. equipmentDto.setLabel(equipment.getName());
  737. equipmentDto.setValue(equipment.getId());
  738. equipmentDtoList.add(equipmentDto);
  739. }
  740. selectLabForVal.setEquipmentDto(equipmentDtoList);
  741. }
  742. selectList.add(selectLabForVal);
  743. }
  744. }
  745. return selectList;
  746. }
  747. //查询场站信息以及场站列表
  748. public HashMap<String, Object> getStationTotalityInfo() {
  749. //总体信息
  750. List<TotalityInfo> totalityInfos = totalityInfoService.selectTotalityInfoList();
  751. //场站信息
  752. List<StationInfo> stationInfos = stationInfoService.selectStationInfo();
  753. HashMap<String, Object> stationMap = new HashMap<>();
  754. if (totalityInfos.size() > 0) {
  755. stationMap.put("fInfo", totalityInfos.get(0).getFInfo());
  756. stationMap.put("gInfo", totalityInfos.get(0).getGInfo());
  757. if (stationInfos.size() > 0) {
  758. ArrayList<Object> arrayList = new ArrayList<>();
  759. for (StationInfo stationInfo : stationInfos) {
  760. HashMap<String, Object> hashMap = new HashMap<>();
  761. hashMap.put("id", stationInfo.getId());
  762. hashMap.put("stationName", stationInfo.getStationBasicInfo().getStationName());
  763. //经度
  764. hashMap.put("longitude", stationInfo.getStationBasicInfo().getLongitude());
  765. //纬度
  766. hashMap.put("latitude", stationInfo.getStationBasicInfo().getLatitude());
  767. arrayList.add(hashMap);
  768. }
  769. stationMap.put("station", arrayList);
  770. }
  771. }
  772. return stationMap;
  773. }
  774. /**
  775. * 查询所有的场站坐标
  776. */
  777. public HashMap<String, Object> getStationSeat() {
  778. HashMap<String, Object> dataMap = new HashMap<>();
  779. List<OtherStationInfo> otherStationInfoList = otherStationInfoService.selectOtherStationInfo();
  780. List<StationInfo> stationInfos = stationInfoService.selectStationInfo();
  781. ArrayList<HashMap<String, Object>> stationList = new ArrayList<>();
  782. for (StationInfo stationInfo : stationInfos) {
  783. HashMap<String, Object> hashMap = new HashMap<>();
  784. hashMap.put("id", stationInfo.getId());
  785. hashMap.put("stationName", stationInfo.getStationBasicInfo().getStationName());
  786. //经度
  787. hashMap.put("longitude", stationInfo.getStationBasicInfo().getLongitude());
  788. //纬度
  789. hashMap.put("latitude", stationInfo.getStationBasicInfo().getLatitude());
  790. stationList.add(hashMap);
  791. }
  792. ArrayList<HashMap<String, Object>> otherStationList = new ArrayList<>();
  793. for (OtherStationInfo otherStationInfo : otherStationInfoList) {
  794. HashMap<String, Object> hashMap = new HashMap<>();
  795. hashMap.put("id", otherStationInfo.getId());
  796. hashMap.put("stationName", otherStationInfo.getStationName());
  797. //经度
  798. hashMap.put("longitude", otherStationInfo.getLongitude());
  799. //纬度
  800. hashMap.put("latitude", otherStationInfo.getLatitude());
  801. otherStationList.add(hashMap);
  802. }
  803. dataMap.put("HDStation",stationList);
  804. dataMap.put("otherStation",otherStationList);
  805. return dataMap;
  806. }
  807. /**
  808. * 查询所有的项目坐标
  809. */
  810. public ArrayList<Object> getProjectSeat() {
  811. ArrayList<Object> arrayList = new ArrayList<>();
  812. //获取项目信息
  813. List<ProjectInfo> projectInfoList = projectInfoService.getProjectInfoList();
  814. for (ProjectInfo projectInfo : projectInfoList) {
  815. if (projectInfo.getEquipment() != null && projectInfo.getEquipment().size() > 0) {
  816. Equipment equipment = projectInfo.getEquipment().get(0);
  817. HashMap<String, Object> map = new HashMap<>();
  818. map.put("longitude", equipment.getLongitude());
  819. map.put("latitude", equipment.getLatitude());
  820. map.put("id", projectInfo.getId());
  821. map.put("projectNameEasy", projectInfo.getProjectBasicInfo().getProjectNameEasy());
  822. map.put("projectName", projectInfo.getProjectBasicInfo().getProjectName());
  823. arrayList.add(map);
  824. }
  825. }
  826. return arrayList;
  827. }
  828. /**
  829. * 查询场站详细信息(风机、机型等)
  830. */
  831. public HashMap<String, Object> getStationInfo(String stationId) {
  832. //场站信息
  833. List<StationInfo> stationInfos = stationInfoService.selectStationInfo();
  834. List<StationInfo> stationInfoList = stationInfos.stream().filter(s -> s.getId().equals(stationId)).collect(Collectors.toList());
  835. List<FanModelData> fanModelDataList = fanModelDataService.getFanModelDataList();
  836. //过滤
  837. List<FanModelData> collect = fanModelDataList.stream().filter(f -> f.getStationId().equals(stationId)).collect(Collectors.toList());
  838. HashMap<String, Object> dataMap = new HashMap<>();
  839. if (stationInfoList.size() > 0) {
  840. ArrayList<HashMap<String, Object>> arrayList = new ArrayList<>();
  841. //根据风机类型分组
  842. Map<String, List<FanTower>> modelMap = stationInfoList.get(0).getFanTowerList().stream()
  843. .collect(Collectors.groupingBy(FanTower::getFanModel));
  844. //遍历map指定key
  845. for (Map.Entry<String, List<FanTower>> entry : modelMap.entrySet()) {
  846. for (FanModelData fanModelData : collect) {
  847. if (fanModelData.getModelName().equals(entry.getKey())) {
  848. HashMap<String, Object> map = new HashMap<>();
  849. //风机名称
  850. map.put("modelType", entry.getKey());
  851. //风机数量
  852. map.put("modelTotal", entry.getValue().size());
  853. //满发小时数
  854. map.put("wsAve", fanModelData.getWsAve());
  855. //主风向
  856. map.put("wdSum", fanModelData.getWdSum());
  857. //发电量
  858. map.put("generatingCapacity", fanModelData.getGeneratingCapacity());
  859. //满发小时数
  860. map.put("realTimeTotal", fanModelData.getRealTimeTotal());
  861. arrayList.add(map);
  862. }
  863. }
  864. }
  865. //过滤塔信息
  866. StationInfo stationInfo = stationInfoList.get(0);
  867. if (stationInfo.getEquipment() != null && stationInfo.getEquipment().size() > 0) {
  868. dataMap.put("longitude", stationInfo.getEquipment().get(0).getLongitude());
  869. dataMap.put("latitude", stationInfo.getEquipment().get(0).getLatitude());
  870. } else {
  871. dataMap.put("longitude", stationInfo.getFanTowerList().get(0).getLongitudeFan());
  872. dataMap.put("latitude", stationInfo.getFanTowerList().get(0).getLatitudeFan());
  873. }
  874. dataMap.put("modelT", arrayList);
  875. }
  876. return dataMap;
  877. }
  878. /**
  879. * 场站测风塔下拉框
  880. *
  881. * @return List<SelectLabForVal>
  882. */
  883. public List<SelectLabForVal> stationSelect() {
  884. List<StationInfo> stationInfoList = stationInfoService.selectStationInfo();
  885. ArrayList<SelectLabForVal> selectList = new ArrayList<>();
  886. if (stationInfoList.size() > 0) {
  887. //循环数据 放入项目id和项目名称
  888. for (StationInfo stationInfo : stationInfoList) {
  889. SelectLabForVal selectLabForVal = new SelectLabForVal();
  890. selectLabForVal.setLabel(stationInfo.getStationBasicInfo().getStationName());
  891. selectLabForVal.setValue(stationInfo.getId());
  892. if (stationInfo.getEquipment().size() > 0) {
  893. ArrayList<EquipmentDto> equipmentDtoList = new ArrayList<>();
  894. //循环数据 放入测风塔id和测风塔名称
  895. for (Equipment equipment : stationInfo.getEquipment()) {
  896. EquipmentDto equipmentDto = new EquipmentDto();
  897. equipmentDto.setLabel(equipment.getName());
  898. equipmentDto.setValue(equipment.getId());
  899. equipmentDtoList.add(equipmentDto);
  900. }
  901. selectLabForVal.setEquipmentDto(equipmentDtoList);
  902. }
  903. selectList.add(selectLabForVal);
  904. }
  905. }
  906. return selectList;
  907. }
  908. //项目进展
  909. public List<ProjectEvolveDto> getProjectEvolve(String projectId) {
  910. //查询项目进展信息
  911. List<ProjectProgress> projectProgresses = proProjectInfoService.selectProProjectInfo();
  912. //根据项目id筛选数据
  913. List<ProjectProgress> progressList = projectProgresses.stream().filter(p -> p.getProjectId().equals(projectId)).collect(Collectors.toList());
  914. ArrayList<ProjectEvolveDto> projectEvolveList = new ArrayList<>();
  915. if (progressList.size() > 0) {
  916. //循环项目进展信息 一般只有一条
  917. for (ProjectProgress progress : progressList) {
  918. if (progress.getProjectMenusOneList().size() > 0) {
  919. //循环一级菜单
  920. for (ProjectMenusOne menusOne : progress.getProjectMenusOneList()) {
  921. ProjectEvolveDto projectEvolveDtoOne = new ProjectEvolveDto();
  922. //一级菜单
  923. projectEvolveDtoOne.setIndex(menusOne.getIndex());
  924. projectEvolveDtoOne.setTaskContent(menusOne.getWorkContent());
  925. projectEvolveDtoOne.setPlanTime(menusOne.getPlanTime());
  926. if (menusOne.getProjectMenusTows().size() > 0 && menusOne.getProjectMenusTows().get(0).getIndex().equals("")) {
  927. if (menusOne.getProjectMenusTows().get(0).getProjectMenusThreeList().size() > 0) {
  928. projectEvolveDtoOne.setStatus(menusOne.getProjectMenusTows().get(0).getProjectMenusThreeList().get(0).getRealTime());
  929. projectEvolveList.add(projectEvolveDtoOne);
  930. }
  931. } else {
  932. projectEvolveList.add(projectEvolveDtoOne);
  933. if (menusOne.getProjectMenusTows() != null && menusOne.getProjectMenusTows().size() > 0) {
  934. //循环二级菜单
  935. for (ProjectMenusTow menusTow : menusOne.getProjectMenusTows()) {
  936. if (menusTow.getProjectMenusThreeList() != null && menusTow.getProjectMenusThreeList().size() > 0) {
  937. //循环三级菜单
  938. for (ProjectMenusThree menusThree : menusTow.getProjectMenusThreeList()) {
  939. ProjectEvolveDto projectEvolveDto = new ProjectEvolveDto();
  940. //放入二级序号
  941. projectEvolveDto.setIndex(menusTow.getIndex());
  942. //放入二级计划时间
  943. projectEvolveDto.setPlanTime(menusTow.getPlanTime());
  944. //放入二级工作内容
  945. projectEvolveDto.setTaskContent(menusTow.getWorkContent());
  946. //详细工作信息 三级工作内容
  947. projectEvolveDto.setDetailedTaskContent(menusThree.getWorkContent());
  948. //实际完成时间 三级时间
  949. projectEvolveDto.setRealTime(menusThree.getRealTime());
  950. //放入状态 三级备注
  951. projectEvolveDto.setStatus(menusThree.getRemark());
  952. projectEvolveList.add(projectEvolveDto);
  953. }
  954. } else {
  955. ProjectEvolveDto projectEvolveDto = new ProjectEvolveDto();
  956. projectEvolveDto.setIndex(menusTow.getIndex());
  957. projectEvolveDto.setTaskContent(menusTow.getWorkContent());
  958. projectEvolveDto.setPlanTime(menusTow.getPlanTime());
  959. projectEvolveList.add(projectEvolveDto);
  960. }
  961. }
  962. }
  963. }
  964. }
  965. }
  966. }
  967. }
  968. return projectEvolveList;
  969. }
  970. }