HomePageServiceImpl.java 60 KB

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