HomePageServiceImpl.java 59 KB

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