HomePageServiceImpl.java 62 KB

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