Commit f937b12d authored by caotao's avatar caotao

运行监盘将查询influxdb迁移到查询es

parent df5f5cdb
......@@ -77,4 +77,17 @@ public class CommonConstans {
}
};
//es EquipIndexName 查绚关键字
public static final String QueryStringEquipmentIndexName = "equipmentIndexName.keyword";
//es gatewayId 查绚关键字
public static final String QueryStringGateWayId = "gatewayId.keyword";
public static final String QueryStringFrontMoudle = "frontModule";
public static final String QueryStringSystemType = "systemType";
public static final String QueryStringEquipmentNumber = "equipmentNumber";
public static final String QueryStringValue = "value";
public static final String QueryStringDataType = "dataType";
public static final String QueryStringDisplayName = "displayName";
public static final String QueryStringIsAlarm = "isAlarm";
public static final String Twodecimalplaces= "%.2f";
public static final String Fourdecimalplaces = "%.4f";
}
......@@ -101,13 +101,13 @@ public class DemoController extends BaseController {
ESEquipmentsRepository equipmentsRepository;
@Autowired
CommonServiceImpl commonServiceImpl;
@Autowired
PowerGenerationImpl powerGenerationImpl;
// @Autowired
// PowerGenerationImpl powerGenerationImpl;
@Autowired
StationCacheDataInit stationCacheDataInit;
@Autowired
LargeScreenImpl largeScreenImpl;
// @Autowired
// LargeScreenImpl largeScreenImpl;
private final String ss= "瞬时风速";
private final String zfs= "WTX-801_25_WTX-801_总辐射";
private final String zfslj= "WTX-801_25_WTX-801_总辐射累计";
......@@ -513,43 +513,43 @@ public class DemoController extends BaseController {
}
return mapdta;
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "分组求和数")
@GetMapping("/test15")
public Map test15() {
Map<String,Double> map= largeScreenImpl.getqg();
return map;
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "分组求和数")
@GetMapping("/test16")
public Map test16() {
//获取每个区域下所有风机网管
List<StationCacheInfoDto> listk =commonServiceImpl.getListStationCacheInfoDto();
Map<String, List<StationCacheInfoDto>> map = listk.stream().filter(v -> StringUtils.isNotEmpty(v.getBelongArea())).collect(Collectors.groupingBy(StationCacheInfoDto :: getBelongArea));
Map<String,Double> maps=null;
for(String key:map.keySet()){
List<String> value1=new ArrayList<>();
List<StationCacheInfoDto> list= map.get(key);
for (StationCacheInfoDto stationCacheInfoDto : list) {
value1.add(stationCacheInfoDto.getBoosterGatewayId());
value1.add(stationCacheInfoDto.getFanGatewayId());
}
maps= largeScreenImpl.getqy(value1);
break;
}
return maps;
}
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "分组求和数")
// @GetMapping("/test15")
// public Map test15() {
//
//// Map<String,Double> map= largeScreenImpl.getqg();
//
// return map;
// }
//
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "分组求和数")
// @GetMapping("/test16")
// public Map test16() {
//
// //获取每个区域下所有风机网管
// List<StationCacheInfoDto> listk =commonServiceImpl.getListStationCacheInfoDto();
//
// Map<String, List<StationCacheInfoDto>> map = listk.stream().filter(v -> StringUtils.isNotEmpty(v.getBelongArea())).collect(Collectors.groupingBy(StationCacheInfoDto :: getBelongArea));
// Map<String,Double> maps=null;
//
// for(String key:map.keySet()){
// List<String> value1=new ArrayList<>();
//
// List<StationCacheInfoDto> list= map.get(key);
//
// for (StationCacheInfoDto stationCacheInfoDto : list) {
// value1.add(stationCacheInfoDto.getBoosterGatewayId());
// value1.add(stationCacheInfoDto.getFanGatewayId());
// }
//
// maps= largeScreenImpl.getqy(value1);
// break;
// }
//
// return maps;
// }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "初始化inlfuxdb-new")
......@@ -607,40 +607,46 @@ public class DemoController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "分组求和数")
@GetMapping("/test18")
public Map test18() {
List<StationCacheInfoDto> list = commonServiceImpl.getListStationCacheInfoDto();
//获取时间天字符串
String datyvalue= "2023-08-11";
elasticsearchTemplate.deleteIndex(ESDailyPowerGeneration.class);
elasticsearchTemplate.deleteIndex(ESMoonPowerGeneration.class);
elasticsearchTemplate.deleteIndex(ESYearPowerGeneration.class);
for (StationCacheInfoDto stationCacheInfoDto : list) {
if("FDZ".equals(stationCacheInfoDto.getStationType())){
//风机
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), dayvalue, dayDateFormat, dayType,"FDZ",datyvalue);
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), moonValue, moonDateFormat, moonType,"FDZ",datyvalue);
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), yearValue, yearDateFormat, yearType,"FDZ",datyvalue);
}else{
//光伏
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), dayvalue, dayDateFormat, dayType,"GFDZ",datyvalue);
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), moonValue, moonDateFormat, moonType,"GFDZ",datyvalue);
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), yearValue, yearDateFormat, yearType,"GFDZ",datyvalue);
}
}
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "分组求和数")
// @GetMapping("/test18")
// public Map test18() {
// List<StationCacheInfoDto> list = commonServiceImpl.getListStationCacheInfoDto();
// //获取时间天字符串
//
// String datyvalue= "2023-08-11";
// elasticsearchTemplate.deleteIndex(ESDailyPowerGeneration.class);
// elasticsearchTemplate.deleteIndex(ESMoonPowerGeneration.class);
// elasticsearchTemplate.deleteIndex(ESYearPowerGeneration.class);
//
// for (StationCacheInfoDto stationCacheInfoDto : list) {
// if("FDZ".equals(stationCacheInfoDto.getStationType())){
//
// //风机
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), dayvalue, dayDateFormat, dayType,"FDZ",datyvalue);
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), moonValue, moonDateFormat, moonType,"FDZ",datyvalue);
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), yearValue, yearDateFormat, yearType,"FDZ",datyvalue);
//
// }else{
//
// //光伏
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), dayvalue, dayDateFormat, dayType,"GFDZ",datyvalue);
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), moonValue, moonDateFormat, moonType,"GFDZ",datyvalue);
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), yearValue, yearDateFormat, yearType,"GFDZ",datyvalue);
//
// }
// }
//
// return null;
// }
return null;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "es获取数据")
@GetMapping("/test19")
public void test19() {
Map<String,List<String>> queryConditon = new HashMap<>();
queryConditon.put("equipmentIndexName.keyword",Arrays.asList("日发电量","月发电量","年发电量"));
commonServiceImpl.getListDataByCondtions(queryConditon,null,ESEquipments.class);
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.scheduled;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESDailyPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESMoonPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.PowerGenerationImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @description:
* @author: tw
* @createDate: 2023/8/9
*/
@Component
@EnableScheduling
public class PowerGeneration {
@Autowired
PowerGenerationImpl powerGenerationImpl;
@Autowired
CommonServiceImpl commonServiceImpl;
private final String dayvalue="日发电量";
private final String moonValue="月发电量";
private final String yearValue="年发电量";
private final String dayDateFormat="yyyy-MM-dd";
private final String moonDateFormat="yyyy-MM";
private final String yearDateFormat="yyyy";
private final String dayType="day";
private final String moonType="moon";
private final String yearType="year";
//定时更新日发电量
@Scheduled(cron = "${daily.power.generation.cron}")
public void addESDailyPowerGeneration(){
List<StationCacheInfoDto> list =commonServiceImpl.getListStationCacheInfoDto();
//获取时间天字符串
SimpleDateFormat myFmt2=new SimpleDateFormat("yyyy-MM-dd");
Date now=new Date();
String daty= myFmt2.format(now);
for (StationCacheInfoDto stationCacheInfoDto : list) {
if("FDZ".equals(stationCacheInfoDto.getStationType())){
//风机
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), dayvalue, dayDateFormat, dayType,"FDZ",daty);
}else{
//光伏
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), dayvalue, dayDateFormat, dayType,"GFDZ",daty);
}
}
}
//定时更新月发电量
@Scheduled(cron = "${moon.power.generation.cron}")
public void addESMoonPowerGeneration(){
List<StationCacheInfoDto> list =commonServiceImpl.getListStationCacheInfoDto();
//获取时间天字符串
SimpleDateFormat myFmt2=new SimpleDateFormat("yyyy-MM-dd");
Date now=new Date();
String daty= myFmt2.format(now);
for (StationCacheInfoDto stationCacheInfoDto : list) {
//风机
if("FDZ".equals(stationCacheInfoDto.getStationType())){
//风机
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), moonValue, moonDateFormat, moonType,"FDZ",daty);
}else{
//光伏
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), moonValue, moonDateFormat, moonType,"GFDZ",daty);
}
}
}
//定时更新年发电量
@Scheduled(cron = "${year.power.generation.cron}")
public void addESYearPowerGeneration(){
List<StationCacheInfoDto> list =commonServiceImpl.getListStationCacheInfoDto();
//获取时间天字符串
SimpleDateFormat myFmt2=new SimpleDateFormat("yyyy-MM-dd");
Date now=new Date();
String daty= myFmt2.format(now);
for (StationCacheInfoDto stationCacheInfoDto : list) {
//风机
if("FDZ".equals(stationCacheInfoDto.getStationType())){
//风机
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), yearValue, yearDateFormat, yearType,"FDZ",daty);
}else{
//光伏
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), yearValue, yearDateFormat, yearType,"GFDZ",daty);
}
}
}
}
//package com.yeejoin.amos.boot.module.jxiop.biz.scheduled;
//
//import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESDailyPowerGeneration;
//import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESMoonPowerGeneration;
//import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
//import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.text.SimpleDateFormat;
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//
///**
// * @description:
// * @author: tw
// * @createDate: 2023/8/9
// */
//
//@Component
//@EnableScheduling
//public class PowerGeneration {
//
//// @Autowired
//// PowerGenerationImpl powerGenerationImpl;
// @Autowired
// CommonServiceImpl commonServiceImpl;
//
// private final String dayvalue="日发电量";
// private final String moonValue="月发电量";
// private final String yearValue="年发电量";
//
// private final String dayDateFormat="yyyy-MM-dd";
// private final String moonDateFormat="yyyy-MM";
// private final String yearDateFormat="yyyy";
//
// private final String dayType="day";
// private final String moonType="moon";
// private final String yearType="year";
//
// //定时更新日发电量
// @Scheduled(cron = "${daily.power.generation.cron}")
// public void addESDailyPowerGeneration(){
// List<StationCacheInfoDto> list =commonServiceImpl.getListStationCacheInfoDto();
// //获取时间天字符串
// SimpleDateFormat myFmt2=new SimpleDateFormat("yyyy-MM-dd");
// Date now=new Date();
// String daty= myFmt2.format(now);
// for (StationCacheInfoDto stationCacheInfoDto : list) {
//
// if("FDZ".equals(stationCacheInfoDto.getStationType())){
//
// //风机
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), dayvalue, dayDateFormat, dayType,"FDZ",daty);
//
// }else{
//
// //光伏
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), dayvalue, dayDateFormat, dayType,"GFDZ",daty);
//
// }
//
// }
//
//
// }
// //定时更新月发电量
// @Scheduled(cron = "${moon.power.generation.cron}")
// public void addESMoonPowerGeneration(){
// List<StationCacheInfoDto> list =commonServiceImpl.getListStationCacheInfoDto();
// //获取时间天字符串
// SimpleDateFormat myFmt2=new SimpleDateFormat("yyyy-MM-dd");
// Date now=new Date();
// String daty= myFmt2.format(now);
// for (StationCacheInfoDto stationCacheInfoDto : list) {
// //风机
// if("FDZ".equals(stationCacheInfoDto.getStationType())){
//
// //风机
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), moonValue, moonDateFormat, moonType,"FDZ",daty);
//
// }else{
//
// //光伏
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), moonValue, moonDateFormat, moonType,"GFDZ",daty);
//
// }
//
// }
// }
// //定时更新年发电量
// @Scheduled(cron = "${year.power.generation.cron}")
// public void addESYearPowerGeneration(){
// List<StationCacheInfoDto> list =commonServiceImpl.getListStationCacheInfoDto();
// //获取时间天字符串
// SimpleDateFormat myFmt2=new SimpleDateFormat("yyyy-MM-dd");
// Date now=new Date();
// String daty= myFmt2.format(now);
// for (StationCacheInfoDto stationCacheInfoDto : list) {
// //风机
// if("FDZ".equals(stationCacheInfoDto.getStationType())){
//
// //风机
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), yearValue, yearDateFormat, yearType,"FDZ",daty);
//
// }else{
//
// //光伏
// powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), yearValue, yearDateFormat, yearType,"GFDZ",daty);
//
// }
//
// }
// }
//
//
//
//}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @description:
* @author: tw
* @createDate: 2023/7/4
*/
@Component
public class MonitorFanIndicatorAsync {
@Autowired
MonitorFanIndicatorImpl monitorFanIndicatorImpl;
@Value("${station.section}")
private int stationSection;
@Value("${station.isok}")
private boolean isok;
@Async("jxiopAsyncExecutor")
public void UpdateMonitorFanIndicator(List<IndexDto> list){
monitorFanIndicatorImpl.UpdateMonitorFanIndicator(list);
}
}
//package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
//
//import com.google.common.collect.Lists;
//import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.scheduling.annotation.Async;
//import org.springframework.stereotype.Component;
//
//import java.util.List;
//
///**
// * @description:
// * @author: tw
// * @createDate: 2023/7/4
// */
//@Component
//public class MonitorFanIndicatorAsync {
// @Autowired
// MonitorFanIndicatorImpl monitorFanIndicatorImpl;
// @Value("${station.section}")
// private int stationSection;
// @Value("${station.isok}")
// private boolean isok;
//
//
// @Async("jxiopAsyncExecutor")
// public void UpdateMonitorFanIndicator(List<IndexDto> list){
// monitorFanIndicatorImpl.UpdateMonitorFanIndicator(list);
// }
//
//
//}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.module.jxiop.api.dto.DeviceDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.StationTaksDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.service.IStationDataTask;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.SjglZsjZsbtz;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.TpriDmpDatabook;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import com.yeejoin.amos.component.influxdb.InfluxDbConnection;
import org.influxdb.dto.QueryResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Component
public class StationDataTaskImpl {
@Autowired
StationBasicServiceImpl stationBasicServiceImpl;
@Autowired
SjglZsjZsbtzServiceImpl sjglZsjZsbtzServiceImpl;
@Autowired
TpriDmpDatabookServiceImpl tpriDmpDatabookServiceImpl;
@Autowired
MonitorFanIndicatorImpl monitorFanIndicatorImpl;
@Value("${station.section}")
private int stationSection;
@Value("${station.isok}")
private boolean isok;
@Autowired
InfluxDButils influxDButils;
@Autowired
MonitorFanIndicatorAsync monitorFanIndicatorAsync;
/**
* 获取 List<StationTaksDto>
* @return <StationTaksDto>
*/
public List<StationTaksDto> getListStationBasic() {
return stationBasicServiceImpl.getStationTaksDtoList();
}
/**
* @deprecated 获取该场站下所有的风机信息
* @param stationTaksDto
* @return List<DeviceDto> 设备信息列表
*/
public List<DeviceDto> getListDevice(StationTaksDto stationTaksDto) {
List<DeviceDto> deviceDtoList = new ArrayList<>();
//获取风机的字典id
TpriDmpDatabook tpriDmpDatabook = tpriDmpDatabookServiceImpl.getTpriDmpDatabookByDataName("风机");
//根据字典id与场站编码获取所有的风机列表
List<SjglZsjZsbtz> sjglZsjZsbtzList = sjglZsjZsbtzServiceImpl .getSjglZsjZsbtzList(tpriDmpDatabook.getDataid(),stationTaksDto.getStationNumber());
//遍历风机列表对于需要的参数进行组装
sjglZsjZsbtzList.forEach(sjglZsjZsbtz -> {
DeviceDto deviceDto = new DeviceDto();
deviceDto.setGateway(stationTaksDto.getGateway());
String kksbm = sjglZsjZsbtz.getKksbm();
String [] kksbms = kksbm.split(" ");
String numberName = kksbms[kksbms.length-1].replace("MD","");
deviceDto.setNumberName(numberName);
deviceDtoList.add(deviceDto);
});
return deviceDtoList;
}
// @Async("jxiopAsyncExecutor")
public List<IndexDto> getIndexDto(DeviceDto deviceDto) {
String querysql ="SELECT createdTime ,gatewayId,address,valueLabel ,equipmentsIdx FROM iot_data WHERE equipmentSpecificName=~/.*"+deviceDto.getNumberName()+"风机"+".*/ and gatewayId='"+deviceDto.getGateway()+"' ORDER BY time desc LIMIT 600";
//每个分机的指标数据
List<IndexDto> list = influxDButils.getListData(querysql,IndexDto.class);
if(list!=null&&list.size()>0){
//对数据切片处理 默认创建
if(stationSection>list.size()||!isok){
monitorFanIndicatorImpl.UpdateMonitorFanIndicator(list);
}else{
//进行分片处理
List<List<IndexDto>> listfp4= Lists.partition(list,stationSection);
for (List<IndexDto> indexDtos : listfp4) {
//每个分级信息处理
monitorFanIndicatorAsync.UpdateMonitorFanIndicator(indexDtos);
}
}
}
return list;
}
}
//package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
//
//import com.google.common.collect.Lists;
//import com.yeejoin.amos.boot.module.jxiop.api.dto.DeviceDto;
//import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
//import com.yeejoin.amos.boot.module.jxiop.api.dto.StationTaksDto;
//import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
//import com.yeejoin.amos.boot.module.jxiop.api.service.IStationDataTask;
//import com.yeejoin.amos.boot.module.jxiop.biz.entity.SjglZsjZsbtz;
//import com.yeejoin.amos.boot.module.jxiop.biz.entity.TpriDmpDatabook;
//import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
//import com.yeejoin.amos.component.influxdb.InfluxDbConnection;
//import org.influxdb.dto.QueryResult;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.scheduling.annotation.Async;
//import org.springframework.scheduling.annotation.EnableAsync;
//import org.springframework.stereotype.Component;
//import org.springframework.stereotype.Service;
//
//import java.util.ArrayList;
//import java.util.List;
////已废弃
//@Component
//public class StationDataTaskImpl {
// @Autowired
// StationBasicServiceImpl stationBasicServiceImpl;
//
// @Autowired
// SjglZsjZsbtzServiceImpl sjglZsjZsbtzServiceImpl;
//
// @Autowired
// TpriDmpDatabookServiceImpl tpriDmpDatabookServiceImpl;
//
// @Autowired
// MonitorFanIndicatorImpl monitorFanIndicatorImpl;
// @Value("${station.section}")
// private int stationSection;
// @Value("${station.isok}")
// private boolean isok;
//
// @Autowired
// InfluxDButils influxDButils;
//// @Autowired
//// MonitorFanIndicatorAsync monitorFanIndicatorAsync;
//
// /**
// * 获取 List<StationTaksDto>
// * @return <StationTaksDto>
// */
// public List<StationTaksDto> getListStationBasic() {
// return stationBasicServiceImpl.getStationTaksDtoList();
// }
//
//
// /**
// * @deprecated 获取该场站下所有的风机信息
// * @param stationTaksDto
// * @return List<DeviceDto> 设备信息列表
// */
// public List<DeviceDto> getListDevice(StationTaksDto stationTaksDto) {
// List<DeviceDto> deviceDtoList = new ArrayList<>();
// //获取风机的字典id
// TpriDmpDatabook tpriDmpDatabook = tpriDmpDatabookServiceImpl.getTpriDmpDatabookByDataName("风机");
// //根据字典id与场站编码获取所有的风机列表
// List<SjglZsjZsbtz> sjglZsjZsbtzList = sjglZsjZsbtzServiceImpl .getSjglZsjZsbtzList(tpriDmpDatabook.getDataid(),stationTaksDto.getStationNumber());
// //遍历风机列表对于需要的参数进行组装
// sjglZsjZsbtzList.forEach(sjglZsjZsbtz -> {
// DeviceDto deviceDto = new DeviceDto();
// deviceDto.setGateway(stationTaksDto.getGateway());
// String kksbm = sjglZsjZsbtz.getKksbm();
// String [] kksbms = kksbm.split(" ");
// String numberName = kksbms[kksbms.length-1].replace("MD","");
// deviceDto.setNumberName(numberName);
// deviceDtoList.add(deviceDto);
// });
// return deviceDtoList;
// }
//
//// @Async("jxiopAsyncExecutor")
// public List<IndexDto> getIndexDto(DeviceDto deviceDto) {
// String querysql ="SELECT createdTime ,gatewayId,address,valueLabel ,equipmentsIdx FROM iot_data WHERE equipmentSpecificName=~/.*"+deviceDto.getNumberName()+"风机"+".*/ and gatewayId='"+deviceDto.getGateway()+"' ORDER BY time desc LIMIT 600";
// //每个分机的指标数据
// List<IndexDto> list = influxDButils.getListData(querysql,IndexDto.class);
// if(list!=null&&list.size()>0){
// //对数据切片处理 默认创建
// if(stationSection>list.size()||!isok){
// monitorFanIndicatorImpl.UpdateMonitorFanIndicator(list);
// }else{
// //进行分片处理
//
// List<List<IndexDto>> listfp4= Lists.partition(list,stationSection);
// for (List<IndexDto> indexDtos : listfp4) {
// //每个分级信息处理
// monitorFanIndicatorAsync.UpdateMonitorFanIndicator(indexDtos);
// }
// }
// }
//
// return list;
// }
//
//
//
//
//
//}
package com.yeejoin.amos.boot.module.jxiop.biz.tasks;
import com.yeejoin.amos.boot.module.jxiop.api.dto.DeviceDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.StationTaksDto;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.StationDataTaskImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @description: 定时获取场站最新数据
* @author: tw
* @createDate: 2023/7/3
*/
@Component
@EnableScheduling
public class StationDataTask {
@Autowired
StationDataTaskImpl stationDataTask;
//定时获取场站指标最新数据
// @Scheduled(cron = "${station.task.cron}")
public void getStationDataTask(){
//获取所有场站信息
List<StationTaksDto> list=stationDataTask.getListStationBasic();
for (StationTaksDto stationTaksDto : list) {
//获取分机
List<DeviceDto> listDeviceDto= stationDataTask.getListDevice(stationTaksDto);
if(listDeviceDto!=null&&listDeviceDto.size()>0){
for (DeviceDto deviceDto : listDeviceDto) {
List<IndexDto> listIndexDto = stationDataTask.getIndexDto(deviceDto);
}
}
}
}
}
//package com.yeejoin.amos.boot.module.jxiop.biz.tasks;
//
//import com.yeejoin.amos.boot.module.jxiop.api.dto.DeviceDto;
//import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
//import com.yeejoin.amos.boot.module.jxiop.api.dto.StationTaksDto;
////import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.StationDataTaskImpl;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.util.List;
//
///**
// * @description: 定时获取场站最新数据
// * @author: tw
// * @createDate: 2023/7/3
// */
//
//@Component
//@EnableScheduling
//public class StationDataTask {
//
// @Autowired
// StationDataTaskImpl stationDataTask;
//
//
// //定时获取场站指标最新数据
// // @Scheduled(cron = "${station.task.cron}")
// public void getStationDataTask(){
// //获取所有场站信息
// List<StationTaksDto> list=stationDataTask.getListStationBasic();
// for (StationTaksDto stationTaksDto : list) {
// //获取分机
// List<DeviceDto> listDeviceDto= stationDataTask.getListDevice(stationTaksDto);
// if(listDeviceDto!=null&&listDeviceDto.size()>0){
// for (DeviceDto deviceDto : listDeviceDto) {
// List<IndexDto> listIndexDto = stationDataTask.getIndexDto(deviceDto);
// }
// }
// }
// }
//}
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