12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100 |
- package com.jiayue.biz.service.impl;
- import cn.hutool.core.date.DateTime;
- import cn.hutool.core.util.ObjectUtil;
- import cn.hutool.core.util.StrUtil;
- import cn.hutool.db.Entity;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.toolkit.Wrappers;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.jiayue.biz.conf.RequestDataHelper;
- import com.jiayue.biz.domain.*;
- import com.jiayue.biz.dto.EquipmentDto;
- import com.jiayue.biz.dto.ProjectEvolveDto;
- import com.jiayue.biz.dto.ProjectInfoDto;
- import com.jiayue.biz.dto.SelectLabForVal;
- import com.jiayue.biz.eunms.WindDirectionEnum;
- import com.jiayue.biz.mapper.ProphaseAnemometryDataMapper;
- import com.jiayue.biz.mapper.ProphaseWeatherDataMapper;
- import com.jiayue.biz.mapper.WindTowerDataParentTableMapper;
- import com.jiayue.biz.service.*;
- import com.jiayue.biz.util.CalculationUtil;
- import com.jiayue.biz.util.DateTimeUtil;
- import com.jiayue.common.core.redis.RedisCache;
- import com.jiayue.common.utils.DateUtil;
- import com.jiayue.common.utils.spring.SpringUtils;
- import com.sun.corba.se.spi.ior.ObjectKey;
- import lombok.AllArgsConstructor;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.math.BigDecimal;
- import java.math.RoundingMode;
- import java.sql.Timestamp;
- import java.sql.Wrapper;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.*;
- import java.util.stream.Collectors;
- /**
- * 首页Service业务层处理
- *
- * @author L.ym
- * @date 2022-05-11
- */
- @Service
- @AllArgsConstructor
- public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMapper, WindTowerDataParentTable> implements HomePageService {
- private final WindTowerInfoService windTowerInfoService;
- private final EquipmentAttributeService equipmentAttributeService;
- private final WindTowerCalculationDataServiceImpl windTowerCalculationDataService;
- private final WindTowerDataParentTableService windTowerDataParentTableService;
- private final StatisticsSituationService iStatisticsSituationService;
- private final ProjectService projectService;
- private final ElectricStationService electricStationService;
- private final ProvincialEnergyStationsService provincialEnergyStationsService;
- private final ProjectInfoService projectInfoService;
- private final StationInfoService stationInfoService;
- private final ProjectProgressService proProjectInfoService;
- private final TotalityInfoService totalityInfoService;
- private final FanModelDataService fanModelDataService;
- private final ProphaseAnemometryDataService prophaseAnemometryDataService;
- private final ProphaseWeatherDataService prophaseWeatherDataService;
- private final OtherStationInfoService otherStationInfoService;
- private final WindDirectionStatisticsDataService windDirectionStatisticsDataService;
- private final BigDecimal threeParameterOne = new BigDecimal("1.146");
- private final BigDecimal threeParameterTow = new BigDecimal("77.42");
- private final BigDecimal threeParameterThree = new BigDecimal("1672");
- private final BigDecimal threeParameterFour = new BigDecimal("5251");
- private final Double e = 10.0;
- /**
- * 风速 风功率 柱状图
- *
- * @param equipmentId 设备编号
- * @return Map<String, Object>
- */
- public Map<String, Object> getWsAndWpdForHeight(String equipmentId, String month) {
- List<WindTowerInfo> windTowerInfoList = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, equipmentId).list();
- String[] heights = windTowerInfoList.get(0).getHeights().split(",");
- //获取最后一条记录
- WindTowerCalculationData lastDataCalculation = windTowerCalculationDataService.getLastDataCalculation(equipmentId);
- Date yearDay = DateTimeUtil.getYearDay(lastDataCalculation.getTime().getTime());
- //获取去年月份开始时间
- Date beginTime = DateUtil.offsetMonth(DateUtil.beginOfMonth(yearDay), 1);
- Date endTime = lastDataCalculation.getTime();
- List<EquipmentAttribute> equipmentAttributeList = equipmentAttributeService.lambdaQuery().likeLeft(EquipmentAttribute::getFieldName, "wpdMonth").or().likeLeft(EquipmentAttribute::getFieldName, "awsMonth").list();
- List<WindTowerCalculationData> windTowerCalculationData = windTowerCalculationDataService.getByBetweenTimeAndEquipmentIdAndEbId(beginTime, endTime, equipmentId, equipmentAttributeList);
- HashMap<String, Object> dataMap = new HashMap<>();
- ArrayList<BigDecimal> wpdList = new ArrayList<>();
- ArrayList<BigDecimal> wsList = new ArrayList<>();
- ArrayList<String> heightList = new ArrayList<>();
- //循环层高
- for (String height : heights) {
- //获取风速风功率的统计id
- List<EquipmentAttribute> equipmentAttributeWpd = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(height + "wpdMonth")).collect(Collectors.toList());
- List<EquipmentAttribute> equipmentAttributeWs = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(height + "awsMonth")).collect(Collectors.toList());
- heightList.add(height + "m");
- //根据id和时间过滤
- BigDecimal wpd = this.getDataForTimeAndId(windTowerCalculationData, equipmentAttributeWpd.get(0).getId(), beginTime.getTime(), endTime.getTime());
- wpdList.add(wpd);
- //根据id和时间过滤
- BigDecimal ws = this.getDataForTimeAndId(windTowerCalculationData, equipmentAttributeWs.get(0).getId(), beginTime.getTime(), endTime.getTime());
- wsList.add(ws);
- }
- // //风速数据
- // List<ProphaseAnemometryData> prophaseAnemometryDataList = new ArrayList<>();
- // //空气密度
- // List<ProphaseWeatherData> weatherDataList = new ArrayList<>();
- // if (!month.equals("")) {
- // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
- // try {
- // Date startDate = sdf.parse(month);
- // Date endDate = DateTimeUtil.endOfMonth(startDate);
- // prophaseAnemometryDataList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
- // weatherDataList = prophaseWeatherDataService.selectAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
- // } catch (ParseException e) {
- // e.printStackTrace();
- // }
- // } else {
- // // 最新一天数据
- // List<Entity> lastData = prophaseWeatherDataService.getLastData(equipmentId);
- // Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
- // DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
- // prophaseAnemometryDataList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
- // weatherDataList = prophaseWeatherDataService.selectAir(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
- //
- // }
- // //时间和空气密度map
- // Map<Timestamp, Float> timeAndAirMap = weatherDataList.stream().collect(Collectors.toMap(ProphaseWeatherData::getTs, ProphaseWeatherData::getAirDensity));
- //
- //
- // for (String height : heights) {
- // //根据层高获取时间和风速map
- // Map<Timestamp, Float> timeAndWsMap = prophaseAnemometryDataList.stream().filter(p -> p.getLayerHeight().equals(height)).collect(Collectors.toMap(ProphaseAnemometryData::getTs, ProphaseAnemometryData::getWsAve));
- //
- // if (!timeAndWsMap.isEmpty() && !timeAndAirMap.isEmpty()) {
- // ArrayList<BigDecimal> wsSumList = new ArrayList<>();
- // ArrayList<BigDecimal> wpdSumList = new ArrayList<>();
- // //遍历空气密度
- // for (Map.Entry<Timestamp, Float> airAndTime : timeAndAirMap.entrySet()) {
- // //过滤风速map
- // Map<Timestamp, Float> map = timeAndWsMap.entrySet().stream().filter(t -> t.getKey().getTime() == airAndTime.getKey().getTime()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
- // if (!map.isEmpty()) {
- // BigDecimal wpdCalculate = CalculationUtil.getWpdCalculate(BigDecimal.valueOf(airAndTime.getValue()), BigDecimal.valueOf(map.get(airAndTime.getKey())));
- // wpdSumList.add(wpdCalculate);
- // wsSumList.add(BigDecimal.valueOf(map.get(airAndTime.getKey())));
- // }
- // }
- // if (wsSumList.size() > 0) {
- // BigDecimal wpdAve = BigDecimal.valueOf(wsSumList.stream().collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
- // wsList.add(wpdAve);
- // }
- // if (wpdSumList.size() > 0) {
- // BigDecimal wpdAve = BigDecimal.valueOf(wpdSumList.stream().collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
- // wpdList.add(wpdAve);
- // }
- // heightList.add(height + "m");
- //
- // }
- // }
- dataMap.put("ws", wsList);
- dataMap.put("wpd", wpdList);
- dataMap.put("height", heightList);
- return dataMap;
- }
- //计算统计数据时间段内平均值
- public BigDecimal getDataForTimeAndId(List<WindTowerCalculationData> windTowerCalculationData, String ebId, Long startTime, Long endTime) {
- List<BigDecimal> calculationData = windTowerCalculationData.stream().filter(w -> w.getEbId().equals(ebId) && w.getTime().getTime() >= startTime && w.getTime().getTime() <= endTime).map(WindTowerCalculationData::getValue).collect(Collectors.toList());
- return calculationData.size() > 0 ? CalculationUtil.getAvgWind(calculationData) : BigDecimal.ZERO;
- }
- /**
- * 首页查询风速对比
- *
- * @param equipmentId 设备编号
- * @return
- */
- public Map<String, Object> homePageCharts(String equipmentId, String month) {
- HashMap<String, Object> everyMap = new HashMap();
- List<WindTowerInfo> windTowerInfoList = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, equipmentId).list();
- String[] heights = windTowerInfoList.get(0).getHeights().split(",");
- //获取最后一条记录
- WindTowerCalculationData lastDataCalculation = windTowerCalculationDataService.getLastDataCalculation(equipmentId);
- Date yearDay = DateTimeUtil.getYearDay(lastDataCalculation.getTime().getTime());
- //获取去年月份开始时间
- Date beginTime = DateUtil.offsetMonth(DateUtil.beginOfMonth(yearDay), 1);
- Date endTime = lastDataCalculation.getTime();
- List<EquipmentAttribute> equipmentAttributeList = equipmentAttributeService.lambdaQuery().likeLeft(EquipmentAttribute::getFieldName, "awsDay").list();
- List<WindTowerCalculationData> windTowerCalculationData = windTowerCalculationDataService.getByBetweenTimeAndEquipmentIdAndEbId(beginTime, endTime, equipmentId, equipmentAttributeList);
- //数据list 风速 层高
- ArrayList<Object> everyData = new ArrayList<>();
- //时间list
- ArrayList<String> timeList = new ArrayList();
- boolean type = true;
- for (String height : heights) {
- List<EquipmentAttribute> equipmentAttributes = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(height + "awsDay")).collect(Collectors.toList());
- ArrayList<Object> hList = new ArrayList();
- HashMap<String, Object> hMap = new HashMap();
- for (long i = beginTime.getTime(); i <= endTime.getTime(); i = i + 86400000) {
- long finalI = i;
- List<WindTowerCalculationData> calculationData = windTowerCalculationData.stream().filter(w -> w.getEbId().equals(equipmentAttributes.get(0).getId()) && w.getTime().getTime() == finalI).collect(Collectors.toList());
- if (type) {
- timeList.add(DateUtil.format(new Date(i), "yyyy-MM-dd"));
- }
- hList.add(calculationData.size() > 0 ? calculationData.get(0).getValue() : BigDecimal.ZERO);
- }
- hMap.put("height", height);
- hMap.put("value", hList);
- everyData.add(hMap);
- type = false;
- }
- everyMap.put("chart", everyData);
- everyMap.put("time", timeList);
- // List<ProphaseAnemometryData> mapList = new ArrayList<>();
- // if (!month.equals("")) {
- // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
- // try {
- // Date startDate = sdf.parse(month);
- // Date endDate = DateTimeUtil.endOfMonth(startDate);
- // mapList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
- // } catch (ParseException e) {
- // e.printStackTrace();
- // }
- // } else {
- // // 最新一天数据
- // List<Entity> lastData = prophaseWeatherDataService.getLastData(equipmentId);
- // Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
- // DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
- // mapList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
- //
- // }
- //// HashMap<String, Object> everyMap = new HashMap();
- // //获取风速层高
- // List<WindTowerInfo> windTowerInfos = windTowerInfoService.getByEquipmentNo(equipmentId);
- // String height = windTowerInfos.get(0).getHeights();
- // String[] heightAll = height.split(",");
- //
- // // 时间list
- //// ArrayList<String> timeList = new ArrayList();
- //// ArrayList<Object> everyData = new ArrayList<>();
- //
- // for (String h : heightAll) {
- // timeList = new ArrayList();
- // ArrayList<Object> hList = new ArrayList();
- // HashMap<String, Object> hMap = new HashMap();
- // //根据层高过滤时间和风速
- // 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)));
- // for (Map.Entry<Long, Float> entry : heightForTimeAndWs.entrySet()) {
- // String time = DateUtil.format(new Date(entry.getKey()), "yyyy-MM-dd HH:mm:ss");
- // timeList.add(time);
- // hList.add(entry.getValue());
- // }
- // hMap.put("height", h);
- // hMap.put("value", hList);
- // everyData.add(hMap);
- // }
- return everyMap;
- }
- /*首页地图 测风塔信息*/
- public List<Map<String, Object>> homePageMap() {
- List<Map<String, Object>> list = new ArrayList<>();
- try {
- SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- Date startDay = DateTimeUtil.getDayStartTime(new Date().getTime() - 1000 * 60 * 60 * 24);
- Date endDay = DateTimeUtil.getDayLastTime(new Date().getTime() - 1000 * 60 * 60 * 24);
- /*测风塔设备*/
- List<WindTowerInfo> windTowerInfoList = windTowerInfoService.list();
- List<StatisticsSituation> statisticsSituationList = iStatisticsSituationService.list();
- /*系统昨日的时间戳*/
- long date = DateTimeUtil.getDayStartTime(new Date().getTime()).getTime() - 86400000;
- for (WindTowerInfo windTowerInfo : windTowerInfoList) {
- Map<String, Object> map = new HashMap();
- // 状态
- Boolean status = true;
- /*判断此塔是否停机状态 若运行状态 计算是否10天内没接入数据*/
- if (windTowerInfo.getStatus() == null || windTowerInfo.getStatus().equals("1")) {
- /*根据设备编号获取该塔的最后一条数据*/
- WindTowerDataParentTable lastData = windTowerDataParentTableService.getLastData(windTowerInfo.getEquipmentNo());
- /*获取该塔接入的时间*/
- long startTime = DateTimeUtil.getDayStartTime(lastData.getTime().getTime()).getTime();
- /*测风塔最新接入时间 - 今日系统时间 = 差值 差值代表此塔几天没有接入数据,若差值>=10 将此塔状态设置为异常*/
- long differenceDays = date - startTime;
- if ((differenceDays / 86400000) >= 10) {
- status = false;
- } else {
- status = true;
- }
- }
- // 缺失的数据条数
- BigDecimal defectCount = new BigDecimal(144);
- /*昨日数据条数*/
- List<Map<String, Object>> maps = windTowerDataParentTableService.countDataIntegrity(windTowerInfo.getEquipmentNo(), sdfTime.format(startDay), sdfTime.format(endDay));
- List<StatisticsSituation> statisticsSituations = statisticsSituationList.stream().filter(w -> w.getEquipmentId().equals(windTowerInfo.getEquipmentNo())).collect(Collectors.toList());
- String info = "";
- if (!statisticsSituations.isEmpty()) {
- StatisticsSituation statisticsSituation = statisticsSituations.get(0);
- String[] split = statisticsSituation.getStartTimeAndEndTime().split(",");
- info = info + "数据起止时间:" + sdf.format(new Date(Long.parseLong(split[0]))) + " - " + sdf.format(new Date(Long.parseLong(split[1])));
- // if (statisticsSituation.getWsAve140() != null)
- // info = info + ";140米风速:" + statisticsSituation.getWsAve140().setScale(2, RoundingMode.HALF_UP);
- // if (statisticsSituation.getWsAve120() != null)
- // info = info + ";120米风速:" + statisticsSituation.getWsAve120().setScale(2, RoundingMode.HALF_UP);
- // if (statisticsSituation.getWsAve100() != null)
- // info = info + ";100米风速:" + statisticsSituation.getWsAve100().setScale(2, RoundingMode.HALF_UP);
- // if (statisticsSituation.getWsAve80() != null)
- // info = info + ";80米风速:" + statisticsSituation.getWsAve80().setScale(2, RoundingMode.HALF_UP);
- // if (statisticsSituation.getWsAve70() != null)
- // info = info + ";70米风速:" + statisticsSituation.getWsAve70().setScale(2, RoundingMode.HALF_UP);
- // if (statisticsSituation.getWsAve50() != null)
- // info = info + ";50米风速:" + statisticsSituation.getWsAve50().setScale(2, RoundingMode.HALF_UP);
- // if (statisticsSituation.getWsAve30() != null)
- // info = info + ";30米风速:" + statisticsSituation.getWsAve30().setScale(2, RoundingMode.HALF_UP);
- // if (statisticsSituation.getWsAve10() != null)
- // info = info + ";10米风速:" + statisticsSituation.getWsAve10().setScale(2, RoundingMode.HALF_UP);
- }
- if (!maps.isEmpty()) {
- defectCount = new BigDecimal(maps.get(0).get("num").toString()).subtract(new BigDecimal(144));
- }
- map.put("name", windTowerInfo.getName());
- map.put("equipmentNo", windTowerInfo.getEquipmentNo());
- map.put("lon", windTowerInfo.getLongitude());
- map.put("lat", windTowerInfo.getLatitude());
- map.put("defectCount", defectCount);
- map.put("status", status);
- map.put("info", info);
- list.add(map);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return list;
- }/*首页地图 测风塔信息*/
- public List<Map<String, Object>> homePageAllWindMap() {
- List<Map<String, Object>> list = new ArrayList<>();
- try {
- /*项目信息*/
- List<Project> projectList = projectService.list();
- /*场站信息*/
- List<ElectricStation> electricStationList = electricStationService.list();
- /*测风塔设备*/
- // List<WindTowerInfo> windTowerInfoList = windTowerInfoService.list();
- List<WindTowerInfo> windTowerInfoList = windTowerInfoService.lambdaQuery().list();
- /*项目塔信息*/
- List<Map<String, Object>> projectTowerList = projectTowerMap(projectList, windTowerInfoList);
- list.addAll(projectTowerList);
- /*场站塔信息*/
- List<Map<String, Object>> electricStationTowerList = electricStationTowerMap(electricStationList, windTowerInfoList);
- list.addAll(electricStationTowerList);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return list;
- }
- /*首页地图项目塔*/
- public List<Map<String, Object>> projectTowerMap(List<Project> projectList, List<WindTowerInfo> windTowerInfoList) {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- List<Map<String, Object>> list = new ArrayList<>();
- /*统计概述*/
- List<StatisticsSituation> statisticsSituationList = iStatisticsSituationService.list();
- /*系统昨日的时间戳*/
- long date = DateTimeUtil.getDayStartTime(new Date().getTime()).getTime() - 86400000;
- /*项目塔*/
- for (Project project : projectList) {
- /*项目关联的塔*/
- String[] strings = project.getRelationEquipment().split(",");
- if (strings.length > 0) {
- for (String equipmentNo : strings) {
- Map<String, Object> map = new HashMap();
- map.put("type", "emailWind");
- map.put("projectId", project.getId());
- List<WindTowerInfo> windTowerInfos = windTowerInfoList.stream().filter(w -> w.getEquipmentNo().equals(equipmentNo)).collect(Collectors.toList());
- WindTowerInfo windTowerInfo = windTowerInfos.get(0);
- // 状态
- Boolean status = true;
- /*判断此塔是否停机状态 若运行状态 计算是否10天内没接入数据*/
- if (windTowerInfo.getStatus() == null || windTowerInfo.getStatus().equals("1")) {
- /*根据设备编号获取该塔的最后一条数据*/
- WindTowerDataParentTable lastData = windTowerDataParentTableService.getLastData(windTowerInfo.getEquipmentNo());
- /*获取该塔接入的时间*/
- long startTime = DateTimeUtil.getDayStartTime(lastData.getTime().getTime()).getTime();
- /*测风塔最新接入时间 - 今日系统时间 = 差值 差值代表此塔几天没有接入数据,若差值>=10 将此塔状态设置为异常*/
- long differenceDays = date - startTime;
- if ((differenceDays / 86400000) >= 10) {
- status = false;
- } else {
- status = true;
- }
- }
- /*获取数据的起止时间*/
- List<StatisticsSituation> statisticsSituations = statisticsSituationList.stream().filter(w -> w.getEquipmentId().equals(windTowerInfo.getEquipmentNo())).collect(Collectors.toList());
- String info = "";
- if (!statisticsSituations.isEmpty()) {
- StatisticsSituation statisticsSituation = statisticsSituations.get(0);
- String[] split = statisticsSituation.getStartTimeAndEndTime().split(",");
- info = info + "数据起止时间:" + sdf.format(new Date(Long.parseLong(split[0]))) + " - " + sdf.format(new Date(Long.parseLong(split[1])));
- }
- map.put("name", windTowerInfo.getName());
- map.put("equipmentNo", windTowerInfo.getEquipmentNo());
- map.put("lon", windTowerInfo.getLongitude());
- map.put("lat", windTowerInfo.getLatitude());
- map.put("status", status);
- map.put("info", info);
- list.add(map);
- }
- }
- }
- return list;
- }
- /*首页地图实时塔*/
- public List<Map<String, Object>> electricStationTowerMap(List<ElectricStation> electricStationList, List<WindTowerInfo> windTowerInfoList) {
- List<Map<String, Object>> list = new ArrayList<>();
- /*实时塔*/
- for (ElectricStation electricStation : electricStationList) {
- /*风场站关联的塔*/
- String[] strings = electricStation.getRelationEquipment().split(",");
- if (strings.length > 0) {
- for (String equipmentNo : strings) {
- Map<String, Object> map = new HashMap();
- map.put("type", "realWind");
- map.put("electricStationId", electricStation.getId());
- List<WindTowerInfo> windTowerInfos = windTowerInfoList.stream().filter(w -> w.getEquipmentNo().equals(equipmentNo)).collect(Collectors.toList());
- if (!windTowerInfos.isEmpty()) {
- WindTowerInfo windTowerInfo = windTowerInfos.get(0);
- // 状态
- Boolean status = windTowerInfo.getStatus() == null || windTowerInfo.getStatus().equals("1") ? true : false;
- map.put("name", windTowerInfo.getName());
- map.put("equipmentNo", windTowerInfo.getEquipmentNo());
- map.put("lon", windTowerInfo.getLongitude());
- map.put("lat", windTowerInfo.getLatitude());
- map.put("status", status);
- list.add(map);
- }
- }
- }
- }
- return list;
- }
- /**
- * 首页查询最新一天的风向玫瑰图
- *
- * @param equipmentId 设备编号
- * @param height 层高
- * @return List<Map < String, Object>>
- */
- @Override
- public HashMap<String, Object> homePageRose(String equipmentId, String height, String month) {
- List<ProphaseAnemometryData> anemometryData = new ArrayList<>();
- if (!month.equals("")) {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
- try {
- Date startDate = sdf.parse(month);
- Date endDate = DateTimeUtil.endOfMonth(startDate);
- anemometryData = prophaseAnemometryDataService.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()), height);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- } else {
- // 最新一天数据
- List<Entity> lastData = prophaseWeatherDataService.getLastData(equipmentId);
- Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
- DateTime startTime = DateUtil.beginOfDay(DateTimeUtil.getYearDay(timeEnd.getTime()));
- anemometryData = prophaseAnemometryDataService.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, new Timestamp(startTime.getTime()), timeEnd, height);
- }
- HashMap<String, Integer> hashMap = new HashMap<>();
- Map<String, BigDecimal> map = new HashMap<>();
- Map<String, BigDecimal> windPowerMap = new HashMap<>();
- for (WindDirectionEnum value : WindDirectionEnum.values()) {
- //根据设备属性风向获取数据
- List<ProphaseAnemometryData> heightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(anemometryData, value);
- BigDecimal wsAve = BigDecimal.ZERO;
- if (heightAndWindDirectionEnum.size() > 0) {
- wsAve = BigDecimal.valueOf(heightAndWindDirectionEnum.stream().map(h -> {
- return BigDecimal.valueOf(h.getWsAve());
- }).collect(Collectors.averagingDouble(BigDecimal::doubleValue)));
- }
- hashMap.put(value.name(), heightAndWindDirectionEnum.size());
- if (anemometryData.size() > 0) {
- //风向频率
- BigDecimal wdF = BigDecimal.valueOf(heightAndWindDirectionEnum.size()).divide(BigDecimal.valueOf(anemometryData.size()), 2, RoundingMode.HALF_UP);
- map.put(value.name(), BigDecimal.valueOf(100).multiply(wdF));
- // 风能:风向频率 * 平均风速的立方
- windPowerMap.put(value.name(), wsAve.multiply(wsAve).multiply(wsAve).multiply(wdF).setScale(2, RoundingMode.HALF_UP));
- } else {
- map.put(value.name(), BigDecimal.ZERO);
- windPowerMap.put(value.name(), BigDecimal.ZERO);
- }
- }
- ArrayList<Map.Entry<String, BigDecimal>> entries = new ArrayList<>(map.entrySet());
- entries.sort((o1, o2) -> {
- return o2.getValue().compareTo(o1.getValue());
- });
- List<Map.Entry<String, BigDecimal>> entries1 = entries.subList(0, 3);
- HashMap<String, Object> everyMap = new HashMap<>();
- everyMap.put("echars", map);
- everyMap.put("windPowerEchars", windPowerMap);
- everyMap.put("proportion", entries1);
- return everyMap;
- }
- /**
- * 首页空气密度、温度、压强平均值 湍流 风切变 满发小时数 日发电量 经纬度 数据起止时间
- *
- * @param equipmentId 场站编号
- * @return Map<String, BigDecimal>
- */
- public Map<String, Object> getAirAndPaAndT(String equipmentId, String month) {
- List<WindTowerInfo> windTowerInfoList = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, equipmentId).list();
- String[] wdHeight = windTowerInfoList.get(0).getWdHeights().split(",");
- ArrayList<String> arrayList = new ArrayList(Arrays.asList(windTowerInfoList.get(0).getHeights().split(",")));
- //层高排序
- List<Integer> heightList = arrayList.stream().map(s -> Integer.parseInt(CalculationUtil.getNumberFromString(s))).sorted().collect(Collectors.toList());
- Integer maxHeight = heightList.get(heightList.size() - 1);
- //获取最后一条记录
- WindTowerCalculationData lastDataCalculation = windTowerCalculationDataService.getLastDataCalculation(equipmentId);
- Date yearDay = DateTimeUtil.getYearDay(lastDataCalculation.getTime().getTime());
- //获取去年月份开始时间
- Date beginTime = DateUtil.offsetMonth(DateUtil.beginOfMonth(yearDay), 1);
- Date endTime = lastDataCalculation.getTime();
- List<EquipmentAttribute> equipmentAttributeList = equipmentAttributeService.lambdaQuery().eq(EquipmentAttribute::getFieldName, "airDensityMonth").or().eq(EquipmentAttribute::getFieldName, "tAVE").or().
- eq(EquipmentAttribute::getFieldName, "paAVE").or().eq(EquipmentAttribute::getFieldName, maxHeight + "turbulenceMonth").or().
- eq(EquipmentAttribute::getFieldName, "windShearMonth").or().eq(EquipmentAttribute::getFieldName, "batteryDay")
- .or().eq(EquipmentAttribute::getFieldName, wdHeight[0] + "monthWdRose").list();
- List<WindTowerCalculationData> windTowerCalculationDataList = windTowerCalculationDataService.getByBetweenTimeAndEquipmentIdAndEbId(beginTime, endTime, equipmentId, equipmentAttributeList);
- HashMap<String, Object> dataMap = new HashMap<>();
- //温度
- dataMap.put("t", this.getDataForCalculationByEb(equipmentAttributeList, windTowerCalculationDataList, "tAVE"));
- //空气密度
- dataMap.put("air", this.getDataForCalculationByEb(equipmentAttributeList, windTowerCalculationDataList, "airDensityMonth"));
- //压强
- dataMap.put("pa", this.getDataForCalculationByEb(equipmentAttributeList, windTowerCalculationDataList, "paAVE"));
- //湍流
- dataMap.put("turbulence", this.getDataForCalculationByEb(equipmentAttributeList, windTowerCalculationDataList, maxHeight + "turbulenceMonth"));
- //风切变
- dataMap.put("windShear", this.getDataForCalculationByEb(equipmentAttributeList, windTowerCalculationDataList, "windShearMonth"));
- //层高
- dataMap.put("height", maxHeight);
- List<EquipmentAttribute> batteryDay1 = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals("batteryDay")).collect(Collectors.toList());
- List<WindTowerCalculationData> calculationDataList = windTowerCalculationDataList.stream().filter(w -> w.getEbId().equals(batteryDay1.get(0).getId())).collect(Collectors.toList());
- BigDecimal batteryDay = calculationDataList.stream().map(WindTowerCalculationData::getValue).reduce(BigDecimal.ZERO, BigDecimal::add);
- BigDecimal hourMax = batteryDay.divide(BigDecimal.valueOf(6.25), 2, RoundingMode.HALF_UP);
- //发电量
- dataMap.put("battery", batteryDay);
- //满发小时数
- dataMap.put("hour", hourMax);
- List<EquipmentAttribute> equipmentAttributes = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(wdHeight[0] + "monthWdRose")).collect(Collectors.toList());
- List<WindDirectionStatisticsData> windDirectionStatisticsDataList = windDirectionStatisticsDataService.lambdaQuery().eq(WindDirectionStatisticsData::getEbId, equipmentAttributes.get(0).getId()).between(WindDirectionStatisticsData::getTime, beginTime, endTime)
- .eq(WindDirectionStatisticsData::getEquipmentId, equipmentId).list();
- Map<String, List<WindDirectionStatisticsData>> collect = windDirectionStatisticsDataList.stream().collect(Collectors.groupingBy(w -> w.getDirection()));
- HashMap<String, BigDecimal> hashMap = new HashMap<>();
- for (Map.Entry<String, List<WindDirectionStatisticsData>> k : collect.entrySet()) {
- BigDecimal reduce = k.getValue().stream().map(WindDirectionStatisticsData::getValue).reduce(BigDecimal.ZERO, BigDecimal::add);
- hashMap.put(k.getKey(), reduce);
- }
- Map.Entry<String, BigDecimal> stringBigDecimalEntry = hashMap.entrySet().stream().max(Comparator.comparing(Map.Entry::getValue)).get();
- //主风向
- dataMap.put("wdSum", stringBigDecimalEntry.getKey());
- //起止时间
- Map<String, Long> dataTimeStartAndEnd = prophaseWeatherDataService.getDataTimeStartAndEnd(equipmentId);
- String startTime = DateUtil.format(new Date(dataTimeStartAndEnd.get("startTime")), "yyyy-MM-dd");
- String endTimeStr = DateUtil.format(endTime, "yyyy-MM-dd");
- dataMap.put("dataTime", startTime + "-" + endTimeStr);
- dataMap.put("longitude", windTowerInfoList.get(0).getLongitude());
- dataMap.put("latitude", windTowerInfoList.get(0).getLatitude());
- return dataMap;
- }
- public BigDecimal getDataForCalculationByEb(List<EquipmentAttribute> equipmentAttributeList, List<WindTowerCalculationData> windTowerCalculationDataList, String fieldName) {
- List<String> ebId = equipmentAttributeList.stream().filter(e -> e.getFieldName().equals(fieldName)).map(EquipmentAttribute::getId).collect(Collectors.toList());
- List<BigDecimal> dataList = windTowerCalculationDataList.stream().filter(w -> w.getEbId().equals(ebId.get(0))).map(WindTowerCalculationData::getValue).collect(Collectors.toList());
- return dataList.size() > 0 ? CalculationUtil.getAvgWind(dataList) : BigDecimal.ZERO;
- }
- //首页全省资源概述
- public HashMap<String, String> getResourcesOverview() {
- ProvincialEnergyStations provincialEnergyStations = provincialEnergyStationsService.getProvincialEnergyStations();
- HashMap<String, String> hashMap = new HashMap<>();
- hashMap.put("resourcesOverview", provincialEnergyStations.getResourcesOverview());
- return hashMap;
- }
- //获取华电以及全省资源概况
- public ProvincialEnergyStations getProvincialEnergyStations() {
- return provincialEnergyStationsService.getProvincialEnergyStations();
- }
- //获取项目类别以及项目概况
- public HashMap<String, Object> getProjectSort() {
- HashMap<String, Object> dataMap = new HashMap<>();
- List<TotalityInfo> totalityInfos = totalityInfoService.selectTotalityInfoList();
- List<ProjectInfo> projectInfoList = projectInfoService.getProjectInfoList();
- //根据类别分组
- Map<String, List<ProjectInfo>> four = projectInfoList.stream()
- .filter(p -> !p.getProjectBasicInfo().getProjectSort().equals("four"))
- .collect(Collectors.groupingBy((ProjectInfo pro) -> {
- return pro.getProjectBasicInfo().getProjectSort();
- }));
- //循环数据 存放Id和项目名称
- for (Map.Entry<String, List<ProjectInfo>> entry : four.entrySet()) {
- ArrayList<ProjectInfoDto> projectInfoDtoList = new ArrayList<>();
- for (ProjectInfo projectInfo : entry.getValue()) {
- ProjectInfoDto projectInfoDto = new ProjectInfoDto();
- projectInfoDto.setId(projectInfo.getId());
- projectInfoDto.setProjectSort(projectInfo.getProjectBasicInfo().getProjectName());
- projectInfoDtoList.add(projectInfoDto);
- }
- dataMap.put(entry.getKey(), projectInfoDtoList);
- }
- //项目基本信息
- dataMap.put("pInfo", totalityInfos.get(0).getPInfo());
- return dataMap;
- }
- //查询项目概况
- public HashMap<String, Object> projectMapInfo(String projectId) {
- HashMap<String, Object> dataMap = new HashMap<>();
- //获取项目信息
- List<ProjectInfo> projectInfoList = projectInfoService.getProjectInfoList();
- //根据项目ID过滤指定数据
- List<ProjectInfo> collect = projectInfoList.stream().filter(p -> p.getId().equals(projectId)).collect(Collectors.toList());
- //获取对应项目概述
- if (!collect.isEmpty()) {
- for (ProjectInfo projectInfo : collect) {
- dataMap.put("projectOverview", projectInfo.getProjectBasicInfo().getProjectOverview());
- dataMap.put("resourcesOverview", projectInfo.getProjectBasicInfo().getResourcesOverview());
- // if (projectInfo.getEquipment() != null && projectInfo.getEquipment().size() > 0) {
- // dataMap.put("longitude", projectInfo.getEquipment().get(0).getLongitude());
- // dataMap.put("latitude", projectInfo.getEquipment().get(0).getLatitude());
- // }
- if (StrUtil.isNotBlank(projectInfo.getProjectBasicInfo().getPosition())) {
- String[] split = projectInfo.getProjectBasicInfo().getPosition().split(",");
- dataMap.put("longitude", split[0]);
- dataMap.put("latitude", split[1]);
- }
- }
- }
- return dataMap;
- }
- //地图点位坐标 (风机、测风塔、拐点)
- public HashMap<String, Object> getPointMap() {
- HashMap<String, Object> dataMap = new HashMap<>();
- //获取项目信息
- List<ProjectInfo> projectInfoList = projectInfoService.getProjectInfoList();
- //获取场站数据
- List<StationInfo> stationInfoList = stationInfoService.selectStationInfo();
- //循环所有项目于信息
- //测风塔List
- HashSet<Map<String, Object>> towerList = new HashSet<>();
- //拐点坐标List
- ArrayList<Map<String, List<List<Coordinates>>>> coordinateList = new ArrayList<>();
- //风机List
- List<HashMap<String, Object>> fanList = new ArrayList<>();
- HashSet<String> eqNoList = new HashSet<>();
- for (StationInfo stationInfo : stationInfoList) {
- if (stationInfo.getEquipment() != null && stationInfo.getEquipment().size() > 0) {
- //循环测风塔信息
- ArrayList<Map<String, Object>> arrayList = new ArrayList<>();
- for (Equipment equipment : stationInfo.getEquipment()) {
- eqNoList.add(equipment.getEquipmentNo());
- HashMap<String, Object> map = new HashMap<>();
- map.put("type", "station");
- map.put("longitude", equipment.getLongitude());
- map.put("latitude", equipment.getLatitude());
- map.put("towerName", equipment.getName());
- map.put("towerNo", equipment.getEquipmentNo());
- map.put("projectId", stationInfo.getId());
- arrayList.add(map);
- }
- towerList.addAll(arrayList);
- }
- Map<String, List<FanTower>> collect = stationInfo.getFanTowerList().stream().collect(Collectors.groupingBy(FanTower::getFanModel));
- for (Map.Entry<String, List<FanTower>> entry : collect.entrySet()) {
- HashMap<String, Object> map = new HashMap<>();
- List<FanTower> collect1 = stationInfo.getFanTowerList().stream().filter(w -> w.getFanModel().equals(entry.getKey())).collect(Collectors.toList());
- map.put("type", "station");
- map.put("name", stationInfo.getStationBasicInfo().getStationName());
- map.put("data", collect1);
- fanList.add(map);
- }
- }
- for (ProjectInfo projectInfo : projectInfoList) {
- Map<String, List<List<Coordinates>>> cmap = new HashMap<>();
- cmap.put(projectInfo.getProjectBasicInfo().getProjectNameEasy(), projectInfo.getCoordinates());
- //拐点坐标
- coordinateList.add(cmap);
- if (projectInfo.getEquipment() != null && projectInfo.getEquipment().size() > 0) {
- //循环测风塔信息
- for (Equipment equipment : projectInfo.getEquipment()) {
- HashMap<String, Object> map = new HashMap<>();
- eqNoList.add(equipment.getEquipmentNo());
- map.put("type", "project");
- map.put("longitude", equipment.getLongitude());
- map.put("latitude", equipment.getLatitude());
- map.put("towerName", equipment.getName());
- map.put("towerNo", equipment.getEquipmentNo());
- map.put("projectId", projectInfo.getId());
- towerList.add(map);
- }
- }
- if (projectInfo.getFanTowerList() != null && projectInfo.getFanTowerList().size() > 0) {
- HashMap<String, Object> map = new HashMap<>();
- map.put("type", "project");
- map.put("name", projectInfo.getProjectBasicInfo().getProjectName());
- map.put("data", projectInfo.getFanTowerList());
- fanList.add(map);
- }
- }
- dataMap.put("coordinatesList", coordinateList);
- List<Map<String, Object>> listMap = new ArrayList<>();
- //利用塔编号过滤分组项目以及场站的id
- for (String s : eqNoList) {
- ArrayList<Object> arrayList = new ArrayList<>();
- List<Map<String, Object>> towerNo = towerList.stream().filter(key -> key.get("towerNo").equals(s)).collect(Collectors.toList());
- //有多条只添加一个其他都是一样的只需要替换id 多余的需要删除
- for (Map<String, Object> map : towerNo) {
- HashMap<Object, Object> hashMap1 = new HashMap<>();
- hashMap1.put("type", map.get("type"));
- if (map.containsKey("projectId")) {
- hashMap1.put("id", map.get("projectId"));
- arrayList.add(hashMap1);
- }
- }
- //替换id值
- towerNo.get(0).put("projectId", arrayList);
- listMap.add(towerNo.get(0));
- }
- dataMap.put("towerList", listMap);
- dataMap.put("fan", fanList);
- return dataMap;
- }
- /**
- * 项目测风塔下拉框
- *
- * @return List<SelectLabForVal>
- */
- public List<SelectLabForVal> projectSelect() {
- List<ProjectInfo> projectInfoList = projectInfoService.getProjectInfoList();
- ArrayList<SelectLabForVal> selectList = new ArrayList<>();
- if (projectInfoList.size() > 0) {
- //循环数据 放入项目id和项目名称
- for (ProjectInfo projectInfo : projectInfoList) {
- SelectLabForVal selectLabForVal = new SelectLabForVal();
- selectLabForVal.setLabel(projectInfo.getProjectBasicInfo().getProjectNameEasy());
- selectLabForVal.setValue(projectInfo.getId());
- if (projectInfo.getEquipment().size() > 0) {
- ArrayList<EquipmentDto> equipmentDtoList = new ArrayList<>();
- //循环数据 放入测风塔id和测风塔名称
- for (Equipment equipment : projectInfo.getEquipment()) {
- EquipmentDto equipmentDto = new EquipmentDto();
- equipmentDto.setLabel(equipment.getName());
- equipmentDto.setValue(equipment.getEquipmentNo());
- equipmentDto.setWdHeight(equipment.getWdHeights());
- equipmentDto.setType(equipment.getType());
- equipmentDtoList.add(equipmentDto);
- }
- selectLabForVal.setEquipmentDto(equipmentDtoList);
- }
- selectList.add(selectLabForVal);
- }
- }
- return selectList;
- }
- //查询场站信息以及场站列表
- public HashMap<String, Object> getStationTotalityInfo() {
- //总体信息
- List<TotalityInfo> totalityInfos = totalityInfoService.selectTotalityInfoList();
- //场站信息
- List<StationInfo> stationInfos = stationInfoService.selectStationInfo();
- HashMap<String, Object> stationMap = new HashMap<>();
- if (totalityInfos.size() > 0) {
- stationMap.put("fInfo", totalityInfos.get(0).getFInfo());
- stationMap.put("gInfo", totalityInfos.get(0).getGInfo());
- if (stationInfos.size() > 0) {
- ArrayList<Object> arrayList = new ArrayList<>();
- for (StationInfo stationInfo : stationInfos) {
- HashMap<String, Object> hashMap = new HashMap<>();
- hashMap.put("id", stationInfo.getId());
- hashMap.put("stationName", stationInfo.getStationBasicInfo().getStationName());
- //经度
- hashMap.put("longitude", stationInfo.getStationBasicInfo().getLongitude());
- //纬度
- hashMap.put("latitude", stationInfo.getStationBasicInfo().getLatitude());
- hashMap.put("type", stationInfo.getStationBasicInfo().getStationType());
- arrayList.add(hashMap);
- }
- stationMap.put("station", arrayList);
- }
- }
- return stationMap;
- }
- /**
- * 查询所有的场站坐标
- */
- public HashMap<String, Object> getStationSeat() {
- HashMap<String, Object> dataMap = new HashMap<>();
- List<OtherStationInfo> otherStationInfoList = otherStationInfoService.selectOtherStationInfo();
- List<StationInfo> stationInfos = stationInfoService.selectStationInfo();
- ArrayList<HashMap<String, Object>> stationList = new ArrayList<>();
- for (StationInfo stationInfo : stationInfos) {
- HashMap<String, Object> hashMap = new HashMap<>();
- hashMap.put("id", stationInfo.getId());
- hashMap.put("stationName", stationInfo.getStationBasicInfo().getStationName());
- //经度
- hashMap.put("longitude", stationInfo.getStationBasicInfo().getLongitude());
- //纬度
- hashMap.put("latitude", stationInfo.getStationBasicInfo().getLatitude());
- hashMap.put("type", stationInfo.getStationBasicInfo().getStationType());
- stationList.add(hashMap);
- }
- ArrayList<HashMap<String, Object>> otherStationList = new ArrayList<>();
- for (OtherStationInfo otherStationInfo : otherStationInfoList) {
- if (otherStationInfo.getStationType().equals("风")) {//目前只要风
- HashMap<String, Object> hashMap = new HashMap<>();
- hashMap.put("id", otherStationInfo.getId());
- hashMap.put("stationName", otherStationInfo.getStationName());
- //经度
- hashMap.put("longitude", otherStationInfo.getLongitude());
- //纬度
- hashMap.put("latitude", otherStationInfo.getLatitude());
- hashMap.put("type", otherStationInfo.getStationType());
- otherStationList.add(hashMap);
- }
- }
- dataMap.put("HDStation", stationList);
- dataMap.put("otherStation", otherStationList);
- return dataMap;
- }
- /**
- * 查询所有的项目坐标
- */
- public ArrayList<Object> getProjectSeat() {
- ArrayList<Object> arrayList = new ArrayList<>();
- //获取项目信息
- List<ProjectInfo> projectInfoList = projectInfoService.getProjectInfoList();
- for (ProjectInfo projectInfo : projectInfoList) {
- HashMap<String, Object> map = new HashMap<>();
- if (StrUtil.isNotBlank(projectInfo.getProjectBasicInfo().getPosition())) {
- map.put("id", projectInfo.getId());
- map.put("projectNameEasy", projectInfo.getProjectBasicInfo().getProjectNameEasy());
- map.put("projectName", projectInfo.getProjectBasicInfo().getProjectName());
- String[] split = projectInfo.getProjectBasicInfo().getPosition().split(",");
- map.put("longitude", split[0]);
- map.put("latitude", split[1]);
- map.put("type", projectInfo.getProjectBasicInfo().getProjectType());
- }
- // if (projectInfo.getEquipment() != null && projectInfo.getEquipment().size() > 0) {
- //
- // }
- arrayList.add(map);
- }
- return arrayList;
- }
- /**
- * 查询场站详细信息(风机、机型等)
- */
- public HashMap<String, Object> getStationInfo(String stationId) {
- //场站信息
- List<StationInfo> stationInfos = stationInfoService.selectStationInfo();
- List<StationInfo> stationInfoList = stationInfos.stream().filter(s -> s.getId().equals(stationId)).collect(Collectors.toList());
- List<FanModelData> fanModelDataList = fanModelDataService.getFanModelDataList();
- //过滤
- List<FanModelData> collect = fanModelDataList.stream().filter(f -> f.getStationId().equals(stationId)).collect(Collectors.toList());
- HashMap<String, Object> dataMap = new HashMap<>();
- if (stationInfoList.size() > 0) {
- ArrayList<HashMap<String, Object>> arrayList = new ArrayList<>();
- //根据风机类型分组
- Map<String, List<FanTower>> modelMap = stationInfoList.get(0).getFanTowerList().stream()
- .collect(Collectors.groupingBy(FanTower::getFanModel));
- //遍历map指定key
- for (Map.Entry<String, List<FanTower>> entry : modelMap.entrySet()) {
- for (FanModelData fanModelData : collect) {
- if (fanModelData.getModelName().equals(entry.getKey())) {
- HashMap<String, Object> map = new HashMap<>();
- //风机名称
- map.put("modelType", entry.getKey());
- //风机数量
- map.put("modelTotal", entry.getValue().size());
- //满发小时数
- map.put("wsAve", fanModelData.getWsAve());
- //主风向
- map.put("wdSum", fanModelData.getWdSum());
- //发电量
- map.put("generatingCapacity", fanModelData.getGeneratingCapacity());
- //满发小时数
- map.put("realTimeTotal", fanModelData.getRealTimeTotal());
- arrayList.add(map);
- }
- }
- }
- //过滤塔信息
- StationInfo stationInfo = stationInfoList.get(0);
- // if (stationInfo.getEquipment() != null && stationInfo.getEquipment().size() > 0) {
- // dataMap.put("longitude", stationInfo.getEquipment().get(0).getLongitude());
- // dataMap.put("latitude", stationInfo.getEquipment().get(0).getLatitude());
- // }
- // if (stationInfo.getFanTowerList() != null && stationInfo.getFanTowerList().size() > 0) {
- // dataMap.put("longitude", stationInfo.getFanTowerList().get(0).getLongitudeFan());
- // dataMap.put("latitude", stationInfo.getFanTowerList().get(0).getLatitudeFan());
- // }
- dataMap.put("longitude", stationInfo.getStationBasicInfo().getLongitude());
- dataMap.put("latitude", stationInfo.getStationBasicInfo().getLatitude());
- dataMap.put("modelT", arrayList);
- }
- return dataMap;
- }
- /**
- * 场站测风塔下拉框
- *
- * @return List<SelectLabForVal>
- */
- public List<SelectLabForVal> stationSelect() {
- List<StationInfo> stationInfoList = stationInfoService.selectStationInfo();
- ArrayList<SelectLabForVal> selectList = new ArrayList<>();
- if (stationInfoList.size() > 0) {
- //循环数据 放入项目id和项目名称
- for (StationInfo stationInfo : stationInfoList) {
- SelectLabForVal selectLabForVal = new SelectLabForVal();
- selectLabForVal.setLabel(stationInfo.getStationBasicInfo().getStationName());
- selectLabForVal.setValue(stationInfo.getId());
- if (stationInfo.getEquipment().size() > 0) {
- ArrayList<EquipmentDto> equipmentDtoList = new ArrayList<>();
- //循环数据 放入测风塔id和测风塔名称
- for (Equipment equipment : stationInfo.getEquipment()) {
- EquipmentDto equipmentDto = new EquipmentDto();
- equipmentDto.setLabel(equipment.getName());
- equipmentDto.setValue(equipment.getEquipmentNo());
- equipmentDto.setWdHeight(equipment.getWdHeights());
- equipmentDto.setType(equipment.getType());
- equipmentDtoList.add(equipmentDto);
- }
- selectLabForVal.setEquipmentDto(equipmentDtoList);
- }
- selectList.add(selectLabForVal);
- }
- }
- return selectList;
- }
- //项目进展
- public List<ProjectEvolveDto> getProjectEvolve(String projectId) {
- //查询项目进展信息
- List<ProjectProgress> projectProgresses = proProjectInfoService.selectProProjectInfo();
- //根据项目id筛选数据
- List<ProjectProgress> progressList = projectProgresses.stream().filter(p -> p.getProjectId().equals(projectId)).collect(Collectors.toList());
- ArrayList<ProjectEvolveDto> projectEvolveList = new ArrayList<>();
- if (progressList.size() > 0) {
- //循环项目进展信息 一般只有一条
- for (ProjectProgress progress : progressList) {
- if (progress.getProjectMenusOneList().size() > 0) {
- //循环一级菜单
- for (ProjectMenusOne menusOne : progress.getProjectMenusOneList()) {
- ProjectEvolveDto projectEvolveDtoOne = new ProjectEvolveDto();
- //一级菜单
- projectEvolveDtoOne.setIndex(menusOne.getIndex());
- projectEvolveDtoOne.setTaskContent(menusOne.getWorkContent());
- projectEvolveDtoOne.setPlanTime(menusOne.getPlanTime());
- if (menusOne.getProjectMenusTows().size() > 0 && menusOne.getProjectMenusTows().get(0).getIndex().equals("")) {
- if (menusOne.getProjectMenusTows().get(0).getProjectMenusThreeList().size() > 0) {
- projectEvolveDtoOne.setStatus(menusOne.getProjectMenusTows().get(0).getProjectMenusThreeList().get(0).getRealTime());
- projectEvolveList.add(projectEvolveDtoOne);
- }
- } else {
- projectEvolveList.add(projectEvolveDtoOne);
- if (menusOne.getProjectMenusTows() != null && menusOne.getProjectMenusTows().size() > 0) {
- //循环二级菜单
- for (ProjectMenusTow menusTow : menusOne.getProjectMenusTows()) {
- if (menusTow.getProjectMenusThreeList() != null && menusTow.getProjectMenusThreeList().size() > 0) {
- //循环三级菜单
- for (ProjectMenusThree menusThree : menusTow.getProjectMenusThreeList()) {
- ProjectEvolveDto projectEvolveDto = new ProjectEvolveDto();
- //放入二级序号
- projectEvolveDto.setIndex(menusTow.getIndex());
- //放入二级计划时间
- projectEvolveDto.setPlanTime(menusTow.getPlanTime());
- //放入二级工作内容
- projectEvolveDto.setTaskContent(menusTow.getWorkContent());
- //详细工作信息 三级工作内容
- projectEvolveDto.setDetailedTaskContent(menusThree.getWorkContent());
- //实际完成时间 三级时间
- projectEvolveDto.setRealTime(menusThree.getRealTime());
- //放入状态 三级备注
- projectEvolveDto.setStatus(menusThree.getRemark());
- projectEvolveList.add(projectEvolveDto);
- }
- } else {
- ProjectEvolveDto projectEvolveDto = new ProjectEvolveDto();
- projectEvolveDto.setIndex(menusTow.getIndex());
- projectEvolveDto.setTaskContent(menusTow.getWorkContent());
- projectEvolveDto.setPlanTime(menusTow.getPlanTime());
- projectEvolveList.add(projectEvolveDto);
- }
- }
- }
- }
- }
- }
- }
- }
- return projectEvolveList;
- }
- }
|