HomePageServiceImpl.java 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125
  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(airAndTime.getValue()), BigDecimal.valueOf(map.get(airAndTime.getKey())));
  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. //
  413. // dataMap.put("proportion", hashMap);
  414. // return dataMap;
  415. // }
  416. /**
  417. * 首页查询最新一天的平均风速
  418. *
  419. * @param equipmentId 设备编号
  420. * @return
  421. */
  422. public Map<String, Object> homePageCharts(String equipmentId, String month) {
  423. List<ProphaseAnemometryData> mapList = new ArrayList<>();
  424. if (!month.equals("")) {
  425. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
  426. try {
  427. Date startDate = sdf.parse(month);
  428. Date endDate = DateTimeUtil.endOfMonth(startDate);
  429. mapList = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
  430. } catch (ParseException e) {
  431. e.printStackTrace();
  432. }
  433. } else {
  434. // 最新一天数据
  435. List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
  436. Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
  437. DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
  438. mapList = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
  439. }
  440. HashMap<String, Object> everyMap = new HashMap();
  441. //获取风速层高
  442. List<WindTowerInfo> windTowerInfos = windTowerInfoService.getByEquipmentNo(equipmentId);
  443. String height = windTowerInfos.get(0).getHeights();
  444. String[] heightAll = height.split(",");
  445. // 时间list
  446. ArrayList<String> timeList = new ArrayList();
  447. ArrayList<Object> everyData = new ArrayList<>();
  448. for (String h : heightAll) {
  449. timeList = new ArrayList();
  450. ArrayList<Object> hList = new ArrayList();
  451. HashMap<String, Object> hMap = new HashMap();
  452. //根据层高过滤时间和风速
  453. 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)));
  454. for (Map.Entry<Long, Float> entry : heightForTimeAndWs.entrySet()) {
  455. String time = DateUtil.format(new Date(entry.getKey()), "yyyy-MM-dd HH:mm:ss");
  456. timeList.add(time);
  457. hList.add(entry.getValue());
  458. }
  459. hMap.put("height", h);
  460. hMap.put("value", hList);
  461. everyData.add(hMap);
  462. }
  463. everyMap.put("chart", everyData);
  464. everyMap.put("time", timeList);
  465. return everyMap;
  466. }
  467. /**
  468. * 首页空气密度和温度 折线图
  469. *
  470. * @param equipmentId 场站编号
  471. * @return List<WindTowerDataAirAndT>
  472. */
  473. public Map<String, List<Object>> selectTForAir(String equipmentId) {
  474. //获取最新一天的数据
  475. List<Map<String, Object>> mapList = windTowerDataParentTableService.getStartTimeAndEndTimeForData(equipmentId);
  476. ArrayList<Object> tList = new ArrayList<>();
  477. ArrayList<Object> airList = new ArrayList<>();
  478. ArrayList<Object> timeList = new ArrayList<>();
  479. HashMap<String, List<Object>> hashMap1 = new HashMap<>();
  480. for (Map<String, Object> map : mapList) {
  481. BigDecimal tAve = BigDecimal.ZERO;
  482. BigDecimal airDensity = BigDecimal.ZERO;
  483. String abnormal_type = "";
  484. //过滤异常值
  485. if (map.get("abnormal_type") != null) {
  486. abnormal_type = map.get("abnormal_type").toString();
  487. }
  488. if (map.get("t_ave") != null && !map.get("t_ave").equals("") && (!abnormal_type.contains("t_ave"))) {
  489. tAve = CalculationUtil.getBigDecimal(map.get("t_ave"));
  490. }
  491. if (map.get("air_density") != null && !map.get("air_density").equals("") && (!abnormal_type.contains("air_density"))) {
  492. airDensity = CalculationUtil.getBigDecimal(map.get("air_density"));
  493. }
  494. tList.add(tAve);
  495. airList.add(airDensity);
  496. String time = DateUtil.format(new Date(Long.parseLong(map.get("time").toString())), "yyyy-MM-dd HH:mm:ss");
  497. timeList.add(time);
  498. }
  499. hashMap1.put("t", tList);
  500. hashMap1.put("air", airList);
  501. hashMap1.put("time", timeList);
  502. return hashMap1;
  503. }
  504. /**
  505. * 首页空气密度、温度、压强平均值 湍流 风切变 满发小时数 日发电量 经纬度 数据起止时间
  506. *
  507. * @param equipmentId 场站编号
  508. * @return Map<String, BigDecimal>
  509. */
  510. public Map<String, Object> getAirAndPaAndT(String equipmentId, String month) {
  511. List<ProphaseWeatherData> weatherDataList = new ArrayList<>();
  512. List<ProphaseAnemometryData> anemometryDataList = new ArrayList<>();
  513. //获取最新数据起止时间
  514. Map<String, Long> dataTimeStartAndEnd = prophaseWeatherDataService.getDataTimeStartAndEnd(equipmentId);
  515. //获取测风塔基本信息
  516. WindTowerInfo windTowerInfo = windTowerInfoService.getByEquipmentNo(equipmentId).get(0);
  517. //获取层高
  518. String[] heights = windTowerInfo.getHeights().split(",");
  519. //获取风向 层高 最高层
  520. String wdHeights = windTowerInfo.getWdHeights();
  521. String wdHeightMax = "";
  522. if (!wdHeights.isEmpty()) {
  523. ArrayList<String> wdHeightList = new ArrayList(Arrays.asList(wdHeights.split(",")));
  524. List<Integer> collect = wdHeightList.stream().map(Integer::parseInt).sorted().collect(Collectors.toList());
  525. wdHeightMax = collect.get(collect.size() - 1).toString();
  526. }
  527. if (!month.equals("")) {
  528. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
  529. try {
  530. Date startDate = sdf.parse(month);
  531. Date endDate = DateTimeUtil.endOfMonth(startDate);
  532. weatherDataList = prophaseWeatherDataMapper.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
  533. anemometryDataList = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsSta(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
  534. } catch (ParseException e) {
  535. e.printStackTrace();
  536. }
  537. } else {
  538. List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
  539. Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
  540. DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
  541. // 最新一天数据
  542. weatherDataList = prophaseWeatherDataMapper.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
  543. anemometryDataList = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsSta(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
  544. }
  545. HashMap<String, Object> dataMap = new HashMap<>();
  546. BigDecimal tAve = BigDecimal.ZERO;
  547. BigDecimal airDensity = BigDecimal.ZERO;
  548. BigDecimal pa = BigDecimal.ZERO;
  549. // 风速集合
  550. String finalHeight = CalculationUtil.getNumberFromString(heights[0]);
  551. List<BigDecimal> wsForHeight = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(finalHeight) && a.getWsAve() != null)
  552. .map(h -> BigDecimal.valueOf(h.getWsAve()))
  553. .collect(Collectors.toList());
  554. // 风速标准差集合
  555. List<BigDecimal> wsStaForHeight = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(finalHeight) && a.getWsSta() != null)
  556. .map(h -> BigDecimal.valueOf(h.getWsSta()))
  557. .collect(Collectors.toList());
  558. BigDecimal avgWs = CalculationUtil.getAvgWind(wsForHeight); // 风速平均值
  559. BigDecimal avgWsSta = CalculationUtil.getAvgWind(wsStaForHeight);// 风速标准差平均值
  560. BigDecimal turbulence = CalculationUtil.caTurbulenceIntensity(avgWsSta, avgWs); // 湍流
  561. BigDecimal windShear = CalculationUtil.getWindShear(anemometryDataList, heights);//计算综合风切变
  562. if (!weatherDataList.isEmpty()) {
  563. airDensity = BigDecimal.valueOf(weatherDataList.stream().map(w -> {
  564. return BigDecimal.valueOf(w.getAirDensity());
  565. }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
  566. tAve = BigDecimal.valueOf(weatherDataList.stream().map(w -> {
  567. return BigDecimal.valueOf(w.getTAve());
  568. }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
  569. pa = BigDecimal.valueOf(weatherDataList.stream().map(w -> {
  570. return BigDecimal.valueOf(w.getPaAve());
  571. }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
  572. }
  573. HashMap<String, Integer> wdMap = new HashMap<>();
  574. for (WindDirectionEnum value : WindDirectionEnum.values()) {
  575. String finalWdHeightMax = wdHeightMax;
  576. List<ProphaseAnemometryData> dataList = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(finalWdHeightMax)).collect(Collectors.toList());
  577. List<ProphaseAnemometryData> forHeightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(dataList, value);
  578. wdMap.put(value.name(), forHeightAndWindDirectionEnum.size());
  579. }
  580. Integer total = 0;
  581. for (Map.Entry<String, Integer> entry : wdMap.entrySet()) {
  582. if (entry.getValue() >= total) {
  583. dataMap.put("wdSum", entry.getKey());
  584. total = entry.getValue();
  585. }
  586. }
  587. BigDecimal batterySum = BigDecimal.ZERO;
  588. for (BigDecimal ws : wsForHeight) {
  589. // 日发电量 = 风速*功率*塔个数*频率 累加至24小时
  590. BigDecimal battery = CalculationUtil.getBattery(ws);
  591. batterySum = batterySum.add(battery);
  592. }
  593. //日发电量
  594. batterySum = batterySum.divide(BigDecimal.valueOf(6 * 1000), 2, RoundingMode.HALF_UP);
  595. //满发小时数
  596. BigDecimal hourMax = batterySum.divide(BigDecimal.valueOf(6.25), 2, RoundingMode.HALF_UP);
  597. dataMap.put("battery", batterySum);
  598. dataMap.put("hour", hourMax);
  599. String startTime = DateUtil.format(new Date(dataTimeStartAndEnd.get("startTime")), "yyyy-MM-dd");
  600. String endTime = DateUtil.format(new Date(dataTimeStartAndEnd.get("endTime")), "yyyy-MM-dd");
  601. dataMap.put("dataTime", startTime + "-" + endTime);
  602. dataMap.put("longitude", windTowerInfo.getLongitude());
  603. dataMap.put("latitude", windTowerInfo.getLatitude());
  604. dataMap.put("t", tAve);
  605. dataMap.put("air", airDensity);
  606. dataMap.put("pa", pa);
  607. dataMap.put("turbulence", turbulence);
  608. dataMap.put("windShear", windShear);
  609. dataMap.put("height", finalHeight);
  610. return dataMap;
  611. }
  612. /**
  613. * 根据时间范围和设备id查询数据
  614. *
  615. * @param startTime 开始时间
  616. * @param endTime 结束时间
  617. * @param equipmentId 设备id
  618. * @return List<Map < String, Object>>
  619. */
  620. public List<Map<String, Object>> selectDataByBetweenTimeAndEquipmetId(Date startTime, Date endTime, String equipmentId) {
  621. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
  622. String key = "homepageWindDataSelect" + sdf.format(startTime) + equipmentId;
  623. Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(key);
  624. if (ObjectUtil.isNotNull(cacheObj)) {
  625. return (List<Map<String, Object>>) cacheObj;
  626. }
  627. List<Map<String, Object>> mapList = windTowerDataParentTableService.selectDataByBetweenTimeAndEquipmetId(startTime, endTime, equipmentId);
  628. SpringUtils.getBean(RedisCache.class).setCacheObject(key, mapList);
  629. return mapList;
  630. }
  631. //首页全省资源概述
  632. public HashMap<String, String> getResourcesOverview() {
  633. ProvincialEnergyStations provincialEnergyStations = provincialEnergyStationsService.getProvincialEnergyStations();
  634. HashMap<String, String> hashMap = new HashMap<>();
  635. hashMap.put("resourcesOverview", provincialEnergyStations.getResourcesOverview());
  636. return hashMap;
  637. }
  638. //获取华电以及全省资源概况
  639. public ProvincialEnergyStations getProvincialEnergyStations() {
  640. return provincialEnergyStationsService.getProvincialEnergyStations();
  641. }
  642. //获取项目类别以及项目概况
  643. public HashMap<String, Object> getProjectSort() {
  644. HashMap<String, Object> dataMap = new HashMap<>();
  645. List<TotalityInfo> totalityInfos = totalityInfoService.selectTotalityInfoList();
  646. List<ProjectInfo> projectInfoList = projectInfoService.getProjectInfoList();
  647. //根据类别分组
  648. Map<String, List<ProjectInfo>> four = projectInfoList.stream()
  649. .filter(p -> !p.getProjectBasicInfo().getProjectSort().equals("four"))
  650. .collect(Collectors.groupingBy((ProjectInfo pro) -> {
  651. return pro.getProjectBasicInfo().getProjectSort();
  652. }));
  653. //循环数据 存放Id和项目名称
  654. for (Map.Entry<String, List<ProjectInfo>> entry : four.entrySet()) {
  655. ArrayList<ProjectInfoDto> projectInfoDtoList = new ArrayList<>();
  656. for (ProjectInfo projectInfo : entry.getValue()) {
  657. ProjectInfoDto projectInfoDto = new ProjectInfoDto();
  658. projectInfoDto.setId(projectInfo.getId());
  659. projectInfoDto.setProjectSort(projectInfo.getProjectBasicInfo().getProjectName());
  660. projectInfoDtoList.add(projectInfoDto);
  661. }
  662. dataMap.put(entry.getKey(), projectInfoDtoList);
  663. }
  664. //项目基本信息
  665. dataMap.put("pInfo", totalityInfos.get(0).getPInfo());
  666. return dataMap;
  667. }
  668. //查询项目概况
  669. public HashMap<String, Object> projectMapInfo(String projectId) {
  670. HashMap<String, Object> dataMap = new HashMap<>();
  671. //获取项目信息
  672. List<ProjectInfo> projectInfoList = projectInfoService.getProjectInfoList();
  673. //根据项目ID过滤指定数据
  674. List<ProjectInfo> collect = projectInfoList.stream().filter(p -> p.getId().equals(projectId)).collect(Collectors.toList());
  675. //获取对应项目概述
  676. if (!collect.isEmpty()) {
  677. for (ProjectInfo projectInfo : collect) {
  678. dataMap.put("projectOverview", projectInfo.getProjectBasicInfo().getProjectOverview());
  679. dataMap.put("resourcesOverview", projectInfo.getProjectBasicInfo().getResourcesOverview());
  680. // if (projectInfo.getEquipment() != null && projectInfo.getEquipment().size() > 0) {
  681. // dataMap.put("longitude", projectInfo.getEquipment().get(0).getLongitude());
  682. // dataMap.put("latitude", projectInfo.getEquipment().get(0).getLatitude());
  683. // }
  684. if (StrUtil.isNotBlank(projectInfo.getProjectBasicInfo().getPosition())) {
  685. String[] split = projectInfo.getProjectBasicInfo().getPosition().split(",");
  686. dataMap.put("longitude", split[0]);
  687. dataMap.put("latitude", split[1]);
  688. }
  689. }
  690. }
  691. return dataMap;
  692. }
  693. //地图点位坐标 (风机、测风塔、拐点)
  694. public HashMap<String, Object> getPointMap() {
  695. HashMap<String, Object> dataMap = new HashMap<>();
  696. //获取项目信息
  697. List<ProjectInfo> projectInfoList = projectInfoService.getProjectInfoList();
  698. //获取场站数据
  699. List<StationInfo> stationInfoList = stationInfoService.selectStationInfo();
  700. //循环所有项目于信息
  701. //测风塔List
  702. HashSet<Map<String, Object>> towerList = new HashSet<>();
  703. //拐点坐标List
  704. ArrayList<List<List<Coordinates>>> coordinateList = new ArrayList<>();
  705. //风机List
  706. ArrayList<FanTower> fanList = new ArrayList<>();
  707. HashSet<String> eqNoList = new HashSet<>();
  708. for (ProjectInfo projectInfo : projectInfoList) {
  709. //拐点坐标
  710. coordinateList.add(projectInfo.getCoordinates());
  711. if (projectInfo.getEquipment() != null && projectInfo.getEquipment().size() > 0) {
  712. //循环测风塔信息
  713. for (Equipment equipment : projectInfo.getEquipment()) {
  714. HashMap<String, Object> map = new HashMap<>();
  715. eqNoList.add(equipment.getEquipmentNo());
  716. map.put("type", "project");
  717. map.put("longitude", equipment.getLongitude());
  718. map.put("latitude", equipment.getLatitude());
  719. map.put("towerName", equipment.getName());
  720. map.put("towerNo", equipment.getEquipmentNo());
  721. map.put("projectId", projectInfo.getId());
  722. towerList.add(map);
  723. }
  724. }
  725. }
  726. dataMap.put("coordinatesList", coordinateList);
  727. for (StationInfo stationInfo : stationInfoList) {
  728. if (stationInfo.getEquipment() != null && stationInfo.getEquipment().size() > 0) {
  729. //循环测风塔信息
  730. ArrayList<Map<String, Object>> arrayList = new ArrayList<>();
  731. for (Equipment equipment : stationInfo.getEquipment()) {
  732. eqNoList.add(equipment.getEquipmentNo());
  733. HashMap<String, Object> map = new HashMap<>();
  734. map.put("type", "station");
  735. map.put("longitude", equipment.getLongitude());
  736. map.put("latitude", equipment.getLatitude());
  737. map.put("towerName", equipment.getName());
  738. map.put("towerNo", equipment.getEquipmentNo());
  739. map.put("projectId", stationInfo.getId());
  740. arrayList.add(map);
  741. }
  742. towerList.addAll(arrayList);
  743. }
  744. fanList.addAll(stationInfo.getFanTowerList());
  745. }
  746. List<Map<String, Object>> listMap = new ArrayList<>();
  747. //利用塔编号过滤分组项目以及场站的id
  748. for (String s : eqNoList) {
  749. ArrayList<Object> arrayList = new ArrayList<>();
  750. List<Map<String, Object>> towerNo = towerList.stream().filter(key -> key.get("towerNo").equals(s)).collect(Collectors.toList());
  751. //有多条只添加一个其他都是一样的只需要替换id 多余的需要删除
  752. for (Map<String, Object> map : towerNo) {
  753. HashMap<Object, Object> hashMap1 = new HashMap<>();
  754. hashMap1.put("type", map.get("type"));
  755. if (map.containsKey("projectId")) {
  756. hashMap1.put("id", map.get("projectId"));
  757. arrayList.add(hashMap1);
  758. }
  759. }
  760. //替换id值
  761. towerNo.get(0).put("projectId", arrayList);
  762. listMap.add(towerNo.get(0));
  763. }
  764. dataMap.put("towerList", listMap);
  765. dataMap.put("fan", fanList);
  766. return dataMap;
  767. }
  768. /**
  769. * 项目测风塔下拉框
  770. *
  771. * @return List<SelectLabForVal>
  772. */
  773. public List<SelectLabForVal> projectSelect() {
  774. List<ProjectInfo> projectInfoList = projectInfoService.getProjectInfoList();
  775. ArrayList<SelectLabForVal> selectList = new ArrayList<>();
  776. if (projectInfoList.size() > 0) {
  777. //循环数据 放入项目id和项目名称
  778. for (ProjectInfo projectInfo : projectInfoList) {
  779. SelectLabForVal selectLabForVal = new SelectLabForVal();
  780. selectLabForVal.setLabel(projectInfo.getProjectBasicInfo().getProjectNameEasy());
  781. selectLabForVal.setValue(projectInfo.getId());
  782. if (projectInfo.getEquipment().size() > 0) {
  783. ArrayList<EquipmentDto> equipmentDtoList = new ArrayList<>();
  784. //循环数据 放入测风塔id和测风塔名称
  785. for (Equipment equipment : projectInfo.getEquipment()) {
  786. EquipmentDto equipmentDto = new EquipmentDto();
  787. equipmentDto.setLabel(equipment.getName());
  788. equipmentDto.setValue(equipment.getEquipmentNo());
  789. equipmentDto.setWdHeight(equipment.getWdHeights());
  790. equipmentDto.setType(equipment.getType());
  791. equipmentDtoList.add(equipmentDto);
  792. }
  793. selectLabForVal.setEquipmentDto(equipmentDtoList);
  794. }
  795. selectList.add(selectLabForVal);
  796. }
  797. }
  798. return selectList;
  799. }
  800. //查询场站信息以及场站列表
  801. public HashMap<String, Object> getStationTotalityInfo() {
  802. //总体信息
  803. List<TotalityInfo> totalityInfos = totalityInfoService.selectTotalityInfoList();
  804. //场站信息
  805. List<StationInfo> stationInfos = stationInfoService.selectStationInfo();
  806. HashMap<String, Object> stationMap = new HashMap<>();
  807. if (totalityInfos.size() > 0) {
  808. stationMap.put("fInfo", totalityInfos.get(0).getFInfo());
  809. stationMap.put("gInfo", totalityInfos.get(0).getGInfo());
  810. if (stationInfos.size() > 0) {
  811. ArrayList<Object> arrayList = new ArrayList<>();
  812. for (StationInfo stationInfo : stationInfos) {
  813. HashMap<String, Object> hashMap = new HashMap<>();
  814. hashMap.put("id", stationInfo.getId());
  815. hashMap.put("stationName", stationInfo.getStationBasicInfo().getStationName());
  816. //经度
  817. hashMap.put("longitude", stationInfo.getStationBasicInfo().getLongitude());
  818. //纬度
  819. hashMap.put("latitude", stationInfo.getStationBasicInfo().getLatitude());
  820. arrayList.add(hashMap);
  821. }
  822. stationMap.put("station", arrayList);
  823. }
  824. }
  825. return stationMap;
  826. }
  827. /**
  828. * 查询所有的场站坐标
  829. */
  830. public HashMap<String, Object> getStationSeat() {
  831. HashMap<String, Object> dataMap = new HashMap<>();
  832. List<OtherStationInfo> otherStationInfoList = otherStationInfoService.selectOtherStationInfo();
  833. List<StationInfo> stationInfos = stationInfoService.selectStationInfo();
  834. ArrayList<HashMap<String, Object>> stationList = new ArrayList<>();
  835. for (StationInfo stationInfo : stationInfos) {
  836. HashMap<String, Object> hashMap = new HashMap<>();
  837. hashMap.put("id", stationInfo.getId());
  838. hashMap.put("stationName", stationInfo.getStationBasicInfo().getStationName());
  839. //经度
  840. hashMap.put("longitude", stationInfo.getStationBasicInfo().getLongitude());
  841. //纬度
  842. hashMap.put("latitude", stationInfo.getStationBasicInfo().getLatitude());
  843. hashMap.put("type", stationInfo.getStationBasicInfo().getStationType());
  844. stationList.add(hashMap);
  845. }
  846. ArrayList<HashMap<String, Object>> otherStationList = new ArrayList<>();
  847. for (OtherStationInfo otherStationInfo : otherStationInfoList) {
  848. if (otherStationInfo.getStationType().equals("风")) {//目前只要风
  849. HashMap<String, Object> hashMap = new HashMap<>();
  850. hashMap.put("id", otherStationInfo.getId());
  851. hashMap.put("stationName", otherStationInfo.getStationName());
  852. //经度
  853. hashMap.put("longitude", otherStationInfo.getLongitude());
  854. //纬度
  855. hashMap.put("latitude", otherStationInfo.getLatitude());
  856. hashMap.put("type", otherStationInfo.getStationType());
  857. otherStationList.add(hashMap);
  858. }
  859. }
  860. dataMap.put("HDStation", stationList);
  861. dataMap.put("otherStation", otherStationList);
  862. return dataMap;
  863. }
  864. /**
  865. * 查询所有的项目坐标
  866. */
  867. public ArrayList<Object> getProjectSeat() {
  868. ArrayList<Object> arrayList = new ArrayList<>();
  869. //获取项目信息
  870. List<ProjectInfo> projectInfoList = projectInfoService.getProjectInfoList();
  871. for (ProjectInfo projectInfo : projectInfoList) {
  872. HashMap<String, Object> map = new HashMap<>();
  873. if (StrUtil.isNotBlank(projectInfo.getProjectBasicInfo().getPosition())) {
  874. map.put("id", projectInfo.getId());
  875. map.put("projectNameEasy", projectInfo.getProjectBasicInfo().getProjectNameEasy());
  876. map.put("projectName", projectInfo.getProjectBasicInfo().getProjectName());
  877. String[] split = projectInfo.getProjectBasicInfo().getPosition().split(",");
  878. map.put("longitude", split[0]);
  879. map.put("latitude", split[1]);
  880. map.put("type", projectInfo.getProjectBasicInfo().getProjectType());
  881. }
  882. // if (projectInfo.getEquipment() != null && projectInfo.getEquipment().size() > 0) {
  883. //
  884. // }
  885. arrayList.add(map);
  886. }
  887. return arrayList;
  888. }
  889. /**
  890. * 查询场站详细信息(风机、机型等)
  891. */
  892. public HashMap<String, Object> getStationInfo(String stationId) {
  893. //场站信息
  894. List<StationInfo> stationInfos = stationInfoService.selectStationInfo();
  895. List<StationInfo> stationInfoList = stationInfos.stream().filter(s -> s.getId().equals(stationId)).collect(Collectors.toList());
  896. List<FanModelData> fanModelDataList = fanModelDataService.getFanModelDataList();
  897. //过滤
  898. List<FanModelData> collect = fanModelDataList.stream().filter(f -> f.getStationId().equals(stationId)).collect(Collectors.toList());
  899. HashMap<String, Object> dataMap = new HashMap<>();
  900. if (stationInfoList.size() > 0) {
  901. ArrayList<HashMap<String, Object>> arrayList = new ArrayList<>();
  902. //根据风机类型分组
  903. Map<String, List<FanTower>> modelMap = stationInfoList.get(0).getFanTowerList().stream()
  904. .collect(Collectors.groupingBy(FanTower::getFanModel));
  905. //遍历map指定key
  906. for (Map.Entry<String, List<FanTower>> entry : modelMap.entrySet()) {
  907. for (FanModelData fanModelData : collect) {
  908. if (fanModelData.getModelName().equals(entry.getKey())) {
  909. HashMap<String, Object> map = new HashMap<>();
  910. //风机名称
  911. map.put("modelType", entry.getKey());
  912. //风机数量
  913. map.put("modelTotal", entry.getValue().size());
  914. //满发小时数
  915. map.put("wsAve", fanModelData.getWsAve());
  916. //主风向
  917. map.put("wdSum", fanModelData.getWdSum());
  918. //发电量
  919. map.put("generatingCapacity", fanModelData.getGeneratingCapacity());
  920. //满发小时数
  921. map.put("realTimeTotal", fanModelData.getRealTimeTotal());
  922. arrayList.add(map);
  923. }
  924. }
  925. }
  926. //过滤塔信息
  927. StationInfo stationInfo = stationInfoList.get(0);
  928. if (stationInfo.getEquipment() != null && stationInfo.getEquipment().size() > 0) {
  929. dataMap.put("longitude", stationInfo.getEquipment().get(0).getLongitude());
  930. dataMap.put("latitude", stationInfo.getEquipment().get(0).getLatitude());
  931. }
  932. if (stationInfo.getFanTowerList() != null && stationInfo.getFanTowerList().size() > 0) {
  933. dataMap.put("longitude", stationInfo.getFanTowerList().get(0).getLongitudeFan());
  934. dataMap.put("latitude", stationInfo.getFanTowerList().get(0).getLatitudeFan());
  935. }
  936. dataMap.put("modelT", arrayList);
  937. }
  938. return dataMap;
  939. }
  940. /**
  941. * 场站测风塔下拉框
  942. *
  943. * @return List<SelectLabForVal>
  944. */
  945. public List<SelectLabForVal> stationSelect() {
  946. List<StationInfo> stationInfoList = stationInfoService.selectStationInfo();
  947. ArrayList<SelectLabForVal> selectList = new ArrayList<>();
  948. if (stationInfoList.size() > 0) {
  949. //循环数据 放入项目id和项目名称
  950. for (StationInfo stationInfo : stationInfoList) {
  951. SelectLabForVal selectLabForVal = new SelectLabForVal();
  952. selectLabForVal.setLabel(stationInfo.getStationBasicInfo().getStationName());
  953. selectLabForVal.setValue(stationInfo.getId());
  954. if (stationInfo.getEquipment().size() > 0) {
  955. ArrayList<EquipmentDto> equipmentDtoList = new ArrayList<>();
  956. //循环数据 放入测风塔id和测风塔名称
  957. for (Equipment equipment : stationInfo.getEquipment()) {
  958. EquipmentDto equipmentDto = new EquipmentDto();
  959. equipmentDto.setLabel(equipment.getName());
  960. equipmentDto.setValue(equipment.getEquipmentNo());
  961. equipmentDto.setWdHeight(equipment.getWdHeights());
  962. equipmentDto.setType(equipment.getType());
  963. equipmentDtoList.add(equipmentDto);
  964. }
  965. selectLabForVal.setEquipmentDto(equipmentDtoList);
  966. }
  967. selectList.add(selectLabForVal);
  968. }
  969. }
  970. return selectList;
  971. }
  972. //项目进展
  973. public List<ProjectEvolveDto> getProjectEvolve(String projectId) {
  974. //查询项目进展信息
  975. List<ProjectProgress> projectProgresses = proProjectInfoService.selectProProjectInfo();
  976. //根据项目id筛选数据
  977. List<ProjectProgress> progressList = projectProgresses.stream().filter(p -> p.getProjectId().equals(projectId)).collect(Collectors.toList());
  978. ArrayList<ProjectEvolveDto> projectEvolveList = new ArrayList<>();
  979. if (progressList.size() > 0) {
  980. //循环项目进展信息 一般只有一条
  981. for (ProjectProgress progress : progressList) {
  982. if (progress.getProjectMenusOneList().size() > 0) {
  983. //循环一级菜单
  984. for (ProjectMenusOne menusOne : progress.getProjectMenusOneList()) {
  985. ProjectEvolveDto projectEvolveDtoOne = new ProjectEvolveDto();
  986. //一级菜单
  987. projectEvolveDtoOne.setIndex(menusOne.getIndex());
  988. projectEvolveDtoOne.setTaskContent(menusOne.getWorkContent());
  989. projectEvolveDtoOne.setPlanTime(menusOne.getPlanTime());
  990. if (menusOne.getProjectMenusTows().size() > 0 && menusOne.getProjectMenusTows().get(0).getIndex().equals("")) {
  991. if (menusOne.getProjectMenusTows().get(0).getProjectMenusThreeList().size() > 0) {
  992. projectEvolveDtoOne.setStatus(menusOne.getProjectMenusTows().get(0).getProjectMenusThreeList().get(0).getRealTime());
  993. projectEvolveList.add(projectEvolveDtoOne);
  994. }
  995. } else {
  996. projectEvolveList.add(projectEvolveDtoOne);
  997. if (menusOne.getProjectMenusTows() != null && menusOne.getProjectMenusTows().size() > 0) {
  998. //循环二级菜单
  999. for (ProjectMenusTow menusTow : menusOne.getProjectMenusTows()) {
  1000. if (menusTow.getProjectMenusThreeList() != null && menusTow.getProjectMenusThreeList().size() > 0) {
  1001. //循环三级菜单
  1002. for (ProjectMenusThree menusThree : menusTow.getProjectMenusThreeList()) {
  1003. ProjectEvolveDto projectEvolveDto = new ProjectEvolveDto();
  1004. //放入二级序号
  1005. projectEvolveDto.setIndex(menusTow.getIndex());
  1006. //放入二级计划时间
  1007. projectEvolveDto.setPlanTime(menusTow.getPlanTime());
  1008. //放入二级工作内容
  1009. projectEvolveDto.setTaskContent(menusTow.getWorkContent());
  1010. //详细工作信息 三级工作内容
  1011. projectEvolveDto.setDetailedTaskContent(menusThree.getWorkContent());
  1012. //实际完成时间 三级时间
  1013. projectEvolveDto.setRealTime(menusThree.getRealTime());
  1014. //放入状态 三级备注
  1015. projectEvolveDto.setStatus(menusThree.getRemark());
  1016. projectEvolveList.add(projectEvolveDto);
  1017. }
  1018. } else {
  1019. ProjectEvolveDto projectEvolveDto = new ProjectEvolveDto();
  1020. projectEvolveDto.setIndex(menusTow.getIndex());
  1021. projectEvolveDto.setTaskContent(menusTow.getWorkContent());
  1022. projectEvolveDto.setPlanTime(menusTow.getPlanTime());
  1023. projectEvolveList.add(projectEvolveDto);
  1024. }
  1025. }
  1026. }
  1027. }
  1028. }
  1029. }
  1030. }
  1031. }
  1032. return projectEvolveList;
  1033. }
  1034. }