HomePageServiceImpl.java 58 KB

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