HomePageServiceImpl.java 62 KB

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