Commit f8c02037 authored by wujiang's avatar wujiang

修复监盘报错

parent 128fd2bc
......@@ -1936,6 +1936,8 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
Double powerOfDay = 0.0000;
Double powerOfMonth = 0.0000;
Double powerOfAnnual = 0.0000;
if(result!=null)
{
if(ObjectUtils.isEmpty(query)){
powerOfDay = powerOfDay + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量"));
powerOfMonth = powerOfMonth + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量"));
......@@ -1946,6 +1948,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
powerOfAnnual = powerOfAnnual + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorYear));
}
}
Map<String, Object> hashMap = new HashMap<>();
hashMap.put("日发电量",powerOfDay);
......
......@@ -30,7 +30,6 @@ import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@Service
public class MonitoringServiceImpl {
Logger logger = LoggerFactory.getLogger(MonitoringServiceImpl.class);
......@@ -62,11 +61,10 @@ public class MonitoringServiceImpl {
@Autowired
SjglZsjZsbtzServiceImpl SjglZsjZsbtzServiceImpl;
@Autowired
CommonServiceImpl commonServiceImpl;
//维护的接口信息
// 维护的接口信息
@Autowired
MapRegionMapper mapRegionMapper;
......@@ -75,7 +73,6 @@ public class MonitoringServiceImpl {
// @Autowired
// InfluxdbUtil influxdbUtil;
/**
* 根据场站编号获取该场站的装机容量
*
......@@ -88,11 +85,10 @@ public class MonitoringServiceImpl {
return ObjectUtils.isEmpty(installCapacity) ? 0.00 : installCapacity;
}
/***
* 获取风站场站
*
* */
*/
public Map<String, String> getStationfs(StationBasic stationBasic) {
String value = "0";
Map<String, String> map = new HashMap<>();
......@@ -101,29 +97,32 @@ public class MonitoringServiceImpl {
String gatewayId = stationBasic.getFanGatewayId();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("30秒平均风速"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
List<ESEquipments> result2 = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
List<ESEquipments> result2 = commonServiceImpl.getListDataByCondtions(queryCondtion, null,
ESEquipments.class);
value = String.format("%.2f", commonServiceImpl.getAvagerByEquipmentIndxName(result2, "30秒平均风速"));
map.put("name", "风速/辐照度");
map.put("value", value + "m/s");
} else {
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("WTX-801_25_WTX-801_总辐射"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
List<ESEquipments> result1 = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
value = String.format("%.2f", commonServiceImpl.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射"));
List<ESEquipments> result1 = commonServiceImpl.getListDataByCondtions(queryCondtion, null,
ESEquipments.class);
value = String.format("%.2f",
commonServiceImpl.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射"));
map.put("name", "风速/辐照度");
map.put("value", value + "W/㎡");
}
return map;
}
/***
* 电站容量
* */
*/
public Map<String, String> getStationrl(StationBasic stationBasic) {
Double installCapacity = 0.0;
installCapacity = this.SjglZsjZsbtzServiceImpl.getStationCapactityByStationWerks(stationBasic.getStationNumber());
installCapacity = this.SjglZsjZsbtzServiceImpl
.getStationCapactityByStationWerks(stationBasic.getStationNumber());
String value = ObjectUtils.isEmpty(installCapacity) ? "0.00" : String.format("%.2f", installCapacity);
Map<String, String> map = new HashMap<>();
map.put("name", "容量");
......@@ -131,7 +130,6 @@ public class MonitoringServiceImpl {
return map;
}
/**
* 根据省份名称查询电站详情
*
......@@ -226,7 +224,6 @@ public class MonitoringServiceImpl {
// return regionNationWideDtoList;
// }
// public ResultsData getCompletionOfPowerIndicatorsByProvinceName(int current, int size, String provinceName) {
//
// List<ColModel> colModels = new ArrayList<>();
......@@ -409,34 +406,47 @@ public class MonitoringServiceImpl {
public List<MapAreaInfoDto> getAreaInfo() {
List<MapAreaInfoDto> mapAreaInfoDtoList = new ArrayList<>();
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("belong_area"));
List<StationBasic> stationBasicList = stationBasicMapper
.selectList(new QueryWrapper<StationBasic>().isNotNull("belong_area"));
List<MapRegion> mapRegionList = mapRegionMapper.selectList(new QueryWrapper<MapRegion>().isNotNull("name"));
List<Region> regionList = regionMapper.selectList(new QueryWrapper<Region>().eq("LEVEL", 1));
mapRegionList.forEach(mapRegion -> {
MapAreaInfoDto mapAreaInfoDto = new MapAreaInfoDto();
//开始处理省份名称-三维与二维的名称有差异
// 开始处理省份名称-三维与二维的名称有差异
ArrayList<String> stringArrayList = mapRegion.getProvince();
List<Region> regions = regionList.stream().filter(region -> stringArrayList.contains(region.getRegionName().substring(0, 2)) || stringArrayList.contains(region.getRegionName().substring(0, 3))).collect(Collectors.toList());
List<String> regionNames = regions.stream().map(region -> region.getRegionName()).collect(Collectors.toList());
List<String> regionCodes = regions.stream().map(region -> String.valueOf(region.getRegionCode())).collect(Collectors.toList());
List<StationBasic> stationBasicListAll = stationBasicList.stream().filter(stationBasic -> regionCodes.contains(stationBasic.getBelongArea().replace("[", "").replace("]", "").split(",")[0])).collect(Collectors.toList());
List<Region> regions = regionList.stream()
.filter(region -> stringArrayList.contains(region.getRegionName().substring(0, 2))
|| stringArrayList.contains(region.getRegionName().substring(0, 3)))
.collect(Collectors.toList());
List<String> regionNames = regions.stream().map(region -> region.getRegionName())
.collect(Collectors.toList());
List<String> regionCodes = regions.stream().map(region -> String.valueOf(region.getRegionCode()))
.collect(Collectors.toList());
List<StationBasic> stationBasicListAll = stationBasicList.stream()
.filter(stationBasic -> regionCodes
.contains(stationBasic.getBelongArea().replace("[", "").replace("]", "").split(",")[0]))
.collect(Collectors.toList());
mapAreaInfoDto.setProvince(regionNames);
// --------------------省份名称处理结束----------------------------
//设置片区名称
// 设置片区名称
mapAreaInfoDto.setAreaName(mapRegion.getName());
//设置片区code
// 设置片区code
mapAreaInfoDto.setAreaCode(mapRegion.getAreaCode());
//风电站数量
mapAreaInfoDto.setWindPowerStationCount(String.valueOf(stationBasicListAll.stream().filter(stationBasic -> stationBasic.getStationType().equals("FDZ")).count()));
//集中式光伏电站数量
mapAreaInfoDto.setCentralizedPhotovoltaicStationCount(String.valueOf(stationBasicListAll.stream().filter(stationBasic -> stationBasic.getStationType().equals("JZSGFDZ")).count()));
//分布式光伏电站数量
mapAreaInfoDto.setDistributedPhotovoltaicStationCount(String.valueOf(stationBasicListAll.stream().filter(stationBasic -> stationBasic.getStationType().equals("FBSGFDZ")).count()));
//储能光伏电站数量
mapAreaInfoDto.setEnergyStorageStationCount(String.valueOf(stationBasicListAll.stream().filter(stationBasic -> stationBasic.getStationType().equals("CNDZ")).count()));
//获取装机容量
// 风电站数量
mapAreaInfoDto.setWindPowerStationCount(String.valueOf(stationBasicListAll.stream()
.filter(stationBasic -> stationBasic.getStationType().equals("FDZ")).count()));
// 集中式光伏电站数量
mapAreaInfoDto.setCentralizedPhotovoltaicStationCount(String.valueOf(stationBasicListAll.stream()
.filter(stationBasic -> stationBasic.getStationType().equals("JZSGFDZ")).count()));
// 分布式光伏电站数量
mapAreaInfoDto.setDistributedPhotovoltaicStationCount(String.valueOf(stationBasicListAll.stream()
.filter(stationBasic -> stationBasic.getStationType().equals("FBSGFDZ")).count()));
// 储能光伏电站数量
mapAreaInfoDto.setEnergyStorageStationCount(String.valueOf(stationBasicListAll.stream()
.filter(stationBasic -> stationBasic.getStationType().equals("CNDZ")).count()));
// 获取装机容量
mapAreaInfoDto.setInstalledCapacity(getInstallCapity(stationBasicListAll));
//获取当日发电量
// 获取当日发电量
mapAreaInfoDto.setElectricityGenerationOfDay(getPowerOfDaily(stationBasicListAll));
mapAreaInfoDto.setPosition(mapRegion.getPosition());
mapAreaInfoDtoList.add(mapAreaInfoDto);
......@@ -488,7 +498,6 @@ public class MonitoringServiceImpl {
// return homeMapStationInfoDtoList;
// }
public Map<String, Object> getDetailsWindSpeedAlldata(StationBasic stationBasic) {
Map<String, Object> map = new HashMap<>();
List<String> values = new ArrayList<>();
......@@ -509,9 +518,11 @@ public class MonitoringServiceImpl {
Double installedCapacity = commonServiceImpl.getStationCapactityByStationWerks(stationBasic.getStationNumber());
if ("FDZ".equals(stationBasic.getStationType())) {
activePowerList = indicatorDataMapper.selectDataByequipmentIndexNameAndtime(CommonConstans.xiazaoActivePowerPoint, startTime, endTime, stationBasic.getBoosterGatewayId());
activePowerList = indicatorDataMapper.selectDataByequipmentIndexNameAndtime(
CommonConstans.xiazaoActivePowerPoint, startTime, endTime, stationBasic.getBoosterGatewayId());
} else {
activePowerList = indicatorDataMapper.selectDataByequipmentIndexNameAndtime(CommonConstans.taiheActivePowerPoint, startTime, endTime, stationBasic.getBoosterGatewayId());
activePowerList = indicatorDataMapper.selectDataByequipmentIndexNameAndtime(
CommonConstans.taiheActivePowerPoint, startTime, endTime, stationBasic.getBoosterGatewayId());
}
for (int i = 0; i < activePowerList.size(); i++) {
IndicatorData indicatorData = activePowerList.get(i);
......@@ -519,19 +530,23 @@ public class MonitoringServiceImpl {
if ("FDZ".equals(stationBasic.getStationType())) {
values.add(String.format(CommonConstans.Twodecimalplaces, indicatorData.getValueF()));
} else {
values.add(String.format(CommonConstans.Twodecimalplaces, indicatorData.getValueF() * CommonConstans.kwToMv));
values.add(String.format(CommonConstans.Twodecimalplaces,
indicatorData.getValueF() * CommonConstans.kwToMv));
}
}
String max = String.format(CommonConstans.Twodecimalplaces, values.stream().mapToDouble(Double::parseDouble).max().getAsDouble());
String min = String.format(CommonConstans.Twodecimalplaces, values.stream().mapToDouble(Double::parseDouble).min().getAsDouble());
String mean = String.format(CommonConstans.Twodecimalplaces, values.stream().mapToDouble(Double::parseDouble).average().getAsDouble());
String max = String.format(CommonConstans.Twodecimalplaces,
values.stream().mapToDouble(Double::parseDouble).max().getAsDouble());
String min = String.format(CommonConstans.Twodecimalplaces,
values.stream().mapToDouble(Double::parseDouble).min().getAsDouble());
String mean = String.format(CommonConstans.Twodecimalplaces,
values.stream().mapToDouble(Double::parseDouble).average().getAsDouble());
activePowerInfo.put("mean", mean);
activePowerInfo.put("max", max);
activePowerInfo.put("min", min);
activePowerInfo.put("maxTime", time.get(values.lastIndexOf(max)));
activePowerInfo.put("minTime", time.get(values.lastIndexOf(min)));
activePowerInfo.put("load", String.format(CommonConstans.Twodecimalplaces, Double.valueOf(values.get(values.size() - 1)) / installedCapacity));
activePowerInfo.put("load", String.format(CommonConstans.Twodecimalplaces,
Double.valueOf(values.get(values.size() - 1)) / installedCapacity));
List<Map<String, Object>> seriesData = new ArrayList<>();
Map<String, Object> map3 = new HashMap<>();
......@@ -542,15 +557,16 @@ public class MonitoringServiceImpl {
map.put("seriesData", seriesData);
map.put("axisData", time);
try {
emqKeeper.getMqttClient().publish(stationBasic.getSequenceNbr() + "_Power_table", JSON.toJSON(map).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish(stationBasic.getSequenceNbr() + "_Power_info", JSON.toJSON(activePowerInfo).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish(stationBasic.getSequenceNbr() + "_Power_table",
JSON.toJSON(map).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish(stationBasic.getSequenceNbr() + "_Power_info",
JSON.toJSON(activePowerInfo).toString().getBytes("UTF-8"), 1, true);
} catch (Exception exception) {
exception.printStackTrace();
}
return map;
}
public String getInstallCapity(List<StationBasic> stationBasicList) {
AtomicReference<Double> total = new AtomicReference<>(0.0);
stationBasicList.forEach(stationBasic -> {
......@@ -571,7 +587,8 @@ public class MonitoringServiceImpl {
stationBasicList.forEach(stationBasic -> {
if (stationBasic.getFanGatewayId() != null) {
try {
total.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "日发电量"));
total.updateAndGet(
v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "日发电量"));
} catch (Exception e) {
}
......@@ -587,9 +604,11 @@ public class MonitoringServiceImpl {
if (!ObjectUtils.isEmpty(areaName)) {
stationBasicListAll = getListOfStationBasicByAreaName(areaName);
} else {
stationBasicListAll = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("fan_gateway_id"));
stationBasicListAll = stationBasicMapper
.selectList(new QueryWrapper<StationBasic>().isNotNull("fan_gateway_id"));
}
Map<String, List<StationBasic>> listMap = stationBasicListAll.stream().collect(Collectors.groupingBy(stationBasic -> stationBasic.getStationTypeName()));
Map<String, List<StationBasic>> listMap = stationBasicListAll.stream()
.collect(Collectors.groupingBy(stationBasic -> stationBasic.getStationTypeName()));
listMap.keySet().forEach(key -> {
Map<String, String> stringStringMap = new HashMap<>();
stringStringMap.put("name", key);
......@@ -599,7 +618,7 @@ public class MonitoringServiceImpl {
return result;
}
//获取装机容量
// 获取装机容量
public HashMap<String, String> getInstallCapityByAreaName(String areaName) {
HashMap<String, String> hashMap = new HashMap<>();
AtomicReference<Double> total = new AtomicReference<>(0.0);
......@@ -607,7 +626,8 @@ public class MonitoringServiceImpl {
if (!ObjectUtils.isEmpty(areaName)) {
stationBasicListAll = getListOfStationBasicByAreaName(areaName);
} else {
stationBasicListAll = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("fan_gateway_id"));
stationBasicListAll = stationBasicMapper
.selectList(new QueryWrapper<StationBasic>().isNotNull("fan_gateway_id"));
}
stationBasicListAll.forEach(stationBasic -> {
total.updateAndGet(v -> v + getStationCaPACITYL(stationBasic.getStationNumber()));
......@@ -616,7 +636,7 @@ public class MonitoringServiceImpl {
return hashMap;
}
//获取有功功率
// 获取有功功率
public HashMap<String, String> getActivePowerByAreaName(String areaName) {
HashMap<String, String> hashMap = new HashMap<>();
AtomicReference<Double> total = new AtomicReference<>(0.0);
......@@ -624,23 +644,25 @@ public class MonitoringServiceImpl {
if (!ObjectUtils.isEmpty(areaName)) {
stationBasicListAll = getListOfStationBasicByAreaName(areaName);
} else {
stationBasicListAll = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("fan_gateway_id"));
stationBasicListAll = stationBasicMapper
.selectList(new QueryWrapper<StationBasic>().isNotNull("fan_gateway_id"));
}
stationBasicListAll.forEach(stationBasic -> {
total.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "有功功率"));
});
//有功功率换算
// 有功功率换算
hashMap.put("title", String.format("%.2f", total.get() / 1000));
return hashMap;
}
//获取社会贡献
// 获取社会贡献
/**
* @param areaName 片区名称
* @param stationId 场站id
* @return 社会贡献列表
* @deprecated 如果areaName 与 stationID 都不传 则查全国、如果areaName传了 staionID没有传则查片区 如果 areaName 与stationId都传 则取场站id
* @deprecated 如果areaName 与 stationID 都不传 则查全国、如果areaName传了 staionID没有传则查片区 如果
* areaName 与stationId都传 则取场站id
*/
// public Page<SocialContributionDto> getSocialContributionDtoList(String areaName, String stationId) {
// AtomicReference<Double> total = new AtomicReference<>(0.0);
......@@ -734,18 +756,19 @@ public class MonitoringServiceImpl {
public List<StationBasic> getListOfStationBasicByAreaName(String areaName) {
List<StationBasic> stationBasicListAll = new ArrayList<>();
MapRegion mapRegion = mapRegionMapper.selectOne(new QueryWrapper<MapRegion>().eq("name", areaName));
//获取片区下的省份名称
// 获取片区下的省份名称
ArrayList<String> stringArrayList = mapRegion.getProvince();
//变量获取所有的场站信息
// 变量获取所有的场站信息
for (int i = 0; i < stringArrayList.size(); i++) {
Region region = regionMapper.selectOne(new QueryWrapper<Region>().eq("LEVEL", 1).like("REGION_NAME", stringArrayList.get(i)));
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().like("belong_area", region.getRegionCode()));
Region region = regionMapper
.selectOne(new QueryWrapper<Region>().eq("LEVEL", 1).like("REGION_NAME", stringArrayList.get(i)));
List<StationBasic> stationBasicList = stationBasicMapper
.selectList(new QueryWrapper<StationBasic>().like("belong_area", region.getRegionCode()));
stationBasicListAll.addAll(stationBasicList);
}
return stationBasicListAll;
}
// public HashMap<String, List<String>> getPowerGenerationTrendsOfCompletionRate(String areaName) {
// List<StationBasic> stationBasicListAll = new ArrayList<>();
// if (!ObjectUtils.isEmpty(areaName)) {
......@@ -774,7 +797,6 @@ public class MonitoringServiceImpl {
// return hashMap;
// }
// public Page<HashMap<String, String>> getPowerGenerationTrendsOfCompletionTopFive(String areaName) {
// Page<HashMap<String, String>> hashMapPage = new Page<>(1, 5);
// List<HashMap<String, String>> mapList = new ArrayList<>();
......@@ -811,7 +833,6 @@ public class MonitoringServiceImpl {
// return hashMapPage;
// }
public List<String> getXListofRecentOneYear() {
List<String> xList = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
......@@ -895,19 +916,21 @@ public class MonitoringServiceImpl {
@Scheduled(cron = "0/5 * * * * *")
public void getTotalData() {
//计算所有场站年计划完成量
// 计算所有场站年计划完成量
int year = Calendar.getInstance().get(Calendar.YEAR);
int Moon = Calendar.getInstance().get(Calendar.MONTH) + 1;
LambdaQueryWrapper<StationPlan> query = new LambdaQueryWrapper<>();
query.eq(StationPlan::getYear, String.valueOf(year));
List<StationPlan> stationPlans = stationPlanMapper.selectList(query);
double yearValue = stationPlans.stream().mapToDouble(StationPlan::getValue).sum();
double fdzValue = stationPlans.stream().filter(e -> e.getStationType().equals("FDZ")).mapToDouble(StationPlan::getValue).sum();
double fdzValue = stationPlans.stream().filter(e -> e.getStationType().equals("FDZ"))
.mapToDouble(StationPlan::getValue).sum();
double gfvalue = yearValue - fdzValue;
double moonValue = stationPlans.stream().filter(e -> e.getMonthly().equals(String.valueOf(Moon))).mapToDouble(StationPlan::getValue).sum();
double moonValue = stationPlans.stream().filter(e -> e.getMonthly().equals(String.valueOf(Moon)))
.mapToDouble(StationPlan::getValue).sum();
//查询风电站年计划完成量
// 查询风电站年计划完成量
//
// List<StationCacheInfoDto> listStationCacheInfoDto = commonServiceImpl.getListStationCacheInfoDto();
// List<String> fdz = listStationCacheInfoDto.stream().filter(e -> e.getStationType().equals("FDZ")).map(StationCacheInfoDto::getStationId).collect(Collectors.toList());
......@@ -917,37 +940,41 @@ public class MonitoringServiceImpl {
// List<StationPlan> fdzPlans = stationPlanMapper.selectList(queryWrapper);
// double fdzValue = fdzPlans.stream().mapToDouble(StationPlan::getValue).sum();
List<StationBasic> stationBasicListAll = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("fan_gateway_id"));
List<StationBasic> fdzList = stationBasicListAll.stream().filter(stationBasic -> stationBasic.getStationType().equals("FDZ")).collect(Collectors.toList());
List<StationBasic> jzsgfdzList = stationBasicListAll.stream().filter(stationBasic -> stationBasic.getStationType().equals("JZSGFDZ")).collect(Collectors.toList());
List<StationBasic> fbsgfdzList = stationBasicListAll.stream().filter(stationBasic -> stationBasic.getStationType().equals("FBSGFDZ")).collect(Collectors.toList());
List<StationBasic> gfList = stationBasicListAll.stream().filter(stationBasic -> !stationBasic.getStationType().equals("FDZ")).collect(Collectors.toList());
List<StationBasic> stationBasicListAll = stationBasicMapper
.selectList(new QueryWrapper<StationBasic>().isNotNull("fan_gateway_id"));
List<StationBasic> fdzList = stationBasicListAll.stream()
.filter(stationBasic -> stationBasic.getStationType().equals("FDZ")).collect(Collectors.toList());
List<StationBasic> jzsgfdzList = stationBasicListAll.stream()
.filter(stationBasic -> stationBasic.getStationType().equals("JZSGFDZ")).collect(Collectors.toList());
List<StationBasic> fbsgfdzList = stationBasicListAll.stream()
.filter(stationBasic -> stationBasic.getStationType().equals("FBSGFDZ")).collect(Collectors.toList());
List<StationBasic> gfList = stationBasicListAll.stream()
.filter(stationBasic -> !stationBasic.getStationType().equals("FDZ")).collect(Collectors.toList());
Page<HashMap<String, String>> page = new Page<>(1, 10);
Page<HashMap<String, String>> page1 = new Page<>(1, 10);
Page<HashMap<String, String>> page2 = new Page<>(1, 10);
Page<HashMap<String, String>> page3 = new Page<>(1, 10);
// ----------------装机容量开始-----------------------
List<HashMap<String, String>> list = new ArrayList<>();
//装机容量
// 装机容量
HashMap<String, String> stringHashMap = new HashMap<>();
BigDecimal totalInstall = new BigDecimal(getInstallCapity(stationBasicListAll));
// stringHashMap.put("title", totalInstall.toString());
//stringHashMap.put("data", "");
// stringHashMap.put("data", "");
// list.add(stringHashMap);
//风电站
// 风电站
HashMap<String, String> stringHashMap1 = new HashMap<>();
BigDecimal fdzInstall = new BigDecimal(getInstallCapity(fdzList));
stringHashMap1.put("title", fdzInstall.toString());
stringHashMap1.put("data", String.valueOf(fdzList.size()));
list.add(stringHashMap1);
//集中式光伏电站
// 集中式光伏电站
HashMap<String, String> stringHashMap2 = new HashMap<>();
BigDecimal jzsInstall = new BigDecimal(getInstallCapity(jzsgfdzList));
stringHashMap2.put("title", jzsInstall.toString());
stringHashMap2.put("data", String.valueOf(jzsgfdzList.size()));
list.add(stringHashMap2);
//分布式光伏电站
// 分布式光伏电站
HashMap<String, String> stringHashMap3 = new HashMap<>();
BigDecimal fbsInstall = new BigDecimal(getInstallCapity(fbsgfdzList));
stringHashMap3.put("title", fbsInstall.toString());
......@@ -970,85 +997,117 @@ public class MonitoringServiceImpl {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null,
ESEquipments.class);
// powerOfDayFD.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量"));
// powerOfMonthFD.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量"));
// powerOfAnnualFD.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量"));
powerOfDayFD.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
powerOfMonthFD.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
powerOfAnnualFD.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
powerOfDayFD.updateAndGet(
v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
powerOfMonthFD.updateAndGet(
v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
powerOfAnnualFD.updateAndGet(
v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
});
gfList.forEach(stationBasic -> {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, CommonConstans.taiHeGenIndicator);
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
powerOfDayGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay));
powerOfMonthGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth));
powerOfAnnualGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorYear));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null,
ESEquipments.class);
powerOfDayGF.updateAndGet(
v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay));
powerOfMonthGF.updateAndGet(v -> v
+ commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth));
powerOfAnnualGF.updateAndGet(
v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorYear));
});
HashMap<String, String> stringHashMap4 = new HashMap<>();
stringHashMap4.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfDayFD.get()) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfDayGF.get()));
stringHashMap4.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfDayFD.get()) + "/"
+ String.format(CommonConstans.Twodecimalplaces, powerOfDayGF.get()));
list1.add(stringHashMap4);
HashMap<String, String> stringHashMap5 = new HashMap<>();
stringHashMap5.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfMonthFD.get()) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfMonthGF.get()));
stringHashMap5.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfMonthFD.get()) + "/"
+ String.format(CommonConstans.Twodecimalplaces, powerOfMonthGF.get()));
list1.add(stringHashMap5);
HashMap<String, String> stringHashMap6 = new HashMap<>();
stringHashMap6.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfAnnualFD.get()) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfAnnualGF.get()));
stringHashMap6.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfAnnualFD.get()) + "/"
+ String.format(CommonConstans.Twodecimalplaces, powerOfAnnualGF.get()));
list1.add(stringHashMap6);
HashMap<String, String> stringHashMap7 = new HashMap<>();
stringHashMap7.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfAnnualFD.get() / fdzValue) + "/" + String.format(CommonConstans.Twodecimalplaces, powerOfAnnualGF.get() / gfvalue));
stringHashMap7.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfAnnualFD.get() / fdzValue)
+ "/" + String.format(CommonConstans.Twodecimalplaces, powerOfAnnualGF.get() / gfvalue));
list1.add(stringHashMap7);
HashMap<String, String> stringHashMap8 = new HashMap<>();
stringHashMap8.put("title", String.format(CommonConstans.Twodecimalplaces, (powerOfAnnualFD.get() * CommonConstans.wkwhToMv) / fdzInstall.doubleValue()) + "/" + String.format(CommonConstans.Twodecimalplaces, (powerOfAnnualGF.get() * CommonConstans.wkwhToMv) / gfInstall.doubleValue()));
stringHashMap8.put("title",
String.format(CommonConstans.Twodecimalplaces,
(powerOfAnnualFD.get() * CommonConstans.wkwhToMv) / fdzInstall.doubleValue()) + "/"
+ String.format(CommonConstans.Twodecimalplaces,
(powerOfAnnualGF.get() * CommonConstans.wkwhToMv) / gfInstall.doubleValue()));
list1.add(stringHashMap8);
page1.setRecords(list1);
HashMap<String, String> stringHashMap9 = new HashMap<>();
stringHashMap9.put("title", String.format(CommonConstans.Fourdecimalplaces, powerOfDayFD.get() + powerOfDayGF.get()));
stringHashMap9.put("title",
String.format(CommonConstans.Fourdecimalplaces, powerOfDayFD.get() + powerOfDayGF.get()));
HashMap<String, String> resultMap = new HashMap<>();
resultMap.put("Day", String.format(CommonConstans.Fourdecimalplaces, powerOfDayFD.get() + powerOfDayGF.get()));
list2.add(stringHashMap9);
HashMap<String, String> stringHashMap10 = new HashMap<>();
stringHashMap10.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfMonthFD.get() + powerOfMonthGF.get()));
resultMap.put("Moon", String.format(CommonConstans.Fourdecimalplaces, powerOfMonthFD.get() + powerOfMonthGF.get()));
resultMap.put("YJHWC", String.format(CommonConstans.Twodecimalplaces, (powerOfMonthFD.get() + powerOfMonthGF.get()) / moonValue * 100));
stringHashMap10.put("title",
String.format(CommonConstans.Twodecimalplaces, powerOfMonthFD.get() + powerOfMonthGF.get()));
resultMap.put("Moon",
String.format(CommonConstans.Fourdecimalplaces, powerOfMonthFD.get() + powerOfMonthGF.get()));
resultMap.put("YJHWC", String.format(CommonConstans.Twodecimalplaces,
(powerOfMonthFD.get() + powerOfMonthGF.get()) / moonValue * 100));
list2.add(stringHashMap10);
HashMap<String, String> stringHashMap11 = new HashMap<>();
stringHashMap11.put("title", String.format(CommonConstans.Fourdecimalplaces, powerOfAnnualFD.get() + powerOfAnnualGF.get()));
resultMap.put("Year", String.format(CommonConstans.Fourdecimalplaces, powerOfAnnualFD.get() + powerOfAnnualGF.get()));
stringHashMap11.put("title",
String.format(CommonConstans.Fourdecimalplaces, powerOfAnnualFD.get() + powerOfAnnualGF.get()));
resultMap.put("Year",
String.format(CommonConstans.Fourdecimalplaces, powerOfAnnualFD.get() + powerOfAnnualGF.get()));
list2.add(stringHashMap11);
HashMap<String, String> stringHashMap12 = new HashMap<>();
stringHashMap12.put("title", String.format(CommonConstans.Twodecimalplaces, (powerOfAnnualFD.get() + powerOfAnnualGF.get()) / yearValue * 100));
resultMap.put("NJHWC", String.format(CommonConstans.Twodecimalplaces, (powerOfAnnualFD.get() + powerOfAnnualGF.get()) / yearValue * 100));
stringHashMap12.put("title", String.format(CommonConstans.Twodecimalplaces,
(powerOfAnnualFD.get() + powerOfAnnualGF.get()) / yearValue * 100));
resultMap.put("NJHWC", String.format(CommonConstans.Twodecimalplaces,
(powerOfAnnualFD.get() + powerOfAnnualGF.get()) / yearValue * 100));
list2.add(stringHashMap12);
page2.setRecords(list2);
Double totalAnnual = (powerOfAnnualFD.get() + powerOfAnnualGF.get());
HashMap<String, String> stringHashMap13 = new HashMap<>();
stringHashMap13.put("title", String.format(CommonConstans.Twodecimalplaces, (totalAnnual * CommonConstans.carbonDioxide)));
stringHashMap13.put("title",
String.format(CommonConstans.Twodecimalplaces, (totalAnnual * CommonConstans.carbonDioxide)));
stringHashMap13.put("unit", "二氧化碳减排量(t)");
list3.add(stringHashMap13);
HashMap<String, String> stringHashMap14 = new HashMap<>();
stringHashMap14.put("title", String.format(CommonConstans.Twodecimalplaces, (totalAnnual * CommonConstans.standardCoal)));
stringHashMap14.put("title",
String.format(CommonConstans.Twodecimalplaces, (totalAnnual * CommonConstans.standardCoal)));
stringHashMap14.put("unit", "节约标准煤(t)");
list3.add(stringHashMap14);
HashMap<String, String> stringHashMap15 = new HashMap<>();
stringHashMap15.put("title", String.format(CommonConstans.Twodecimalplaces, (totalAnnual * CommonConstans.toner)));
stringHashMap15.put("title",
String.format(CommonConstans.Twodecimalplaces, (totalAnnual * CommonConstans.toner)));
stringHashMap15.put("unit", "碳粉尘减排量(t)");
list3.add(stringHashMap15);
HashMap<String, String> stringHashMap16 = new HashMap<>();
stringHashMap16.put("title", String.format(CommonConstans.Twodecimalplaces, (totalAnnual * CommonConstans.sulfurDioxide)));
stringHashMap16.put("title",
String.format(CommonConstans.Twodecimalplaces, (totalAnnual * CommonConstans.sulfurDioxide)));
stringHashMap16.put("unit", "二氧化硫减排量(t)");
list3.add(stringHashMap16);
page3.setRecords(list3);
try {
emqKeeper.getMqttClient().publish("bigscreen_zjrl_topic", JSON.toJSON(page).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish("bigscreen_ssscsj_topic", JSON.toJSON(page1).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish("bigscreen_zssscsj_topic", JSON.toJSON(page2).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish("bigscreen_qgjrdz_topic", JSON.toJSON(resultMap).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish("bigscreen_zshgx_topic", JSON.toJSON(page3).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish("bigscreen_zjrl_topic", JSON.toJSON(page).toString().getBytes("UTF-8"), 1,
true);
emqKeeper.getMqttClient().publish("bigscreen_ssscsj_topic", JSON.toJSON(page1).toString().getBytes("UTF-8"),
1, true);
emqKeeper.getMqttClient().publish("bigscreen_zssscsj_topic",
JSON.toJSON(page2).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish("bigscreen_qgjrdz_topic",
JSON.toJSON(resultMap).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish("bigscreen_zshgx_topic", JSON.toJSON(page3).toString().getBytes("UTF-8"),
1, true);
} catch (Exception ex) {
}
......@@ -1076,7 +1135,8 @@ public class MonitoringServiceImpl {
// return resultHashMap;
// }
public HashMap<String, Object> getTableByStationListAndTitle(String title, List<StationBasic> stationBasicList, String color) {
public HashMap<String, Object> getTableByStationListAndTitle(String title, List<StationBasic> stationBasicList,
String color) {
HashMap<String, Object> hashMap = new HashMap<>();
List<String> xData = new ArrayList<>();
List<String> yData = new ArrayList<>();
......@@ -1093,13 +1153,16 @@ public class MonitoringServiceImpl {
public List<HashMap<String, Object>> getSelectDataForNational() {
List<HashMap<String, Object>> hashMapList = new ArrayList<>();
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("belong_area").isNotNull("fan_gateway_id"));
List<StationBasic> stationBasicList = stationBasicMapper
.selectList(new QueryWrapper<StationBasic>().isNotNull("belong_area").isNotNull("fan_gateway_id"));
List<Region> regionList = this.regionMapper.selectList(new QueryWrapper<Region>().eq("level", 1));
regionList.forEach(region -> {
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("label", region.getRegionName());
hashMap.put("value", region.getRegionCode());
List<HashMap<String, Object>> children = stationBasicList.stream().filter(stationBasic -> stationBasic.getBelongArea().contains(String.valueOf(region.getRegionCode()))).map(stationBasic -> {
List<HashMap<String, Object>> children = stationBasicList.stream().filter(
stationBasic -> stationBasic.getBelongArea().contains(String.valueOf(region.getRegionCode())))
.map(stationBasic -> {
HashMap<String, Object> hashMap1 = new HashMap<>();
hashMap1.put("label", stationBasic.getStationName());
hashMap1.put("value", stationBasic.getSequenceNbr());
......@@ -1131,13 +1194,13 @@ public class MonitoringServiceImpl {
HashMap<String, Object> result = new HashMap<>();
List<HashMap<String, Object>> hashMapList = new ArrayList<>();
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
//x轴数据
// x轴数据
List<String> xdata = new ArrayList<>();
//实时有功功率
// 实时有功功率
List<String> currentPowerYdata = new ArrayList<>();
//短期功率预测
// 短期功率预测
List<String> shortPowerYdata = new ArrayList<>();
//超短期功率预测
// 超短期功率预测
List<String> superPowerShortYdata = new ArrayList<>();
for (int i = 0; i < 25; i++) {
xdata.add(String.format("%02d", i) + ":00");
......@@ -1159,9 +1222,12 @@ public class MonitoringServiceImpl {
superShortPowerHashMap.put("yData", currentPowerYdata);
result.put("superShortPower", superShortPowerHashMap);
HashMap<String, Object> footerList = new HashMap<>();
String currentMin = String.format("%.2f", currentPowerYdata.stream().mapToDouble(Double::parseDouble).min().getAsDouble());
String shortMin = String.format("%.2f", shortPowerYdata.stream().mapToDouble(Double::parseDouble).min().getAsDouble());
String supreMin = String.format("%.2f", superPowerShortYdata.stream().mapToDouble(Double::parseDouble).min().getAsDouble());
String currentMin = String.format("%.2f",
currentPowerYdata.stream().mapToDouble(Double::parseDouble).min().getAsDouble());
String shortMin = String.format("%.2f",
shortPowerYdata.stream().mapToDouble(Double::parseDouble).min().getAsDouble());
String supreMin = String.format("%.2f",
superPowerShortYdata.stream().mapToDouble(Double::parseDouble).min().getAsDouble());
List<String> gz = new ArrayList<>();
List<String> sj1 = new ArrayList<>();
gz.add(currentMin);
......@@ -1171,9 +1237,12 @@ public class MonitoringServiceImpl {
gz.add(supreMin);
sj1.add(xdata.get(superPowerShortYdata.indexOf(supreMin)));
String currentMax = String.format("%.2f", currentPowerYdata.stream().mapToDouble(Double::parseDouble).max().getAsDouble());
String shortMax = String.format("%.2f", shortPowerYdata.stream().mapToDouble(Double::parseDouble).max().getAsDouble());
String supreMax = String.format("%.2f", superPowerShortYdata.stream().mapToDouble(Double::parseDouble).max().getAsDouble());
String currentMax = String.format("%.2f",
currentPowerYdata.stream().mapToDouble(Double::parseDouble).max().getAsDouble());
String shortMax = String.format("%.2f",
shortPowerYdata.stream().mapToDouble(Double::parseDouble).max().getAsDouble());
String supreMax = String.format("%.2f",
superPowerShortYdata.stream().mapToDouble(Double::parseDouble).max().getAsDouble());
List<String> zdz = new ArrayList<>();
List<String> sj2 = new ArrayList<>();
zdz.add(currentMax);
......@@ -1217,47 +1286,66 @@ public class MonitoringServiceImpl {
List<StationCacheInfoDto> stationCacheInfoDtos = commonServiceImpl.getListStationCacheInfoDto();
if (StringUtils.isNotBlank(areaCode)) {
stationCacheInfoDtos = stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getAreaCode().equals(areaCode)).collect(Collectors.toList());
stationCacheInfoDtos = stationCacheInfoDtos.stream()
.filter(stationCacheInfoDto -> stationCacheInfoDto.getAreaCode().equals(areaCode))
.collect(Collectors.toList());
}
if (StringUtils.isNotBlank(stationId)) {
stationCacheInfoDtos = stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getStationId().equals(stationId)).collect(Collectors.toList());
stationCacheInfoDtos = stationCacheInfoDtos.stream()
.filter(stationCacheInfoDto -> stationCacheInfoDto.getStationId().equals(stationId))
.collect(Collectors.toList());
}
//月发电量
// 月发电量
AtomicReference<Double> monthlyPower = new AtomicReference<>(0.0);
//年发电量
// 年发电量
AtomicReference<Double> annualPower = new AtomicReference<>(0.0);
for (StationCacheInfoDto stationCacheInfoDto : stationCacheInfoDtos) {
if ("FDZ".equals(stationCacheInfoDto.getStationType())) {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
queryCondtion.put(CommonConstans.QueryStringGateWayId,
Arrays.asList(stationCacheInfoDto.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null,
ESEquipments.class);
monthlyPower.updateAndGet(
v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
annualPower.updateAndGet(
v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
} else {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, CommonConstans.taiHeGenIndicator);
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getBoosterGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth)));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorYear)));
queryCondtion.put(CommonConstans.QueryStringGateWayId,
Arrays.asList(stationCacheInfoDto.getBoosterGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null,
ESEquipments.class);
monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(
commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth)));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(
commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorYear)));
}
}
List<String> stationIds = stationCacheInfoDtos.stream().map(StationCacheInfoDto::getStationId).collect(Collectors.toList());
List<StationPlan> stationPlans = stationPlanMapper.selectList(new QueryWrapper<StationPlan>().in("station_basic_id", stationIds));
List<String> stationIds = stationCacheInfoDtos.stream().map(StationCacheInfoDto::getStationId)
.collect(Collectors.toList());
List<StationPlan> stationPlans = stationPlanMapper
.selectList(new QueryWrapper<StationPlan>().in("station_basic_id", stationIds));
String currentYearAndMonth = DateUtil.format(new Date(), DatePattern.NORM_MONTH_PATTERN);
String currentYear = currentYearAndMonth.split("-")[0];
Integer currentMonth = Integer.valueOf(currentYearAndMonth.split("-")[1]);
Double yearPlanValue = stationPlans.stream().filter(stationPlan -> stationPlan.getYear().equals(currentYear)).mapToDouble(i -> i.getValue()).sum();
Double monthPlanValue = stationPlans.stream().filter(stationPlan -> currentMonth == Integer.valueOf(stationPlan.getMonthly())).mapToDouble(i -> i.getValue()).sum();
Double yearPlanValue = stationPlans.stream().filter(stationPlan -> stationPlan.getYear().equals(currentYear))
.mapToDouble(i -> i.getValue()).sum();
Double monthPlanValue = stationPlans.stream()
.filter(stationPlan -> currentMonth == Integer.valueOf(stationPlan.getMonthly()))
.mapToDouble(i -> i.getValue()).sum();
if (monthlyPower.get() > 0 && monthPlanValue > 0) {
returnResult.put("monthCompleteRate", String.format(CommonConstans.Twodecimalplaces, (monthlyPower.get() / monthPlanValue) * 100) + "%");
returnResult.put("monthCompleteRate",
String.format(CommonConstans.Twodecimalplaces, (monthlyPower.get() / monthPlanValue) * 100) + "%");
returnResult.put("monthValue", String.format(CommonConstans.Fourdecimalplaces, monthlyPower.get()));
returnResult.put("monthPlanValue", String.format(CommonConstans.Fourdecimalplaces, monthPlanValue));
}
if (annualPower.get() > 0 && yearPlanValue > 0) {
returnResult.put("yearCompleteRate", String.format(CommonConstans.Twodecimalplaces, (annualPower.get() / yearPlanValue) * 100) + "%");
returnResult.put("yearCompleteRate",
String.format(CommonConstans.Twodecimalplaces, (annualPower.get() / yearPlanValue) * 100) + "%");
returnResult.put("yearValue", String.format(CommonConstans.Fourdecimalplaces, annualPower.get()));
returnResult.put("yearPlanValue", String.format(CommonConstans.Fourdecimalplaces, yearPlanValue));
}
......@@ -1267,16 +1355,23 @@ public class MonitoringServiceImpl {
public Map<String, Object> getGenPowerInfo(String areaCode) {
List<StationCacheInfoDto> stationCacheInfoDtos = commonServiceImpl.getListStationCacheInfoDto();
if (StringUtils.isNotBlank(areaCode)) {
MapRegion mapRegion = mapRegionMapper.selectOne(new QueryWrapper<MapRegion>().eq("area_code",areaCode));
List<StationCacheInfoDto> filterData = stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getAreaCode().equals(areaCode)).collect(Collectors.toList());
MapRegion mapRegion = mapRegionMapper.selectOne(new QueryWrapper<MapRegion>().eq("area_code", areaCode));
List<StationCacheInfoDto> filterData = stationCacheInfoDtos.stream()
.filter(stationCacheInfoDto -> stationCacheInfoDto.getAreaCode().equals(areaCode))
.collect(Collectors.toList());
stationCacheInfoDtos = filterData.size() > 0 ? filterData : stationCacheInfoDtos;
if(!ObjectUtils.isEmpty(mapRegion)){
stationCacheInfoDtos =filterData;
if (!ObjectUtils.isEmpty(mapRegion)) {
stationCacheInfoDtos = filterData;
}
}
List<StationCacheInfoDto> fanStationList = stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getStationType().equals("FDZ")).collect(Collectors.toList());
List<StationCacheInfoDto> pvStationList = stationCacheInfoDtos.stream().filter(stationCacheInfoDto -> !stationCacheInfoDto.getStationType().equals("FDZ")).collect(Collectors.toList());
Map<String, List<StationCacheInfoDto>> groupByProvince = stationCacheInfoDtos.stream().collect(Collectors.groupingBy(StationCacheInfoDto::getBelongProvince));
List<StationCacheInfoDto> fanStationList = stationCacheInfoDtos.stream()
.filter(stationCacheInfoDto -> stationCacheInfoDto.getStationType().equals("FDZ"))
.collect(Collectors.toList());
List<StationCacheInfoDto> pvStationList = stationCacheInfoDtos.stream()
.filter(stationCacheInfoDto -> !stationCacheInfoDto.getStationType().equals("FDZ"))
.collect(Collectors.toList());
Map<String, List<StationCacheInfoDto>> groupByProvince = stationCacheInfoDtos.stream()
.collect(Collectors.groupingBy(StationCacheInfoDto::getBelongProvince));
HashMap<String, Object> returnResult = new HashMap<>();
HashMap<String, Object> pv_interval = new HashMap<>();
HashMap<String, Object> fan_interval = new HashMap<>();
......@@ -1294,42 +1389,64 @@ public class MonitoringServiceImpl {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
powerOfDayFD.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
powerOfMonthFD.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
dayGenCache.put(stationBasic.getStationId(), keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
monthGenCache.put(stationBasic.getStationId(), keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null,
ESEquipments.class);
if (result != null) {
powerOfDayFD.updateAndGet(
v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
powerOfMonthFD.updateAndGet(
v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
dayGenCache.put(stationBasic.getStationId(),
keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
monthGenCache.put(stationBasic.getStationId(),
keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
}
planOfFD.updateAndGet(v -> v + getPlanGenByStationIdAndMonth(stationBasic.getStationId()));
});
pvStationList.forEach(stationBasic -> {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, CommonConstans.taiHeGenIndicator);
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
powerOfDayGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay));
powerOfMonthGF.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth));
dayGenCache.put(stationBasic.getStationId(), keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay)));
monthGenCache.put(stationBasic.getStationId(), keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth)));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null,
ESEquipments.class);
if (result != null) {
powerOfDayGF.updateAndGet(v -> v
+ commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay));
powerOfMonthGF.updateAndGet(v -> v
+ commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth));
dayGenCache.put(stationBasic.getStationId(), keepFourdecimalPlaces(
commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay)));
monthGenCache.put(stationBasic.getStationId(), keepFourdecimalPlaces(
commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth)));
}
planOfGF.updateAndGet(v -> v + getPlanGenByStationIdAndMonth(stationBasic.getStationId()));
});
returnResult.put("today_pv_power", String.format(CommonConstans.Twodecimalplaces, powerOfDayGF.get()));
returnResult.put("today_fan_power", String.format(CommonConstans.Twodecimalplaces, powerOfDayFD.get()));
returnResult.put("month_pv_power", String.format(CommonConstans.Twodecimalplaces, powerOfMonthGF.get()));
returnResult.put("month_fan_power", String.format(CommonConstans.Twodecimalplaces, powerOfMonthFD.get()));
returnResult.put("month_pv_quota_schedule", String.format(CommonConstans.Twodecimalplaces, (powerOfMonthGF.get() / planOfGF.get()) * 100));
if(returnResult.get("month_pv_quota_schedule").toString().equals("NaN")){
returnResult.put("month_pv_quota_schedule",0.00f);
returnResult.put("month_pv_quota_schedule",
String.format(CommonConstans.Twodecimalplaces, (powerOfMonthGF.get() / planOfGF.get()) * 100));
if (returnResult.get("month_pv_quota_schedule").toString().equals("NaN")) {
returnResult.put("month_pv_quota_schedule", 0.00f);
}
returnResult.put("month_fan_quota_schedule", String.format(CommonConstans.Twodecimalplaces, (powerOfMonthFD.get() / planOfFD.get()) * 100));
if(returnResult.get("month_fan_quota_schedule").toString().equals("NaN")){
returnResult.put("month_fan_quota_schedule",0.00f);
returnResult.put("month_fan_quota_schedule",
String.format(CommonConstans.Twodecimalplaces, (powerOfMonthFD.get() / planOfFD.get()) * 100));
if (returnResult.get("month_fan_quota_schedule").toString().equals("NaN")) {
returnResult.put("month_fan_quota_schedule", 0.00f);
}
groupByProvince.keySet().forEach(s -> {
HashMap<String, Object> fan = new HashMap<>();
HashMap<String, Object> pv = new HashMap<>();
List<StationCacheInfoDto> list = groupByProvince.get(s);
List<String> fanStationIds = list.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getStationType().equals("FDZ")).collect(Collectors.toList()).stream().map(stationCacheInfoDto -> stationCacheInfoDto.getStationId()).collect(Collectors.toList());
List<String> pvStationIds = list.stream().filter(stationCacheInfoDto -> !stationCacheInfoDto.getStationType().equals("FDZ")).collect(Collectors.toList()).stream().map(stationCacheInfoDto -> stationCacheInfoDto.getStationId()).collect(Collectors.toList());
List<String> fanStationIds = list.stream()
.filter(stationCacheInfoDto -> stationCacheInfoDto.getStationType().equals("FDZ"))
.collect(Collectors.toList()).stream()
.map(stationCacheInfoDto -> stationCacheInfoDto.getStationId()).collect(Collectors.toList());
List<String> pvStationIds = list.stream()
.filter(stationCacheInfoDto -> !stationCacheInfoDto.getStationType().equals("FDZ"))
.collect(Collectors.toList()).stream()
.map(stationCacheInfoDto -> stationCacheInfoDto.getStationId()).collect(Collectors.toList());
fan.put("station_count", fanStationIds.size());
pv.put("station_count", pvStationIds.size());
fan.put("today_power", getTotalPowerFromCache(fanStationIds, dayGenCache));
......@@ -1347,14 +1464,24 @@ public class MonitoringServiceImpl {
public Double getPlanGenByStationIdAndMonth(String stationId) {
String[] dates = DateUtil.today().split("-");
return stationPlanMapper.getPlanGenByStationIdAndMonth(stationId, dates[0], String.valueOf(Integer.valueOf(dates[1])));
Double plan = stationPlanMapper.getPlanGenByStationIdAndMonth(stationId, dates[0],
String.valueOf(Integer.valueOf(dates[1])));
if (plan == null) {
plan = 0.0;
}
return plan;
}
public Double getTotalPowerFromCache(List<String> keys, HashMap<String, Double> cache) {
AtomicReference<Double> result = new AtomicReference<>(0.0);
if (keys != null && !keys.isEmpty() && cache != null && !cache.isEmpty()) {
keys.forEach(s -> {
if(cache.get(s)!=null)
{
result.set(result.get() + cache.get(s));
}
});
}
return keepFourdecimalPlaces(result.get());
}
}
......@@ -567,7 +567,10 @@ public class CommonServiceImpl {
public Double getSumByEquipmentIndxName(List<ESEquipments> equipments, String indexName) {
Double result = 0.00;
if(equipments!=null)
{
result = equipments.stream().filter(esEquipments -> esEquipments.getEquipmentIndexName().equals(indexName)).filter(esEquipments -> esEquipments.getValueF() != null).mapToDouble(ESEquipments::getValueF).sum();
}
return result;
}
......
......@@ -301,13 +301,14 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
public TreeDto getTreeInfo(String sequenceNbr, ReginParams reginParams) {
String userId = reginParams.getUserModel().getUserId();
String companyLevel ="";
StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH"));
String companyLevel = "";
StdUserEmpower stdUserEmpower = userEmpowerMapper
.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH"));
if (ObjectUtils.isEmpty(stdUserEmpower)) {
// throw new BadRequest("您当前未配置数据权限!");
}else{
} else {
String permissionOrgCode = stdUserEmpower.getAmosOrgCode().get(0);
Map<String,String> companyInfo= userEmpowerMapper.getCompanyInfoByOrgCode(permissionOrgCode);
Map<String, String> companyInfo = userEmpowerMapper.getCompanyInfoByOrgCode(permissionOrgCode);
companyLevel = companyInfo.get("level").toString();
}
StationBasic stationBasic = stationBasicMapper.selectById(sequenceNbr);
......@@ -350,11 +351,12 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
gfzTreeDto.setChildren(gfz);
List<TreeDto> treeDtos = Arrays.asList(fdzTreeDto, gfzTreeDto);
treeDto.setChildren(treeDtos);
if(companyLevel.equals("station")){
List<TreeDto> children = stationListByRegionCode.stream().filter(t->t.getCode().equals(sequenceNbr)).collect(Collectors.toList());
if(stationBasic.getStationType().equals("FDZ")){
if (companyLevel.equals("station")) {
List<TreeDto> children = stationListByRegionCode.stream().filter(t -> t.getCode().equals(sequenceNbr))
.collect(Collectors.toList());
if (stationBasic.getStationType().equals("FDZ")) {
treeDto = fdzTreeDto;
}else {
} else {
treeDto = gfzTreeDto;
}
treeDto.setChildren(children);
......@@ -372,8 +374,8 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
return new ArrayList<ESEquipmentsDTO>();
}
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName,
Arrays.asList("风机状态", "有功功率", "发电状态", "报警状态", "停机状态", "故障状态", "待机状态", "维护状态", "发电机转速", "正常发电状态","30秒平均风速"));
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("风机状态", "有功功率", "发电状态", "报警状态",
"停机状态", "故障状态", "待机状态", "维护状态", "发电机转速", "正常发电状态", "30秒平均风速"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
Map<String, List<String>> queryCondtion1 = new HashMap<>();
......@@ -2398,6 +2400,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
@Override
public Map<String, Object> partofWaring3D(String stationId, String equipNum) {
Map<String, Object> resultMap = new HashMap<>();
if (stationId == null || equipNum == null || "null".equals(stationId) || "equipNum".equals(equipNum)) {
return resultMap;
}
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
......
......@@ -893,7 +893,14 @@ public class MonitoringServiceImpl {
total.set(commonServiceImpl.getSumByEquipmentIndxName(result, finalIndicator));
}
}
stationCacheInfoDto.setAddress(String.format(CommonConstans.Twodecimalplaces, (total.get()) * 100 / getPlanGenByStationIdAndMonth(stationCacheInfoDto.getStationId())));
Double PlanGen = getPlanGenByStationIdAndMonth(stationCacheInfoDto.getStationId());
if(PlanGen!=null)
{
stationCacheInfoDto.setAddress(String.format(CommonConstans.Twodecimalplaces, (total.get()) * 100 /PlanGen));
}else
{
stationCacheInfoDto.setAddress("0.0");
}
});
List<StationCacheInfoDto> sorted = stationCacheInfoDtoList.stream().sorted(Comparator.comparing(StationCacheInfoDto::getAddress, Comparator.comparingDouble(Double::parseDouble)).reversed()).collect(Collectors.toList());
sorted.forEach(stationBasic -> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment