123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131 |
- 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.extension.service.impl.ServiceImpl;
- 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.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 ProphaseAnemometryDataMapper prophaseAnemometryDataMapper;
- private final ProphaseWeatherDataMapper prophaseWeatherDataMapper;
- private final ProphaseWeatherDataService prophaseWeatherDataService;
- private final OtherStationInfoService otherStationInfoService;
- 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(",");
- //风速数据
- 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 = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
- weatherDataList = prophaseWeatherDataMapper.selectAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
- } catch (ParseException e) {
- e.printStackTrace();
- }
- } else {
- // 最新一天数据
- List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
- Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
- DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
- prophaseAnemometryDataList = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
- weatherDataList = prophaseWeatherDataMapper.selectAir(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
- }
- //时间和空气密度map
- Map<Timestamp, Float> timeAndAirMap = weatherDataList.stream().collect(Collectors.toMap(ProphaseWeatherData::getTs, ProphaseWeatherData::getAirDensity));
- 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) {
- //根据层高获取时间和风速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(map.get(airAndTime.getKey())), BigDecimal.valueOf(airAndTime.getValue()));
- 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 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 = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()), height);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- } else {
- // 最新一天数据
- List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
- Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
- DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
- anemometryData = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, new Timestamp(startTime.getTime()), timeEnd, height);
- }
- HashMap<String, Integer> hashMap = new HashMap<>();
- BigDecimal total = BigDecimal.ZERO;
- 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());
- total = total.add(BigDecimal.valueOf(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 设备编号
- * @param height 层高
- * @return Map<String, Object>
- */
- public Map<String, Object> getHeightForAveWs(String equipmentId, String height) {
- // 最新一天数据
- List<Map<String, Object>> mapList = windTowerDataParentTableService.getStartTimeAndEndTimeForData(equipmentId);
- List<BigDecimal> wsForHeight = CalculationUtil.getWsForHeight(mapList, height);
- //本层高风速总和
- BigDecimal aveWs = wsForHeight.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
- HashMap<String, Long> hashMap = new HashMap<>();
- //层高所有条数
- long total = 0;
- for (int i = 0; i < 11; i = i + 2) {
- long count;
- int finalI = i;
- String iStr = "";
- if (i >= 10) {
- count = wsForHeight.stream().filter(w -> w.compareTo(BigDecimal.valueOf(finalI)) > 0).count();
- iStr = ">" + finalI + "m/s";
- } else {
- count = wsForHeight.stream().filter(w -> w.compareTo(BigDecimal.valueOf(finalI)) > 0 && w.compareTo(BigDecimal.valueOf(finalI + 2)) < 0).count();
- iStr = finalI + "~" + (finalI + 2) + "m/s";
- }
- total += count;
- if (count > 0) {
- hashMap.put(iStr, count);
- }
- }
- HashMap<String, Object> dataMap = new HashMap<>();
- if (total > 0) {
- dataMap.put("wsAve", aveWs.divide(BigDecimal.valueOf(total), 2, RoundingMode.HALF_UP));
- } else {
- dataMap.put("wsAve", BigDecimal.ZERO);
- }
- dataMap.put("proportion", hashMap);
- return dataMap;
- }
- /**
- * 首页查询最新一天的平均风速
- *
- * @param equipmentId 设备编号
- * @return
- */
- public Map<String, Object> homePageCharts(String equipmentId, String month) {
- 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 = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
- } catch (ParseException e) {
- e.printStackTrace();
- }
- } else {
- // 最新一天数据
- List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
- Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
- DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
- mapList = prophaseAnemometryDataMapper.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);
- }
- everyMap.put("chart", everyData);
- everyMap.put("time", timeList);
- return everyMap;
- }
- /**
- * 首页空气密度和温度 折线图
- *
- * @param equipmentId 场站编号
- * @return List<WindTowerDataAirAndT>
- */
- public Map<String, List<Object>> selectTForAir(String equipmentId) {
- //获取最新一天的数据
- List<Map<String, Object>> mapList = windTowerDataParentTableService.getStartTimeAndEndTimeForData(equipmentId);
- ArrayList<Object> tList = new ArrayList<>();
- ArrayList<Object> airList = new ArrayList<>();
- ArrayList<Object> timeList = new ArrayList<>();
- HashMap<String, List<Object>> hashMap1 = new HashMap<>();
- for (Map<String, Object> map : mapList) {
- BigDecimal tAve = BigDecimal.ZERO;
- BigDecimal airDensity = BigDecimal.ZERO;
- String abnormal_type = "";
- //过滤异常值
- if (map.get("abnormal_type") != null) {
- abnormal_type = map.get("abnormal_type").toString();
- }
- if (map.get("t_ave") != null && !map.get("t_ave").equals("") && (!abnormal_type.contains("t_ave"))) {
- tAve = CalculationUtil.getBigDecimal(map.get("t_ave"));
- }
- if (map.get("air_density") != null && !map.get("air_density").equals("") && (!abnormal_type.contains("air_density"))) {
- airDensity = CalculationUtil.getBigDecimal(map.get("air_density"));
- }
- tList.add(tAve);
- airList.add(airDensity);
- String time = DateUtil.format(new Date(Long.parseLong(map.get("time").toString())), "yyyy-MM-dd HH:mm:ss");
- timeList.add(time);
- }
- hashMap1.put("t", tList);
- hashMap1.put("air", airList);
- hashMap1.put("time", timeList);
- return hashMap1;
- }
- /**
- * 首页空气密度、温度、压强平均值 湍流 风切变 满发小时数 日发电量 经纬度 数据起止时间
- *
- * @param equipmentId 场站编号
- * @return Map<String, BigDecimal>
- */
- public Map<String, Object> getAirAndPaAndT(String equipmentId, String month) {
- List<ProphaseWeatherData> weatherDataList = new ArrayList<>();
- List<ProphaseAnemometryData> anemometryDataList = new ArrayList<>();
- Map<String, Long> dataTimeStartAndEnd = prophaseWeatherDataService.getDataTimeStartAndEnd(equipmentId);
- WindTowerInfo windTowerInfo = windTowerInfoService.getByEquipmentNo(equipmentId).get(0);
- String height;
- String[] strings = windTowerInfo.getHeights().split(",");
- height = CalculationUtil.getNumberFromString(strings[0]);
- String minHeight = CalculationUtil.getNumberFromString(strings[strings.length - 1]); //最底层
- if (windTowerInfo.getDisplayHeight() != null && !windTowerInfo.getDisplayHeight().equals("")) {
- height = windTowerInfo.getDisplayHeight();
- }
- //获取风向 层高 最高层
- String wdHeights = windTowerInfo.getWdHeights();
- String wdHeightMax = "";
- if (!wdHeights.isEmpty()) {
- ArrayList<String> wdHeightList = new ArrayList(Arrays.asList(wdHeights.split(",")));
- List<Integer> collect = wdHeightList.stream().map(Integer::parseInt).sorted().collect(Collectors.toList());
- wdHeightMax = collect.get(collect.size() - 1).toString();
- }
- if (!month.equals("")) {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
- try {
- Date startDate = sdf.parse(month);
- Date endDate = DateTimeUtil.endOfMonth(startDate);
- weatherDataList = prophaseWeatherDataMapper.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
- anemometryDataList = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsSta(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
- } catch (ParseException e) {
- e.printStackTrace();
- }
- } else {
- List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
- Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
- DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
- // 最新一天数据
- weatherDataList = prophaseWeatherDataMapper.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
- anemometryDataList = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsSta(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
- }
- HashMap<String, Object> dataMap = new HashMap<>();
- BigDecimal tAve = BigDecimal.ZERO;
- BigDecimal airDensity = BigDecimal.ZERO;
- BigDecimal pa = BigDecimal.ZERO;
- // 风速集合
- String finalHeight = height;
- List<BigDecimal> wsForHeight = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(finalHeight) && a.getWsAve() != null)
- .map(h -> BigDecimal.valueOf(h.getWsAve()))
- .collect(Collectors.toList());
- //最小风速集合
- List<BigDecimal> minWsForHeight = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(minHeight) && a.getWsAve() != null)
- .map(h -> BigDecimal.valueOf(h.getWsAve()))
- .collect(Collectors.toList());
- // 风速标准差集合
- List<BigDecimal> wsStaForHeight = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(finalHeight) && a.getWsSta() != null)
- .map(h -> BigDecimal.valueOf(h.getWsSta()))
- .collect(Collectors.toList());
- BigDecimal avgWs = CalculationUtil.getAvgWind(wsForHeight); // 风速平均值
- BigDecimal avgMinWs = CalculationUtil.getAvgWind(minWsForHeight); // 最小风速平均值
- BigDecimal avgWsSta = CalculationUtil.getAvgWind(wsStaForHeight);// 风速标准差平均值
- BigDecimal turbulence = CalculationUtil.caTurbulenceIntensity(avgWsSta, avgWs); // 湍流
- BigDecimal windShear = BigDecimal.ZERO;
- if (avgWs.compareTo(BigDecimal.ZERO) != 0) {
- windShear = CalculationUtil.caWindShear(avgWs, avgMinWs, new BigDecimal(height), new BigDecimal(minHeight));// 风切变
- }
- if (!weatherDataList.isEmpty()) {
- airDensity = BigDecimal.valueOf(weatherDataList.stream().map(w -> {
- return BigDecimal.valueOf(w.getAirDensity());
- }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
- tAve = BigDecimal.valueOf(weatherDataList.stream().map(w -> {
- return BigDecimal.valueOf(w.getTAve());
- }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
- pa = BigDecimal.valueOf(weatherDataList.stream().map(w -> {
- return BigDecimal.valueOf(w.getPaAve());
- }).collect(Collectors.averagingDouble(BigDecimal::doubleValue))).setScale(2, RoundingMode.HALF_UP);
- }
- HashMap<String, Integer> wdMap = new HashMap<>();
- for (WindDirectionEnum value : WindDirectionEnum.values()) {
- String finalWdHeightMax = wdHeightMax;
- List<ProphaseAnemometryData> dataList = anemometryDataList.stream().filter(a -> a.getLayerHeight().equals(finalWdHeightMax)).collect(Collectors.toList());
- List<ProphaseAnemometryData> forHeightAndWindDirectionEnum = CalculationUtil.getForHeightAndWindDirectionEnum(dataList, value);
- wdMap.put(value.name(), forHeightAndWindDirectionEnum.size());
- }
- Integer total = 0;
- for (Map.Entry<String, Integer> entry : wdMap.entrySet()) {
- if (entry.getValue() >= total) {
- dataMap.put("wdSum", entry.getKey());
- total = entry.getValue();
- }
- }
- BigDecimal batterySum = BigDecimal.ZERO;
- for (BigDecimal ws : wsForHeight) {
- // 日发电量 = 风速*功率*塔个数*频率 累加至24小时
- BigDecimal battery = CalculationUtil.getBattery(ws);
- batterySum = batterySum.add(battery);
- }
- //日发电量
- batterySum = batterySum.divide(BigDecimal.valueOf(6 * 1000), 2, RoundingMode.HALF_UP);
- //满发小时数
- BigDecimal hourMax = batterySum.divide(BigDecimal.valueOf(6.25), 2, RoundingMode.HALF_UP);
- dataMap.put("battery", batterySum);
- dataMap.put("hour", hourMax);
- String startTime = DateUtil.format(new Date(dataTimeStartAndEnd.get("startTime")), "yyyy-MM-dd");
- String endTime = DateUtil.format(new Date(dataTimeStartAndEnd.get("endTime")), "yyyy-MM-dd");
- dataMap.put("dataTime", startTime + "-" + endTime);
- dataMap.put("longitude", windTowerInfo.getLongitude());
- dataMap.put("latitude", windTowerInfo.getLatitude());
- dataMap.put("t", tAve);
- dataMap.put("air", airDensity);
- dataMap.put("pa", pa);
- dataMap.put("turbulence", turbulence);
- dataMap.put("windShear", windShear);
- dataMap.put("height", height);
- return dataMap;
- }
- /**
- * 根据时间范围和设备id查询数据
- *
- * @param startTime 开始时间
- * @param endTime 结束时间
- * @param equipmentId 设备id
- * @return List<Map < String, Object>>
- */
- public List<Map<String, Object>> selectDataByBetweenTimeAndEquipmetId(Date startTime, Date endTime, String equipmentId) {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
- String key = "homepageWindDataSelect" + sdf.format(startTime) + equipmentId;
- Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(key);
- if (ObjectUtil.isNotNull(cacheObj)) {
- return (List<Map<String, Object>>) cacheObj;
- }
- List<Map<String, Object>> mapList = windTowerDataParentTableService.selectDataByBetweenTimeAndEquipmetId(startTime, endTime, equipmentId);
- SpringUtils.getBean(RedisCache.class).setCacheObject(key, mapList);
- return mapList;
- }
- //首页全省资源概述
- 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
- ArrayList<Map<String, Object>> towerList = new ArrayList<>();
- //拐点坐标List
- ArrayList<List<List<Coordinates>>> coordinateList = new ArrayList<>();
- //风机List
- ArrayList<FanTower> fanList = new ArrayList<>();
- ArrayList<String> eqNoList = new ArrayList<>();
- for (ProjectInfo projectInfo : projectInfoList) {
- //拐点坐标
- coordinateList.add(projectInfo.getCoordinates());
- 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);
- }
- }
- }
- dataMap.put("towerList", towerList);
- dataMap.put("coordinatesList", coordinateList);
- for (StationInfo stationInfo : stationInfoList) {
- if (stationInfo.getEquipment() != null && stationInfo.getEquipment().size() > 0) {
- //循环测风塔信息
- ArrayList<Map<String, Object>> arrayList = new ArrayList<>();
- for (Equipment equipment : stationInfo.getEquipment()) {
- 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("stationId", stationInfo.getId());
- arrayList.add(map);
- }
- towerList.addAll(arrayList);
- }
- fanList.addAll(stationInfo.getFanTowerList());
- }
- ArrayList<HashMap<String,Object>> projectForStationIdList = new ArrayList<>();
- for (String s : eqNoList) {
- HashMap<String, Object> hashMap = new HashMap<>();
- ArrayList<Object> arrayList = new ArrayList<>();
- List<Map<String, Object>> towerNo = towerList.stream().filter(key -> key.get("towerNo").equals(s)).collect(Collectors.toList());
- for (Map<String, Object> map : towerNo) {
- if(map.containsKey("projectId")){
- arrayList.add(map.get("projectId"));
- }
- if(map.containsKey("stationId")){
- arrayList.add(map.get("stationId"));
- }
- }
- hashMap.put("towerNo",s);
- hashMap.put("projectForStationId",arrayList);
- projectForStationIdList.add(hashMap);
- }
- dataMap.put("projectForStationId",projectForStationIdList);
- 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());
- 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());
- 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());
- 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]);
- }
- // 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("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;
- }
- }
|