Commit 93071dca authored by caotao's avatar caotao

运行监盘集成tdengine且iot历史数据从tdengine查询

parent e8717d2a
......@@ -46,6 +46,11 @@
<version>1.9.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId>
<version>3.2.4</version>
</dependency>
</dependencies>
<build>
......
package com.yeejoin.amos.boot.module.jxiop.biz.config;
import com.alibaba.druid.pool.DruidDataSource;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
/**
* 从数据源配置
* 若需要配置更多数据源 , 直接在yml中添加数据源配置再增加相应的新的数据源配置类即可
*/
@Configuration
@MapperScan(basePackages = "com.yeejoin.amos.boot.module.jxiop.biz.tdmapper", sqlSessionFactoryRef = "taosSqlSessionFactory")
public class TdEngineConfig {
private Logger logger = LoggerFactory.getLogger(TdEngineConfig.class);
// 精确到 cluster 目录,以便跟其他数据源隔离
private static final String MAPPER_LOCATION = "classpath*:mapper/tdengine/*.xml";
@Value("${spring.db3.datasource.url}")
private String dbUrl;
@Value("${spring.db3.datasource.username}")
private String username;
@Value("${spring.db3.datasource.password}")
private String password;
@Value("${spring.db3.datasource.driver-class-name}")
private String driverClassName;
@Bean(name = "taosDataSource") //声明其为Bean实例
public DataSource clusterDataSource() {
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(this.dbUrl);
datasource.setUsername(username);
datasource.setPassword(password);
datasource.setDriverClassName(driverClassName);
return datasource;
}
@Bean(name = "taosTransactionManager")
public DataSourceTransactionManager clusterTransactionManager() {
return new DataSourceTransactionManager(clusterDataSource());
}
@Bean(name = "taosSqlSessionFactory")
public SqlSessionFactory clusterSqlSessionFactory(@Qualifier("taosDataSource") DataSource culsterDataSource)
throws Exception {
final MybatisSqlSessionFactoryBean sessionFactory = new MybatisSqlSessionFactoryBean();
sessionFactory.setDataSource(culsterDataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources(TdEngineConfig.MAPPER_LOCATION));
sessionFactory.setTypeAliasesPackage("com.yeejoin.amos.boot.module.jxiop.biz.entity");
//mybatis 数据库字段与实体类属性驼峰映射配置
sessionFactory.getObject().getConfiguration().setMapUnderscoreToCamelCase(true);
return sessionFactory.getObject();
}
}
......@@ -6,7 +6,8 @@ import java.util.HashMap;
public class CommonConstans {
//光伏发电量系数
public static final Double pvGenPoweActor = 0.000001;
public static final Double pvGenPoweActor = 0.00001;
public static final Double pvGenPoweActorDay = 0.01;
// 风电站:
// (日/月/年)发电量=场站所有风机(日/月/年)发电量总和
// 装机容量=场站所有风机装机容量总和
......@@ -33,6 +34,10 @@ public class CommonConstans {
public static final Double tToWT = 0.0001;
//万Kwh转MV
public static final Integer wkwhToMv = 10;
//kw转MV
public static final Double kwToMv =0.0001 ;
// 正常运行 发电状态=1
// 告警运行 报警状态=1
// 正常停机 停机状态=1
......
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -19,6 +20,7 @@ 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.EquipAlarmEventServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import com.yeejoin.amos.component.influxdb.InfluxdbUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -69,6 +71,8 @@ public class MonitorFanIdxController extends BaseController {
@Value("${fan.statuts.stattuspath}")
private String fanStatusImagePathPrefix;
@Autowired
IndicatorDataMapper indicatorDataMapper;
@Autowired
MonitorFanIndicatorMapper monitorFanIndicatorMapper;
......@@ -609,23 +613,21 @@ public class MonitorFanIdxController extends BaseController {
for (String column : columnList) {
Double result = commonService.getTotalByIndicatiorByGF(gatewayId, column);
columnMap.put(column, String.format("%.2f",result));
columnMap.put(column, String.format("%.2f",result*CommonConstans.pvGenPoweActor));
}
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("南瑞光差保护_313P","WTX-801_25_WTX-801_总辐射累计","WTX-801_25_WTX-801_总辐射"));
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("南瑞光差保护_313P","WTX-801_25_WTX-801_总辐射累计","WTX-801_25_WTX-801_总辐射","313光差保护_总反向有功电度"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
List<ESEquipments> result1 = commonService.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
columnMap.put("有功功率", String.format("%.2f", commonService.getSumByEquipmentIndxName(result1,"南瑞光差保护_313P")/1000));
columnMap.put("有功功率", String.format("%.2f", commonService.getSumByEquipmentIndxName(result1,"南瑞光差保护_313P")*CommonConstans.kwToMv));
// mapList = influxdbUtil.query("SELECT * FROM indicators_" + stationBasic.getFanGatewayId() + " where frontModule=~/逆变器/ and(equipmentIndexName='日发电量' or equipmentIndexName='月发电量' or equipmentIndexName='年发电量' or equipmentIndexName='有功功率')");
//日-月-年-发电量需要保留四位小数问题修改
String num = monitorFanIndicator.getEquipCount(gatewayId,"GF");
columnMap.put("风机台数",num);
Double capacityl = commonService.getStationCapactityByStationWerks(stationBasic.getStationNumber());
//装机容量保留两位小数
columnMap.put("装机容量",String.format("%.2f",capacityl));
......@@ -658,7 +660,12 @@ public class MonitorFanIdxController extends BaseController {
data8.put("title",String.format("%.2f",commonService.getSumByEquipmentIndxName(result1,"WTX-801_25_WTX-801_总辐射累计")));
objects.add(data8);
Map<String, Object> data9 = new HashMap<>();
data9.put("title","0.00%");//综合效率
//综合效率 = 发电量/理论发电量
//理论发电量 = 峰值日照数 * 总装机容量
//峰值日照数 = 累计辐照度/3.6
Double powerAll = Double.valueOf((indicatorDataMapper.selectLastDataOfPower("313光差保护_总反向有功电度",boosterGatewayId).getValueF()*CommonConstans.kwToMv*0.028));
Double overallEfficiency = powerAll/((commonService.getSumByEquipmentIndxName(result1,"WTX-801_25_WTX-801_总辐射累计")/3.6)*capacityl);
data9.put("title",String.format("%.2f",overallEfficiency*100)+"%");//综合效率
objects.add(data9);
IPage<Map<String,Object>> result = new Page<>();
result.setRecords(objects);
......
package com.yeejoin.amos.boot.module.jxiop.biz.entity;
import io.github.classgraph.json.Id;
import lombok.Data;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import java.sql.Timestamp;
import java.util.Date;
@Data
public class IndicatorData {
private String id;
private String address;
private String dataType;
private String equipmentSpecificName;
private String gatewayId;
private String isAlarm;
private Date createdTime;
private String unit;
private String value;
private Float valueF ;
private String valueLabel;
private String equipmentIndexName;
private String equipmentNumber;
private String displayName;
}
......@@ -43,34 +43,34 @@ public class StationCacheDataInit implements CommandLineRunner {
Logger logger = LoggerFactory.getLogger(StationCacheDataInit.class);
public void run(String... args) throws Exception {
List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>();
redisTemplate.delete("station_info_cache");
List<Region> regionList = regionMapper.selectList(new QueryWrapper<Region>().eq("LEVEL", 1));
List<MapRegion> mapRegionList = mapRegionMapper.selectList(new QueryWrapper<MapRegion>().isNotNull("name"));
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("belong_area").isNotNull("fan_gateway_id"));
stationBasicList.forEach(stationBasic -> {
StationCacheInfoDto stationCacheInfoDto = new StationCacheInfoDto();
stationCacheInfoDto.setStationId(stationBasic.getSequenceNbr().toString());
stationCacheInfoDto.setStationName(stationBasic.getStationName());
stationCacheInfoDto.setStationType(stationBasic.getStationType());
stationCacheInfoDto.setBelongProvince(regionList.stream().filter(region -> region.getRegionCode().toString().equals(stationBasic.getBelongArea().replace("[", "").split(",")[0])).map(region -> region.getRegionName()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setBelongArea(mapRegionList.stream().filter(mapRegion -> mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0, 2)) || mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0, 3))).map(mapRegion -> mapRegion.getName()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setInstalledCapacity(String.format("%.2f", sjglZsjZsbtzMapper.getStationCapactityByStationWerks(stationBasic.getStationNumber())));
try {
List<QueryDto> queryDtoList = new ArrayList<>();
queryDtoList.add(new QueryDto("gatewayId", stationBasic.getFanGatewayId()));
queryDtoList.add(new QueryDto("equipmentIndexName.keyword", "有功功率"));
if (!stationBasic.getStationType().equals("FDZ")) {
queryDtoList.add(new QueryDto("frontModule", "逆变器"));
}
stationCacheInfoDto.setEquipmentNumbers(commonServiceImpl.getCount(queryDtoList, "equipmentNumber.Keyword", ESEquipments.class).toString());
} catch (Exception exception) {
logger.info("--------------------查询ES错误---------------------------");
}
stationCacheInfoDto.setFanGatewayId(stationBasic.getFanGatewayId());
stationCacheInfoDto.setBoosterGatewayId(stationBasic.getBoosterGatewayId());
stationCacheInfoDtos.add(stationCacheInfoDto);
});
redisTemplate.opsForList().leftPushAll("station_info_cache", stationCacheInfoDtos);
// List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>();
// redisTemplate.delete("station_info_cache");
// List<Region> regionList = regionMapper.selectList(new QueryWrapper<Region>().eq("LEVEL", 1));
// List<MapRegion> mapRegionList = mapRegionMapper.selectList(new QueryWrapper<MapRegion>().isNotNull("name"));
// List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("belong_area").isNotNull("fan_gateway_id"));
// stationBasicList.forEach(stationBasic -> {
// StationCacheInfoDto stationCacheInfoDto = new StationCacheInfoDto();
// stationCacheInfoDto.setStationId(stationBasic.getSequenceNbr().toString());
// stationCacheInfoDto.setStationName(stationBasic.getStationName());
// stationCacheInfoDto.setStationType(stationBasic.getStationType());
// stationCacheInfoDto.setBelongProvince(regionList.stream().filter(region -> region.getRegionCode().toString().equals(stationBasic.getBelongArea().replace("[", "").split(",")[0])).map(region -> region.getRegionName()).collect(Collectors.toList()).get(0));
// stationCacheInfoDto.setBelongArea(mapRegionList.stream().filter(mapRegion -> mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0, 2)) || mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0, 3))).map(mapRegion -> mapRegion.getName()).collect(Collectors.toList()).get(0));
// stationCacheInfoDto.setInstalledCapacity(String.format("%.2f", sjglZsjZsbtzMapper.getStationCapactityByStationWerks(stationBasic.getStationNumber())));
// try {
// List<QueryDto> queryDtoList = new ArrayList<>();
// queryDtoList.add(new QueryDto("gatewayId", stationBasic.getFanGatewayId()));
// queryDtoList.add(new QueryDto("equipmentIndexName.keyword", "有功功率"));
// if (!stationBasic.getStationType().equals("FDZ")) {
// queryDtoList.add(new QueryDto("frontModule", "逆变器"));
// }
// stationCacheInfoDto.setEquipmentNumbers(commonServiceImpl.getCount(queryDtoList, "equipmentNumber.Keyword", ESEquipments.class).toString());
// } catch (Exception exception) {
// logger.info("--------------------查询ES错误---------------------------");
// }
// stationCacheInfoDto.setFanGatewayId(stationBasic.getFanGatewayId());
// stationCacheInfoDto.setBoosterGatewayId(stationBasic.getBoosterGatewayId());
// stationCacheInfoDtos.add(stationCacheInfoDto);
// });
// redisTemplate.opsForList().leftPushAll("station_info_cache", stationCacheInfoDtos);
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.biz.dto.ColModel;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.DataGridMock;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.EquipAlarmEventDto;
......@@ -11,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
......@@ -19,16 +23,19 @@ public class EquipAlarmEventServiceImpl extends BaseService<EquipAlarmEventDto,
@Autowired
EquipAlarmEventMapper equipAlarmEventMapper;
@Autowired
StationBasicMapper stationBasicMapper;
public ResultsData getEventByEquipIndex(String gatewayId, int current, int size, String equipIndex, String frontModule) {
public ResultsData getEventByEquipIndex(String gatewayId, int current, int size, String equipIndex, String frontModule) {
List<EquipAlarmEvent> equipAlarmEvents = new ArrayList<>();
//参数传递进来的实际上为场站id
StationBasic stationBasic = this.stationBasicMapper.selectById(gatewayId);
LambdaQueryWrapper<EquipAlarmEvent> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(EquipAlarmEvent::getEquipIndex, equipIndex);
queryWrapper.eq(EquipAlarmEvent::getGatewayId, gatewayId);
queryWrapper.eq(EquipAlarmEvent::getGatewayId, stationBasic.getFanGatewayId());
queryWrapper.eq(EquipAlarmEvent::getFrontModule, frontModule);
queryWrapper.orderByDesc(EquipAlarmEvent::getCreatedTime);
List<EquipAlarmEvent> equipAlarmEvents = equipAlarmEventMapper.selectList(queryWrapper);
equipAlarmEvents = equipAlarmEventMapper.selectList(queryWrapper);
DataGridMock DataGridMock = new DataGridMock(current, equipAlarmEvents.size(), false, current, equipAlarmEvents);
ColModel colModelEventMovement = new ColModel("equipName", "equipName", "设备名", "设备名", "dataGrid", "equipName");
ColModel colModelStationName = new ColModel("alarmDesc", "alarmDesc", "事件描述", "事件描述", "dataGrid", "alarmDesc");
......@@ -37,6 +44,4 @@ public class EquipAlarmEventServiceImpl extends BaseService<EquipAlarmEventDto,
ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
return resultsData;
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -26,6 +27,7 @@ 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.entity.*;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IMonitorFanIndicator;
import com.yeejoin.amos.component.robot.BadRequest;
......@@ -47,6 +49,7 @@ import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.text.Collator;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
......@@ -106,6 +109,8 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
@Value("classpath:/json/fanlocation.json")
private Resource fanlocation;
@Autowired
private IndicatorDataMapper indicatorDataMapper;
private List<Map> list;
......@@ -118,17 +123,17 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
@Override
public ResultsData getNationWideInfo(int current, int size, String gateway, String equipmentNumber) {
String table = gateway;
Map<String,List<String>> queryCodntion = new HashMap<>();
queryCodntion.put(CommonConstans.QueryStringGateWayId,Arrays.asList(gateway));
queryCodntion.put(CommonConstans.QueryStringIsAlarmKeyword,Arrays.asList("1"));
List<ESEquipments> alldata = commonServiceImpl.getListDataByCondtionsAndLike(queryCodntion,null,ESEquipments.class, null);
List<ESEquipments> waringData = alldata.stream().filter(esEquipments -> !esEquipments.getValue().equals("0.0")&&!esEquipments.getValue().equals(esEquipments.getValueLabel())).collect(Collectors.toList());
Map<String, List<String>> queryCodntion = new HashMap<>();
queryCodntion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gateway));
queryCodntion.put(CommonConstans.QueryStringIsAlarmKeyword, Arrays.asList("1"));
List<ESEquipments> alldata = commonServiceImpl.getListDataByCondtionsAndLike(queryCodntion, null, ESEquipments.class, null);
List<ESEquipments> waringData = alldata.stream().filter(esEquipments -> !esEquipments.getValue().equals("0.0") && !esEquipments.getValue().equals(esEquipments.getValueLabel())).collect(Collectors.toList());
if (StringUtils.isNotEmpty(equipmentNumber)) {
waringData= waringData.stream().filter(esEquipments -> esEquipments.getEquipmentNumber().equals(equipmentNumber)).collect(Collectors.toList());
waringData = waringData.stream().filter(esEquipments -> esEquipments.getEquipmentNumber().equals(equipmentNumber)).collect(Collectors.toList());
}
if (CollectionUtils.isNotEmpty(waringData)) {
Integer newSize = waringData.size() >= size ? size : waringData.size();
waringData=waringData.stream().sorted(Comparator.comparing(ESEquipments::getCreatedTime).reversed()).collect(Collectors.toList()).subList(((current - 1) * newSize),(current*newSize));
waringData = waringData.stream().sorted(Comparator.comparing(ESEquipments::getCreatedTime).reversed()).collect(Collectors.toList()).subList(((current - 1) * newSize), (current * newSize));
}
//对于查询到的告警信息进行按照时间顺序进行排序
DataGridMock DataGridMock = new DataGridMock(current, !waringData.isEmpty() ? waringData.size() : 0, false, current, waringData);
......@@ -150,24 +155,24 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
StationBasic stationBasic = stationBasicMapper.selectById(stationBasicId);
String gateway = stationBasic.getFanGatewayId();
Map<String,List<String>> queryCodntion = new HashMap<>();
queryCodntion.put(CommonConstans.QueryStringGateWayId,Arrays.asList(gateway));
queryCodntion.put(CommonConstans.QueryStringIsAlarmKeyword,Arrays.asList("1"));
Map<String, List<String>> queryCodntion = new HashMap<>();
queryCodntion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gateway));
queryCodntion.put(CommonConstans.QueryStringIsAlarmKeyword, Arrays.asList("1"));
HashMap<String, String> notMustMap = new HashMap<>();
notMustMap.put(CommonConstans.QueryStringValueKeyword, "0.0");
notMustMap.put(CommonConstans.QueryStringValueLabelKeyword, "0.0");
Integer newSize = size;
List<ESEquipments> lisSort= new ArrayList<>();
List<ESEquipments> waringData = commonServiceImpl.getListDataByCondtionsByValueNotEqValueLabel(queryCodntion,null, notMustMap, ESEquipments.class);
List<ESEquipments> lisSort = new ArrayList<>();
List<ESEquipments> waringData = commonServiceImpl.getListDataByCondtionsByValueNotEqValueLabel(queryCodntion, null, notMustMap, ESEquipments.class);
if (StringUtils.isNotEmpty(equipmentNumber) && CollectionUtils.isNotEmpty(waringData)) {
waringData= waringData.stream().filter(esEquipments -> esEquipments.getEquipmentNumber().equals(equipmentNumber)&&esEquipments.getEquipmentSpecificName().contains("风机")).collect(Collectors.toList());
waringData = waringData.stream().filter(esEquipments -> esEquipments.getEquipmentNumber().equals(equipmentNumber) && esEquipments.getEquipmentSpecificName().contains("风机")).collect(Collectors.toList());
newSize = waringData.size() >= size ? size : waringData.size();
lisSort = waringData.stream().sorted(Comparator.comparing(ESEquipments::getCreatedTime).reversed()).collect(Collectors.toList()).subList(((current - 1) * newSize),(current*newSize));
lisSort = waringData.stream().sorted(Comparator.comparing(ESEquipments::getCreatedTime).reversed()).collect(Collectors.toList()).subList(((current - 1) * newSize), (current * newSize));
}
//对于查询到的告警信息进行按照时间顺序进行排序
//构建平台数据
DataGridMock DataGridMock = new DataGridMock(current, CollectionUtils.isNotEmpty(waringData)? waringData.size(): 0, false, current, lisSort);
DataGridMock DataGridMock = new DataGridMock(current, CollectionUtils.isNotEmpty(waringData) ? waringData.size() : 0, false, current, lisSort);
ColModel colModelequipmentNumber = new ColModel("equipmentNumber", "equipmentSpecificName", "风机号", "风机号", "dataGrid", "equipmentNumber");
ColModel colModelvalueLabel = new ColModel("valueLabel", "valueLabel", "事件描述", "事件描述", "dataGrid", "valueLabel");
ColModel colModelcreatedTime = new ColModel("createdTime", "createdTime", "发生时间", "发生时间", "dataGrid", "createdTime");
......@@ -303,7 +308,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
colorMap.put("通讯中断", "#7d8e95");
List<ESEquipmentsDTO> resultList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(equipNumList)){
if (CollectionUtils.isNotEmpty(equipNumList)) {
equipNumList.forEach(item -> {
String status = ObjectUtils.isEmpty(CommonConstans.fanStatus.get(collect.get(item.getEquipmentNumber()))) ? "通讯中断" : CommonConstans.fanStatus.get(collect.get(item.getEquipmentNumber()));
item.setAddress(status);
......@@ -394,7 +399,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
ESEquipments esEquipments = result.get(i);
if (esEquipments.getEquipmentIndexName().contains("温度")) {
xList.add(esEquipments.getEquipmentIndexName());
yList.add(null == esEquipments.getValueF()?"0": esEquipments.getValueF().toString());
yList.add(null == esEquipments.getValueF() ? "0" : esEquipments.getValueF().toString());
}
}
realTimeTemperatureResult.put("axisData", xList);
......@@ -427,18 +432,18 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
}
}
public String getEquipCount(String gatewayId,String stationType) {
public String getEquipCount(String gatewayId, String stationType) {
Map<String, List<String>> queryCondtion1 = new HashMap<>();
if (stationType.equals("FDZ")){
if (stationType.equals("FDZ")) {
queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("有功功率"));
}else {
} else {
queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("运行"));
}
queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
List<ESEquipments> equipNumList = commonServiceImpl.getListDataByCondtions(queryCondtion1, null, ESEquipments.class);
if (!CollectionUtils.isEmpty(equipNumList)){
return equipNumList.size()+"";
}
if (!CollectionUtils.isEmpty(equipNumList)) {
return equipNumList.size() + "";
}
return "0";
}
......@@ -474,67 +479,57 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
}
public Map<String, Object> getDetailsWindSpeed(String gatewayId, String name) {
Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
String time = "";
try {
time = DateUtils.dateFormat(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
} catch (ParseException e) {
e.printStackTrace();
Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
String startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(currentDayEndTime, DateUtils.DATE_TIME_PATTERN);
List<IndicatorData> indicatorDataListWindSpeed = new ArrayList<>();
List<IndicatorData> indicatorDataListActivePower = new ArrayList<>();
indicatorDataListWindSpeed = indicatorDataMapper.selectDataByequipmentIndexNameAndtimeAndEquipmentNumber("瞬时风速", name, startTime, endTime, gatewayId);
indicatorDataListActivePower = indicatorDataMapper.selectDataByequipmentIndexNameAndtimeAndEquipmentNumber("有功功率", name, startTime, endTime, gatewayId);
List<String> windSpeeds = new ArrayList<>();
List<String> activePowers = new ArrayList<>();
List<String> axisData = new ArrayList<>();
for (int i = 0; i < indicatorDataListWindSpeed.size(); i++) {
windSpeeds.add(indicatorDataListWindSpeed.get(i).getValue());
activePowers.add(indicatorDataListActivePower.get(i).getValue());
axisData.add(DateUtil.format(indicatorDataListWindSpeed.get(i).getCreatedTime(), "HH:mm"));
}
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)";
List<IndicatorsDto> indicatorsDtoList = influxDButils.getListDataAll(sql, 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> collects = indicatorsDtoLists.stream().collect(Collectors.toMap(IndicatorsDto::getTime, IndicatorsDto::getDistinct, (key1, ky2) -> (String) key1, LinkedHashMap::new));
Collection<String> values = collect.values();
Collection<String> valuess = collects.values();
Set<String> keySet = collect.keySet();
Set<String> keySets = collects.keySet();
List<Map<String, Object>> seriesData = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
Map<String, Object> map1 = new HashMap<>();
Map<String, Object> map2 = new HashMap<>();
map1.put("data", values);
map2.put("data", valuess);
map1.put("data", windSpeeds);
map2.put("data", activePowers);
seriesData.add(map1);
seriesData.add(map2);
map.put("seriesData", seriesData);
map.put("axisData", keySet.size() > keySets.size() ? keySet : keySets);
map.put("axisData", axisData);
return map;
}
public Map<String, Object> getDetailsWindSpeeds(String gatewayId, String name) {
Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
String time = "";
try {
time = DateUtils.dateFormat(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
} catch (ParseException e) {
e.printStackTrace();
}
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
queryCondtion.put(CommonConstans.QueryStringEquipmentNumberKeyword, Arrays.asList(name));
List<ESEquipments> indicatorsDtoList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
name = indicatorsDtoList.get(0).getEquipmentSpecificName();
StringBuffer param = new StringBuffer();
String[] split = name.replace("#", "").split("/");
for (int i = 0; i < split.length; i++) {
param.append(" and equipmentSpecificName =~/" + split[i] + "/");
Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
String startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(currentDayEndTime, DateUtils.DATE_TIME_PATTERN);
List<IndicatorData> indicatorDataListActivePowers = new ArrayList<>();
indicatorDataListActivePowers= indicatorDataMapper.selectDataByequipmentIndexNameAndtimeAndEquipmentNumber("有功功率",name,startTime,endTime,gatewayId);
List<String> axisData= new ArrayList<>();
List<String> activePowers = new ArrayList<>();
for (int i = 0; i < indicatorDataListActivePowers.size(); i++) {
activePowers.add(indicatorDataListActivePowers.get(i).getValue());
axisData.add(DateUtil.format(indicatorDataListActivePowers.get(i).getCreatedTime(),"HH:mm"));
}
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);
LinkedHashMap<String, String> collects = indicatorsDtoLists.stream().collect(Collectors.toMap(IndicatorsDto::getTime, IndicatorsDto::getDistinct, (key1, ky2) -> (String) key1, LinkedHashMap::new));
Collection<String> valuess = collects.values();
Set<String> keySets = collects.keySet();
List<Map<String, Object>> seriesData = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
Map<String, Object> map2 = new HashMap<>();
map2.put("data", valuess);
map2.put("data", activePowers);
seriesData.add(map2);
map.put("seriesData", seriesData);
map.put("axisData", keySets);
map.put("axisData", axisData);
return map;
}
......@@ -660,7 +655,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
temporaryData.setCreatedTime(time.split(" ")[1]);
temporaryData.setEquipmentIndexName(indicatorsDto.getEquipmentIndexName());
temporaryData.setGatewayId(stationBasic.getFanGatewayId());
temporaryData.setValue(null ==indicatorsDto.getValueF()?0:indicatorsDto.getValueF());
temporaryData.setValue(null == indicatorsDto.getValueF() ? 0 : indicatorsDto.getValueF());
temporaryData.setEquipmentNumber(indicatorsDto.getEquipmentNumber());
temporaryDatas.add(temporaryData);
} catch (Exception e) {
......@@ -674,7 +669,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
temporaryData.setCreatedTime(time.split(" ")[1]);
temporaryData.setEquipmentIndexName("有功功率");
temporaryData.setGatewayId(stationBasic.getFanGatewayId());
temporaryData.setValue(null ==indicatorsDto.getValueF()?0:indicatorsDto.getValueF());
temporaryData.setValue(null == indicatorsDto.getValueF() ? 0 : indicatorsDto.getValueF());
temporaryData.setEquipmentNumber(indicatorsDto.getEquipmentNumber());
temporaryDatass.add(temporaryData);
} catch (Exception e) {
......@@ -723,7 +718,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
temporaryData.setBatchNo(timeInMillis);
temporaryData.setCreatedTime(time.split(" ")[1]);
temporaryData.setGatewayId(indicatorsDto.getGatewayId());
temporaryData.setValue(indicatorsDto.getValueF()/1000);
temporaryData.setValue(indicatorsDto.getValueF() / 1000);
temporaryData.setEquipmentNumber(indicatorsDto.getEquipmentNumber());
temporaryData.setEquipmentIndexName("有功功率");
temporaryDatass.add(temporaryData);
......@@ -826,8 +821,8 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
Map<String, String> likeCodtion = new HashMap<>();
likeCodtion.put(CommonConstans.QueryStringFrontMoudle, frontModule);
likeCodtion.put(CommonConstans.QueryStringDisplayName+".keyword", "合位");
List<ESEquipments> listData = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class,likeCodtion);
likeCodtion.put(CommonConstans.QueryStringDisplayName + ".keyword", "合位");
List<ESEquipments> listData = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class, likeCodtion);
Collator instance = Collator.getInstance(Locale.CHINA);
Collections.sort(listData, (e1, e2) -> {
......@@ -840,9 +835,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
Map<String, Object> statusMap = new HashMap<>();
if (frontModule.equals("前光")) {
likeCodtion.remove(CommonConstans.QueryStringDisplayName+".keyword");
likeCodtion.put(CommonConstans.QueryStringSystemType+".keyword", "模拟量");
List<ESEquipments> value = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class,likeCodtion);
likeCodtion.remove(CommonConstans.QueryStringDisplayName + ".keyword");
likeCodtion.put(CommonConstans.QueryStringSystemType + ".keyword", "模拟量");
List<ESEquipments> value = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class, likeCodtion);
for (ESEquipments indicatorsDto : value) {
Double aDouble = Double.valueOf(indicatorsDto.getValue());
......@@ -903,12 +898,12 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
List<String> numList = Arrays.asList(dataMap.get("equipNum").toString().split(","));
List<Map<String, Object>> statusMaps = new ArrayList<>();
for (ESEquipments listDatum : listData) {
if (null == listDatum.getValueF()){
if (null == listDatum.getValueF()) {
listDatum.setValueF(0F);
}
for (ESEquipments indicatorsDto : listData1) {
if (listDatum.getEquipmentNumber().equals(indicatorsDto.getEquipmentNumber())) {
listDatum.setValueLabel(String.valueOf(indicatorsDto.getValueF() == null?0:indicatorsDto.getValueF()/1000));
listDatum.setValueLabel(String.valueOf(indicatorsDto.getValueF() == null ? 0 : indicatorsDto.getValueF() / 1000));
}
}
......@@ -1053,9 +1048,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
for (ESEquipments indicatorsDto : stringListEntry.getValue()) {
stringStringHashMap.put(ElectricQuantity.getCode(indicatorsDto.getDisplayName()), String.format("%.3f", ObjectUtils.isEmpty(indicatorsDto.getValueF()) ? 0.0 : indicatorsDto.getValueF()));
}
if (stringListEntry.getKey().contains("SVG")){
if (stringListEntry.getKey().contains("SVG")) {
resultList1.add(stringStringHashMap);
}else {
} else {
resultList.add(stringStringHashMap);
}
}
......@@ -1159,9 +1154,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
HashMap<String, Object> resultMap = new HashMap<>();
xianData.forEach(item -> {
if ("220kVⅠ母PT".equals(item.getFrontModule())) {
resultMap.put("220" + item.getDisplayName(), item.getValueF() ==null?"0":keepTwoDecimalPlaces(item.getValueF().toString()));
resultMap.put("220" + item.getDisplayName(), item.getValueF() == null ? "0" : keepTwoDecimalPlaces(item.getValueF().toString()));
} else if ("35kVⅠ母PT".equals(item.getFrontModule())) {
resultMap.put("35" + item.getDisplayName(),item.getValueF() ==null?"0": keepTwoDecimalPlaces(item.getValueF().toString()));
resultMap.put("35" + item.getDisplayName(), item.getValueF() == null ? "0" : keepTwoDecimalPlaces(item.getValueF().toString()));
}
});
List<String> xyxDisplayNameList = Arrays.asList("Ia", "P", "Q", "Ux");
......@@ -1171,9 +1166,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
// 正向总有功正向总无功需要计算
dlbjSqlData.forEach(item -> {
if ("正向总有功".equals(item.getDisplayName())) {
resultMap.put("2000S1",item.getValueF() ==null?"0": keepTwoDecimalPlaces(String.valueOf((Double.parseDouble(item.getValueF().toString()) / 1000))));
resultMap.put("2000S1", item.getValueF() == null ? "0" : keepTwoDecimalPlaces(String.valueOf((Double.parseDouble(item.getValueF().toString()) / 1000))));
} else if ("正向总无功".equals(item.getDisplayName())) {
resultMap.put("2000S2",item.getValueF() ==null?"0": keepTwoDecimalPlaces(String.valueOf((Double.parseDouble(item.getValueF().toString()) / 1000))));
resultMap.put("2000S2", item.getValueF() == null ? "0" : keepTwoDecimalPlaces(String.valueOf((Double.parseDouble(item.getValueF().toString()) / 1000))));
}
});
......@@ -1227,13 +1222,13 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
stringStringHashMap.put("value3", "0.0");
listData.forEach(item -> {
if (item.getDisplayName().equals("Ia")) {
stringStringHashMap.put("value1",item.getValueF() ==null?"0": keepTwoDecimalPlaces(item.getValueF().toString()));
stringStringHashMap.put("value1", item.getValueF() == null ? "0" : keepTwoDecimalPlaces(item.getValueF().toString()));
}
if (item.getDisplayName().equals("P")) {
stringStringHashMap.put("value2",item.getValueF() ==null?"0": keepTwoDecimalPlaces(item.getValueF().toString()));
stringStringHashMap.put("value2", item.getValueF() == null ? "0" : keepTwoDecimalPlaces(item.getValueF().toString()));
}
if (item.getDisplayName().equals("Q")) {
stringStringHashMap.put("value3",item.getValueF() ==null?"0":keepTwoDecimalPlaces(item.getValueF().toString()));
stringStringHashMap.put("value3", item.getValueF() == null ? "0" : keepTwoDecimalPlaces(item.getValueF().toString()));
}
});
resultList.add(stringStringHashMap);
......@@ -1513,43 +1508,43 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
String load = String.format(CommonConstans.Twodecimalplaces, Double.parseDouble(String.valueOf(listData.get(0).getValueF())) / Double.parseDouble(stationCacheInfoDto.getInstalledCapacity()));
List<Map<String, Object>> list = temporaryDataMapper.timingTemporarysSorageDataByIndexName(gatewayId,equipmentIndexName);
Map<String,Object> map = new HashMap<>();
List<Map<String, Object>> list = temporaryDataMapper.timingTemporarysSorageDataByIndexName(gatewayId, equipmentIndexName);
Map<String, Object> map = new HashMap<>();
List<String> values = new ArrayList<>();
Set<String> time = new TreeSet<>();
String v = null ==list ?"":list.get(0).get("value").toString();
Set<String> time = new TreeSet<>();
String v = null == list ? "" : list.get(0).get("value").toString();
double min = Double.parseDouble(v);
double max = Double.parseDouble(v);
double mean = 0.0;
String minTime =null ==list?"":list.get(0).get("createdTime").toString();
String maxTime =null ==list?"":list.get(0).get("createdTime").toString();
String minTime = null == list ? "" : list.get(0).get("createdTime").toString();
String maxTime = null == list ? "" : list.get(0).get("createdTime").toString();
for (Map<String, Object> stringStringMap : list) {
double value = Double.parseDouble(stringStringMap.get("value").toString());
values.add( String.format("%.2f",value));
if (value < min){
min = value;
minTime = stringStringMap.get("createdTime").toString();
}else if (value > max){
max = value;
maxTime = stringStringMap.get("createdTime").toString();
}
time.add(stringStringMap.get("createdTime").toString());
double value = Double.parseDouble(stringStringMap.get("value").toString());
values.add(String.format("%.2f", value));
if (value < min) {
min = value;
minTime = stringStringMap.get("createdTime").toString();
} else if (value > max) {
max = value;
maxTime = stringStringMap.get("createdTime").toString();
}
time.add(stringStringMap.get("createdTime").toString());
}
for (String value : values) {
mean += Double.parseDouble(value);
}
mean = Double.parseDouble(String.format("%.2f",mean/values.size()));
mean = Double.parseDouble(String.format("%.2f", mean / values.size()));
List<Map<String,Object>> seriesData = new ArrayList<>();
List<Map<String, Object>> seriesData = new ArrayList<>();
map.put("mean",mean);
map.put("max",max);
map.put("min",min);
map.put("maxTime",maxTime);
map.put("minTime",minTime);
map.put("mean", mean);
map.put("max", max);
map.put("min", min);
map.put("maxTime", maxTime);
map.put("minTime", minTime);
map.put("load", load);
return map;
......@@ -1607,9 +1602,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
queryConditon.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
Map<String, String> shouldConditon = new HashMap<>();
shouldConditon.put(CommonConstans.QueryStringEquipmentIndexName, "合闸");
List<ESEquipments> list = commonServiceImpl.getListDataByCondtions(queryConditon, null, ESEquipments.class,shouldConditon);
List<ESEquipments> list = commonServiceImpl.getListDataByCondtions(queryConditon, null, ESEquipments.class, shouldConditon);
if (!ValidationUtil.isEmpty(list)) {
Map<String, List<ESEquipments>> collect = list.stream().filter(e->StringUtils.isNotBlank(e.getEquipmentNumber())).collect(Collectors.groupingBy(ESEquipments::getEquipmentNumber));
Map<String, List<ESEquipments>> collect = list.stream().filter(e -> StringUtils.isNotBlank(e.getEquipmentNumber())).collect(Collectors.groupingBy(ESEquipments::getEquipmentNumber));
for (String s : collect.keySet()) {
HashMap<String, Object> resultMap = new HashMap<>();
collect.get(s).stream().forEach(e -> {
......@@ -1743,38 +1738,23 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
public Map<String, Object> hlWindSpeeds(String gatewayId, String equipNum) {
Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
String time = "";
try {
time = DateUtils.dateFormat(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
} catch (ParseException e) {
e.printStackTrace();
}
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 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.getListDataAll(sql, IndicatorsDto.class);
Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
String startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(currentDayEndTime, DateUtils.DATE_TIME_PATTERN);
List<IndicatorData> originarPVs = indicatorDataMapper.selectDataByequipmentIndexNameAndtimeAndEquipmentNumberPv(equipNum,startTime,endTime,gatewayId);
originarPVs.size();
Map<String, Object> resultMap = new HashMap<>();
Map<String, List<IndicatorsDto>> data = dataList.stream().collect(Collectors.groupingBy(IndicatorsDto::getEquipmentIndexName, LinkedHashMap::new, Collectors.toList()));
int num = 0;
Map<String, List<IndicatorData>> data = originarPVs.stream().collect(Collectors.groupingBy(IndicatorData::getEquipmentIndexName, TreeMap::new, Collectors.toList()));
List<String> axisData = new ArrayList<>();
List<Map<String, Object>> seriesData = new ArrayList<>();
for (String s : data.keySet()) {
data.get(s).stream().forEach(e -> {
e.setTimeValue(e.getTime());
});
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(IndicatorData::getValue).collect(Collectors.toList());
axisData =data.get(s).stream().map(indicatorData -> DateUtil.format(indicatorData.getCreatedTime(),"HH:mm")).collect(Collectors.toList());
map.put("data", value);
// map.put("name","pv"+s.substring(4,6));
seriesData.add(map);
if (value.size() > num) {
Map<String, List<IndicatorsDto>> timeMap = data.get(s).stream().collect(Collectors.groupingBy(IndicatorsDto::getTimeValue, LinkedHashMap::new, Collectors.toList()));
resultMap.put("axisData", timeMap.keySet());
}
num = value.size() > num ? value.size() : num;
}
resultMap.put("axisData",axisData);
resultMap.put("seriesData", seriesData);
return resultMap;
}
......
......@@ -163,7 +163,7 @@ public class MonitoringServiceIMQTTmpl {
Map<String, String> shouldQueryCondtion = new HashMap<>();
shouldQueryCondtion.put("frontModule", "逆变器");
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, shouldQueryCondtion, ESEquipments.class);
dailyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")*CommonConstans.pvGenPoweActor);
dailyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")*CommonConstans.pvGenPoweActor*CommonConstans.pvGenPoweActorDay);
monthlyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")*CommonConstans.pvGenPoweActor);
annualPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")*CommonConstans.pvGenPoweActor);
}
......
......@@ -221,8 +221,8 @@ public class MonitoringServiceImpl {
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class,likeQuerCondtion);
List<ESEquipments> result1 = commonServiceImpl.getListDataByCondtions(queryCondtion1, null, ESEquipments.class);
completionOfPowerIndicatorsDto.setWindSpeedOrIrradiance(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射")));
completionOfPowerIndicatorsDto.setActivePower(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result1, "南瑞光差保护_313P")/1000));
completionOfPowerIndicatorsDto.setDailyPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor));
completionOfPowerIndicatorsDto.setActivePower(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result1, "南瑞光差保护_313P")*CommonConstans.kwToMv));
completionOfPowerIndicatorsDto.setDailyPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor*CommonConstans.pvGenPoweActorDay));
completionOfPowerIndicatorsDto.setMonthlyPower(String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量") * CommonConstans.pvGenPoweActor));
completionOfPowerIndicatorsDto.setAnnualPower(String.format(CommonConstans.Fourdecimalplaces, new BigDecimal(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量") * CommonConstans.pvGenPoweActor)));
}
......@@ -287,7 +287,7 @@ public class MonitoringServiceImpl {
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
dailyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor);
dailyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor*CommonConstans.pvGenPoweActorDay);
monthlyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量") * CommonConstans.pvGenPoweActor);
annualPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量") * CommonConstans.pvGenPoweActor);
}
......@@ -611,7 +611,7 @@ public class MonitoringServiceImpl {
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
dailyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor);
dailyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量") * CommonConstans.pvGenPoweActor*CommonConstans.pvGenPoweActorDay);
monthlyPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量") * CommonConstans.pvGenPoweActor);
annualPower.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量") * CommonConstans.pvGenPoweActor);
}
......@@ -927,7 +927,7 @@ public class MonitoringServiceImpl {
list1.add(stringHashMap8);
page1.setRecords(list1);
HashMap<String, String> stringHashMap9 = new HashMap<>();
stringHashMap9.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfDayFD.get() + powerOfDayGF.get() * CommonConstans.pvGenPoweActor));
stringHashMap9.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfDayFD.get() + (powerOfDayGF.get() * CommonConstans.pvGenPoweActor*CommonConstans.pvGenPoweActorDay)));
list2.add(stringHashMap9);
HashMap<String, String> stringHashMap10 = new HashMap<>();
stringHashMap10.put("title", String.format(CommonConstans.Twodecimalplaces, powerOfMonthFD.get() + powerOfMonthGF.get() * CommonConstans.pvGenPoweActor));
......
package com.yeejoin.amos.boot.module.jxiop.biz.tdmapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface IndicatorDataMapper extends BaseMapper<IndicatorData> {
@Select("select `value`, created_time, `value_f` as valueF from iot_data.indicator_data where equipment_index_name =#{equipmentIndexName} and equipment_number = #{equipmentNumber} and ts >= #{startTime} and ts <= #{endTime} and gateway_id =#{gatewayId}")
List<IndicatorData> selectDataByequipmentIndexNameAndtimeAndEquipmentNumber(@Param("equipmentIndexName") String equipmentIndexName, @Param("equipmentNumber") String equipmentNumber, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("gatewayId") String gatewayId);
@Select("select `value`, created_time, `value_f` as valueF, equipment_index_name from iot_data.indicator_data where equipment_index_name like '%路电流%' and equipment_number = #{equipmentNumber} and ts >= #{startTime} and ts <= #{endTime} and gateway_id =#{gatewayId}")
List<IndicatorData> selectDataByequipmentIndexNameAndtimeAndEquipmentNumberPv(@Param("equipmentNumber") String equipmentNumber, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("gatewayId") String gatewayId);
@Select("select last(`value_f`) as `value_f`,created_time from iot_data.indicator_data where equipment_index_name =#{equipmentIndexName} and gateway_id=#{gatewayId} ")
IndicatorData selectLastDataOfPower(@Param("equipmentIndexName") String equipmentIndexName, @Param("gatewayId") String gatewayId);
}
## DB properties:
## db1-production database
spring.db1.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db1.datasource.url=jdbc:mysql://39.98.224.23:3306/production?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db1.datasource.url=jdbc:mysql://139.9.173.44:3306/production?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db1.datasource.username=root
spring.db1.datasource.password=Yeejoin@2020
spring.db1.datasource.driver-class-name: com.mysql.cj.jdbc.Driver
## db2-sync_data
spring.db2.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db2.datasource.url=jdbc:mysql://39.98.224.23:3306/jxiop_sync_data?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db2.datasource.url=jdbc:mysql://139.9.173.44:3306/jxiop_sync_data?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db2.datasource.username=root
spring.db2.datasource.password=Yeejoin@2020
spring.db2.datasource.driver-class-name: com.mysql.cj.jdbc.Driver
## db3-td-engine
#spring.db3.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db3.datasource.url=jdbc:TAOS-RS://139.9.170.47:6041/iot_data?user=root&password=taosdata&timezone=GMT%2b8&allowMultiQueries=true
spring.db3.datasource.username=root
spring.db3.datasource.password=taosdata
spring.db3.datasource.driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
## eureka properties:
eureka.instance.hostname=172.16.10.220
eureka.client.serviceUrl.defaultZone=http://admin:a1234560@${eureka.instance.hostname}:10001/eureka/
......
......@@ -82,10 +82,10 @@ windSpeed.cron = 0 25 9 * * ?
#本地使用 0 0 5 29 2 ? ? 线上使用 0 */5 * * * ?
windSpeed.Scheduled.cron = 0 0 5 29 2 ?
spring.elasticsearch.rest.uris=http://39.98.224.23:9200
spring.elasticsearch.rest.uris=http://139.9.173.44:9200
spring.elasticsearch.rest.connection-timeout=30000
spring.elasticsearch.rest.username=elastic
spring.elasticsearch.rest.password=123456
spring.elasticsearch.rest.password=Yeejoin@2020
spring.elasticsearch.rest.read-timeout=30000
#elasticsearch.username= elastic
......
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