Commit c158ee73 authored by caotao's avatar caotao

1.修改监盘客户现场对接问题

parent 94ee5511
...@@ -32,6 +32,11 @@ ...@@ -32,6 +32,11 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.22</version>
</dependency>
<dependency>
<groupId>org.influxdb</groupId> <groupId>org.influxdb</groupId>
<artifactId>influxdb-java</artifactId> <artifactId>influxdb-java</artifactId>
</dependency> </dependency>
......
package com.yeejoin.amos.boot.module.jxiop.biz.constants;
import org.checkerframework.checker.units.qual.C;
public class CommonConstans {
//光伏发电量系数
public static final Double pvGenPoweActor = 0.0001;
// 风电站:
// (日/月/年)发电量=场站所有风机(日/月/年)发电量总和
// 装机容量=场站所有风机装机容量总和
//
// 光伏站:
// (日/月/年)发电量=场站所有逆变器(日/月/年)发电量总和
// 装机容量=场站所有逆变器装机容量总和
//
// 通用:
// 发电量完成率=(月/年)发电量/(月/年)发电量指标
// 小时数完成率=(月/年)可利用小时/(月/年)可利用小时数指标
// 可利用小时(h)=(日/月/年)发电量(万kW·h)/装机容量(万kW)
// 二氧化碳减排量(万t)=发电量(万kW·h)*0.79
public static final Double carbonDioxide = 0.79;
// 节约标准煤(万t)=发电量(万kW·h)*0.29
public static final Double standardCoal = 0.29;
// 炭粉尘减排量(t)=发电量(万kW·h)*0.30
public static final Double toner = 0.30;
// 二氧化硫减排量(t)=发电量(万kW·h)*1.51
public static final Double sulfurDioxide = 1.51;
// 氮氧化物减排量(t)=发电量(万kW·h)*1.69
public static final Double oxynitride = 1.69;
//吨转万吨
public static final Double tToWT = 0.0001;
//万Kwh转MV
public static final Integer wkwhToMv = 10;
}
...@@ -376,7 +376,6 @@ public class DemoController extends BaseController { ...@@ -376,7 +376,6 @@ public class DemoController extends BaseController {
public ResponseModel<Object> demoTest9() { public ResponseModel<Object> demoTest9() {
QueryBuilder queryBuilder = QueryBuilders.matchQuery("equipmentIndexName", "有功功率"); QueryBuilder queryBuilder = QueryBuilders.matchQuery("equipmentIndexName", "有功功率");
AvgAggregationBuilder buyCountAvg = AggregationBuilders.avg("buyCountAvg").field("valueDouble"); AvgAggregationBuilder buyCountAvg = AggregationBuilders.avg("buyCountAvg").field("valueDouble");
Query query = new NativeSearchQueryBuilder() Query query = new NativeSearchQueryBuilder()
.withQuery(queryBuilder) .withQuery(queryBuilder)
......
package com.yeejoin.amos.boot.module.jxiop.biz.controller; package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import cn.hutool.extra.pinyin.PinyinUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
...@@ -12,6 +13,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.dto.TreeDto; ...@@ -12,6 +13,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.dto.TreeDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic; import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData; import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl;
...@@ -108,18 +110,20 @@ public class MonitorFanIdxController extends BaseController { ...@@ -108,18 +110,20 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风机布置图 - 风机状态图片") @ApiOperation(value = "风机布置图 - 风机状态图片")
@GetMapping("/getFanStatusListImage") @GetMapping("/getFanStatusListImage")
public ResponseModel<IPage<HashMap<String,String>>> getFanStatusListImages() { public ResponseModel<IPage<HashMap<String,String>>> getFanStatusListImages(@RequestParam(value = "stationId", required = false) String stationId){
List<IndexDto> fanStatusList = monitorFanIndicator.getFanStatusList("1660231556607774721"); List<IndexDto> fanStatusList = monitorFanIndicator.getFanStatusList(stationId);
List<IndexDto> collect = fanStatusList.stream() List<IndexDto> collect = fanStatusList.stream()
.limit(999) .limit(999)
.collect(Collectors.toList()); .collect(Collectors.toList());
IPage<HashMap<String,String>> page = new Page<>(); IPage<HashMap<String,String>> page = new Page<>();
HashMap<String,String> hashMap = new HashMap<>(); HashMap<String,String> hashMap = new HashMap<>();
List<IndexDto> indexDtoList = collect.stream().sorted(Comparator.comparing(IndexDto::getEquipmentNumber)).collect(Collectors.toList()); List<IndexDto> indexDtoList = collect.stream().sorted(Comparator.comparing(IndexDto::getEquipmentNumber)).collect(Collectors.toList());
//获取拼音首字母
String prefix =commonService.getFanDevicePrefix(stationId);
for (int i = 1; i <= indexDtoList.size(); i++) { for (int i = 1; i <= indexDtoList.size(); i++) {
IndexDto indexDto = indexDtoList.get(i-1); IndexDto indexDto = indexDtoList.get(i-1);
hashMap.put("url"+i,fanStatusImagePathPrefix+"/"+"风机-"+indexDto.getState()+".gif"); hashMap.put("url"+i,fanStatusImagePathPrefix+"/"+"风机-"+indexDto.getState()+".gif");
hashMap.put("name"+i,indexDto.getEquipmentNumber()); hashMap.put("name"+i,prefix+indexDto.getEquipmentNumber());
} }
page.setTotal(10); page.setTotal(10);
page.setSize(10); page.setSize(10);
...@@ -589,7 +593,7 @@ public class MonitorFanIdxController extends BaseController { ...@@ -589,7 +593,7 @@ public class MonitorFanIdxController extends BaseController {
//日-月-年-发电量需要保留四位小数问题修改 //日-月-年-发电量需要保留四位小数问题修改
for (String column : columnList) { for (String column : columnList) {
Double result = commonService.getTotalByIndicatior(mapList, column); Double result = commonService.getTotalByIndicatior(mapList, column);
columnMap.put(column, String.format("%.4f",result/10000)); columnMap.put(column, String.format("%.4f",result* CommonConstans.pvGenPoweActor));
} }
for (String column : syLists) { for (String column : syLists) {
Double result = commonService.getNumByIndicatior(boosterGatewayId, column); Double result = commonService.getNumByIndicatior(boosterGatewayId, column);
......
...@@ -40,10 +40,17 @@ import java.util.logging.Handler; ...@@ -40,10 +40,17 @@ import java.util.logging.Handler;
@Api(tags = "监盘地图接口") @Api(tags = "监盘地图接口")
@RequestMapping(value = "/monitormap") @RequestMapping(value = "/monitormap")
public class MonitoringMapController extends BaseController { public class MonitoringMapController extends BaseController {
@Value("${sec.startdate:2017-06-30}")
String secStartDate;
@Autowired @Autowired
MonitoringServiceImpl monitoringServiceImpl; MonitoringServiceImpl monitoringServiceImpl;
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(value = "获取监盘全国-安全生产天数")
@GetMapping("/getSecDays")
public ResponseModel<String> getSecDays(@RequestParam (value = "provinceName", required = false)String provinceName,@RequestParam (value = "type", required = false)String type) {
return ResponseHelper.buildResponse(monitoringServiceImpl.getSecDays(secStartDate));
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(value = "获取监盘全国地图数据") @ApiOperation(value = "获取监盘全国地图数据")
@GetMapping("/nationwide") @GetMapping("/nationwide")
......
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.extra.pinyin.PinyinUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic; import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationPlanMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments; import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto; import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.initdata.StationCacheDataInit; import com.yeejoin.amos.boot.module.jxiop.biz.initdata.StationCacheDataInit;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESEquipmentsRepository; import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESEquipmentsRepository;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import com.yeejoin.amos.component.influxdb.InfluxdbUtil; import com.yeejoin.amos.component.influxdb.InfluxdbUtil;
import net.bytebuddy.asm.Advice;
import org.apache.poi.ss.formula.functions.Count;
import org.apache.poi.ss.formula.functions.T;
import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms; import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms;
import org.elasticsearch.search.aggregations.bucket.terms.ParsedTerms;
import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.*; import org.elasticsearch.search.aggregations.metrics.*;
...@@ -37,17 +32,10 @@ import org.springframework.data.redis.core.RedisTemplate; ...@@ -37,17 +32,10 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@Service @Service
public class CommonServiceImpl { public class CommonServiceImpl {
@Autowired
InfluxDButils influxDButils;
@Autowired @Autowired
InfluxdbUtil influxdbUtil; InfluxdbUtil influxdbUtil;
...@@ -63,7 +51,8 @@ public class CommonServiceImpl { ...@@ -63,7 +51,8 @@ public class CommonServiceImpl {
@Autowired @Autowired
private RedisTemplate redisTemplate; private RedisTemplate redisTemplate;
@Autowired
private StationBasicMapper stationBasicMapper;
/** /**
* 带参数 求平均值 * 带参数 求平均值
* *
...@@ -92,7 +81,6 @@ public class CommonServiceImpl { ...@@ -92,7 +81,6 @@ public class CommonServiceImpl {
return value; return value;
} }
/* /*
*分组平均值 *分组平均值
...@@ -127,7 +115,6 @@ public class CommonServiceImpl { ...@@ -127,7 +115,6 @@ public class CommonServiceImpl {
return listdata; return listdata;
} }
/* /*
*分组求和 *分组求和
...@@ -161,9 +148,6 @@ public class CommonServiceImpl { ...@@ -161,9 +148,6 @@ public class CommonServiceImpl {
return listdata; return listdata;
} }
/** /**
* 带参数 求和 * 带参数 求和
* *
...@@ -207,20 +191,6 @@ public class CommonServiceImpl { ...@@ -207,20 +191,6 @@ public class CommonServiceImpl {
return search.getSearchHits().size(); return search.getSearchHits().size();
} }
/** /**
* @deprecated 获取指标值总和 * @deprecated 获取指标值总和
* @param gatewayId 网关id 用于拼接sql语句 * @param gatewayId 网关id 用于拼接sql语句
...@@ -275,7 +245,6 @@ public class CommonServiceImpl { ...@@ -275,7 +245,6 @@ public class CommonServiceImpl {
} }
/** /**
* @deprecated 获取指标值平均值 * @deprecated 获取指标值平均值
* @param gatewayId 网关id 用于拼接sql语句
* @param indicator 指标名称 查询条件-根据指标名称获取风速 * @param indicator 指标名称 查询条件-根据指标名称获取风速
* @return 指标值总和 * @return 指标值总和
*/ */
...@@ -312,16 +281,16 @@ public class CommonServiceImpl { ...@@ -312,16 +281,16 @@ public class CommonServiceImpl {
氮氧化物减排量(t)=发电量(万kW·h)*1.69 氮氧化物减排量(t)=发电量(万kW·h)*1.69
*/ */
co2.setUnit("二氧化碳减排量(万t)"); co2.setUnit("二氧化碳减排量(万t)");
co2.setTitle(String.format("%.2f",totalSocialContribution * 0.79)); co2.setTitle(String.format("%.2f",totalSocialContribution * CommonConstans.carbonDioxide));
socialContributionDtoList.add(co2); socialContributionDtoList.add(co2);
coal.setUnit("节约标准煤(万t)"); coal.setUnit("节约标准煤(万t)");
coal.setTitle(String.format("%.2f",(totalSocialContribution * 0.29)/10000)); coal.setTitle(String.format("%.2f",(totalSocialContribution * CommonConstans.standardCoal)));
socialContributionDtoList.add(coal); socialContributionDtoList.add(coal);
toner.setUnit("碳粉尘减排量(万t)"); toner.setUnit("碳粉尘减排量(万t)");
toner.setTitle(String.format("%.2f",(totalSocialContribution * 0.30)/10000)); toner.setTitle(String.format("%.2f",(totalSocialContribution * CommonConstans.toner*CommonConstans.tToWT)));
socialContributionDtoList.add(toner); socialContributionDtoList.add(toner);
so2.setUnit("二氧化硫减排量(万t)"); so2.setUnit("二氧化硫减排量(万t)");
so2.setTitle(String.format("%.2f",(totalSocialContribution * 1.51)/10000)); so2.setTitle(String.format("%.2f",(totalSocialContribution * CommonConstans.sulfurDioxide*CommonConstans.tToWT)));
socialContributionDtoList.add(so2); socialContributionDtoList.add(so2);
socialContributionDtoPage.setRecords(socialContributionDtoList); socialContributionDtoPage.setRecords(socialContributionDtoList);
socialContributionDtoPage.setTotal(100); socialContributionDtoPage.setTotal(100);
...@@ -342,4 +311,8 @@ public class CommonServiceImpl { ...@@ -342,4 +311,8 @@ public class CommonServiceImpl {
return stationCacheInfoDtoList; return stationCacheInfoDtoList;
} }
public String getFanDevicePrefix(String stationid){
StationBasic stationBasic = stationBasicMapper.selectById(stationid);
return PinyinUtil.getFirstLetter(stationBasic.getStationName().split("风")[0],"").toUpperCase(Locale.ROOT);
}
} }
...@@ -96,6 +96,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -96,6 +96,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
TemporaryDataServiceImpl temporaryDataService; TemporaryDataServiceImpl temporaryDataService;
@Autowired @Autowired
CommonServiceImpl commonServiceImpl;
@Autowired
EmqKeeper emqKeeper; EmqKeeper emqKeeper;
//风机状态列表 //风机状态列表
@Value("${fan.statuts.stattuspath}") @Value("${fan.statuts.stattuspath}")
...@@ -134,9 +137,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -134,9 +137,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
List<IndexDto> list = influxDButils.getListData(querysqln, IndexDto.class); List<IndexDto> list = influxDButils.getListData(querysqln, IndexDto.class);
List<IndexDto> list1 = influxDButils.getListData(querysqlcountn, IndexDto.class); List<IndexDto> list1 = influxDButils.getListData(querysqlcountn, IndexDto.class);
//对于查询到的告警信息进行按照时间顺序进行排序 //对于查询到的告警信息进行按照时间顺序进行排序
ArrayList<IndexDto> lisSort= (ArrayList<IndexDto>) list.stream().sorted(Comparator.comparing(IndexDto::getTimeString,Comparator.comparingLong(Long::parseLong)).reversed()).collect(Collectors.toList()); ArrayList<IndexDto> lisSort = (ArrayList<IndexDto>) list.stream().sorted(Comparator.comparing(IndexDto::getTimeString, Comparator.comparingLong(Long::parseLong)).reversed()).collect(Collectors.toList());
//构建平台数据 //构建平台数据
DataGridMock DataGridMock = new DataGridMock(current, !list1.isEmpty()? list1.get(0).getCount() : 0, false, current, lisSort); DataGridMock DataGridMock = new DataGridMock(current, !list1.isEmpty() ? list1.get(0).getCount() : 0, false, current, lisSort);
ColModel colModelequipmentNumber = new ColModel("equipmentNumber", "equipmentNumber", "设备", "设备", "dataGrid", "equipmentNumber"); ColModel colModelequipmentNumber = new ColModel("equipmentNumber", "equipmentNumber", "设备", "设备", "dataGrid", "equipmentNumber");
ColModel colModelvalueLabel = new ColModel("valueLabel", "valueLabel", "事件描述", "事件描述", "dataGrid", "valueLabel"); ColModel colModelvalueLabel = new ColModel("valueLabel", "valueLabel", "事件描述", "事件描述", "dataGrid", "valueLabel");
ColModel colModelcreatedTime = new ColModel("createdTime", "createdTime", "发生时间", "发生时间", "dataGrid", "createdTime"); ColModel colModelcreatedTime = new ColModel("createdTime", "createdTime", "发生时间", "发生时间", "dataGrid", "createdTime");
...@@ -163,13 +166,13 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -163,13 +166,13 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} else { } else {
gateway = String.format("'%s'", gateway); gateway = String.format("'%s'", gateway);
} }
String querysqln = String.format(querysql.toString(), table, gateway, size, (current - 1) *size); String querysqln = String.format(querysql.toString(), table, gateway, size, (current - 1) * size);
String querysqlcountn = String.format(querysqlcount.toString(), table, gateway); String querysqlcountn = String.format(querysqlcount.toString(), table, gateway);
//每个分机的指标数据 //每个分机的指标数据
List<IndexDto> list = influxDButils.getListData(querysqln, IndexDto.class); List<IndexDto> list = influxDButils.getListData(querysqln, IndexDto.class);
List<IndexDto> list1 = influxDButils.getListData(querysqlcountn, IndexDto.class); List<IndexDto> list1 = influxDButils.getListData(querysqlcountn, IndexDto.class);
//对于查询到的告警信息进行按照时间顺序进行排序 //对于查询到的告警信息进行按照时间顺序进行排序
ArrayList<IndexDto> lisSort= (ArrayList<IndexDto>) list.stream().sorted(Comparator.comparing(IndexDto::getTimeString,Comparator.comparingLong(Long::parseLong)).reversed()).collect(Collectors.toList()); ArrayList<IndexDto> lisSort = (ArrayList<IndexDto>) list.stream().sorted(Comparator.comparing(IndexDto::getTimeString, Comparator.comparingLong(Long::parseLong)).reversed()).collect(Collectors.toList());
//构建平台数据 //构建平台数据
DataGridMock DataGridMock = new DataGridMock(current, !list1.isEmpty() ? list1.get(0).getCount() : 0, false, current, lisSort); DataGridMock DataGridMock = new DataGridMock(current, !list1.isEmpty() ? list1.get(0).getCount() : 0, false, current, lisSort);
ColModel colModelequipmentNumber = new ColModel("equipmentNumber", "equipmentSpecificName", "风机号", "风机号", "dataGrid", "equipmentNumber"); ColModel colModelequipmentNumber = new ColModel("equipmentNumber", "equipmentSpecificName", "风机号", "风机号", "dataGrid", "equipmentNumber");
...@@ -186,7 +189,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -186,7 +189,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
public IPage<IndexDto> getFanIdxInfoByPage(String equipNum, String stationId, String frontModule, int current, int size, String systemType) { public IPage<IndexDto> getFanIdxInfoByPage(String equipNum, String stationId, String frontModule, int current, int size, String systemType) {
StationBasic stationBasic = getOneByStationNumber(stationId); StationBasic stationBasic = getOneByStationNumber(stationId);
Page<IndexDto> page = new Page<>(current, size); Page<IndexDto> page = new Page<>(current, size);
...@@ -197,14 +199,14 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -197,14 +199,14 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
sql = String.format("SELECT equipmentIndexName, value, frontModule, unit FROM \"indicators_%s\" WHERE equipmentNumber = '%s' and frontModule =~/%s/", stationBasic.getFanGatewayId(), equipNum, frontModule); sql = String.format("SELECT equipmentIndexName, value, frontModule, unit FROM \"indicators_%s\" WHERE equipmentNumber = '%s' and frontModule =~/%s/", stationBasic.getFanGatewayId(), equipNum, frontModule);
} }
List<IndexDto> influxDBList = influxDButils.getListData(sql, IndexDto.class); List<IndexDto> influxDBList = influxDButils.getListData(sql, IndexDto.class);
influxDBList.stream().forEach(e->{ influxDBList.stream().forEach(e -> {
Double f = Double.valueOf(e.getValue()); Double f = Double.valueOf(e.getValue());
e.setValue(String.format("%.2f",f)); e.setValue(String.format("%.2f", f));
}); });
Collator instance = Collator.getInstance(Locale.CHINA); Collator instance = Collator.getInstance(Locale.CHINA);
Collections.sort(influxDBList,(e1,e2)->{ Collections.sort(influxDBList, (e1, e2) -> {
return instance.compare(e1.getSystemType(),e2.getSystemType()); return instance.compare(e1.getSystemType(), e2.getSystemType());
}); });
List<IndexDto> collect = influxDBList.stream() List<IndexDto> collect = influxDBList.stream()
.skip((long) (current - 1) * size) .skip((long) (current - 1) * size)
...@@ -238,7 +240,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -238,7 +240,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
fdzTreeDto.setCode("FDZ"); fdzTreeDto.setCode("FDZ");
fdzTreeDto.setParentCode(String.valueOf(region.getRegionCode())); fdzTreeDto.setParentCode(String.valueOf(region.getRegionCode()));
fdzTreeDto.setIsOnClick(0); fdzTreeDto.setIsOnClick(0);
List<TreeDto> fdz = stationListByRegionCode.stream().filter(t -> t.getParentCode().contains("FDZ")&&t.getParentCode().length()<4).collect(Collectors.toList()); List<TreeDto> fdz = stationListByRegionCode.stream().filter(t -> t.getParentCode().contains("FDZ") && t.getParentCode().length() < 4).collect(Collectors.toList());
fdzTreeDto.setChildren(fdz); fdzTreeDto.setChildren(fdz);
TreeDto gfzTreeDto = new TreeDto(); TreeDto gfzTreeDto = new TreeDto();
...@@ -318,10 +320,11 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -318,10 +320,11 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
return equipNumList; return equipNumList;
} }
public List<IndexDto> getFanStatusListOptimize(String stationId) { public List<IndexDto> getFanStatusListOptimize(String stationId) {
StationBasic stationBasic = getOneByStationNumber(stationId); StationBasic stationBasic = getOneByStationNumber(stationId);
String sqlAll = String.format("SELECT * FROM \"indicators_%s\"",stationBasic.getFanGatewayId()); String sqlAll = String.format("SELECT * FROM \"indicators_%s\"", stationBasic.getFanGatewayId());
List<IndexDto> indexDtoList = influxDButils.getListData(sqlAll,IndexDto.class); List<IndexDto> indexDtoList = influxDButils.getListData(sqlAll, IndexDto.class);
// String sql = String.format("SELECT equipmentNumber, equipmentIndexName as state FROM \"indicators_%s\" WHERE equipmentIndexName =~/^报警状态|停机状态|故障状态|待机状态|维护状态|正常发电状态$/ and value = 'true'", stationBasic.getFanGatewayId()); // String sql = String.format("SELECT equipmentNumber, equipmentIndexName as state FROM \"indicators_%s\" WHERE equipmentIndexName =~/^报警状态|停机状态|故障状态|待机状态|维护状态|正常发电状态$/ and value = 'true'", stationBasic.getFanGatewayId());
// List<IndexDto> influxDBList = influxDButils.getListData(sql, IndexDto.class); // List<IndexDto> influxDBList = influxDButils.getListData(sql, IndexDto.class);
// Map<String, String> collect = influxDBList.stream().collect(Collectors.toMap(IndexDto::getEquipmentNumber, IndexDto::getState, (item1, item2) -> item1)); // Map<String, String> collect = influxDBList.stream().collect(Collectors.toMap(IndexDto::getEquipmentNumber, IndexDto::getState, (item1, item2) -> item1));
...@@ -330,14 +333,14 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -330,14 +333,14 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
// String equipmentSpecificNames = fanConfigPower.stream().map(t -> t.get("equipmentSpecificName")).collect(Collectors.joining("|")); // String equipmentSpecificNames = fanConfigPower.stream().map(t -> t.get("equipmentSpecificName")).collect(Collectors.joining("|"));
List<IndexDto> influxDBList = indexDtoList.stream(). List<IndexDto> influxDBList = indexDtoList.stream().
filter(indexDto -> fanStatesList.contains(indexDto.getEquipmentIndexName())&&indexDto.getValue().equals("true")).collect(Collectors.toList()); filter(indexDto -> fanStatesList.contains(indexDto.getEquipmentIndexName()) && indexDto.getValue().equals("true")).collect(Collectors.toList());
Map<String, String> collect = influxDBList.stream().collect(Collectors.toMap(IndexDto::getEquipmentNumber, IndexDto::getState, (item1, item2) -> item1)); Map<String, String> collect = influxDBList.stream().collect(Collectors.toMap(IndexDto::getEquipmentNumber, IndexDto::getState, (item1, item2) -> item1));
List<IndexDto> equipNumList=indexDtoList.stream().filter(indexDto -> !ObjectUtils.isEmpty(indexDto.getEquipmentNumber())).collect(Collectors.collectingAndThen(Collectors.toCollection(()->new TreeSet<>(Comparator.comparing(IndexDto::getEquipmentNumber))),ArrayList::new)); List<IndexDto> equipNumList = indexDtoList.stream().filter(indexDto -> !ObjectUtils.isEmpty(indexDto.getEquipmentNumber())).collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(IndexDto::getEquipmentNumber))), ArrayList::new));
List<Map<String, String>> fanConfigPower = monitorFanIndicatorregionMapper.getFanConfigPower(stationBasic.getFanGatewayId(), null); List<Map<String, String>> fanConfigPower = monitorFanIndicatorregionMapper.getFanConfigPower(stationBasic.getFanGatewayId(), null);
List<String > equipmentSpecificNames=fanConfigPower.stream().map(t -> t.get("equipmentSpecificName")).collect(Collectors.toList()); List<String> equipmentSpecificNames = fanConfigPower.stream().map(t -> t.get("equipmentSpecificName")).collect(Collectors.toList());
// String powerSql = String.format("SELECT equipmentNumber, value FROM \"indicators_%s\" WHERE equipmentSpecificName =~/^%s$/ and value = '9.0'", stationBasic.getFanGatewayId(), equipmentSpecificNames); // String powerSql = String.format("SELECT equipmentNumber, value FROM \"indicators_%s\" WHERE equipmentSpecificName =~/^%s$/ and value = '9.0'", stationBasic.getFanGatewayId(), equipmentSpecificNames);
// List<IndexDto> powerNum = influxDButils.getListData(powerSql, IndexDto.class); // List<IndexDto> powerNum = influxDButils.getListData(powerSql, IndexDto.class);
List<IndexDto> powerNum = indexDtoList.stream().filter(indexDto1 ->indexDto1.getValue().equals("9.0")&&equipmentSpecificNames.contains(indexDto1.getEquipmentSpecificName())).collect(Collectors.toList()); List<IndexDto> powerNum = indexDtoList.stream().filter(indexDto1 -> indexDto1.getValue().equals("9.0") && equipmentSpecificNames.contains(indexDto1.getEquipmentSpecificName())).collect(Collectors.toList());
List<String> powList = powerNum.stream().map(IndexDto::getEquipmentNumber).collect(Collectors.toList()); List<String> powList = powerNum.stream().map(IndexDto::getEquipmentNumber).collect(Collectors.toList());
Date currentDayStartTime = DateUtils.dateAddMinutes(new Date(), -15); Date currentDayStartTime = DateUtils.dateAddMinutes(new Date(), -15);
String time = ""; String time = "";
...@@ -362,6 +365,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -362,6 +365,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
return equipNumList; return equipNumList;
} }
public List<IndexDto> getFanStatusStatistics(String stationId) { public List<IndexDto> getFanStatusStatistics(String stationId) {
StationBasic stationBasic = getOneByStationNumber(stationId); StationBasic stationBasic = getOneByStationNumber(stationId);
String sql = String.format("SELECT equipmentNumber, equipmentIndexName as state FROM \"indicators_%s\" WHERE equipmentIndexName =~/^报警状态|停机状态|故障状态|待机状态|维护状态|正常发电状态$/ and value = 'true'", stationBasic.getFanGatewayId()); String sql = String.format("SELECT equipmentNumber, equipmentIndexName as state FROM \"indicators_%s\" WHERE equipmentIndexName =~/^报警状态|停机状态|故障状态|待机状态|维护状态|正常发电状态$/ and value = 'true'", stationBasic.getFanGatewayId());
...@@ -465,6 +469,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -465,6 +469,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
/** /**
* 根据风机号 场站号 模块获取实时温度 * 根据风机号 场站号 模块获取实时温度
*
* @param equipNum * @param equipNum
* @param stationId * @param stationId
* @param frontModule * @param frontModule
...@@ -479,7 +484,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -479,7 +484,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
List<String> yList = new ArrayList<>(); List<String> yList = new ArrayList<>();
for (int i = 0; i < influxDBList.size(); i++) { for (int i = 0; i < influxDBList.size(); i++) {
IndexDto indexDto = influxDBList.get(i); IndexDto indexDto = influxDBList.get(i);
if(indexDto.getEquipmentIndexName().contains("温度")){ if (indexDto.getEquipmentIndexName().contains("温度")) {
xList.add(indexDto.getEquipmentIndexName()); xList.add(indexDto.getEquipmentIndexName());
yList.add(indexDto.getValue()); yList.add(indexDto.getValue());
} }
...@@ -507,10 +512,10 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -507,10 +512,10 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
} }
public String getFJCount(String gatewayId){ public String getFJCount(String gatewayId) {
String sql = "SELECT count(DISTINCT equipmentNumber) as value FROM indicators_"+gatewayId; String sql = "SELECT count(DISTINCT equipmentNumber) as value FROM indicators_" + gatewayId;
List<IndicatorsDto> indicatorsDtoList = influxDButils.getListData(sql,IndicatorsDto.class); List<IndicatorsDto> indicatorsDtoList = influxDButils.getListData(sql, IndicatorsDto.class);
if (indicatorsDtoList.size()>0){ if (indicatorsDtoList.size() > 0) {
return indicatorsDtoList.get(0).getValue(); return indicatorsDtoList.get(0).getValue();
} }
...@@ -518,37 +523,37 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -518,37 +523,37 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
public Map<String,Object> getDetailsWindSpeedAll(String gatewayId){ public Map<String, Object> getDetailsWindSpeedAll(String gatewayId) {
List<Map<String, String>> list = temporaryDataMapper.timingTemporarysSorageData(gatewayId); List<Map<String, String>> list = temporaryDataMapper.timingTemporarysSorageData(gatewayId);
Map<String,Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
List<String> values = new ArrayList<>(); List<String> values = new ArrayList<>();
List<String> valueList = new ArrayList<>(); List<String> valueList = new ArrayList<>();
Set<String> time = new TreeSet<>(); Set<String> time = new TreeSet<>();
for (Map<String, String> stringStringMap : list) { for (Map<String, String> stringStringMap : list) {
if (stringStringMap.get("equipmentIndexName").equals("有功功率")){ if (stringStringMap.get("equipmentIndexName").equals("有功功率")) {
values.add(stringStringMap.get("value")); values.add(stringStringMap.get("value"));
}else { } else {
valueList.add(stringStringMap.get("value")); valueList.add(stringStringMap.get("value"));
time.add(stringStringMap.get("createdTime")); time.add(stringStringMap.get("createdTime"));
} }
} }
List< Map<String,Object>> seriesData = new ArrayList<>(); List<Map<String, Object>> seriesData = new ArrayList<>();
Map<String,Object> map3 = new HashMap<>(); Map<String, Object> map3 = new HashMap<>();
Map<String,Object> map1 = new HashMap<>(); Map<String, Object> map1 = new HashMap<>();
Map<String,Object> map2 = new HashMap<>(); Map<String, Object> map2 = new HashMap<>();
map1.put("data", values); map1.put("data", values);
map2.put("data", valueList); map2.put("data", valueList);
seriesData.add(map2); seriesData.add(map2);
seriesData.add(map1); seriesData.add(map1);
map.put("seriesData", seriesData); map.put("seriesData", seriesData);
map.put("axisData",time); map.put("axisData", time);
return map; return map;
} }
public Map<String,Object> getDetailsWindSpeed(String gatewayId,String name){ public Map<String, Object> getDetailsWindSpeed(String gatewayId, String name) {
Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date()); Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
String time = ""; String time = "";
try { try {
...@@ -556,31 +561,31 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -556,31 +561,31 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
String sql = "SELECT DISTINCT value FROM iot_data_"+gatewayId+" WHERE equipmentIndexName = '瞬时风速' and equipmentSpecificName =~/"+name+"/and time >='"+time+"'GROUP BY time(2m)"; String sql = "SELECT DISTINCT value FROM iot_data_" + gatewayId + " WHERE equipmentIndexName = '瞬时风速' and equipmentSpecificName =~/" + name + "/and time >='" + time + "'GROUP BY time(2m)";
String sql1 = "SELECT DISTINCT value FROM iot_data_"+gatewayId+" WHERE equipmentIndexName = '有功功率' and equipmentSpecificName =~/"+name+"/ and time >='"+time+"'GROUP BY time(2m)"; String sql1 = "SELECT DISTINCT value FROM iot_data_" + gatewayId + " WHERE equipmentIndexName = '有功功率' and equipmentSpecificName =~/" + name + "/ and time >='" + time + "'GROUP BY time(2m)";
List<IndicatorsDto> indicatorsDtoList = influxDButils.getListDataAll(sql,IndicatorsDto.class); List<IndicatorsDto> indicatorsDtoList = influxDButils.getListDataAll(sql, IndicatorsDto.class);
List<IndicatorsDto> indicatorsDtoLists = influxDButils.getListDataAll(sql1,IndicatorsDto.class); List<IndicatorsDto> indicatorsDtoLists = influxDButils.getListDataAll(sql1, IndicatorsDto.class);
LinkedHashMap<String, String> collect = indicatorsDtoList.stream().collect(Collectors.toMap(IndicatorsDto::getTime, IndicatorsDto::getDistinct,(key1, ky2)-> (String) key1,LinkedHashMap::new)); LinkedHashMap<String, String> collect = indicatorsDtoList.stream().collect(Collectors.toMap(IndicatorsDto::getTime, IndicatorsDto::getDistinct, (key1, ky2) -> (String) key1, LinkedHashMap::new));
LinkedHashMap<String, String> collects = indicatorsDtoLists.stream().collect(Collectors.toMap(IndicatorsDto::getTime, IndicatorsDto::getDistinct,(key1, ky2)-> (String) key1,LinkedHashMap::new)); LinkedHashMap<String, String> collects = indicatorsDtoLists.stream().collect(Collectors.toMap(IndicatorsDto::getTime, IndicatorsDto::getDistinct, (key1, ky2) -> (String) key1, LinkedHashMap::new));
Collection<String> values = collect.values(); Collection<String> values = collect.values();
Collection<String> valuess = collects.values(); Collection<String> valuess = collects.values();
Set<String> keySet = collect.keySet(); Set<String> keySet = collect.keySet();
Set<String> keySets = collects.keySet(); Set<String> keySets = collects.keySet();
List< Map<String,Object>> seriesData = new ArrayList<>(); List<Map<String, Object>> seriesData = new ArrayList<>();
Map<String,Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
Map<String,Object> map1 = new HashMap<>(); Map<String, Object> map1 = new HashMap<>();
Map<String,Object> map2 = new HashMap<>(); Map<String, Object> map2 = new HashMap<>();
map1.put("data", values); map1.put("data", values);
map2.put("data", valuess); map2.put("data", valuess);
seriesData.add(map1); seriesData.add(map1);
seriesData.add(map2); seriesData.add(map2);
map.put("seriesData", seriesData); map.put("seriesData", seriesData);
map.put("axisData",keySet.size()>keySets.size()?keySet:keySets); map.put("axisData", keySet.size() > keySets.size() ? keySet : keySets);
return map; return map;
} }
public Map<String,Object> getDetailsWindSpeeds(String gatewayId,String name){ public Map<String, Object> getDetailsWindSpeeds(String gatewayId, String name) {
Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date()); Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
String time = ""; String time = "";
try { try {
...@@ -588,76 +593,73 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -588,76 +593,73 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
String sql = "SELECT equipmentSpecificName FROM indicators_"+gatewayId+" WHERE equipmentNumber = '"+name+"' limit 1"; String sql = "SELECT equipmentSpecificName FROM indicators_" + gatewayId + " WHERE equipmentNumber = '" + name + "' limit 1";
List<IndicatorsDto> indicatorsDtoList = influxDButils.getListDataAll(sql,IndicatorsDto.class); List<IndicatorsDto> indicatorsDtoList = influxDButils.getListDataAll(sql, IndicatorsDto.class);
name = indicatorsDtoList.get(0).getEquipmentSpecificName(); name = indicatorsDtoList.get(0).getEquipmentSpecificName();
StringBuffer param = new StringBuffer(); StringBuffer param = new StringBuffer();
String[] split = name.replace("#", "").split("/"); String[] split = name.replace("#", "").split("/");
for (int i = 0; i < split.length; i++) { for (int i = 0; i < split.length; i++) {
param .append(" and equipmentSpecificName =~/"+split[i]+"/") ; param.append(" and equipmentSpecificName =~/" + split[i] + "/");
} }
String sql1 = "SELECT DISTINCT value FROM iot_data_"+gatewayId+" WHERE equipmentIndexName = '有功功率'"+param+" and time >='"+time+"'GROUP BY time(2m)"; String sql1 = "SELECT DISTINCT value FROM iot_data_" + gatewayId + " WHERE equipmentIndexName = '有功功率'" + param + " and time >='" + time + "'GROUP BY time(2m)";
List<IndicatorsDto> indicatorsDtoLists = influxDButils.getListDataAll(sql1,IndicatorsDto.class); List<IndicatorsDto> indicatorsDtoLists = influxDButils.getListDataAll(sql1, IndicatorsDto.class);
LinkedHashMap<String, String> collects = indicatorsDtoLists.stream().collect(Collectors.toMap(IndicatorsDto::getTime, IndicatorsDto::getDistinct,(key1, ky2)-> (String) key1,LinkedHashMap::new)); LinkedHashMap<String, String> collects = indicatorsDtoLists.stream().collect(Collectors.toMap(IndicatorsDto::getTime, IndicatorsDto::getDistinct, (key1, ky2) -> (String) key1, LinkedHashMap::new));
Collection<String> valuess = collects.values(); Collection<String> valuess = collects.values();
Set<String> keySets = collects.keySet(); Set<String> keySets = collects.keySet();
List< Map<String,Object>> seriesData = new ArrayList<>(); List<Map<String, Object>> seriesData = new ArrayList<>();
Map<String,Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
Map<String,Object> map2 = new HashMap<>(); Map<String, Object> map2 = new HashMap<>();
map2.put("data", valuess); map2.put("data", valuess);
seriesData.add(map2); seriesData.add(map2);
map.put("seriesData", seriesData); map.put("seriesData", seriesData);
map.put("axisData",keySets); map.put("axisData", keySets);
return map; return map;
} }
@Scheduled(cron = "0 */5 * * * ?") @Scheduled(cron = "0 */5 * * * ?")
private void schedTaskData(){ private void schedTaskData() {
LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BaseEntity::getIsDelete,false); wrapper.eq(BaseEntity::getIsDelete, false);
List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper); List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
for (StationBasic stationBasic : stationBasics) { for (StationBasic stationBasic : stationBasics) {
if (stationBasic.getStationType().equals("FDZ")){ if (stationBasic.getStationType().equals("FDZ")) {
timingTemporarysSorageData(stationBasic.getFanGatewayId()); timingTemporarysSorageData(stationBasic.getFanGatewayId());
} }
if (stationBasic.getStationType().equals("JZSGFDZ")){ if (stationBasic.getStationType().equals("JZSGFDZ")) {
schedSolarPower(stationBasic.getBoosterGatewayId()); schedSolarPower(stationBasic.getBoosterGatewayId());
} }
} }
} }
@Scheduled(cron = "0 59 23 * * ?") @Scheduled(cron = "0 59 23 * * ?")
private void deleteSchedData(){ private void deleteSchedData() {
QueryWrapper<TemporaryData> wrapper = new QueryWrapper<>(); QueryWrapper<TemporaryData> wrapper = new QueryWrapper<>();
temporaryDataMapper.delete(wrapper); temporaryDataMapper.delete(wrapper);
String sort = alarmEventMapper.getLastDataBySort(null); String sort = alarmEventMapper.getLastDataBySort(null);
LambdaQueryWrapper<AlarmEvent> params = new LambdaQueryWrapper<>(); LambdaQueryWrapper<AlarmEvent> params = new LambdaQueryWrapper<>();
params.notIn(AlarmEvent::getSort,sort); params.notIn(AlarmEvent::getSort, sort);
alarmEventMapper.delete(params); alarmEventMapper.delete(params);
} }
@Scheduled(cron = "0 */5 * * * ?") @Scheduled(cron = "0 */5 * * * ?")
private void schedAlarmEventData(){ private void schedAlarmEventData() {
LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BaseEntity::getIsDelete,false); wrapper.eq(BaseEntity::getIsDelete, false);
List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper); List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
long currentsort = new Date().getTime(); long currentsort = new Date().getTime();
for (StationBasic stationBasic : stationBasics) { for (StationBasic stationBasic : stationBasics) {
schedAddAlarmEventData(stationBasic.getBoosterGatewayId(),stationBasic.getSequenceNbr().toString(),stationBasic.getStationName(),currentsort); schedAddAlarmEventData(stationBasic.getBoosterGatewayId(), stationBasic.getSequenceNbr().toString(), stationBasic.getStationName(), currentsort);
} }
} }
public void schedAddAlarmEventData(String gatewayId, String stationId, String stationName, long currentsort) {
public void schedAddAlarmEventData(String gatewayId,String stationId,String stationName,long currentsort){ String sql = "SELECT * FROM indicators_" + gatewayId + " WHERE systemType = '光字牌' and value = 'false'";
String sql = "SELECT * FROM indicators_"+gatewayId+" WHERE systemType = '光字牌' and value = 'false'"; List<IndicatorsDto> indicatorsDtoList = influxDButils.getListDataAll(sql, IndicatorsDto.class);
List<IndicatorsDto> indicatorsDtoList = influxDButils.getListDataAll(sql,IndicatorsDto.class);
List<AlarmEvent> newAlarmEvents = new ArrayList<>(); List<AlarmEvent> newAlarmEvents = new ArrayList<>();
List<String> alarmsNames = new ArrayList<>(); List<String> alarmsNames = new ArrayList<>();
...@@ -712,13 +714,11 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -712,13 +714,11 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
public void timingTemporarysSorageData(String gatewayId) {
String sql = "SELECT * FROM indicators_" + gatewayId + " WHERE equipmentIndexName = '瞬时风速' ";
public void timingTemporarysSorageData(String gatewayId){ String sql1 = "SELECT * FROM indicators_" + gatewayId + " WHERE equipmentIndexName = '有功功率'";
String sql = "SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName = '瞬时风速' "; List<IndicatorsDto> indicatorsDtoList = influxDButils.getListDataAll(sql, IndicatorsDto.class);
String sql1 = "SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName = '有功功率'"; List<IndicatorsDto> indicatorsDtoLists = influxDButils.getListDataAll(sql1, IndicatorsDto.class);
List<IndicatorsDto> indicatorsDtoList = influxDButils.getListDataAll(sql,IndicatorsDto.class);
List<IndicatorsDto> indicatorsDtoLists = influxDButils.getListDataAll(sql1,IndicatorsDto.class);
List<TemporaryData> temporaryDatas = new ArrayList<>(); List<TemporaryData> temporaryDatas = new ArrayList<>();
List<TemporaryData> temporaryDatass = new ArrayList<>(); List<TemporaryData> temporaryDatass = new ArrayList<>();
String time = ""; String time = "";
...@@ -760,11 +760,11 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -760,11 +760,11 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
temporaryDataService.saveBatch(temporaryDatass); temporaryDataService.saveBatch(temporaryDatass);
} }
public void schedSolarPower(String gatewayId){ public void schedSolarPower(String gatewayId) {
String sql = "SELECT * FROM indicators_"+gatewayId+" WHERE displayName = '总辐射累计' "; String sql = "SELECT * FROM indicators_" + gatewayId + " WHERE displayName = '总辐射累计' ";
String sql1 = "SELECT * FROM indicators_"+gatewayId+" WHERE displayName = '有功功率'"; String sql1 = "SELECT * FROM indicators_" + gatewayId + " WHERE displayName = '有功功率'";
List<IndicatorsDto> indicatorsDtoList = influxDButils.getListDataAll(sql,IndicatorsDto.class); List<IndicatorsDto> indicatorsDtoList = influxDButils.getListDataAll(sql, IndicatorsDto.class);
List<IndicatorsDto> indicatorsDtoLists = influxDButils.getListDataAll(sql1,IndicatorsDto.class); List<IndicatorsDto> indicatorsDtoLists = influxDButils.getListDataAll(sql1, IndicatorsDto.class);
List<TemporaryData> temporaryDatas = new ArrayList<>(); List<TemporaryData> temporaryDatas = new ArrayList<>();
List<TemporaryData> temporaryDatass = new ArrayList<>(); List<TemporaryData> temporaryDatass = new ArrayList<>();
String time = ""; String time = "";
...@@ -805,21 +805,21 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -805,21 +805,21 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
public List<Map<String,Object>> getStatusMonitoring(String gatewayId,String equipNum,String systemName){ public List<Map<String, Object>> getStatusMonitoring(String gatewayId, String equipNum, String systemName) {
String sql = "SELECT * FROM indicators_"+gatewayId+" WHERE equipmentNumber = '"+equipNum+"' and equipmentIndexName =~/实时故障/"; String sql = "SELECT * FROM indicators_" + gatewayId + " WHERE equipmentNumber = '" + equipNum + "' and equipmentIndexName =~/实时故障/";
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
String type = listData.get(0).getEquipmentSpecificName().substring(0,5); String type = listData.get(0).getEquipmentSpecificName().substring(0, 5);
List<SystemEnumDto> statusMonitoring = systemEnumMapper.getStatusMonitoring(type, systemName); List<SystemEnumDto> statusMonitoring = systemEnumMapper.getStatusMonitoring(type, systemName);
List<Map<String,Object>> statusMaps = new ArrayList<>(); List<Map<String, Object>> statusMaps = new ArrayList<>();
for (SystemEnumDto systemEnumDto : statusMonitoring) { for (SystemEnumDto systemEnumDto : statusMonitoring) {
Map<String, Object> statusMap = new HashMap<>(); Map<String, Object> statusMap = new HashMap<>();
statusMap.put("title1",systemEnumDto.getEnumDesc()); statusMap.put("title1", systemEnumDto.getEnumDesc());
for (IndicatorsDto listDatum : listData) { for (IndicatorsDto listDatum : listData) {
if (listDatum.getEquipmentSpecificName().contains(systemEnumDto.getCode()) && if (listDatum.getEquipmentSpecificName().contains(systemEnumDto.getCode()) &&
systemEnumDto.getEunmValue().equals(listDatum.getValue())){ systemEnumDto.getEunmValue().equals(listDatum.getValue())) {
statusMap.put("state","1"); statusMap.put("state", "1");
}else { } else {
statusMap.put("state","0"); statusMap.put("state", "0");
} }
} }
statusMaps.add(statusMap); statusMaps.add(statusMap);
...@@ -828,127 +828,130 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -828,127 +828,130 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
public List<Map<String,Object>> getStatusGzp(String gatewayId,String systemType,String frontModule,String equipNum){ public List<Map<String, Object>> getStatusGzp(String gatewayId, String systemType, String frontModule, String equipNum) {
String sql = " SELECT displayName , value as state,equipmentIndexName FROM indicators_"+gatewayId+" WHERE frontModule =~/"+frontModule+"/ and systemType = '"+systemType+"'"; String sql = " SELECT displayName , value as state,equipmentIndexName FROM indicators_" + gatewayId + " WHERE frontModule =~/" + frontModule + "/ and systemType = '" + systemType + "'";
if (null != equipNum){ if (null != equipNum) {
sql = " SELECT displayName , value as state,equipmentIndexName FROM indicators_"+gatewayId+" WHERE frontModule =~/"+frontModule+"/ and systemType = '"+systemType+"' and equipmentNumber ='"+equipNum+"'"; sql = " SELECT displayName , value as state,equipmentIndexName FROM indicators_" + gatewayId + " WHERE frontModule =~/" + frontModule + "/ and systemType = '" + systemType + "' and equipmentNumber ='" + equipNum + "'";
} }
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
List<Map<String,Object>> statusMaps = new ArrayList<>(); List<Map<String, Object>> statusMaps = new ArrayList<>();
for (IndicatorsDto listDatum : listData) { for (IndicatorsDto listDatum : listData) {
Map<String, Object> statusMap = new HashMap<>(); Map<String, Object> statusMap = new HashMap<>();
statusMap.put("data",StringUtils.isEmpty(listDatum.getDisplayName())?listDatum.getEquipmentIndexName():listDatum.getDisplayName()); statusMap.put("data", StringUtils.isEmpty(listDatum.getDisplayName()) ? listDatum.getEquipmentIndexName() : listDatum.getDisplayName());
statusMap.put("state",listDatum.getState().equals("false")? 1:0); statusMap.put("state", listDatum.getState().equals("false") ? 1 : 0);
statusMap.put("status",listDatum.getState().equals("false")? 1:0); statusMap.put("status", listDatum.getState().equals("false") ? 1 : 0);
statusMap.put("title",listDatum.getState().equals("false")?"断":"通"); statusMap.put("title", listDatum.getState().equals("false") ? "断" : "通");
statusMaps.add(statusMap); statusMaps.add(statusMap);
} }
return statusMaps; return statusMaps;
} }
public List<Map<String,Object>> getAnalogQuantity (String gatewayId,String frontModule,String systemType){ public List<Map<String, Object>> getAnalogQuantity(String gatewayId, String frontModule, String systemType) {
String sql = " SELECT * FROM indicators_"+gatewayId+" WHERE frontModule =~/"+frontModule+"/ and systemType = '"+systemType+"' and displayName != ''"; String sql = " SELECT * FROM indicators_" + gatewayId + " WHERE frontModule =~/" + frontModule + "/ and systemType = '" + systemType + "' and displayName != ''";
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
List<Map<String,Object>> statusMaps = new ArrayList<>(); List<Map<String, Object>> statusMaps = new ArrayList<>();
for (IndicatorsDto listDatum : listData) { for (IndicatorsDto listDatum : listData) {
Map<String, Object> statusMap = new HashMap<>(); Map<String, Object> statusMap = new HashMap<>();
statusMap.put("title",listDatum.getValue().equals("")? 0.00: keepTwoDecimalPlaces(listDatum.getValue())+" "+listDatum.getUnit() == null?"":listDatum.getUnit()); statusMap.put("title", listDatum.getValue().equals("") ? 0.00 : keepTwoDecimalPlaces(listDatum.getValue()) + " " + listDatum.getUnit() == null ? "" : listDatum.getUnit());
statusMap.put("title1",listDatum.getDisplayName()); statusMap.put("title1", listDatum.getDisplayName());
statusMaps.add(statusMap); statusMaps.add(statusMap);
} }
return statusMaps; return statusMaps;
} }
public void getStatusJDX(String gatewayId, String stationId, String frontModule) {
public void getStatusJDX(String gatewayId, String stationId,String frontModule){ String sql = " SELECT * FROM indicators_" + gatewayId + " WHERE frontModule =~/" + frontModule + "/ and displayName =~/合位$/";
String sql = " SELECT * FROM indicators_"+gatewayId+" WHERE frontModule =~/"+frontModule+"/ and displayName =~/合位$/";
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
List<Map<String,Object>> statusMaps = new ArrayList<>(); List<Map<String, Object>> statusMaps = new ArrayList<>();
Map<String, List<IndicatorsDto>> collect = listData.stream().collect(Collectors.groupingBy(IndicatorsDto::getFrontModule,LinkedHashMap::new,Collectors.toList())); Map<String, List<IndicatorsDto>> collect = listData.stream().collect(Collectors.groupingBy(IndicatorsDto::getFrontModule, LinkedHashMap::new, Collectors.toList()));
for (String s : collect.keySet()) { for (String s : collect.keySet()) {
Map<String, Object> statusMap = new HashMap<>(); Map<String, Object> statusMap = new HashMap<>();
if (frontModule.equals("前光")){ if (frontModule.equals("前光")) {
String sql1 = " SELECT * FROM indicators_"+gatewayId+" WHERE frontModule =~/"+s+"/ and systemType =~/模拟量/"; String sql1 = " SELECT * FROM indicators_" + gatewayId + " WHERE frontModule =~/" + s + "/ and systemType =~/模拟量/";
List<IndicatorsDto> value = influxDButils.getListData(sql1, IndicatorsDto.class); List<IndicatorsDto> value = influxDButils.getListData(sql1, IndicatorsDto.class);
for (IndicatorsDto indicatorsDto : value) { for (IndicatorsDto indicatorsDto : value) {
Double aDouble = Double.valueOf(indicatorsDto.getValue()); Double aDouble = Double.valueOf(indicatorsDto.getValue());
statusMap.put(indicatorsDto.getDisplayName()+"Value",String.format("%.2f",aDouble)); statusMap.put(indicatorsDto.getDisplayName() + "Value", String.format("%.2f", aDouble));
} }
} }
List<IndicatorsDto> indicatorsDtos = collect.get(s); List<IndicatorsDto> indicatorsDtos = collect.get(s);
for (IndicatorsDto indicatorsDto : indicatorsDtos) { for (IndicatorsDto indicatorsDto : indicatorsDtos) {
if (indicatorsDto.getDisplayName().contains("合位")){ if (indicatorsDto.getDisplayName().contains("合位")) {
statusMap.put("type",indicatorsDto.getValue()); statusMap.put("type", indicatorsDto.getValue());
statusMap.put("status",indicatorsDto.getValue().equals("false")?"0":"1"); statusMap.put("status", indicatorsDto.getValue().equals("false") ? "0" : "1");
statusMap.put("position",indicatorsDto.getDisplayName().split("_")[0]+"开关位置"); statusMap.put("position", indicatorsDto.getDisplayName().split("_")[0] + "开关位置");
} }
} }
statusMap.put("title",s.substring(3)); statusMap.put("title", s.substring(3));
statusMap.put("power","有功 (kW)"); statusMap.put("power", "有功 (kW)");
statusMap.put("windSpeed","风速 (m/s)"); statusMap.put("windSpeed", "风速 (m/s)");
statusMaps.add(statusMap); statusMaps.add(statusMap);
} }
IPage<Map<String,Object>> result = new Page<>(); IPage<Map<String, Object>> result = new Page<>();
result.setRecords(statusMaps); result.setRecords(statusMaps);
result.setCurrent(1); result.setCurrent(1);
result.setTotal(statusMaps.size()); result.setTotal(statusMaps.size());
try { try {
emqKeeper.getMqttClient().publish(stationId+"/fxqTree",JSON.toJSONString(result).getBytes(),0,false); emqKeeper.getMqttClient().publish(stationId + "/fxqTree", JSON.toJSONString(result).getBytes(), 0, false);
} catch (MqttException e) { } catch (MqttException e) {
log.info("消息发送失败"); log.info("消息发送失败");
e.printStackTrace(); e.printStackTrace();
} }
} }
public void getListByFJ(String gatewayId,String werks,String stationId){ public void getListByFJ(String gatewayId, String werks, String stationId) {
HashMap<String,String> fanstatutsHashMap = new HashMap<>(); HashMap<String, String> fanstatutsHashMap = new HashMap<>();
String sql = " SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName ='瞬时风速' "; StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String sql1 = " SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName ='有功功率'"; String sql = " SELECT * FROM indicators_" + gatewayId + " WHERE equipmentIndexName ='瞬时风速' ";
String sql1 = " SELECT * FROM indicators_" + gatewayId + " WHERE equipmentIndexName ='有功功率'";
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
List<IndicatorsDto> listData1 = influxDButils.getListData(sql1, IndicatorsDto.class); List<IndicatorsDto> listData1 = influxDButils.getListData(sql1, IndicatorsDto.class);
TpriDmpDatabook tpriDmpDatabook = tpriDmpDatabookServiceImpl.getTpriDmpDatabookByDataName("风机"); TpriDmpDatabook tpriDmpDatabook = tpriDmpDatabookServiceImpl.getTpriDmpDatabookByDataName("风机");
List<Map<String,Object>> dataMaps = sjglZsjZsbtzServiceImpl.sjglZsjZsbtzMapper.getStationInfoMapByStationWerks(werks, tpriDmpDatabook.getDataid().toString()); List<Map<String, Object>> dataMaps = sjglZsjZsbtzServiceImpl.sjglZsjZsbtzMapper.getStationInfoMapByStationWerks(werks, tpriDmpDatabook.getDataid().toString());
//获取风机列表 //获取风机列表
List<IndexDto> fanStatusList = getFanStatusList(stationId); List<IndexDto> fanStatusList = getFanStatusList(stationId);
fanStatusList.forEach(indexDto -> {fanstatutsHashMap.put(indexDto.getEquipmentNumber(),indexDto.getState());}); fanStatusList.forEach(indexDto -> {
fanstatutsHashMap.put(indexDto.getEquipmentNumber(), indexDto.getState());
});
String prefix = commonServiceImpl.getFanDevicePrefix(stationId);
int i = 0; int i = 0;
for (Map<String, Object> dataMap : dataMaps) { for (Map<String, Object> dataMap : dataMaps) {
List<String> numList = Arrays.asList(dataMap.get("equipNum").toString().split(",")); List<String> numList = Arrays.asList(dataMap.get("equipNum").toString().split(","));
List<Map<String,Object>> statusMaps = new ArrayList<>(); List<Map<String, Object>> statusMaps = new ArrayList<>();
for (IndicatorsDto listDatum : listData) { for (IndicatorsDto listDatum : listData) {
for (IndicatorsDto indicatorsDto : listData1) { for (IndicatorsDto indicatorsDto : listData1) {
if (listDatum.getEquipmentNumber().equals(indicatorsDto.getEquipmentNumber())){ if (listDatum.getEquipmentNumber().equals(indicatorsDto.getEquipmentNumber())) {
listDatum.setValueLabel(indicatorsDto.getValue()); listDatum.setValueLabel(indicatorsDto.getValue());
} }
} }
for (String num : numList) { for (String num : numList) {
if (Integer.parseInt(num) == Integer.parseInt(listDatum.getEquipmentNumber())){ if (Integer.parseInt(num) == Integer.parseInt(listDatum.getEquipmentNumber())) {
Map<String,Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("title",listDatum.getEquipmentNumber()); map.put("title", prefix + listDatum.getEquipmentNumber());
map.put("windSpeed",listDatum.getValue()); map.put("windSpeed", listDatum.getValue());
map.put("power",listDatum.getValueLabel()); map.put("power", listDatum.getValueLabel());
//获取风机状态如果获取到的状态为空-则默认为正常运行状态 //获取风机状态如果获取到的状态为空-则默认为正常运行状态
String fantStatus = ObjectUtils.isEmpty(fanstatutsHashMap.get(num))?"正常运行":fanstatutsHashMap.get(num); String fantStatus = ObjectUtils.isEmpty(fanstatutsHashMap.get(num)) ? "正常运行" : fanstatutsHashMap.get(num);
map.put("url",fanStatusImagePathPrefix + File.separator + "风机-" + fantStatus + ".gif"); map.put("url", fanStatusImagePathPrefix + File.separator + "风机-" + fantStatus + ".gif");
statusMaps.add(map); statusMaps.add(map);
} }
} }
} }
IPage<Map<String,Object>> result = new Page<>(); IPage<Map<String, Object>> result = new Page<>();
result.setRecords(statusMaps); result.setRecords(statusMaps);
result.setCurrent(1); result.setCurrent(1);
result.setTotal(statusMaps.size()); result.setTotal(statusMaps.size());
i += 1; i += 1;
try { try {
emqKeeper.getMqttClient().publish(stationId+"/fj/group"+i,JSON.toJSONString(result).getBytes(),0,false); emqKeeper.getMqttClient().publish(stationId + "/fj/group" + i, JSON.toJSONString(result).getBytes(), 0, false);
} catch (MqttException e) { } catch (MqttException e) {
log.info("消息发送失败"); log.info("消息发送失败");
e.printStackTrace(); e.printStackTrace();
...@@ -958,7 +961,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -958,7 +961,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
public List<Map<String, String>> getBoosterStationInfo(String stationId) { public List<Map<String, String>> getBoosterStationInfo(String stationId) {
StationBasic stationBasic = getOneByStationNumber(stationId); StationBasic stationBasic = getOneByStationNumber(stationId);
List<Map<String, String>> boosterStationInfo = new ArrayList<>(); List<Map<String, String>> boosterStationInfo = new ArrayList<>();
...@@ -974,7 +976,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -974,7 +976,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
StationBasic stationBasic = stationBasicMapper.selectById(stationId); StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String baseSql = "SELECT equipmentNumber, value, equipmentIndexName FROM \"indicators_%s\" where equipmentIndexName = '%s' or equipmentIndexName = '%s' or equipmentIndexName = '%s' or equipmentIndexName = '%s'"; String baseSql = "SELECT equipmentNumber, value, equipmentIndexName FROM \"indicators_%s\" where equipmentIndexName = '%s' or equipmentIndexName = '%s' or equipmentIndexName = '%s' or equipmentIndexName = '%s'";
String windSql = String.format(baseSql, stationBasic.getFanGatewayId(), "风向角", "有功功率", "瞬时风速", "日发电量"); String windSql = String.format(baseSql, stationBasic.getFanGatewayId(), "风向角", "有功功率", "瞬时风速", "日发电量");
List<IndicatorsDto> allList = influxDButils.getListDataAll(windSql,IndicatorsDto.class); List<IndicatorsDto> allList = influxDButils.getListDataAll(windSql, IndicatorsDto.class);
List<IndicatorsDto> windSqlList = new ArrayList<>(); List<IndicatorsDto> windSqlList = new ArrayList<>();
List<IndicatorsDto> powerSqlList = new ArrayList<>(); List<IndicatorsDto> powerSqlList = new ArrayList<>();
List<IndicatorsDto> windSpeedSqlList = new ArrayList<>(); List<IndicatorsDto> windSpeedSqlList = new ArrayList<>();
...@@ -982,12 +984,15 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -982,12 +984,15 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
allList.forEach(item -> { allList.forEach(item -> {
if ("风向角".equals(item.getEquipmentIndexName())) { if ("风向角".equals(item.getEquipmentIndexName())) {
windSqlList.add(item); windSqlList.add(item);
} if ("有功功率".equals(item.getEquipmentIndexName())) { }
item.setValue(String.format("%.2f",Double.parseDouble(item.getValue())/1000)); if ("有功功率".equals(item.getEquipmentIndexName())) {
item.setValue(String.format("%.2f", Double.parseDouble(item.getValue()) / 1000));
powerSqlList.add(item); powerSqlList.add(item);
} if ("瞬时风速".equals(item.getEquipmentIndexName())) { }
if ("瞬时风速".equals(item.getEquipmentIndexName())) {
windSpeedSqlList.add(item); windSpeedSqlList.add(item);
} if ("日发电量".equals(item.getEquipmentIndexName())) { }
if ("日发电量".equals(item.getEquipmentIndexName())) {
electricitySqlList.add(item); electricitySqlList.add(item);
} }
}); });
...@@ -1001,7 +1006,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1001,7 +1006,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
stringStringHashMap.put("wind", item.getValue()); stringStringHashMap.put("wind", item.getValue());
stringStringHashMap.put("power", powerSqlMap.get(item.getEquipmentNumber())); stringStringHashMap.put("power", powerSqlMap.get(item.getEquipmentNumber()));
stringStringHashMap.put("windSpeed", windSpeedSqlMap.get(item.getEquipmentNumber())); stringStringHashMap.put("windSpeed", windSpeedSqlMap.get(item.getEquipmentNumber()));
stringStringHashMap.put("electricity", String.format("%.4f",Double.valueOf(electricitySqlMap.get(item.getEquipmentNumber())))); stringStringHashMap.put("electricity", String.format("%.4f", Double.valueOf(electricitySqlMap.get(item.getEquipmentNumber()))));
resultList.add(stringStringHashMap); resultList.add(stringStringHashMap);
}); });
//构建平台数据 //构建平台数据
...@@ -1017,11 +1022,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1017,11 +1022,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
public ResultsData getAlarmEventList(int current, int size, String stationId) {
List<AlarmEventDto> alarmEventList = alarmEventMapper.getAlarmEventList(null, stationId, current, size);
public ResultsData getAlarmEventList(int current, int size,String stationId) {
List<AlarmEventDto> alarmEventList = alarmEventMapper.getAlarmEventList(null, stationId,current,size);
List<AlarmEventDto> sorrtedAlarmEventList = alarmEventList.stream().sorted(Comparator.comparing(AlarmEventDto::getCreatedTime).reversed()).collect(Collectors.toList()); List<AlarmEventDto> sorrtedAlarmEventList = alarmEventList.stream().sorted(Comparator.comparing(AlarmEventDto::getCreatedTime).reversed()).collect(Collectors.toList());
ArrayList<Map<String, String>> resultList = new ArrayList<>(); ArrayList<Map<String, String>> resultList = new ArrayList<>();
...@@ -1047,7 +1050,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1047,7 +1050,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
public ResultsData getElectricQuantityList(int current, int size,String gatewayId,String stationType) { public ResultsData getElectricQuantityList(int current, int size, String gatewayId, String stationType) {
String sql = " SELECT * FROM indicators_" + gatewayId + " WHERE frontModule ='电量表计' and displayName != '' and displayName != '检修状态' "; String sql = " SELECT * FROM indicators_" + gatewayId + " WHERE frontModule ='电量表计' and displayName != '' and displayName != '检修状态' ";
List<IndicatorsDto> windSqlList = influxDButils.getListDataAll(sql, IndicatorsDto.class); List<IndicatorsDto> windSqlList = influxDButils.getListDataAll(sql, IndicatorsDto.class);
...@@ -1057,7 +1060,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1057,7 +1060,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
HashMap<String, String> stringStringHashMap = new HashMap<>(); HashMap<String, String> stringStringHashMap = new HashMap<>();
stringStringHashMap.put("name", stringListEntry.getKey()); stringStringHashMap.put("name", stringListEntry.getKey());
for (IndicatorsDto indicatorsDto : stringListEntry.getValue()) { for (IndicatorsDto indicatorsDto : stringListEntry.getValue()) {
stringStringHashMap.put(ElectricQuantity.getCode(indicatorsDto.getDisplayName()), String.format("%.3f",ObjectUtils.isEmpty(indicatorsDto.getValue())?0.0:Double.parseDouble(indicatorsDto.getValue()))); stringStringHashMap.put(ElectricQuantity.getCode(indicatorsDto.getDisplayName()), String.format("%.3f", ObjectUtils.isEmpty(indicatorsDto.getValue()) ? 0.0 : Double.parseDouble(indicatorsDto.getValue())));
} }
resultList.add(stringStringHashMap); resultList.add(stringStringHashMap);
} }
...@@ -1068,7 +1071,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1068,7 +1071,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
ColModel colModelEventDesc = new ColModel("fxzyg", "fxzyg", "反向总有功", "反向总有功", "dataGrid", "fxzyg"); ColModel colModelEventDesc = new ColModel("fxzyg", "fxzyg", "反向总有功", "反向总有功", "dataGrid", "fxzyg");
ColModel colModelAlarmGroupName = new ColModel("zxzwg", "zxzwg", "正向总无功", "正向总无功", "dataGrid", "zxzwg"); ColModel colModelAlarmGroupName = new ColModel("zxzwg", "zxzwg", "正向总无功", "正向总无功", "dataGrid", "zxzwg");
ColModel colModelEventTime = new ColModel("fxzwg", "fxzwg", "反向总无功", "反向总无功", "dataGrid", "fxzwg"); ColModel colModelEventTime = new ColModel("fxzwg", "fxzwg", "反向总无功", "反向总无功", "dataGrid", "fxzwg");
if (null != stationType){ if (null != stationType) {
colModelEventMovement = new ColModel("name", "name", "测量点", "测量点", "dataGrid", "name"); colModelEventMovement = new ColModel("name", "name", "测量点", "测量点", "dataGrid", "name");
colModelStationName = new ColModel("zgxwg", "zgxwg", "总感性无功", "总感性无功", "dataGrid", "zgxwg"); colModelStationName = new ColModel("zgxwg", "zgxwg", "总感性无功", "总感性无功", "dataGrid", "zgxwg");
colModelEventDesc = new ColModel("zzxwg", "zzxwg", "总正向有功", "总正向有功", "dataGrid", "zzxwg"); colModelEventDesc = new ColModel("zzxwg", "zzxwg", "总正向有功", "总正向有功", "dataGrid", "zzxwg");
...@@ -1132,7 +1135,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1132,7 +1135,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
result.setTotal(resultList.size()); result.setTotal(resultList.size());
try { try {
log.info("消息内容:{}", JSON.toJSONString(result)); log.info("消息内容:{}", JSON.toJSONString(result));
emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, routeName, "mnl"), JSON.toJSONString(result).getBytes(),2,false); emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, routeName, "mnl"), JSON.toJSONString(result).getBytes(), 2, false);
} catch (MqttException e) { } catch (MqttException e) {
log.info("消息发送失败"); log.info("消息发送失败");
e.printStackTrace(); e.printStackTrace();
...@@ -1165,9 +1168,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1165,9 +1168,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
// 正向总有功正向总无功需要计算 // 正向总有功正向总无功需要计算
dlbjSqlData.forEach(item -> { dlbjSqlData.forEach(item -> {
if ("正向总有功".equals(item.getDisplayName())) { if ("正向总有功".equals(item.getDisplayName())) {
resultMap.put("2000S1", keepTwoDecimalPlaces(String.valueOf((Double.parseDouble(item.getValue())/1000)))); resultMap.put("2000S1", keepTwoDecimalPlaces(String.valueOf((Double.parseDouble(item.getValue()) / 1000))));
} else if ("正向总无功".equals(item.getDisplayName())) { } else if ("正向总无功".equals(item.getDisplayName())) {
resultMap.put("2000S2", keepTwoDecimalPlaces(String.valueOf((Double.parseDouble(item.getValue())/1000)))); resultMap.put("2000S2", keepTwoDecimalPlaces(String.valueOf((Double.parseDouble(item.getValue()) / 1000))));
} }
}); });
...@@ -1179,13 +1182,13 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1179,13 +1182,13 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
resultMap.put("value4", "0.0"); resultMap.put("value4", "0.0");
zb1SqlData.forEach(item -> { zb1SqlData.forEach(item -> {
if ("档位".equals(item.getDisplayName())) { if ("档位".equals(item.getDisplayName())) {
resultMap.put("value4", ObjectUtils.isEmpty(item.getValue())?"0":String.format("%.0f",Double.parseDouble(item.getValue()))); resultMap.put("value4", ObjectUtils.isEmpty(item.getValue()) ? "0" : String.format("%.0f", Double.parseDouble(item.getValue())));
} else if ("油面温1".equals(item.getDisplayName())) { } else if ("油面温1".equals(item.getDisplayName())) {
resultMap.put("value1", ObjectUtils.isEmpty(item.getValue())?"0.0":String.format("%.1f",Double.parseDouble(item.getValue()))); resultMap.put("value1", ObjectUtils.isEmpty(item.getValue()) ? "0.0" : String.format("%.1f", Double.parseDouble(item.getValue())));
} else if ("油面温2".equals(item.getDisplayName())) { } else if ("油面温2".equals(item.getDisplayName())) {
resultMap.put("value2", ObjectUtils.isEmpty(item.getValue())?"0.0":String.format("%.1f",Double.parseDouble(item.getValue()))); resultMap.put("value2", ObjectUtils.isEmpty(item.getValue()) ? "0.0" : String.format("%.1f", Double.parseDouble(item.getValue())));
} else if ("绕组温度".equals(item.getDisplayName())) { } else if ("绕组温度".equals(item.getDisplayName())) {
resultMap.put("value3", ObjectUtils.isEmpty(item.getValue())?"0.0":String.format("%.1f",Double.parseDouble(item.getValue()))); resultMap.put("value3", ObjectUtils.isEmpty(item.getValue()) ? "0.0" : String.format("%.1f", Double.parseDouble(item.getValue())));
} }
}); });
...@@ -1324,7 +1327,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1324,7 +1327,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
resultPage.setTotal(finallyResultList.size()); resultPage.setTotal(finallyResultList.size());
try { try {
log.info("消息内容:{}", JSON.toJSONString(resultPage)); log.info("消息内容:{}", JSON.toJSONString(resultPage));
emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, "major", "data"), JSON.toJSONString(resultPage).getBytes(),0,false); emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, "major", "data"), JSON.toJSONString(resultPage).getBytes(), 0, false);
} catch (MqttException e) { } catch (MqttException e) {
log.info("消息发送失败"); log.info("消息发送失败");
e.printStackTrace(); e.printStackTrace();
...@@ -1333,10 +1336,10 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1333,10 +1336,10 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
public void getSwitchUrlAll(StationBasic stationBasic){ public void getSwitchUrlAll(StationBasic stationBasic) {
String gatewayId = stationBasic.getBoosterGatewayId(); String gatewayId = stationBasic.getBoosterGatewayId();
String sql = "SELECT * FROM indicators_"+gatewayId+" WHERE systemType = '开关' and displayName =~/合位$/"; String sql = "SELECT * FROM indicators_" + gatewayId + " WHERE systemType = '开关' and displayName =~/合位$/";
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
Set<String> names = new HashSet<>(); Set<String> names = new HashSet<>();
...@@ -1345,20 +1348,20 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1345,20 +1348,20 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
for (String name : names) { for (String name : names) {
getSwitchUrl(gatewayId,name); getSwitchUrl(gatewayId, name);
} }
} }
public Map<String, Object> getSwitchUrl(String gatewayId,String equipName ){ public Map<String, Object> getSwitchUrl(String gatewayId, String equipName) {
String sql = "SELECT * FROM indicators_" + gatewayId + " WHERE systemType =~/开关/" + " and displayName =~/合位$/"; String sql = "SELECT * FROM indicators_" + gatewayId + " WHERE systemType =~/开关/" + " and displayName =~/合位$/";
String sql1 = "SELECT * FROM indicators_" + gatewayId + " WHERE systemType =~/开关/" + " and displayName =~/远方就地开关$/"; String sql1 = "SELECT * FROM indicators_" + gatewayId + " WHERE systemType =~/开关/" + " and displayName =~/远方就地开关$/";
String sql2 = "SELECT * FROM indicators_" + gatewayId + " WHERE systemType =~/开关/" + " and displayName =~/接地刀位置$/"; String sql2 = "SELECT * FROM indicators_" + gatewayId + " WHERE systemType =~/开关/" + " and displayName =~/接地刀位置$/";
if (StringUtils.isNotEmpty(equipName)) { if (StringUtils.isNotEmpty(equipName)) {
sql = "SELECT * FROM indicators_"+gatewayId+" WHERE systemType =~/开关/ and frontModule =~ /"+equipName+"/ and displayName =~/合位$/"; sql = "SELECT * FROM indicators_" + gatewayId + " WHERE systemType =~/开关/ and frontModule =~ /" + equipName + "/ and displayName =~/合位$/";
sql1 = "SELECT * FROM indicators_"+gatewayId+" WHERE systemType =~/开关/ and frontModule =~ /"+equipName+"/ and displayName =~/远方就地开关$/"; sql1 = "SELECT * FROM indicators_" + gatewayId + " WHERE systemType =~/开关/ and frontModule =~ /" + equipName + "/ and displayName =~/远方就地开关$/";
sql2 = "SELECT * FROM indicators_"+gatewayId+" WHERE systemType =~/开关/ and frontModule =~ /"+equipName+"/ and displayName =~/接地刀位置$/"; sql2 = "SELECT * FROM indicators_" + gatewayId + " WHERE systemType =~/开关/ and frontModule =~ /" + equipName + "/ and displayName =~/接地刀位置$/";
} }
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
List<IndicatorsDto> listDatas = influxDButils.getListData(sql1, IndicatorsDto.class); List<IndicatorsDto> listDatas = influxDButils.getListData(sql1, IndicatorsDto.class);
...@@ -1368,49 +1371,51 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1368,49 +1371,51 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
for (IndicatorsDto datass : listDatass) { for (IndicatorsDto datass : listDatass) {
String url = ""; String url = "";
String[] urls = datass.getPictureName().split(","); String[] urls = datass.getPictureName().split(",");
if (datass.getValue().equals("false")){ if (datass.getValue().equals("false")) {
url =pictureUrl+urls[0]; url = pictureUrl + urls[0];
}else { } else {
url =pictureUrl+ urls[1];; url = pictureUrl + urls[1];
;
} }
photoUrls.put(datass.getDisplayName().split("_")[0]+"jddwz",url); photoUrls.put(datass.getDisplayName().split("_")[0] + "jddwz", url);
} }
for (IndicatorsDto data : listDatas) { for (IndicatorsDto data : listDatas) {
String url = ""; String url = "";
String[] urls = data.getPictureName().split(","); String[] urls = data.getPictureName().split(",");
if (StringUtils.isNotEmpty(data.getValue()) && data.getValue().equals("false")){ if (StringUtils.isNotEmpty(data.getValue()) && data.getValue().equals("false")) {
url =pictureUrl+urls[1]; url = pictureUrl + urls[1];
}else { } else {
url =pictureUrl+ urls[0];; url = pictureUrl + urls[0];
;
} }
if (data.getDisplayName().split("_").length > 2){ if (data.getDisplayName().split("_").length > 2) {
photoUrls.put(KGName.getCode(data.getDisplayName().split("_")[1]),url); photoUrls.put(KGName.getCode(data.getDisplayName().split("_")[1]), url);
}else { } else {
photoUrls.put(data.getDisplayName().split("_")[0]+"yfjdkgurl",url); photoUrls.put(data.getDisplayName().split("_")[0] + "yfjdkgurl", url);
} }
} }
for (IndicatorsDto listDatum : listData) { for (IndicatorsDto listDatum : listData) {
String url = ""; String url = "";
if (listDatum.getDisplayName().contains("手车工作位置")){ if (listDatum.getDisplayName().contains("手车工作位置")) {
String[] split = listDatum.getPictureName().split(":"); String[] split = listDatum.getPictureName().split(":");
if (listDatum.getValue().equals("false")){ if (listDatum.getValue().equals("false")) {
String[] split1 = split[0].split(","); String[] split1 = split[0].split(",");
photoUrls.put(listDatum.getDisplayName().split("_")[0]+"scsurl",pictureUrl+split1[0]); photoUrls.put(listDatum.getDisplayName().split("_")[0] + "scsurl", pictureUrl + split1[0]);
photoUrls.put(listDatum.getDisplayName().split("_")[0]+"scxurl",pictureUrl+split1[1]); photoUrls.put(listDatum.getDisplayName().split("_")[0] + "scxurl", pictureUrl + split1[1]);
}else { } else {
String[] split1 = split[1].split(","); String[] split1 = split[1].split(",");
photoUrls.put(listDatum.getDisplayName().split("_")[0]+"scsurl",pictureUrl+split1[0]); photoUrls.put(listDatum.getDisplayName().split("_")[0] + "scsurl", pictureUrl + split1[0]);
photoUrls.put(listDatum.getDisplayName().split("_")[0]+"scxurl",pictureUrl+split1[1]); photoUrls.put(listDatum.getDisplayName().split("_")[0] + "scxurl", pictureUrl + split1[1]);
} }
}else { } else {
if (listDatum.getValue().equals("false")){ if (listDatum.getValue().equals("false")) {
url =pictureUrl+ listDatum.getPictureName(); url = pictureUrl + listDatum.getPictureName();
}else { } else {
url =pictureUrl+ listDatum.getPictureName().replace("green", "red"); url = pictureUrl + listDatum.getPictureName().replace("green", "red");
} }
photoUrls.put(listDatum.getDisplayName().split("_")[0]+"url",url); photoUrls.put(listDatum.getDisplayName().split("_")[0] + "url", url);
} }
} }
return photoUrls; return photoUrls;
...@@ -1418,7 +1423,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1418,7 +1423,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
public HashMap<String, Object> getyw(String gatewayId){ public HashMap<String, Object> getyw(String gatewayId) {
HashMap<String, Object> resultMap = new HashMap<>(); HashMap<String, Object> resultMap = new HashMap<>();
String zb1Sql = String.format("SELECT * FROM \"indicators_%s\" WHERE frontModule = '1主变' and systemType = '模拟量' and (displayName = '档位' or displayName = '油面温1' or displayName = '油面温2' or displayName = '绕组温度' ) ", gatewayId); String zb1Sql = String.format("SELECT * FROM \"indicators_%s\" WHERE frontModule = '1主变' and systemType = '模拟量' and (displayName = '档位' or displayName = '油面温1' or displayName = '油面温2' or displayName = '绕组温度' ) ", gatewayId);
List<IndicatorsDto> zb1SqlData = influxDButils.getListData(zb1Sql, IndicatorsDto.class); List<IndicatorsDto> zb1SqlData = influxDButils.getListData(zb1Sql, IndicatorsDto.class);
...@@ -1442,38 +1447,36 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1442,38 +1447,36 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
public HashMap<String, Object> getEquipInfoByEquipNum(String gatewayId, String equipmentNumber) {
public HashMap<String, Object> getEquipInfoByEquipNum(String gatewayId ,String equipmentNumber){
HashMap<String, Object> resultMap = new HashMap<>(); HashMap<String, Object> resultMap = new HashMap<>();
String sql = "SELECT * FROM indicators_"+gatewayId+" WHERE equipmentNumber ='"+equipmentNumber +"' limit 1 "; String sql = "SELECT * FROM indicators_" + gatewayId + " WHERE equipmentNumber ='" + equipmentNumber + "' limit 1 ";
List<IndicatorsDto> list = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> list = influxDButils.getListData(sql, IndicatorsDto.class);
if (!ValidationUtil.isEmpty(list)){ if (!ValidationUtil.isEmpty(list)) {
resultMap.put("equipmentSpecificName",list.get(0).getEquipmentSpecificName()); resultMap.put("equipmentSpecificName", list.get(0).getEquipmentSpecificName());
resultMap.put("equipmentIndexName",list.get(0).getEquipmentSpecificName()); resultMap.put("equipmentIndexName", list.get(0).getEquipmentSpecificName());
resultMap.put("equipmentInfoName",list.get(0).getEquipmentSpecificName().substring(5).replace("/"," ")); resultMap.put("equipmentInfoName", list.get(0).getEquipmentSpecificName().substring(5).replace("/", " "));
resultMap.put("status",list.get(0).getValue().equals("false")?"异常":"正常运行"); resultMap.put("status", list.get(0).getValue().equals("false") ? "异常" : "正常运行");
} }
return resultMap; return resultMap;
} }
public Map<String, String> getStatisticsInfo(String gatewayId ,String equipmentIndexName){ public Map<String, String> getStatisticsInfo(String gatewayId, String equipmentIndexName) {
return temporaryDataMapper.getStatisticsInfo(gatewayId,equipmentIndexName); return temporaryDataMapper.getStatisticsInfo(gatewayId, equipmentIndexName);
} }
public List<Map<String, Object>> getEquipmentNum(String gatewayId, String frontModule, String equipmentNumber) {
public List<Map<String,Object>> getEquipmentNum (String gatewayId,String frontModule,String equipmentNumber){ String sql = " SELECT equipmentNumber, equipmentSpecificName FROM indicators_" + gatewayId + " WHERE frontModule = '" + frontModule + "' and equipmentNumber !=''";
String sql = " SELECT equipmentNumber, equipmentSpecificName FROM indicators_"+gatewayId+" WHERE frontModule = '"+frontModule+"' and equipmentNumber !=''"; if (null != equipmentNumber) {
if (null != equipmentNumber){ sql = " SELECT equipmentNumber, equipmentSpecificName FROM indicators_" + gatewayId + " WHERE equipmentNumber =~/" + equipmentNumber + "/ and frontModule = '" + frontModule + "'";
sql = " SELECT equipmentNumber, equipmentSpecificName FROM indicators_"+gatewayId+" WHERE equipmentNumber =~/"+equipmentNumber+"/ and frontModule = '"+frontModule+"'";
} }
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
LinkedHashSet<IndicatorsDto> data = new LinkedHashSet<>(listData); LinkedHashSet<IndicatorsDto> data = new LinkedHashSet<>(listData);
List<Map<String,Object>> statusMaps = new ArrayList<>(); List<Map<String, Object>> statusMaps = new ArrayList<>();
for (IndicatorsDto listDatum : data) { for (IndicatorsDto listDatum : data) {
Map<String, Object> statusMap = new HashMap<>(); Map<String, Object> statusMap = new HashMap<>();
statusMap.put("equipmentNumber",listDatum.getEquipmentNumber()); statusMap.put("equipmentNumber", listDatum.getEquipmentNumber());
statusMap.put("equipmentSpecificName",listDatum.getEquipmentSpecificName().substring(5).replace("/"," ")); statusMap.put("equipmentSpecificName", listDatum.getEquipmentSpecificName().substring(5).replace("/", " "));
statusMaps.add(statusMap); statusMaps.add(statusMap);
} }
return statusMaps; return statusMaps;
...@@ -1492,39 +1495,39 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1492,39 +1495,39 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
public HashMap<String, Object> SpeedIndicator(String gatewayId ,String equipmentNumber,String equipmentIndexName){ public HashMap<String, Object> SpeedIndicator(String gatewayId, String equipmentNumber, String equipmentIndexName) {
HashMap<String, Object> resultMap = new HashMap<>(); HashMap<String, Object> resultMap = new HashMap<>();
String sql = "SELECT * FROM indicators_"+gatewayId+" WHERE equipmentNumber ='"+equipmentNumber +"' and equipmentIndexName = '"+equipmentIndexName+"'"; String sql = "SELECT * FROM indicators_" + gatewayId + " WHERE equipmentNumber ='" + equipmentNumber + "' and equipmentIndexName = '" + equipmentIndexName + "'";
log.info("执行sql"+sql); log.info("执行sql" + sql);
List<IndicatorsDto> list = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> list = influxDButils.getListData(sql, IndicatorsDto.class);
if (!ValidationUtil.isEmpty(list)){ if (!ValidationUtil.isEmpty(list)) {
resultMap.put("value",String.format("%.2f",Double.parseDouble(list.get(0).getValue()))); resultMap.put("value", String.format("%.2f", Double.parseDouble(list.get(0).getValue())));
} }
return resultMap; return resultMap;
} }
public void getEquipSwitchStatus(StationBasic stationBasic ){ public void getEquipSwitchStatus(StationBasic stationBasic) {
String gatewayId = stationBasic.getFanGatewayId(); String gatewayId = stationBasic.getFanGatewayId();
Long stationId = stationBasic.getSequenceNbr(); Long stationId = stationBasic.getSequenceNbr();
String sql = "SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName =~/合闸/"; String sql = "SELECT * FROM indicators_" + gatewayId + " WHERE equipmentIndexName =~/合闸/";
List<IndicatorsDto> list = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> list = influxDButils.getListData(sql, IndicatorsDto.class);
if (!ValidationUtil.isEmpty(list)){ if (!ValidationUtil.isEmpty(list)) {
Map<String, List<IndicatorsDto>> collect = list.stream().collect(Collectors.groupingBy(IndicatorsDto::getEquipmentNumber)); Map<String, List<IndicatorsDto>> collect = list.stream().collect(Collectors.groupingBy(IndicatorsDto::getEquipmentNumber));
for (String s : collect.keySet()) { for (String s : collect.keySet()) {
HashMap<String, Object> resultMap = new HashMap<>(); HashMap<String, Object> resultMap = new HashMap<>();
collect.get(s).stream().forEach(e->{ collect.get(s).stream().forEach(e -> {
String picturl = ""; String picturl = "";
if (e.getValue().equals("false")){ if (e.getValue().equals("false")) {
picturl = pictureUrl+"dlg-h-red.png"; picturl = pictureUrl + "dlg-h-red.png";
}else { } else {
picturl = pictureUrl+"dlg-h-green.png"; picturl = pictureUrl + "dlg-h-green.png";
} }
if(e.getEquipmentIndexName().endsWith("断路器合闸")){ if (e.getEquipmentIndexName().endsWith("断路器合闸")) {
resultMap.put(e.getEquipmentIndexName().substring(0,3),picturl); resultMap.put(e.getEquipmentIndexName().substring(0, 3), picturl);
}else { } else {
resultMap.put("gy",picturl); resultMap.put("gy", picturl);
} }
}); });
IPage<Map<String, Object>> result = new Page<>(); IPage<Map<String, Object>> result = new Page<>();
...@@ -1534,7 +1537,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1534,7 +1537,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
result.setCurrent(1); result.setCurrent(1);
result.setTotal(100); result.setTotal(100);
try { try {
emqKeeper.getMqttClient().publish(stationId+"/xbjg/"+s,JSON.toJSONString(result).getBytes(),0,false); emqKeeper.getMqttClient().publish(stationId + "/xbjg/" + s, JSON.toJSONString(result).getBytes(), 0, false);
} catch (MqttException e) { } catch (MqttException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -1545,40 +1548,39 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1545,40 +1548,39 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
public ResultsData collectingBox(String gatewayId, int current, int size) {
public ResultsData collectingBox(String gatewayId ,int current,int size){
ArrayList<Map<String, Object>> resultList = new ArrayList<>(); ArrayList<Map<String, Object>> resultList = new ArrayList<>();
String sql = "SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName =~/路电流/ "; String sql = "SELECT * FROM indicators_" + gatewayId + " WHERE equipmentIndexName =~/路电流/ ";
String sql1 = "SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName =~/平均电流/ "; String sql1 = "SELECT * FROM indicators_" + gatewayId + " WHERE equipmentIndexName =~/平均电流/ ";
List<IndicatorsDto> list = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> list = influxDButils.getListData(sql, IndicatorsDto.class);
List<IndicatorsDto> list1 = influxDButils.getListData(sql1, IndicatorsDto.class); List<IndicatorsDto> list1 = influxDButils.getListData(sql1, IndicatorsDto.class);
if (!ValidationUtil.isEmpty(list)){ if (!ValidationUtil.isEmpty(list)) {
Map<String, List<IndicatorsDto>> collect = list.stream().collect(Collectors.groupingBy(IndicatorsDto::getEquipmentNumber)); Map<String, List<IndicatorsDto>> collect = list.stream().collect(Collectors.groupingBy(IndicatorsDto::getEquipmentNumber));
for (String s : collect.keySet()) { for (String s : collect.keySet()) {
List<IndicatorsDto> indicatorsDtos = collect.get(s); List<IndicatorsDto> indicatorsDtos = collect.get(s);
HashMap<String, Object> resultMap = new HashMap<>(); HashMap<String, Object> resultMap = new HashMap<>();
Double avageValue = 0.0; Double avageValue = 0.0;
avageValue =indicatorsDtos.stream().filter(e -> !ObjectUtils.isEmpty(e.getValue())).mapToDouble(l->Double.parseDouble((String) l.getValue())).average().getAsDouble(); avageValue = indicatorsDtos.stream().filter(e -> !ObjectUtils.isEmpty(e.getValue())).mapToDouble(l -> Double.parseDouble((String) l.getValue())).average().getAsDouble();
avageValue = Double.valueOf(String.format("%.2f", avageValue)); avageValue = Double.valueOf(String.format("%.2f", avageValue));
resultMap.put("avg",avageValue); resultMap.put("avg", avageValue);
String[] name = s.split("-"); String[] name = s.split("-");
resultMap.put("zz","#"+name[0]+"子阵"); resultMap.put("zz", "#" + name[0] + "子阵");
resultMap.put("nbq","逆变器"+name[1]); resultMap.put("nbq", "逆变器" + name[1]);
resultMap.put("hlx","#"+name[2]+"汇流箱"); resultMap.put("hlx", "#" + name[2] + "汇流箱");
double lsv = 0.00; double lsv = 0.00;
if(!ValidationUtil.isEmpty(list1)){ if (!ValidationUtil.isEmpty(list1)) {
List<IndicatorsDto> dtos = list1.stream().filter(e -> e.getEquipmentNumber().equals(s)).collect(Collectors.toList()); List<IndicatorsDto> dtos = list1.stream().filter(e -> e.getEquipmentNumber().equals(s)).collect(Collectors.toList());
if (!ValidationUtil.isEmpty(dtos)){ if (!ValidationUtil.isEmpty(dtos)) {
for (IndicatorsDto indicatorsDto : indicatorsDtos) { for (IndicatorsDto indicatorsDto : indicatorsDtos) {
lsv= lsv + Math.pow(Double.parseDouble(indicatorsDto.getValue()) - Double.parseDouble(dtos.get(0).getValue()), 2); lsv = lsv + Math.pow(Double.parseDouble(indicatorsDto.getValue()) - Double.parseDouble(dtos.get(0).getValue()), 2);
} }
} }
lsv= Math.sqrt(lsv)/Double.parseDouble(dtos.get(0).getValue()); lsv = Math.sqrt(lsv) / Double.parseDouble(dtos.get(0).getValue());
} }
resultMap.put("lsv",String.format("%.2f", lsv)); resultMap.put("lsv", String.format("%.2f", lsv));
resultList.add(resultMap); resultList.add(resultMap);
} }
} }
...@@ -1596,33 +1598,33 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1596,33 +1598,33 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
public List<Map<String, Object>> solarPowerOperation(String gatewayId) { public List<Map<String, Object>> solarPowerOperation(String gatewayId) {
String sql = "SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName = '有功功率' or equipmentIndexName = '逆变器效率' or equipmentIndexName ='总直流功率' or equipmentIndexName ='日发电量' or equipmentIndexName ='总发电量' "; String sql = "SELECT * FROM indicators_" + gatewayId + " WHERE equipmentIndexName = '有功功率' or equipmentIndexName = '逆变器效率' or equipmentIndexName ='总直流功率' or equipmentIndexName ='日发电量' or equipmentIndexName ='总发电量' ";
List<IndicatorsDto> list = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> list = influxDButils.getListData(sql, IndicatorsDto.class);
List<IndicatorsDto> collect = list.stream().filter(e -> StringUtils.isNotEmpty(e.getEquipmentNumber())).collect(Collectors.toList()); List<IndicatorsDto> collect = list.stream().filter(e -> StringUtils.isNotEmpty(e.getEquipmentNumber())).collect(Collectors.toList());
Map<String, List<IndicatorsDto>> collects = collect.stream().collect(Collectors.groupingBy(IndicatorsDto::getEquipmentNumber)); Map<String, List<IndicatorsDto>> collects = collect.stream().collect(Collectors.groupingBy(IndicatorsDto::getEquipmentNumber));
List<Map<String, Object>> result = new ArrayList(); List<Map<String, Object>> result = new ArrayList();
for (String s : collects.keySet()){ for (String s : collects.keySet()) {
List<IndicatorsDto> indicatorsDtos = collects.get(s); List<IndicatorsDto> indicatorsDtos = collects.get(s);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("name",s); map.put("name", s);
map.put("type","兆能");//此处暂时未提供数据 待定 暂写死值 map.put("type", "兆能");//此处暂时未提供数据 待定 暂写死值
map.put("status","1");//此处暂时未提供数据 待定 暂写死值 map.put("status", "1");//此处暂时未提供数据 待定 暂写死值
indicatorsDtos.forEach(e->{ indicatorsDtos.forEach(e -> {
switch (e.getEquipmentIndexName()){ switch (e.getEquipmentIndexName()) {
case "总直流功率": case "总直流功率":
map.put("sr",keepTwoDecimalPlaces(e.getValue())); map.put("sr", keepTwoDecimalPlaces(e.getValue()));
break; break;
case "有功功率": case "有功功率":
map.put("sc",keepTwoDecimalPlaces(e.getValue())); map.put("sc", keepTwoDecimalPlaces(e.getValue()));
break; break;
case "逆变器效率": case "逆变器效率":
map.put("efficiency",keepTwoDecimalPlaces(e.getValue())); map.put("efficiency", keepTwoDecimalPlaces(e.getValue()));
break; break;
case "日发电量": case "日发电量":
map.put("dayNum",keepTwoDecimalPlaces(e.getValue())); map.put("dayNum", keepTwoDecimalPlaces(e.getValue()));
break; break;
case "总发电量": case "总发电量":
map.put("yearNum",keepTwoDecimalPlaces(e.getValue())); map.put("yearNum", keepTwoDecimalPlaces(e.getValue()));
break; break;
} }
}); });
...@@ -1640,41 +1642,41 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1640,41 +1642,41 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
e.printStackTrace(); e.printStackTrace();
} }
String[] equipNumber = equipNum.split("-"); String[] equipNumber = equipNum.split("-");
String sql = "SELECT time ,equipmentIndexName ,value FROM iot_data_"+gatewayId+" WHERE time >'"+time+"' and equipmentSpecificName =~/"+equipNumber[0]+"子阵/ and equipmentSpecificName =~/逆变器"+equipNumber[1]+"/ and equipmentSpecificName =~/"+Integer.parseInt(equipNumber[2])+"汇流箱/ and equipmentIndexName =~/路电流/"; String sql = "SELECT time ,equipmentIndexName ,value FROM iot_data_" + gatewayId + " WHERE time >'" + time + "' and equipmentSpecificName =~/" + equipNumber[0] + "子阵/ and equipmentSpecificName =~/逆变器" + equipNumber[1] + "/ and equipmentSpecificName =~/" + Integer.parseInt(equipNumber[2]) + "汇流箱/ and equipmentIndexName =~/路电流/";
String timeSql = "SELECT DISTINCT value FROM iot_data_"+gatewayId+" WHERE time >'"+time+"' and equipmentSpecificName =~/"+equipNumber[0]+"子阵/ and equipmentSpecificName =~/逆变器"+equipNumber[1]+"/ and equipmentSpecificName =~/"+Integer.parseInt(equipNumber[2])+"汇流箱/ and equipmentIndexName =~/路电流/ group by time(2m)"; String timeSql = "SELECT DISTINCT value FROM iot_data_" + gatewayId + " WHERE time >'" + time + "' and equipmentSpecificName =~/" + equipNumber[0] + "子阵/ and equipmentSpecificName =~/逆变器" + equipNumber[1] + "/ and equipmentSpecificName =~/" + Integer.parseInt(equipNumber[2]) + "汇流箱/ and equipmentIndexName =~/路电流/ group by time(2m)";
List<IndicatorsDto> dataList = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> dataList = influxDButils.getListData(sql, IndicatorsDto.class);
List<IndicatorsDto> timeList = influxDButils.getListDataAll(timeSql, IndicatorsDto.class); List<IndicatorsDto> timeList = influxDButils.getListDataAll(timeSql, IndicatorsDto.class);
Map<String, List<IndicatorsDto>> timeMap = timeList.stream().collect(Collectors.groupingBy(IndicatorsDto::getTime, LinkedHashMap::new, Collectors.toList())); Map<String, List<IndicatorsDto>> timeMap = timeList.stream().collect(Collectors.groupingBy(IndicatorsDto::getTime, LinkedHashMap::new, Collectors.toList()));
Map<String, List<IndicatorsDto>> data = dataList.stream().collect(Collectors.groupingBy(IndicatorsDto::getEquipmentIndexName, LinkedHashMap::new, Collectors.toList())); Map<String, List<IndicatorsDto>> data = dataList.stream().collect(Collectors.groupingBy(IndicatorsDto::getEquipmentIndexName, LinkedHashMap::new, Collectors.toList()));
List< Map<String,Object>> seriesData = new ArrayList<>(); List<Map<String, Object>> seriesData = new ArrayList<>();
for (String s : data.keySet()) { for (String s : data.keySet()) {
Map<String,Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
List<String> value = data.get(s).stream().map(IndicatorsDto::getValue).collect(Collectors.toList()); List<String> value = data.get(s).stream().map(IndicatorsDto::getValue).collect(Collectors.toList());
map.put("data",value); map.put("data", value);
seriesData.add(map); seriesData.add(map);
} }
Map<String,Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("seriesData", seriesData); map.put("seriesData", seriesData);
map.put("axisData",timeMap.keySet()); map.put("axisData", timeMap.keySet());
return map; return map;
} }
public void getListByNbq(String gatewayId,String werks,String stationId){ public void getListByNbq(String gatewayId, String werks, String stationId) {
String sql = " SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName ='总直流功率' and frontModule = '逆变器'"; String sql = " SELECT * FROM indicators_" + gatewayId + " WHERE equipmentIndexName ='总直流功率' and frontModule = '逆变器'";
String sql1 = " SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName ='有功功率' and frontModule = '逆变器'"; String sql1 = " SELECT * FROM indicators_" + gatewayId + " WHERE equipmentIndexName ='有功功率' and frontModule = '逆变器'";
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
List<IndicatorsDto> listData1 = influxDButils.getListData(sql1, IndicatorsDto.class); List<IndicatorsDto> listData1 = influxDButils.getListData(sql1, IndicatorsDto.class);
// 将两组数据合并成一个集合中 将总直流功率数据 放入 另一个集合的valueLable中 // 将两组数据合并成一个集合中 将总直流功率数据 放入 另一个集合的valueLable中
for (IndicatorsDto listDatum : listData) { for (IndicatorsDto listDatum : listData) {
for (IndicatorsDto indicatorsDto : listData1) { for (IndicatorsDto indicatorsDto : listData1) {
if (indicatorsDto.getEquipmentNumber().equals(listDatum.getEquipmentNumber())){ if (indicatorsDto.getEquipmentNumber().equals(listDatum.getEquipmentNumber())) {
indicatorsDto.setValueLabel(listDatum.getValue()); indicatorsDto.setValueLabel(listDatum.getValue());
} }
} }
} }
List< Map<String, String>> maps = new ArrayList<>(); List<Map<String, String>> maps = new ArrayList<>();
Set<String> nums = new HashSet<>(); Set<String> nums = new HashSet<>();
//此处组装数据 每一个Map代表一个逆变器 //此处组装数据 每一个Map代表一个逆变器
for (IndicatorsDto indicatorsDto : listData1) { for (IndicatorsDto indicatorsDto : listData1) {
...@@ -1683,38 +1685,38 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1683,38 +1685,38 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
String equipNum = indicatorsDto.getEquipmentNumber(); String equipNum = indicatorsDto.getEquipmentNumber();
String number = equipNum.substring(equipNum.length() - 1); String number = equipNum.substring(equipNum.length() - 1);
map.put("titie",String.valueOf(num)); map.put("titie", String.valueOf(num));
map.put("titie"+number,equipNum); map.put("titie" + number, equipNum);
map.put("value"+number,indicatorsDto.getValue()); map.put("value" + number, indicatorsDto.getValue());
map.put("valueLabel"+number,indicatorsDto.getValueLabel()); map.put("valueLabel" + number, indicatorsDto.getValueLabel());
maps.add(map); maps.add(map);
} }
TpriDmpDatabook tpriDmpDatabook = tpriDmpDatabookServiceImpl.getTpriDmpDatabookByDataName("集电线"); TpriDmpDatabook tpriDmpDatabook = tpriDmpDatabookServiceImpl.getTpriDmpDatabookByDataName("集电线");
List<Map<String,Object>> dataMaps = sjglZsjZsbtzServiceImpl.sjglZsjZsbtzMapper.getStationInfoMapByStationGFWerks(werks, tpriDmpDatabook.getDataid().toString()); List<Map<String, Object>> dataMaps = sjglZsjZsbtzServiceImpl.sjglZsjZsbtzMapper.getStationInfoMapByStationGFWerks(werks, tpriDmpDatabook.getDataid().toString());
int i = 0; int i = 0;
//逆变器需要根据所属集电线分类组装 下面循环是将同一子阵下的不同逆变器组装为消息数据 //逆变器需要根据所属集电线分类组装 下面循环是将同一子阵下的不同逆变器组装为消息数据
for (Map<String, Object> dataMap : dataMaps) { for (Map<String, Object> dataMap : dataMaps) {
List<Map<String,String>> statusMaps = new ArrayList<>(); List<Map<String, String>> statusMaps = new ArrayList<>();
String equipNum = dataMap.get("equipNum").toString(); String equipNum = dataMap.get("equipNum").toString();
for (String num : nums) { for (String num : nums) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("titie","#"+num); map.put("titie", "#" + num);
for (Map<String, String> stringMap : maps) { for (Map<String, String> stringMap : maps) {
if (stringMap.get("titie").equals(num)){ if (stringMap.get("titie").equals(num)) {
map.putAll(stringMap); map.putAll(stringMap);
} }
} }
if (equipNum.contains(num)){ if (equipNum.contains(num)) {
statusMaps.add(map); statusMaps.add(map);
} }
} }
IPage<Map<String,String>> result = new Page<>(); IPage<Map<String, String>> result = new Page<>();
result.setRecords(statusMaps); result.setRecords(statusMaps);
result.setCurrent(1); result.setCurrent(1);
result.setTotal(statusMaps.size()); result.setTotal(statusMaps.size());
i += 1; i += 1;
try { try {
emqKeeper.getMqttClient().publish(stationId+"/fj/group"+i,JSON.toJSONString(result).getBytes(),0,false); emqKeeper.getMqttClient().publish(stationId + "/fj/group" + i, JSON.toJSONString(result).getBytes(), 0, false);
} catch (MqttException e) { } catch (MqttException e) {
log.info("消息发送失败"); log.info("消息发送失败");
e.printStackTrace(); e.printStackTrace();
...@@ -1724,22 +1726,21 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1724,22 +1726,21 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
@Override @Override
public Map<String, Object> partofWaring3D(String stationId, String equipNum) { public Map<String, Object> partofWaring3D(String stationId, String equipNum) {
Map<String,Object> resultMap=new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
StationBasic stationBasic = stationBasicMapper.selectById(stationId); StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String querySql = "SELECT * FROM indicators_"+stationBasic.getFanGatewayId()+" WHERE equipmentNumber = '"+equipNum+"' and equipmentIndexName =~/实时故障/"; String querySql = "SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " WHERE equipmentNumber = '" + equipNum + "' and equipmentIndexName =~/实时故障/";
List<IndicatorsDto> indicatorsDtoList = influxDButils.getListData(querySql,IndicatorsDto.class); List<IndicatorsDto> indicatorsDtoList = influxDButils.getListData(querySql, IndicatorsDto.class);
//获取风机型号 //获取风机型号
String type = indicatorsDtoList.get(0).getEquipmentSpecificName().substring(0,5); String type = indicatorsDtoList.get(0).getEquipmentSpecificName().substring(0, 5);
List<String> sytemNames =Arrays.asList("发电机系统","机舱与塔筒系统","变流与主控系统","偏航与液压系统","叶轮系统"); List<String> sytemNames = Arrays.asList("发电机系统", "机舱与塔筒系统", "变流与主控系统", "偏航与液压系统", "叶轮系统");
List<SystemEnum> systemEnumListAll = systemEnumMapper.selectList(new QueryWrapper<SystemEnum>().isNotNull("system_name")); List<SystemEnum> systemEnumListAll = systemEnumMapper.selectList(new QueryWrapper<SystemEnum>().isNotNull("system_name"));
sytemNames.forEach(name->{ sytemNames.forEach(name -> {
resultMap.put(name,false); resultMap.put(name, false);
List<SystemEnum> systemEnumList = systemEnumListAll.stream().filter(systemEnum -> systemEnum.getSyetemName().equals(name)).collect(Collectors.toList()); List<SystemEnum> systemEnumList = systemEnumListAll.stream().filter(systemEnum -> systemEnum.getSyetemName().equals(name)).collect(Collectors.toList());
outer:for(SystemEnum systemEnum:systemEnumList) { outer:
for (SystemEnum systemEnum : systemEnumList) {
for (IndicatorsDto indicatorsDto : indicatorsDtoList) { for (IndicatorsDto indicatorsDto : indicatorsDtoList) {
if (indicatorsDto.getEquipmentSpecificName().contains(systemEnum.getCode()) && indicatorsDto.getValue().equals(systemEnum.getEunmValue())) { if (indicatorsDto.getEquipmentSpecificName().contains(systemEnum.getCode()) && indicatorsDto.getValue().equals(systemEnum.getEunmValue())) {
resultMap.put(name, true); resultMap.put(name, true);
...@@ -1753,23 +1754,23 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1753,23 +1754,23 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
public Map<String, Object> nbqStatus(String gatewayId) { public Map<String, Object> nbqStatus(String gatewayId) {
String sql = " SELECT * FROM indicators_"+gatewayId+" WHERE (equipmentIndexName ='待机' or equipmentIndexName ='故障停机' or equipmentIndexName ='告警运行' or equipmentIndexName ='限额运行' or equipmentIndexName ='停机') and value = 'true'"; String sql = " SELECT * FROM indicators_" + gatewayId + " WHERE (equipmentIndexName ='待机' or equipmentIndexName ='故障停机' or equipmentIndexName ='告警运行' or equipmentIndexName ='限额运行' or equipmentIndexName ='停机') and value = 'true'";
List<IndicatorsDto> indicatorsDtoList = influxDButils.getListData(sql,IndicatorsDto.class); List<IndicatorsDto> indicatorsDtoList = influxDButils.getListData(sql, IndicatorsDto.class);
int djNum = 0 ; int djNum = 0;
int gzNum = 0 ; int gzNum = 0;
int gjNum = 0 ; int gjNum = 0;
int xeNum = 0 ; int xeNum = 0;
int xdNum = 0 ; int xdNum = 0;
int txNum = 0 ; int txNum = 0;
int tjNum = 0 ; int tjNum = 0;
int zcNum = 0 ; int zcNum = 0;
Map<String, Object> numMap = new HashMap<>(); Map<String, Object> numMap = new HashMap<>();
Set<String> equipNum = new HashSet<>(); Set<String> equipNum = new HashSet<>();
for (IndicatorsDto indicatorsDto : indicatorsDtoList) { for (IndicatorsDto indicatorsDto : indicatorsDtoList) {
switch(indicatorsDto.getEquipmentIndexName()){ switch (indicatorsDto.getEquipmentIndexName()) {
case "待机": case "待机":
djNum += 1; djNum += 1;
break; break;
...@@ -1789,65 +1790,64 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1789,65 +1790,64 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
} }
String xesql = " SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName ='有功功率' and frontModule = '逆变器' and value < '0.5'"; String xesql = " SELECT * FROM indicators_" + gatewayId + " WHERE equipmentIndexName ='有功功率' and frontModule = '逆变器' and value < '0.5'";
List<IndicatorsDto> xeList = influxDButils.getListData(xesql,IndicatorsDto.class); List<IndicatorsDto> xeList = influxDButils.getListData(xesql, IndicatorsDto.class);
for (IndicatorsDto dto : xeList) { for (IndicatorsDto dto : xeList) {
if (!ValidationUtil.isEmpty(equipNum) && equipNum.contains(dto.getEquipmentNumber())){ if (!ValidationUtil.isEmpty(equipNum) && equipNum.contains(dto.getEquipmentNumber())) {
xdNum += 1; xdNum += 1;
} }
} }
String querySql = " SELECT * FROM indicators_"+gatewayId+" WHERE ( equipmentIndexName ='告警运行' or equipmentIndexName ='限额运行' ) and value != 'true'"; String querySql = " SELECT * FROM indicators_" + gatewayId + " WHERE ( equipmentIndexName ='告警运行' or equipmentIndexName ='限额运行' ) and value != 'true'";
List<IndicatorsDto> queryList = influxDButils.getListData(querySql,IndicatorsDto.class); List<IndicatorsDto> queryList = influxDButils.getListData(querySql, IndicatorsDto.class);
if (!ValidationUtil.isEmpty(queryList)) { if (!ValidationUtil.isEmpty(queryList)) {
List<String> collect = queryList.stream().map(IndicatorsDto::getEquipmentNumber).collect(Collectors.toList()); List<String> collect = queryList.stream().map(IndicatorsDto::getEquipmentNumber).collect(Collectors.toList());
Set<String> strings = new HashSet<>(collect); Set<String> strings = new HashSet<>(collect);
zcNum = collect.size() - strings.size(); zcNum = collect.size() - strings.size();
} }
String querySql1 = " SELECT * FROM indicators_"+gatewayId+" equipmentIndexName ='通讯异常' and value = 'true'"; String querySql1 = " SELECT * FROM indicators_" + gatewayId + " equipmentIndexName ='通讯异常' and value = 'true'";
List<IndicatorsDto> queryList1 = influxDButils.getListData(querySql1,IndicatorsDto.class); List<IndicatorsDto> queryList1 = influxDButils.getListData(querySql1, IndicatorsDto.class);
if (!ValidationUtil.isEmpty(queryList1)){ if (!ValidationUtil.isEmpty(queryList1)) {
List<String> collect1 = queryList.stream().map(IndicatorsDto::getEquipmentNumber).collect(Collectors.toList()); List<String> collect1 = queryList.stream().map(IndicatorsDto::getEquipmentNumber).collect(Collectors.toList());
Set<String> strings1 = new HashSet<>(collect1); Set<String> strings1 = new HashSet<>(collect1);
txNum = collect1.size()-strings1.size(); txNum = collect1.size() - strings1.size();
} }
numMap.put("djNum", djNum);
numMap.put("djNum",djNum); numMap.put("gzNum", gzNum);
numMap.put("gzNum",gzNum); numMap.put("gjNum", gjNum);
numMap.put("gjNum",gjNum); numMap.put("xeNum", xeNum);
numMap.put("xeNum",xeNum); numMap.put("xdNum", xdNum);
numMap.put("xdNum",xdNum); numMap.put("txNum", txNum);
numMap.put("txNum",txNum); numMap.put("tjNum", tjNum);
numMap.put("tjNum",tjNum); numMap.put("zcNum", zcNum);
numMap.put("zcNum",zcNum);
return numMap; return numMap;
} }
public void sendMqttByRanking( List< Map<String,Object>> list,String code,String topic){ public void sendMqttByRanking(List<Map<String, Object>> list, String code, String topic) {
list.stream().sorted((o1,o2)->{ list.stream().sorted((o1, o2) -> {
double o1Num = Double.parseDouble(o1.get("value").toString()); double o1Num = Double.parseDouble(o1.get("value").toString());
double o2Num = Double.parseDouble(o2.get("value").toString()); double o2Num = Double.parseDouble(o2.get("value").toString());
if ((o1Num-o2Num)<0){ if ((o1Num - o2Num) < 0) {
return -1; return -1;
}else if ((o1Num-o2Num)>0){ } else if ((o1Num - o2Num) > 0) {
return 1; return 1;
}else { } else {
return 0; return 0;
} }
}); });
IPage<Map<String,Object>> result = new Page<>(); IPage<Map<String, Object>> result = new Page<>();
result.setRecords(list); result.setRecords(list);
result.setCurrent(1); result.setCurrent(1);
result.setTotal(list.size()); result.setTotal(list.size());
try { try {
emqKeeper.getMqttClient().publish(topic+"/"+code,JSON.toJSONString(result).getBytes(),0,false); emqKeeper.getMqttClient().publish(topic + "/" + code, JSON.toJSONString(result).getBytes(), 0, false);
} catch (MqttException e) { } catch (MqttException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -1855,18 +1855,18 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1855,18 +1855,18 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
public Map<String, Object> generatingCapacity (String gatewayId,String query){ public Map<String, Object> generatingCapacity(String gatewayId, String query) {
String querySql = " SELECT * FROM indicators_"+gatewayId+" WHERE equipmentIndexName='日发电量' or equipmentIndexName='月发电量' or equipmentIndexName='年发电量'"; String querySql = " SELECT * FROM indicators_" + gatewayId + " WHERE equipmentIndexName='日发电量' or equipmentIndexName='月发电量' or equipmentIndexName='年发电量'";
if (null != query){ if (null != query) {
querySql = querySql + " "+ query; querySql = querySql + " " + query;
} }
List<IndicatorsDto> queryList = influxDButils.getListData(querySql,IndicatorsDto.class); List<IndicatorsDto> queryList = influxDButils.getListData(querySql, IndicatorsDto.class);
Map<String, List<IndicatorsDto>> maps = queryList.stream().collect(Collectors.groupingBy(IndicatorsDto::getEquipmentIndexName)); Map<String, List<IndicatorsDto>> maps = queryList.stream().collect(Collectors.groupingBy(IndicatorsDto::getEquipmentIndexName));
Map<String, Object> hashMap = new HashMap<>(); Map<String, Object> hashMap = new HashMap<>();
for (String s : maps.keySet()) { for (String s : maps.keySet()) {
List<IndicatorsDto> indicatorsDtos = maps.get(s); List<IndicatorsDto> indicatorsDtos = maps.get(s);
Double totalvalue =indicatorsDtos.stream().filter(obj -> !ObjectUtils.isEmpty(obj.getValue())).mapToDouble(l->Double.parseDouble(l.getValue())).sum(); Double totalvalue = indicatorsDtos.stream().filter(obj -> !ObjectUtils.isEmpty(obj.getValue())).mapToDouble(l -> Double.parseDouble(l.getValue())).sum();
hashMap.put(s,totalvalue); hashMap.put(s, totalvalue);
} }
return hashMap; return hashMap;
} }
......
...@@ -11,6 +11,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic; ...@@ -11,6 +11,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils; import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
...@@ -23,6 +24,7 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -23,6 +24,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import java.io.File; import java.io.File;
...@@ -69,7 +71,8 @@ public class MonitoringServiceIMQTTmpl { ...@@ -69,7 +71,8 @@ public class MonitoringServiceIMQTTmpl {
CommonServiceImpl commonService; CommonServiceImpl commonService;
@Autowired @Autowired
InfluxDButils influxDButils; InfluxDButils influxDButils;
@Autowired
MonitoringServiceImpl monitoringServiceImpl;
@Autowired @Autowired
private MonitorFanIndicatorMapper monitorFanIndicatorregionMapper; private MonitorFanIndicatorMapper monitorFanIndicatorregionMapper;
...@@ -79,7 +82,6 @@ public class MonitoringServiceIMQTTmpl { ...@@ -79,7 +82,6 @@ public class MonitoringServiceIMQTTmpl {
*/ */
@Scheduled(cron = totalSocialContributionCron) @Scheduled(cron = totalSocialContributionCron)
public void getTotalSocialContribution() { public void getTotalSocialContribution() {
Page<SocialContributionDto> socialContributionDtoPage = new Page<SocialContributionDto>();
logger.error("--------------------------社会贡献定时执行----------------------------------------------"); logger.error("--------------------------社会贡献定时执行----------------------------------------------");
List<SocialContributionDto> socialContributionDtoList = new ArrayList<>(); List<SocialContributionDto> socialContributionDtoList = new ArrayList<>();
//定义社会贡献列表 //定义社会贡献列表
...@@ -87,37 +89,13 @@ public class MonitoringServiceIMQTTmpl { ...@@ -87,37 +89,13 @@ public class MonitoringServiceIMQTTmpl {
//获取所有网关id不为空的数据 //获取所有网关id不为空的数据
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("fan_gateway_id")); List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("fan_gateway_id"));
stationBasicList.forEach(stationBasic -> { stationBasicList.forEach(stationBasic -> {
if ("FDZ".equals(stationBasic.getStationType())) {
totalSocialContribution.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "年发电量")); totalSocialContribution.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "年发电量"));
} else {
totalSocialContribution.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "年发电量") * CommonConstans.pvGenPoweActor);
}
}); });
//二氧化碳贡献数 Page<SocialContributionDto> socialContributionDtoPage = commonService.getSocialContributionDtoList(totalSocialContribution.get());
SocialContributionDto co2 = new SocialContributionDto();
//标准煤贡献度
SocialContributionDto coal = new SocialContributionDto();
//碳粉尘计算公式
SocialContributionDto toner = new SocialContributionDto();
//二氧化硫贡献度
SocialContributionDto so2 = new SocialContributionDto();
/** 社会贡献原始计算公式,后边的数据已经经过处理
//二氧化碳计算公式 *10000*832/10000/1000/1000
//标准煤计算公式 *10000*304.9/10000/1000/1000
//碳粉尘计算公式 *10000*0.032/1000/1000
//二氧化硫计算公式 =A2*10000*0.16/1000/1000
*/
co2.setUnit("二氧化碳减排量(万t)");
co2.setTitle(String.format("%.2f",totalSocialContribution.get() * 0.000832));
socialContributionDtoList.add(co2);
coal.setUnit("节约标准煤(万t)");
coal.setTitle(String.format("%.2f",totalSocialContribution.get() * 0.0003049));
socialContributionDtoList.add(coal);
toner.setUnit("碳粉尘减排量(万t)");
toner.setTitle(String.format("%.2f",totalSocialContribution.get() * 0.00032));
socialContributionDtoList.add(toner);
so2.setUnit("二氧化硫减排量(万t)");
so2.setTitle(String.format("%.2f",totalSocialContribution.get() * 0.0016));
socialContributionDtoList.add(so2);
socialContributionDtoPage.setRecords(socialContributionDtoList);
socialContributionDtoPage.setTotal(100);
socialContributionDtoPage.setCurrent(1);
try { try {
emqKeeper.getMqttClient().publish("socialcontribution_topic", JSON.toJSON(socialContributionDtoPage).toString().getBytes("UTF-8"), 1, true); emqKeeper.getMqttClient().publish("socialcontribution_topic", JSON.toJSON(socialContributionDtoPage).toString().getBytes("UTF-8"), 1, true);
logger.info("-----------------发送社会贡献消息=================== 成功!" + JSON.toJSONString(socialContributionDtoPage)); logger.info("-----------------发送社会贡献消息=================== 成功!" + JSON.toJSONString(socialContributionDtoPage));
...@@ -144,28 +122,31 @@ public class MonitoringServiceIMQTTmpl { ...@@ -144,28 +122,31 @@ public class MonitoringServiceIMQTTmpl {
AtomicReference<Double> annualPower = new AtomicReference<>(0.0); AtomicReference<Double> annualPower = new AtomicReference<>(0.0);
//年发电量完成比例 //年发电量完成比例
String completionRatio = "23.11"; String completionRatio = "23.11";
//年利用小时数
AtomicReference<Double> useHours = new AtomicReference<>(0.01);
stationBasicList.forEach(stationBasic -> { stationBasicList.forEach(stationBasic -> {
if ("FDZ".equals(stationBasic.getStationType())) {
dailyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "日发电量")); dailyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "日发电量"));
monthlyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "月发电量")); monthlyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "月发电量"));
annualPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "年发电量")); annualPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "年发电量"));
useHours.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "日工作时间")); } else {
dailyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "日发电量")*CommonConstans.pvGenPoweActor);
monthlyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "月发电量")*CommonConstans.pvGenPoweActor);
annualPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "年发电量")*CommonConstans.pvGenPoweActor);
}
}); });
SocialContributionDto dailyPowerdto = new SocialContributionDto(); SocialContributionDto dailyPowerdto = new SocialContributionDto();
dailyPowerdto.setTitle(String.format("%.2f",dailyPower.get())); dailyPowerdto.setTitle(String.format("%.2f", dailyPower.get()));
dailyPowerdto.setUnit("万kWh"); dailyPowerdto.setUnit("万kWh");
SocialContributionDto monthlyPowerdto = new SocialContributionDto(); SocialContributionDto monthlyPowerdto = new SocialContributionDto();
monthlyPowerdto.setTitle(String.format("%.2f",monthlyPower.get())); monthlyPowerdto.setTitle(String.format("%.2f", monthlyPower.get()));
monthlyPowerdto.setUnit("万kWh"); monthlyPowerdto.setUnit("万kWh");
SocialContributionDto annualPowerdto = new SocialContributionDto(); SocialContributionDto annualPowerdto = new SocialContributionDto();
annualPowerdto.setTitle(String.format("%.2f",annualPower.get())); annualPowerdto.setTitle(String.format("%.2f", annualPower.get()));
annualPowerdto.setUnit("万kWh"); annualPowerdto.setUnit("万kWh");
SocialContributionDto completionRatioDto = new SocialContributionDto(); SocialContributionDto completionRatioDto = new SocialContributionDto();
completionRatioDto.setTitle(completionRatio); completionRatioDto.setTitle(completionRatio);
completionRatioDto.setUnit("%"); completionRatioDto.setUnit("%");
SocialContributionDto useHoursDto = new SocialContributionDto(); SocialContributionDto useHoursDto = new SocialContributionDto();
useHoursDto.setTitle(String.format("%.2f",useHours.get())); useHoursDto.setTitle(String.format("%.2f", (annualPower.get() / Double.valueOf(monitoringServiceImpl.getInstallCapity(stationBasicList)))));
useHoursDto.setUnit("h"); useHoursDto.setUnit("h");
socialContributionDtoList.add(dailyPowerdto); socialContributionDtoList.add(dailyPowerdto);
socialContributionDtoList.add(monthlyPowerdto); socialContributionDtoList.add(monthlyPowerdto);
...@@ -428,34 +409,35 @@ public class MonitoringServiceIMQTTmpl { ...@@ -428,34 +409,35 @@ public class MonitoringServiceIMQTTmpl {
List<Map<String, String>> boosterStationInfo = monitorFanIndicatorregionMapper.getBoosterStationInfo(stationBasic.getBoosterGatewayId()); List<Map<String, String>> boosterStationInfo = monitorFanIndicatorregionMapper.getBoosterStationInfo(stationBasic.getBoosterGatewayId());
for (int i = 0; i < boosterStationInfo.size(); i++) { for (int i = 0; i < boosterStationInfo.size(); i++) {
Map<String, String> map = boosterStationInfo.get(i); Map<String, String> map = boosterStationInfo.get(i);
sendIndicatorSwitch(stationBasic.getSequenceNbr().toString(),stationBasic.getBoosterGatewayId(), map.get("boosterName")); sendIndicatorSwitch(stationBasic.getSequenceNbr().toString(), stationBasic.getBoosterGatewayId(), map.get("boosterName"));
} }
}); });
} }
public void sendIndicatorSwitch(String stationId,String bootStationGateWayId, String frontMoudule) {
public void sendIndicatorSwitch(String stationId, String bootStationGateWayId, String frontMoudule) {
String sql = "SELECT * FROM indicators_" + bootStationGateWayId + " where frontModule = '" + frontMoudule + "' and systemType='开关'"; String sql = "SELECT * FROM indicators_" + bootStationGateWayId + " where frontModule = '" + frontMoudule + "' and systemType='开关'";
List<IndicatorsDto> indicatorsDtoList = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> indicatorsDtoList = influxDButils.getListData(sql, IndicatorsDto.class);
//过滤掉包含数字的开关 //过滤掉包含数字的开关
List<IndicatorsDto> result = indicatorsDtoList.stream().filter(indicatorsDto -> !indicatorsDto.getDisplayName().matches(".*\\d+.*")).collect(Collectors.toList()); List<IndicatorsDto> result = indicatorsDtoList.stream().filter(indicatorsDto -> !indicatorsDto.getDisplayName().matches(".*\\d+.*")).collect(Collectors.toList());
HashMap<String,String> hashMap =new HashMap<>(); HashMap<String, String> hashMap = new HashMap<>();
for (int i = 0; i < result.size(); i++) { for (int i = 0; i < result.size(); i++) {
IndicatorsDto indicatorsDto = result.get(i); IndicatorsDto indicatorsDto = result.get(i);
//此处需要根据查询的结果来动态的给定图片的url路径。 //此处需要根据查询的结果来动态的给定图片的url路径。
hashMap.put("url"+i,"tetee"); hashMap.put("url" + i, "tetee");
hashMap.put("display"+i,indicatorsDto.getDisplayName()); hashMap.put("display" + i, indicatorsDto.getDisplayName());
} }
Page<HashMap<String,String>> hashMapPage = new Page<>(); Page<HashMap<String, String>> hashMapPage = new Page<>();
List<HashMap<String,String>> list = new ArrayList<>(); List<HashMap<String, String>> list = new ArrayList<>();
list.add(hashMap); list.add(hashMap);
hashMapPage.setRecords(list); hashMapPage.setRecords(list);
hashMapPage.setTotal(list.size()); hashMapPage.setTotal(list.size());
hashMapPage.setCurrent(1); hashMapPage.setCurrent(1);
System.out.println(result.size()); System.out.println(result.size());
try { try {
emqKeeper.getMqttClient().publish(stationId+bootStationGateWayId + "_topic", JSON.toJSON(hashMapPage).toString().getBytes("UTF-8"), 1, true); emqKeeper.getMqttClient().publish(stationId + bootStationGateWayId + "_topic", JSON.toJSON(hashMapPage).toString().getBytes("UTF-8"), 1, true);
logger.info(JSON.toJSONString(hashMapPage)); logger.info(JSON.toJSONString(hashMapPage));
logger.info("-----------------发送升压站数据成功=================== 成功!"); logger.info("-----------------发送升压站数据成功=================== 成功!");
}catch (Exception e){ } catch (Exception e) {
logger.info("-----------------发送升压站数据成功=================== 成功!"); logger.info("-----------------发送升压站数据成功=================== 成功!");
} }
} }
......
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -11,9 +13,9 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.MapRegionMapper; ...@@ -11,9 +13,9 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.MapRegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationCoordinateMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationCoordinateMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.*; import com.yeejoin.amos.boot.module.jxiop.biz.dto.*;
import com.yeejoin.amos.component.influxdb.InfluxdbUtil; import com.yeejoin.amos.component.influxdb.InfluxdbUtil;
import lombok.Data;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -221,9 +223,9 @@ public class MonitoringServiceImpl { ...@@ -221,9 +223,9 @@ public class MonitoringServiceImpl {
mapList1 = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getBoosterGatewayId() + " where equipmentIndexName='WTX-801_25_WTX-801_总辐射'"); mapList1 = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getBoosterGatewayId() + " where equipmentIndexName='WTX-801_25_WTX-801_总辐射'");
completionOfPowerIndicatorsDto.setWindSpeedOrIrradiance(String.valueOf(commonServiceImpl.getTotalByIndicatior(mapList1, "WTX-801_25_WTX-801_总辐射"))); completionOfPowerIndicatorsDto.setWindSpeedOrIrradiance(String.valueOf(commonServiceImpl.getTotalByIndicatior(mapList1, "WTX-801_25_WTX-801_总辐射")));
completionOfPowerIndicatorsDto.setActivePower(String.valueOf(commonServiceImpl.getTotalByIndicatior(mapList, "有功功率"))); completionOfPowerIndicatorsDto.setActivePower(String.valueOf(commonServiceImpl.getTotalByIndicatior(mapList, "有功功率")));
completionOfPowerIndicatorsDto.setDailyPower(String.valueOf(commonServiceImpl.getTotalByIndicatior(mapList, "日发电量"))); completionOfPowerIndicatorsDto.setDailyPower(String.valueOf(commonServiceImpl.getTotalByIndicatior(mapList, "日发电量") * CommonConstans.pvGenPoweActor));
completionOfPowerIndicatorsDto.setMonthlyPower(String.valueOf(commonServiceImpl.getTotalByIndicatior(mapList, "月发电量"))); completionOfPowerIndicatorsDto.setMonthlyPower(String.valueOf(commonServiceImpl.getTotalByIndicatior(mapList, "月发电量") * CommonConstans.pvGenPoweActor));
completionOfPowerIndicatorsDto.setAnnualPower(String.format("%.2f", new BigDecimal(commonServiceImpl.getTotalByIndicatior(mapList, "年发电量") / 1000))); completionOfPowerIndicatorsDto.setAnnualPower(String.format("%.2f", new BigDecimal(commonServiceImpl.getTotalByIndicatior(mapList, "年发电量") * CommonConstans.pvGenPoweActor)));
} }
...@@ -284,9 +286,9 @@ public class MonitoringServiceImpl { ...@@ -284,9 +286,9 @@ public class MonitoringServiceImpl {
monthlyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "月发电量")); monthlyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "月发电量"));
annualPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "年发电量")); annualPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "年发电量"));
} else { } else {
dailyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "日发电量") / 10000); dailyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "日发电量") * CommonConstans.pvGenPoweActor);
monthlyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "月发电量") / 10000); monthlyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "月发电量") * CommonConstans.pvGenPoweActor);
annualPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "年发电量") / 10000); annualPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "年发电量") * CommonConstans.pvGenPoweActor);
} }
installCapacity.updateAndGet(v -> v + getStationCaPACITYL(stationBasic.getStationNumber())); installCapacity.updateAndGet(v -> v + getStationCaPACITYL(stationBasic.getStationNumber()));
}); });
...@@ -424,12 +426,17 @@ public class MonitoringServiceImpl { ...@@ -424,12 +426,17 @@ public class MonitoringServiceImpl {
//设置装机容量 //设置装机容量
homeMapStationInfoDto.setStationInstalledCapacity(String.format("%.2f", getStationCaPACITYL(stationBasic.getStationNumber()))); homeMapStationInfoDto.setStationInstalledCapacity(String.format("%.2f", getStationCaPACITYL(stationBasic.getStationNumber())));
//设置风速辐照度 //设置风速辐照度
String speendOrirradiate = ""; List<Map<String, Object>> mapList;
List<Map<String, Object>> mapList1;
if (stationBasic.getStationType().equals("FDZ")) { if (stationBasic.getStationType().equals("FDZ")) {
speendOrirradiate = String.valueOf(commonServiceImpl.getAvgvalueByIndicatior(stationBasic.getFanGatewayId(), "30秒平均风速")); mapList = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where (equipmentIndexName='日发电量' or equipmentIndexName='月发电量' or equipmentIndexName='年发电量' or equipmentIndexName='有功功率' or equipmentIndexName='30秒平均风速' )");
homeMapStationInfoDto.setSpeendOrirradiate(speendOrirradiate); homeMapStationInfoDto.setSpeendOrirradiate(String.valueOf(commonServiceImpl.getAvgvalueByIndicatior(mapList, "30秒平均风速")));
homeMapStationInfoDto.setCurrentPower(String.valueOf(commonServiceImpl.getTotalByIndicatior(mapList, "有功功率")));
} else { } else {
homeMapStationInfoDto.setSpeendOrirradiate("0.00"); mapList = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and(equipmentIndexName='日发电量' or equipmentIndexName='月发电量' or equipmentIndexName='年发电量' or equipmentIndexName='有功功率')");
mapList1 = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getBoosterGatewayId() + " where equipmentIndexName='WTX-801_25_WTX-801_总辐射'");
homeMapStationInfoDto.setSpeendOrirradiate(String.valueOf(commonServiceImpl.getTotalByIndicatior(mapList1, "WTX-801_25_WTX-801_总辐射")));
homeMapStationInfoDto.setCurrentPower(String.valueOf(commonServiceImpl.getTotalByIndicatior(mapList, "有功功率")));
} }
StationCoordinate stationCoordinate = stationCoordinateList.stream().filter(stationCoordinate1 -> stationCoordinate1.getStationId().equals(stationBasic.getSequenceNbr())).collect(Collectors.toList()).get(0); StationCoordinate stationCoordinate = stationCoordinateList.stream().filter(stationCoordinate1 -> stationCoordinate1.getStationId().equals(stationBasic.getSequenceNbr())).collect(Collectors.toList()).get(0);
//获取场站经纬度 //获取场站经纬度
...@@ -437,8 +444,6 @@ public class MonitoringServiceImpl { ...@@ -437,8 +444,6 @@ public class MonitoringServiceImpl {
list.add(stationCoordinate.getLongitude()); list.add(stationCoordinate.getLongitude());
list.add(stationCoordinate.getLaitude()); list.add(stationCoordinate.getLaitude());
homeMapStationInfoDto.setStationPosition(list); homeMapStationInfoDto.setStationPosition(list);
//设置当前功率
homeMapStationInfoDto.setCurrentPower("0");
homeMapStationInfoDtoList.add(homeMapStationInfoDto); homeMapStationInfoDtoList.add(homeMapStationInfoDto);
}); });
} }
...@@ -468,7 +473,7 @@ public class MonitoringServiceImpl { ...@@ -468,7 +473,7 @@ public class MonitoringServiceImpl {
if ("FDZ".equals(stationBasic.getStationType())) { if ("FDZ".equals(stationBasic.getStationType())) {
total.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "日发电量")); total.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "日发电量"));
} else { } else {
total.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "日发电量") / 10000); total.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "日发电量") * CommonConstans.pvGenPoweActor);
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -529,7 +534,7 @@ public class MonitoringServiceImpl { ...@@ -529,7 +534,7 @@ public class MonitoringServiceImpl {
total.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "有功功率")); total.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "有功功率"));
}); });
//有功功率换算 //有功功率换算
hashMap.put("title", String.format("%.2f", total.get() / 1000)); hashMap.put("title", String.format("%.2f", total.get()));
return hashMap; return hashMap;
} }
...@@ -554,13 +559,16 @@ public class MonitoringServiceImpl { ...@@ -554,13 +559,16 @@ public class MonitoringServiceImpl {
stationBasicListAll.forEach(stationBasic -> { stationBasicListAll.forEach(stationBasic -> {
List<Map<String, Object>> mapListData = new ArrayList<>(); List<Map<String, Object>> mapListData = new ArrayList<>();
String finalIndicator = "年发电量"; String finalIndicator = "年发电量";
if (stationBasic.getStationType().equals("FDZ")) { Double total1 = 0.00;
if (!stationBasic.getStationType().equals("FDZ")) {
mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and (equipmentIndexName='" + finalIndicator + "' )"); mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and (equipmentIndexName='" + finalIndicator + "' )");
total1 = commonServiceImpl.getTotalByIndicatior(mapListData, finalIndicator) * CommonConstans.pvGenPoweActor;
} else { } else {
mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where (equipmentIndexName='" + finalIndicator + "' )"); mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where (equipmentIndexName='" + finalIndicator + "' )");
total1 = commonServiceImpl.getTotalByIndicatior(mapListData, finalIndicator);
} }
Double total1 = commonServiceImpl.getTotalByIndicatior(mapListData, finalIndicator); Double finalTotal = total1;
total.updateAndGet(v -> v + total1); total.updateAndGet(v -> v + finalTotal);
}); });
return commonServiceImpl.getSocialContributionDtoList(total.get()); return commonServiceImpl.getSocialContributionDtoList(total.get());
} }
...@@ -578,9 +586,9 @@ public class MonitoringServiceImpl { ...@@ -578,9 +586,9 @@ public class MonitoringServiceImpl {
List<Map<String, Object>> mapListData = new ArrayList<>(); List<Map<String, Object>> mapListData = new ArrayList<>();
Double total = 0.00; Double total = 0.00;
String finalIndicator = "月发电量"; String finalIndicator = "月发电量";
if (stationBasic.getStationType().equals("FDZ")) { if (!stationBasic.getStationType().equals("FDZ")) {
mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and (equipmentIndexName='" + finalIndicator + "' )"); mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and (equipmentIndexName='" + finalIndicator + "' )");
total = commonServiceImpl.getTotalByIndicatior(mapListData, finalIndicator); total = commonServiceImpl.getTotalByIndicatior(mapListData, finalIndicator) * CommonConstans.pvGenPoweActor;
} else { } else {
mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where (equipmentIndexName='" + finalIndicator + "' )"); mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where (equipmentIndexName='" + finalIndicator + "' )");
total = commonServiceImpl.getTotalByIndicatior(mapListData, finalIndicator); total = commonServiceImpl.getTotalByIndicatior(mapListData, finalIndicator);
...@@ -591,7 +599,7 @@ public class MonitoringServiceImpl { ...@@ -591,7 +599,7 @@ public class MonitoringServiceImpl {
}); });
HashMap<String, List<String>> hashMap = new HashMap<>(); HashMap<String, List<String>> hashMap = new HashMap<>();
List<String> xList = getXListofRecentOneYear(); List<String> xList = getXListofRecentOneYear();
List<String> yList = Arrays.asList("0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "12000", String.format("%.2f", monthlyPower.get() / 1000)); List<String> yList = Arrays.asList("0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "12000", String.format("%.2f", monthlyPower.get()));
hashMap.put("axisData", xList); hashMap.put("axisData", xList);
hashMap.put("seriesData", yList); hashMap.put("seriesData", yList);
return hashMap; return hashMap;
...@@ -615,14 +623,14 @@ public class MonitoringServiceImpl { ...@@ -615,14 +623,14 @@ public class MonitoringServiceImpl {
mapList = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and (equipmentIndexName='日发电量' or equipmentIndexName='月发电量' or equipmentIndexName='年发电量' )"); mapList = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and (equipmentIndexName='日发电量' or equipmentIndexName='月发电量' or equipmentIndexName='年发电量' )");
} }
List<Map<String, Object>> finalMapList = mapList; List<Map<String, Object>> finalMapList = mapList;
if("FDZ".equals(stationBasic.getStationType())){ if ("FDZ".equals(stationBasic.getStationType())) {
dailyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "日发电量")); dailyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "日发电量"));
monthlyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "月发电量")); monthlyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "月发电量"));
annualPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "年发电量")); annualPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "年发电量"));
}else { } else {
dailyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "日发电量")/10000); dailyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "日发电量") * CommonConstans.pvGenPoweActor);
monthlyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "月发电量")/10000); monthlyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "月发电量") * CommonConstans.pvGenPoweActor);
annualPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "年发电量")/10000); annualPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(finalMapList, "年发电量") * CommonConstans.pvGenPoweActor);
} }
}); });
HashMap<String, String> dayHashMap = new HashMap<>(); HashMap<String, String> dayHashMap = new HashMap<>();
...@@ -668,13 +676,17 @@ public class MonitoringServiceImpl { ...@@ -668,13 +676,17 @@ public class MonitoringServiceImpl {
stationBasicListAll.forEach(stationBasic -> { stationBasicListAll.forEach(stationBasic -> {
List<Map<String, Object>> mapListData = new ArrayList<>(); List<Map<String, Object>> mapListData = new ArrayList<>();
String finalIndicator = "月发电量"; String finalIndicator = "月发电量";
Double total = 0.00;
if (!stationBasic.getStationType().equals("FDZ")) { if (!stationBasic.getStationType().equals("FDZ")) {
mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and (equipmentIndexName='" + finalIndicator + "' )"); mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and (equipmentIndexName='" + finalIndicator + "' )");
total = commonServiceImpl.getTotalByIndicatior(mapListData, finalIndicator) * CommonConstans.pvGenPoweActor;
} else { } else {
mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where (equipmentIndexName='" + finalIndicator + "' )"); mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where (equipmentIndexName='" + finalIndicator + "' )");
total = commonServiceImpl.getTotalByIndicatior(mapListData, finalIndicator);
} }
Double total = commonServiceImpl.getTotalByIndicatior(mapListData, finalIndicator); Double finalTotal = total;
monthlyPower.updateAndGet(v -> v + total); monthlyPower.updateAndGet(v -> v + finalTotal);
}); });
HashMap<String, List<String>> hashMap = new HashMap<>(); HashMap<String, List<String>> hashMap = new HashMap<>();
List<String> xList = getXListofRecentOneYear(); List<String> xList = getXListofRecentOneYear();
...@@ -697,17 +709,20 @@ public class MonitoringServiceImpl { ...@@ -697,17 +709,20 @@ public class MonitoringServiceImpl {
HashMap<String, List<String>> hashMap = new HashMap<>(); HashMap<String, List<String>> hashMap = new HashMap<>();
List<String> xList = new ArrayList<>(); List<String> xList = new ArrayList<>();
List<String> yList = new ArrayList<>(); List<String> yList = new ArrayList<>();
AtomicReference<Double> total = new AtomicReference<>(0.00);
//月发电量 //月发电量
String finalIndicator = "月发电量"; String finalIndicator = "月发电量";
stationBasicListAll.forEach(stationBasic -> { stationBasicListAll.forEach(stationBasic -> {
List<Map<String, Object>> mapListData = new ArrayList<>(); List<Map<String, Object>> mapListData = new ArrayList<>();
if (!stationBasic.getStationType().equals("FDZ")) { if (!stationBasic.getStationType().equals("FDZ")) {
mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and (equipmentIndexName='" + finalIndicator + "' )"); mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and (equipmentIndexName='" + finalIndicator + "' )");
total.set(commonServiceImpl.getTotalByIndicatior(mapListData, finalIndicator) * CommonConstans.pvGenPoweActor);
} else { } else {
mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where (equipmentIndexName='" + finalIndicator + "' )"); mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where (equipmentIndexName='" + finalIndicator + "' )");
total.set(commonServiceImpl.getTotalByIndicatior(mapListData, finalIndicator));
} }
Double total = commonServiceImpl.getTotalByIndicatior(mapListData, finalIndicator); stationBasic.setAddress(String.format("%.2f", total.get() % 100));
stationBasic.setAddress(String.format("%.2f", total % 100));
}); });
List<StationBasic> sorted = stationBasicListAll.stream().sorted(Comparator.comparing(StationBasic::getAddress, Comparator.comparingDouble(Double::parseDouble)).reversed()).collect(Collectors.toList()); List<StationBasic> sorted = stationBasicListAll.stream().sorted(Comparator.comparing(StationBasic::getAddress, Comparator.comparingDouble(Double::parseDouble)).reversed()).collect(Collectors.toList());
sorted.forEach(stationBasic -> { sorted.forEach(stationBasic -> {
...@@ -756,19 +771,16 @@ public class MonitoringServiceImpl { ...@@ -756,19 +771,16 @@ public class MonitoringServiceImpl {
String finalIndicator = indicator; String finalIndicator = indicator;
stationBasicListAll.forEach(stationBasic -> { stationBasicListAll.forEach(stationBasic -> {
Double install = getStationCaPACITYL(stationBasic.getStationNumber()); Double install = getStationCaPACITYL(stationBasic.getStationNumber());
Double total = 0.00;
List<Map<String, Object>> mapListData = new ArrayList<>(); List<Map<String, Object>> mapListData = new ArrayList<>();
if (!stationBasic.getStationType().equals("FDZ")) { if (!stationBasic.getStationType().equals("FDZ")) {
mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and (equipmentIndexName='" + finalIndicator + "' )"); mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and (equipmentIndexName='" + finalIndicator + "' )");
total = commonServiceImpl.getTotalByIndicatior(mapListData, finalIndicator) * CommonConstans.pvGenPoweActor;
} else { } else {
mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where (equipmentIndexName='" + finalIndicator + "' )"); mapListData = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where (equipmentIndexName='" + finalIndicator + "' )");
total = commonServiceImpl.getTotalByIndicatior(mapListData, finalIndicator);
} }
Double total = commonServiceImpl.getTotalByIndicatior(mapListData, finalIndicator);
stationBasic.setAddress(String.format("%.2f", total));
if (stationBasic.getStationType().equals("FDZ")) {
stationBasic.setAddress(String.format("%.2f", (total / 1000) / install));
} else {
stationBasic.setAddress(String.format("%.2f", (total * 10) / install)); stationBasic.setAddress(String.format("%.2f", (total * 10) / install));
}
if (stationBasic.getAddress().equals("NaN")) { if (stationBasic.getAddress().equals("NaN")) {
stationBasic.setAddress("0.00"); stationBasic.setAddress("0.00");
} }
...@@ -786,7 +798,7 @@ public class MonitoringServiceImpl { ...@@ -786,7 +798,7 @@ public class MonitoringServiceImpl {
stringHashMap.put("hours1", stationBasic.getAddress() + "h"); stringHashMap.put("hours1", stationBasic.getAddress() + "h");
} else { } else {
stringHashMap.put("stationName1", ""); stringHashMap.put("stationName1", "");
stringHashMap.put("hours1", ""); stringHashMap.put("hours1", "0.00h");
} }
if (i < (gfdzlist.size())) { if (i < (gfdzlist.size())) {
stationBasic = gfdzlist.get(i); stationBasic = gfdzlist.get(i);
...@@ -794,7 +806,7 @@ public class MonitoringServiceImpl { ...@@ -794,7 +806,7 @@ public class MonitoringServiceImpl {
stringHashMap.put("hours2", stationBasic.getAddress() + "h"); stringHashMap.put("hours2", stationBasic.getAddress() + "h");
} else { } else {
stringHashMap.put("stationName2", ""); stringHashMap.put("stationName2", "");
stringHashMap.put("hours2", ""); stringHashMap.put("hours2", "0.00h");
} }
mapList.add(stringHashMap); mapList.add(stringHashMap);
} }
...@@ -867,48 +879,49 @@ public class MonitoringServiceImpl { ...@@ -867,48 +879,49 @@ public class MonitoringServiceImpl {
powerOfAnnualGF.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(mapList, "年发电量")); powerOfAnnualGF.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(mapList, "年发电量"));
}); });
HashMap<String, String> stringHashMap4 = new HashMap<>(); HashMap<String, String> stringHashMap4 = new HashMap<>();
stringHashMap4.put("title", String.format("%.2f", powerOfDayFD.get()) + "/" + String.format("%.2f", powerOfDayGF.get())); stringHashMap4.put("title", String.format("%.2f", powerOfDayFD.get()) + "/" + String.format("%.2f", powerOfDayGF.get() * CommonConstans.pvGenPoweActor));
list1.add(stringHashMap4); list1.add(stringHashMap4);
HashMap<String, String> stringHashMap5 = new HashMap<>(); HashMap<String, String> stringHashMap5 = new HashMap<>();
stringHashMap5.put("title", String.format("%.2f", powerOfMonthFD.get()) + "/" + String.format("%.2f", powerOfMonthGF.get())); stringHashMap5.put("title", String.format("%.2f", powerOfMonthFD.get()) + "/" + String.format("%.2f", powerOfMonthGF.get() * CommonConstans.pvGenPoweActor));
list1.add(stringHashMap5); list1.add(stringHashMap5);
HashMap<String, String> stringHashMap6 = new HashMap<>(); HashMap<String, String> stringHashMap6 = new HashMap<>();
stringHashMap6.put("title", String.format("%.2f", powerOfAnnualFD.get()) + "/" + String.format("%.2f", powerOfAnnualGF.get())); stringHashMap6.put("title", String.format("%.2f", powerOfAnnualFD.get()) + "/" + String.format("%.2f", powerOfAnnualGF.get() * CommonConstans.pvGenPoweActor));
list1.add(stringHashMap6); list1.add(stringHashMap6);
HashMap<String, String> stringHashMap7 = new HashMap<>(); HashMap<String, String> stringHashMap7 = new HashMap<>();
stringHashMap7.put("title", String.format("%.2f", powerOfAnnualFD.get() % 200) + "/" + String.format("%.2f", powerOfAnnualGF.get() % 200)); stringHashMap7.put("title", String.format("%.2f", powerOfAnnualFD.get() % 200) + "/" + String.format("%.2f", powerOfAnnualGF.get() % 200));
list1.add(stringHashMap7); list1.add(stringHashMap7);
HashMap<String, String> stringHashMap8 = new HashMap<>(); HashMap<String, String> stringHashMap8 = new HashMap<>();
stringHashMap8.put("title", String.format("%.2f", powerOfAnnualFD.get() / fdzInstall.doubleValue()) + "/" + String.format("%.2f", powerOfAnnualGF.get() / gfInstall.doubleValue())); stringHashMap8.put("title", String.format("%.2f", (powerOfAnnualFD.get() * CommonConstans.wkwhToMv) / fdzInstall.doubleValue()) + "/" + String.format("%.2f", (powerOfAnnualGF.get() * CommonConstans.pvGenPoweActor * CommonConstans.wkwhToMv) / gfInstall.doubleValue()));
list1.add(stringHashMap8); list1.add(stringHashMap8);
page1.setRecords(list1); page1.setRecords(list1);
HashMap<String, String> stringHashMap9 = new HashMap<>(); HashMap<String, String> stringHashMap9 = new HashMap<>();
stringHashMap9.put("title", String.format("%.2f", powerOfDayFD.get() + powerOfDayGF.get())); stringHashMap9.put("title", String.format("%.2f", powerOfDayFD.get() + powerOfDayGF.get() * CommonConstans.pvGenPoweActor));
list2.add(stringHashMap9); list2.add(stringHashMap9);
HashMap<String, String> stringHashMap10 = new HashMap<>(); HashMap<String, String> stringHashMap10 = new HashMap<>();
stringHashMap10.put("title", String.format("%.2f", powerOfMonthFD.get() + powerOfMonthGF.get())); stringHashMap10.put("title", String.format("%.2f", powerOfMonthFD.get() + powerOfMonthGF.get() * CommonConstans.pvGenPoweActor));
list2.add(stringHashMap10); list2.add(stringHashMap10);
HashMap<String, String> stringHashMap11 = new HashMap<>(); HashMap<String, String> stringHashMap11 = new HashMap<>();
stringHashMap11.put("title", String.format("%.2f", powerOfAnnualFD.get() + powerOfAnnualGF.get())); stringHashMap11.put("title", String.format("%.2f", powerOfAnnualFD.get() + powerOfAnnualGF.get() * CommonConstans.pvGenPoweActor));
list2.add(stringHashMap11); list2.add(stringHashMap11);
HashMap<String, String> stringHashMap12 = new HashMap<>(); HashMap<String, String> stringHashMap12 = new HashMap<>();
stringHashMap12.put("title", String.format("%.2f", (powerOfAnnualFD.get() % 200 + powerOfAnnualGF.get() % 200) / 2)); stringHashMap12.put("title", String.format("%.2f", (powerOfAnnualFD.get() % 200 + powerOfAnnualGF.get() % 200) / 2));
list2.add(stringHashMap12); list2.add(stringHashMap12);
page2.setRecords(list2); page2.setRecords(list2);
Double totalAnnual = (powerOfAnnualFD.get() + powerOfAnnualGF.get() * CommonConstans.pvGenPoweActor);
HashMap<String, String> stringHashMap13 = new HashMap<>(); HashMap<String, String> stringHashMap13 = new HashMap<>();
stringHashMap13.put("title1", String.format("%.2f", (powerOfAnnualFD.get() + powerOfAnnualGF.get()) * 0.000832)); stringHashMap13.put("title1", String.format("%.2f", (totalAnnual * CommonConstans.carbonDioxide)));
stringHashMap13.put("title2", "二氧化碳减排量(万t)"); stringHashMap13.put("title2", "二氧化碳减排量(万t)");
list3.add(stringHashMap13); list3.add(stringHashMap13);
HashMap<String, String> stringHashMap14 = new HashMap<>(); HashMap<String, String> stringHashMap14 = new HashMap<>();
stringHashMap14.put("title1", String.format("%.2f", (powerOfAnnualFD.get() + powerOfAnnualGF.get()) * 0.0003049)); stringHashMap14.put("title1", String.format("%.2f", (totalAnnual * CommonConstans.standardCoal)));
stringHashMap14.put("title2", "节约标准煤(万t)"); stringHashMap14.put("title2", "节约标准煤(万t)");
list3.add(stringHashMap14); list3.add(stringHashMap14);
HashMap<String, String> stringHashMap15 = new HashMap<>(); HashMap<String, String> stringHashMap15 = new HashMap<>();
stringHashMap15.put("title1", String.format("%.2f", (powerOfAnnualFD.get() + powerOfAnnualGF.get()) * 0.00032)); stringHashMap15.put("title1", String.format("%.2f", (totalAnnual * CommonConstans.toner * CommonConstans.tToWT)));
stringHashMap15.put("title2", "碳粉尘减排量(万t)"); stringHashMap15.put("title2", "碳粉尘减排量(万t)");
list3.add(stringHashMap15); list3.add(stringHashMap15);
HashMap<String, String> stringHashMap16 = new HashMap<>(); HashMap<String, String> stringHashMap16 = new HashMap<>();
stringHashMap16.put("title1", String.format("%.2f", (powerOfAnnualFD.get() + powerOfAnnualGF.get()) * 0.0016)); stringHashMap16.put("title1", String.format("%.2f", (totalAnnual * CommonConstans.sulfurDioxide * CommonConstans.tToWT)));
stringHashMap16.put("title2", "二氧化硫减排量(万t)"); stringHashMap16.put("title2", "二氧化硫减排量(万t)");
list3.add(stringHashMap16); list3.add(stringHashMap16);
page3.setRecords(list3); page3.setRecords(list3);
...@@ -932,7 +945,7 @@ public class MonitoringServiceImpl { ...@@ -932,7 +945,7 @@ public class MonitoringServiceImpl {
stationBasic.setAddress(String.format("%.2f", commonServiceImpl.getTotalByIndicatior(mapList, "年发电量"))); stationBasic.setAddress(String.format("%.2f", commonServiceImpl.getTotalByIndicatior(mapList, "年发电量")));
} else { } else {
mapList = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and (equipmentIndexName='日发电量' or equipmentIndexName='月发电量' or equipmentIndexName='年发电量' )"); mapList = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and (equipmentIndexName='日发电量' or equipmentIndexName='月发电量' or equipmentIndexName='年发电量' )");
stationBasic.setAddress(String.format("%.2f", commonServiceImpl.getTotalByIndicatior(mapList, "年发电量") / 10000)); stationBasic.setAddress(String.format("%.2f", commonServiceImpl.getTotalByIndicatior(mapList, "年发电量") * CommonConstans.pvGenPoweActor));
} }
}); });
List<StationBasic> fdzList = stationBasicListAll.stream().filter(stationBasic -> stationBasic.getStationType().equals("FDZ")).collect(Collectors.toList()); List<StationBasic> fdzList = stationBasicListAll.stream().filter(stationBasic -> stationBasic.getStationType().equals("FDZ")).collect(Collectors.toList());
...@@ -1070,4 +1083,8 @@ public class MonitoringServiceImpl { ...@@ -1070,4 +1083,8 @@ public class MonitoringServiceImpl {
result.put("footerList", footerList); result.put("footerList", footerList);
return result; return result;
} }
public String getSecDays(String secStartDate) {
return String.valueOf(DateUtil.between(DateUtil.parse(secStartDate), DateUtil.date(), DateUnit.DAY));
}
} }
...@@ -757,7 +757,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -757,7 +757,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
Long sequenceNbr = companyModelFeignClientResult.getResult().getSequenceNbr(); Long sequenceNbr = companyModelFeignClientResult.getResult().getSequenceNbr();
// 查询企业对应角色下的用户 // 查询企业对应角色下的用户
logger.info("向privilege发送参数roleId,companyId,{},{}", roleId, sequenceNbr); logger.info("向privilege发送参数roleId,companyId,{},{}", roleId, sequenceNbr);
FeignClientResult<List<AgencyUserModel>> listFeignClientResult = Privilege.agencyUserClient.queryByCompanyRoles(sequenceNbr, roleId, null, null); FeignClientResult<List<AgencyUserModel>> listFeignClientResult = Privilege.agencyUserClient.queryByCompanyId(sequenceNbr, roleId, null, null);
logger.info("privilege返回用户信息,{}", JSONObject.toJSONString(listFeignClientResult)); logger.info("privilege返回用户信息,{}", JSONObject.toJSONString(listFeignClientResult));
if (!ObjectUtils.isEmpty(listFeignClientResult) && !ObjectUtils.isEmpty(listFeignClientResult.getResult())){ if (!ObjectUtils.isEmpty(listFeignClientResult) && !ObjectUtils.isEmpty(listFeignClientResult.getResult())){
listFeignClientResult.getResult().forEach(item ->{ listFeignClientResult.getResult().forEach(item ->{
......
...@@ -294,24 +294,24 @@ ...@@ -294,24 +294,24 @@
<repository> <repository>
<id>Releases</id> <id>Releases</id>
<name>Releases</name> <name>Releases</name>
<url>http://113.142.68.105:8081/nexus/content/repositories/releases/</url> <url>http://36.46.149.14:8081/nexus/content/repositories/releases/</url>
</repository> </repository>
<repository> <repository>
<id>com.e-iceblue</id> <id>com.e-iceblue</id>
<name>e-iceblue</name> <name>e-iceblue</name>
<url>http://113.142.68.105:8081/nexus/content/groups/public/</url> <url>http://36.46.149.14:8081/nexus/content/groups/public/</url>
</repository> </repository>
<repository> <repository>
<id>Snapshots</id> <id>Snapshots</id>
<name>Snapshots</name> <name>Snapshots</name>
<url>http://113.142.68.105:8081/nexus/content/repositories/snapshots/</url> <url>http://36.46.149.14:8081/nexus/content/repositories/snapshots/</url>
</repository> </repository>
<repository> <repository>
<id>thirdparty</id> <id>thirdparty</id>
<name>thirdparty</name> <name>thirdparty</name>
<url>http://113.142.68.105:8081/nexus/content/repositories/thirdparty/</url> <url>http://36.46.149.14:8081/nexus/content/repositories/thirdparty/</url>
</repository> </repository>
</repositories> </repositories>
......
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