Commit fff556ba authored by hezhuozhi's avatar hezhuozhi

Merge branches 'developer' and 'developer' of…

Merge branches 'developer' and 'developer' of http://36.40.66.175:5000/moa/jxdj_zx/amos-boot-zx-biz into developer
parents bed542c8 94d18836
...@@ -30,10 +30,8 @@ import org.springframework.scheduling.annotation.EnableScheduling; ...@@ -30,10 +30,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import java.net.InetAddress; import java.net.InetAddress;
/** /**
* <pre> * <pre>
* 智信能源科技服务启动类 * 智信能源科技服务启动类
...@@ -51,17 +49,19 @@ import java.net.InetAddress; ...@@ -51,17 +49,19 @@ import java.net.InetAddress;
@EnableScheduling @EnableScheduling
@MapperScan({ "org.typroject.tyboot.demo.face.orm.dao*", "org.typroject.tyboot.face.*.orm.dao*", @MapperScan({ "org.typroject.tyboot.demo.face.orm.dao*", "org.typroject.tyboot.face.*.orm.dao*",
"org.typroject.tyboot.core.auth.face.orm.dao*", "org.typroject.tyboot.component.*.face.orm.dao*", "org.typroject.tyboot.core.auth.face.orm.dao*", "org.typroject.tyboot.component.*.face.orm.dao*",
"com.yeejoin.amos.boot.module.**.api.mapper", "com.yeejoin.amos.boot.biz.common.dao.mapper","com.yeejoin.amos.boot.module.common.biz.*","com.yeejoin.amos.boot.module.jxiop.api.mapper","com.yeejoin.amos.boot.module.jxiop.biz.tdmapper","com.yeejoin.amos.boot.module.jxiop.biz.mapper5" }) "com.yeejoin.amos.boot.module.**.api.mapper", "com.yeejoin.amos.boot.biz.common.dao.mapper",
"com.yeejoin.amos.boot.module.common.biz.*", "com.yeejoin.amos.boot.module.jxiop.api.mapper",
"com.yeejoin.amos.boot.module.jxiop.biz.tdmapper", "com.yeejoin.amos.boot.module.jxiop.biz.mapper5" })
@ComponentScan(basePackages = { "org.typroject", "com.yeejoin.amos" }) @ComponentScan(basePackages = { "org.typroject", "com.yeejoin.amos" })
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class}) @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class })
//@SpringBootApplication //@SpringBootApplication
public class AmosJxiopAnalyseApplication { public class AmosJxiopAnalyseApplication {
@Autowired @Autowired
private EmqKeeper emqKeeper; private EmqKeeper emqKeeper;
//本地是否执行健康指数算法开关 // 本地是否执行健康指数算法开关
@Value("${openHealth:false}") @Value("${openHealth:false}")
Boolean openHealth; Boolean openHealth;
@Autowired @Autowired
private SyncESDataToTdengineMqttListener syncESDataToTdengineMqttListener; private SyncESDataToTdengineMqttListener syncESDataToTdengineMqttListener;
@Autowired @Autowired
private SyncDasSuccessMqttListener syncDasSuccessMqttListener; private SyncDasSuccessMqttListener syncDasSuccessMqttListener;
...@@ -76,17 +76,18 @@ public class AmosJxiopAnalyseApplication { ...@@ -76,17 +76,18 @@ public class AmosJxiopAnalyseApplication {
String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path")); String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
logger.info("\n----------------------------------------------------------\n\t" logger.info("\n----------------------------------------------------------\n\t"
+ "Application Amos-Biz-Boot-Jxiop-Montior is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port + "Application Amos-Biz-Boot-Jxiop-Montior is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip
+ path + "/doc.html\n" + "----------------------------------------------------------"); + ":" + port + path + "/doc.html\n" + "----------------------------------------------------------");
} }
@Bean @Bean
public void initMqtt() throws Exception { public void initMqtt() throws Exception {
if (openHealth) { if (!openHealth) {
//订阅固化周期性数据成功的消息 return;
emqKeeper.subscript("sync_esdata_to_tdengine_notice", 1, syncESDataToTdengineMqttListener);
//订阅业务固化同步数据成功消息
emqKeeper.subscript("sync_iotdata_to_tdengine_notice", 1, syncDasSuccessMqttListener);
} }
// 订阅固化周期性数据成功的消息
emqKeeper.subscript("sync_esdata_to_tdengine_notice", 1, syncESDataToTdengineMqttListener);
// 订阅业务固化同步数据成功消息
emqKeeper.subscript("sync_iotdata_to_tdengine_notice", 1, syncDasSuccessMqttListener);
} }
} }
...@@ -49,14 +49,19 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; ...@@ -49,14 +49,19 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningPeriodEnum; import com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningPeriodEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallDataDTO; import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallDataDTO;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallInfoDTO; import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallInfoDTO;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthIndexLatest;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRuleSet; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRuleSet;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthIndexLatest;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthLevel; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthLevel;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRuleSet; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRuleSet;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthIndexLatestMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthIndexMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthLevelMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthLevelMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanWarningRecordMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanWarningRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthIndexLatestMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthLevelMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthLevelMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IPermissionService; import com.yeejoin.amos.boot.module.jxiop.biz.service.IPermissionService;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
...@@ -69,10 +74,8 @@ import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexDayMapper; ...@@ -69,10 +74,8 @@ import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexDayMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvWaringRecordMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvWaringRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndexDay;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.TimeRangeUtil; import com.yeejoin.amos.boot.module.jxiop.biz.utils.TimeRangeUtil;
...@@ -94,6 +97,12 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -94,6 +97,12 @@ public class TDBigScreenAnalyseController extends BaseController {
@Autowired @Autowired
IdxBizFanHealthIndexMapper idxBizFanHealthIndexMapper; IdxBizFanHealthIndexMapper idxBizFanHealthIndexMapper;
@Autowired @Autowired
IdxBizPvHealthIndexMapper idxBizPvHealthIndexMapper;
@Autowired
IdxBizFanHealthIndexLatestMapper idxBizFanHealthIndexLatestMapper;
@Autowired
IdxBizPvHealthIndexLatestMapper idxBizPvHealthIndexLatestMapper;
@Autowired
IdxBizFanWarningRecordMapper idxBizFanWarningRecordMapper; IdxBizFanWarningRecordMapper idxBizFanWarningRecordMapper;
@Autowired @Autowired
IdxBizPvHealthLevelMapper idxBizPvHealthLevelMapper; IdxBizPvHealthLevelMapper idxBizPvHealthLevelMapper;
...@@ -481,7 +490,7 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -481,7 +490,7 @@ public class TDBigScreenAnalyseController extends BaseController {
FanHealthIndex fanHealthIndex = fanHealthIndexMapper.selectOne(wrapper); FanHealthIndex fanHealthIndex = fanHealthIndexMapper.selectOne(wrapper);
LambdaQueryWrapper<FanHealthIndex> wrapperl = new LambdaQueryWrapper<FanHealthIndex>(); LambdaQueryWrapper<FanHealthIndex> wrapperl = new LambdaQueryWrapper<FanHealthIndex>();
wrapperl.select(FanHealthIndex::getTs,FanHealthIndex::getArea,FanHealthIndex::getHealthIndex); wrapperl.select(FanHealthIndex::getTs, FanHealthIndex::getArea, FanHealthIndex::getHealthIndex);
wrapperl.eq(FanHealthIndex::getAnalysisType, "按10分钟"); wrapperl.eq(FanHealthIndex::getAnalysisType, "按10分钟");
wrapperl.eq(FanHealthIndex::getAnalysisObjType, "片区"); wrapperl.eq(FanHealthIndex::getAnalysisObjType, "片区");
wrapperl.eq(FanHealthIndex::getAnalysisTime, fanHealthIndex.getAnalysisTime()); wrapperl.eq(FanHealthIndex::getAnalysisTime, fanHealthIndex.getAnalysisTime());
...@@ -512,47 +521,61 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -512,47 +521,61 @@ public class TDBigScreenAnalyseController extends BaseController {
public ResponseModel<Map<String, Object>> getStationHealthInfoByMinute( public ResponseModel<Map<String, Object>> getStationHealthInfoByMinute(
@RequestParam(required = false) String areaCode) { @RequestParam(required = false) String areaCode) {
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
LambdaQueryWrapper<FanHealthIndex> wrapper = new LambdaQueryWrapper<FanHealthIndex>(); // LambdaQueryWrapper<FanHealthIndex> wrapper = new LambdaQueryWrapper<FanHealthIndex>();
wrapper.orderByDesc(FanHealthIndex::getTs); // wrapper.orderByDesc(FanHealthIndex::getTs);
wrapper.eq(FanHealthIndex::getAnalysisType, "按10分钟"); // wrapper.eq(FanHealthIndex::getAnalysisType, "按10分钟");
wrapper.eq(FanHealthIndex::getAnalysisObjType, "片区"); // wrapper.eq(FanHealthIndex::getAnalysisObjType, "片区");
wrapper.last("limit 1"); // wrapper.last("limit 1");
FanHealthIndex fanHealthIndex = fanHealthIndexMapper.selectOne(wrapper); // FanHealthIndex fanHealthIndex = fanHealthIndexMapper.selectOne(wrapper);
//
LambdaQueryWrapper<FanHealthIndex> wrapperl = new LambdaQueryWrapper<FanHealthIndex>(); // LambdaQueryWrapper<FanHealthIndex> wrapperl = new LambdaQueryWrapper<FanHealthIndex>();
wrapperl.select(FanHealthIndex::getTs,FanHealthIndex::getStation,FanHealthIndex::getHealthIndex); // wrapperl.select(FanHealthIndex::getTs,FanHealthIndex::getStation,FanHealthIndex::getHealthIndex);
wrapperl.eq(FanHealthIndex::getAnalysisType, "按10分钟"); // wrapperl.eq(FanHealthIndex::getAnalysisType, "按10分钟");
wrapperl.eq(FanHealthIndex::getAnalysisObjType, "场站"); // wrapperl.eq(FanHealthIndex::getAnalysisObjType, "场站");
wrapperl.eq(FanHealthIndex::getArea, areaCode+"区域"); // wrapperl.eq(FanHealthIndex::getArea, areaCode+"区域");
wrapperl.eq(FanHealthIndex::getAnalysisTime, fanHealthIndex.getAnalysisTime()); // wrapperl.eq(FanHealthIndex::getAnalysisTime, fanHealthIndex.getAnalysisTime());
List<FanHealthIndex> fanHealthIndexList = fanHealthIndexMapper.selectList(wrapper); // wrapperl.last("limit 10");
// List<FanHealthIndex> fanHealthIndexList = fanHealthIndexMapper.selectList(wrapperl);
LambdaQueryWrapper<PvHealthIndex> wrapper1 = new LambdaQueryWrapper<PvHealthIndex>(); //
wrapper1.orderByDesc(PvHealthIndex::getTs); // LambdaQueryWrapper<PvHealthIndex> wrapper1 = new LambdaQueryWrapper<PvHealthIndex>();
wrapper1.eq(PvHealthIndex::getAnalysisType, "按10分钟"); // wrapper1.orderByDesc(PvHealthIndex::getTs);
wrapper1.eq(PvHealthIndex::getAnalysisObjType, "片区"); // wrapper1.eq(PvHealthIndex::getAnalysisType, "按10分钟");
wrapper1.last("limit 1"); // wrapper1.eq(PvHealthIndex::getAnalysisObjType, "片区");
PvHealthIndex pvHealthIndex = pvHealthIndexMapper.selectOne(wrapper1); // wrapper1.last("limit 1");
// PvHealthIndex pvHealthIndex = pvHealthIndexMapper.selectOne(wrapper1);
LambdaQueryWrapper<PvHealthIndex> pvWrapper = new LambdaQueryWrapper<PvHealthIndex>(); //
pvWrapper.select(PvHealthIndex::getTs,PvHealthIndex::getStation,PvHealthIndex::getHealthIndex); // LambdaQueryWrapper<PvHealthIndex> pvWrapper = new LambdaQueryWrapper<PvHealthIndex>();
pvWrapper.eq(PvHealthIndex::getAnalysisType, "按10分钟"); // pvWrapper.select(PvHealthIndex::getTs,PvHealthIndex::getStation,PvHealthIndex::getHealthIndex);
pvWrapper.eq(PvHealthIndex::getAnalysisObjType, "场站"); // pvWrapper.eq(PvHealthIndex::getAnalysisType, "按10分钟");
pvWrapper.eq(PvHealthIndex::getArea, areaCode+"区域"); // pvWrapper.eq(PvHealthIndex::getAnalysisObjType, "场站");
pvWrapper.eq(PvHealthIndex::getAnalysisTime, pvHealthIndex.getAnalysisTime()); // pvWrapper.eq(PvHealthIndex::getArea, areaCode+"区域");
List<PvHealthIndex> pvHealthIndexList = pvHealthIndexMapper.selectList(pvWrapper); // pvWrapper.eq(PvHealthIndex::getAnalysisTime, pvHealthIndex.getAnalysisTime());
// pvWrapper.last("limit 10");
Map<String, List<FanHealthIndex>> fanHealthGroupedData = fanHealthIndexList.stream() // List<PvHealthIndex> pvHealthIndexList = pvHealthIndexMapper.selectList(pvWrapper);
.collect(Collectors.groupingBy(FanHealthIndex::getStation));
Map<String, FanHealthIndex> fanHealthLatestData = fanHealthGroupedData.values().stream() LambdaQueryWrapper<IdxBizFanHealthIndexLatest> wrapperl = new LambdaQueryWrapper<IdxBizFanHealthIndexLatest>();
.map(list -> list.stream().max(Comparator.comparing(FanHealthIndex::getTs)).get()) wrapperl.eq(IdxBizFanHealthIndexLatest::getAnalysisType, "按10分钟");
.collect(Collectors.toMap(FanHealthIndex::getStation, Function.identity())); wrapperl.eq(IdxBizFanHealthIndexLatest::getAnalysisObjType, "场站");
wrapperl.eq(IdxBizFanHealthIndexLatest::getArae, areaCode+"区域");
Map<String, List<PvHealthIndex>> pvHealthGroupedData = pvHealthIndexList.stream() List<IdxBizFanHealthIndexLatest> fanHealthIndexList=idxBizFanHealthIndexLatestMapper.selectList(wrapperl);
.collect(Collectors.groupingBy(PvHealthIndex::getStation));
Map<String, PvHealthIndex> pvHealthLatestData = pvHealthGroupedData.values().stream() LambdaQueryWrapper<IdxBizPvHealthIndexLatest> wrapperp = new LambdaQueryWrapper<IdxBizPvHealthIndexLatest>();
.map(list -> list.stream().max(Comparator.comparing(PvHealthIndex::getTs)).get()) wrapperp.eq(IdxBizPvHealthIndexLatest::getAnalysisType, "按10分钟");
.collect(Collectors.toMap(PvHealthIndex::getStation, Function.identity())); wrapperp.eq(IdxBizPvHealthIndexLatest::getAnalysisObjType, "场站");
wrapperp.eq(IdxBizPvHealthIndexLatest::getArae, areaCode+"区域");
List<IdxBizPvHealthIndexLatest> pvHealthIndexList=idxBizPvHealthIndexLatestMapper.selectList(wrapperp);
Map<String, List<IdxBizFanHealthIndexLatest>> fanHealthGroupedData = fanHealthIndexList.stream()
.collect(Collectors.groupingBy(IdxBizFanHealthIndexLatest::getStation));
Map<String, IdxBizFanHealthIndexLatest> fanHealthLatestData = fanHealthGroupedData.values().stream()
.map(list -> list.stream().max(Comparator.comparing(IdxBizFanHealthIndexLatest::getRecDate)).get())
.collect(Collectors.toMap(IdxBizFanHealthIndexLatest::getStation, Function.identity()));
Map<String, List<IdxBizPvHealthIndexLatest>> pvHealthGroupedData = pvHealthIndexList.stream()
.collect(Collectors.groupingBy(IdxBizPvHealthIndexLatest::getStation));
Map<String, IdxBizPvHealthIndexLatest> pvHealthLatestData = pvHealthGroupedData.values().stream()
.map(list -> list.stream().max(Comparator.comparing(IdxBizPvHealthIndexLatest::getRecDate)).get())
.collect(Collectors.toMap(IdxBizPvHealthIndexLatest::getStation, Function.identity()));
List<String> finalAxisData = new ArrayList<>(); List<String> finalAxisData = new ArrayList<>();
List<Object> finaleSeriesData = new ArrayList<>(); List<Object> finaleSeriesData = new ArrayList<>();
......
package com.yeejoin.amos.boot.module.jxiop.biz.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
*
*
* @author system_generator
* @date 2023-08-15
*/
@Data
@Accessors(chain = true)
@TableName("fan_health_index_latest_data")
public class IdxBizFanHealthIndexLatest {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value = "SEQUENCE_NBR", type = IdType.ID_WORKER_STR)
private String sequenceNbr;
/**
*
*/
@TableField("REC_DATE")
private Date recDate;
/**
* 分析维度类型
*/
@TableField("ANALYSIS_OBJ_TYPE")
private String analysisObjType;
/**
* 分析维度seq
*/
@TableField("ANALYSIS_OBJ_SEQ")
private String analysisObjSeq;
/**
*
*/
@TableField("WEIGTH")
private Double weigth;
/**
*
*/
@TableField("HEALTH_INDEX")
private Double healthIndex;
/**
* 健康等级
*/
@TableField("HEALTH_LEVEL")
private String healthLevel;
/**
*
*/
@TableField("ANALYSIS_TYPE")
private String analysisType;
/**
*
*/
@TableField("ANALYSIS_START_TIME")
private Date analysisStartTime;
/**
*
*/
@TableField("ANALYSIS_END_TIME")
private Date analysisEndTime;
/**
* 片区
*/
@TableField("ARAE")
private String arae;
/**
* 场站
*/
@TableField("STATION")
private String station;
/**
* 子系统
*/
@TableField("SUB_SYSTEM")
private String subSystem;
/**
* 型号
*/
@TableField("NUMBER")
private String number;
/**
* 设备名称
*/
@TableField("EQUIPMENT_NAME")
private String equipmentName;
/**
*
*/
@TableField("GATEWAY_ID")
private String gatewayId;
/**
* 点表地址
*/
@TableField("INDEX_ADDRESS")
private String indexAddress;
@TableField("ANOMALY")
private Double ANOMALY;
/**
* 分析变量名称
*/
@TableField("POINT_NAME")
private String pointName;
@TableField("ANALYSIS_TIME")
private String ANALYSISTIME;
/**
* KKS码
*/
@TableField("KKS")
private String kks;
}
package com.yeejoin.amos.boot.module.jxiop.biz.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.Date;
/**
*
*
* @author system_generator
* @date 2023-08-15
*/
@Data
@Accessors(chain = true)
@TableName("pv_health_index_latest_data")
public class IdxBizPvHealthIndexLatest{
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value = "SEQUENCE_NBR", type = IdType.ID_WORKER_STR)
private String sequenceNbr;
/**
*
*/
@TableField("REC_DATE")
private Date recDate;
/**
* 分析维度类型
*/
@TableField("ANALYSIS_OBJ_TYPE")
private String analysisObjType;
/**
* 分析维度seq
*/
@TableField("ANALYSIS_OBJ_SEQ")
private String analysisObjSeq;
/**
*
*/
@TableField("WEIGTH")
private Double weigth;
/**
*
*/
@TableField("HEALTH_INDEX")
private Double healthIndex;
/**
* 健康等级
*/
@TableField("HEALTH_LEVEL")
private String healthLevel;
/**
* 分析周期
*/
@TableField("ANALYSIS_TYPE")
private String analysisType;
/**
*
*/
@TableField("ANALYSIS_START_TIME")
private Date analysisStartTime;
/**
*
*/
@TableField("ANALYSIS_END_TIME")
private Date analysisEndTime;
/**
* 片区
*/
@TableField("ARAE")
private String arae;
/**
* 场站
*/
@TableField("STATION")
private String station;
/**
* 子阵
*/
@TableField("SUBARRAY")
private String subarray;
/**
* 厂商
*/
@TableField("MANUFACTURER")
private String manufacturer;
/**
* 设备类型
*/
@TableField("DEVICE_TYPE")
private String deviceType;
/**
* 网关ID
*/
@TableField("GATEWAY_ID")
private String gatewayId;
/**
* 点表地址
*/
@TableField("INDEX_ADDRESS")
private String indexAddress;
/**
* 设备名称
*/
@TableField("EQUIPMENT_NAME")
private String equipmentName;
@TableField("ANOMALY")
private Double ANOMALY;
/**
* 分析变量名称
*/
@TableField("POINT_NAME")
private String pointName;
@TableField("ANALYSIS_TIME")
private String ANALYSISTIME;
/**
* KKS码
*/
@TableField("KKS")
private String kks;
}
...@@ -2,9 +2,14 @@ package com.yeejoin.amos.boot.module.jxiop.biz.listener; ...@@ -2,9 +2,14 @@ package com.yeejoin.amos.boot.module.jxiop.biz.listener;
import java.text.ParseException; import java.text.ParseException;
import java.util.Date; import java.util.Date;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
import org.eclipse.paho.client.mqttv3.MqttMessage; import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -13,6 +18,7 @@ import org.typroject.tyboot.component.emq.EmqxListener; ...@@ -13,6 +18,7 @@ import org.typroject.tyboot.component.emq.EmqxListener;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
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.TdengineTimeServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.TdengineTimeServiceImpl;
...@@ -28,12 +34,24 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener { ...@@ -28,12 +34,24 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener {
@Autowired @Autowired
private CommonServiceImpl commonServiceImpl; private CommonServiceImpl commonServiceImpl;
@Autowired @Autowired
private TdengineTimeServiceImpl tdengineTimeService; private TdengineTimeServiceImpl tdengineTimeService;
@Autowired
private RedisUtils redisUtils;
private final static String JXIOP_ANALYSE_TIME = "JXIOP_ANALYSE_TIME";
@PostConstruct
public void test() {
// 每次启动清空redis
//redisUtils.set(JXIOP_ANALYSE_TIME, "2024-07-30 13:40:00");
redisUtils.del(JXIOP_ANALYSE_TIME);
}
@Override @Override
public void processMessage(String topic, MqttMessage mqttMessage) throws InterruptedException, ParseException { public void processMessage(String topic, MqttMessage mqttMessage) throws ParseException {
log.info(topic + "收到数据同步成功,开始计算健康指数!"); log.info(topic + "收到数据同步成功,开始计算健康指数!");
byte[] payload = mqttMessage.getPayload(); byte[] payload = mqttMessage.getPayload();
String str = new String(payload); String str = new String(payload);
...@@ -41,31 +59,77 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener { ...@@ -41,31 +59,77 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener {
JSONObject jsonObject = JSONObject.parseObject(msg); JSONObject jsonObject = JSONObject.parseObject(msg);
String flag = jsonObject.get("sync_flag").toString(); String flag = jsonObject.get("sync_flag").toString();
if ("success".equals(flag)) { if ("success".equals(flag)) {
Date time = new Date(); Date time = new Date();
time = DateUtil.offsetMinute(time, -DateUtil.minute(time) % 10); time = DateUtil.offsetMinute(time, -DateUtil.minute(time) % 10);
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00"); String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00"); time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00");
if (redisUtils.get(JXIOP_ANALYSE_TIME) != null) {
ExecutorService excutorService = Executors.newFixedThreadPool(4); // 如果相差20分钟 按10分钟处理 可能装备发消息晚了
int taskCount = 2; String lastformat = String.valueOf(redisUtils.get(JXIOP_ANALYSE_TIME));
final CountDownLatch latch = new CountDownLatch(taskCount); Date oldTime = DateUtil.parse(lastformat, "yyyy-MM-dd HH:mm:00");
excutorService.submit(()->{ long diffInMillies = Math.abs(time.getTime() - oldTime.getTime());
commonServiceImpl.healthWarningMinuteByFan(); long diffInMinutes = TimeUnit.MINUTES.convert(diffInMillies, TimeUnit.MILLISECONDS);
latch.countDown(); if (diffInMinutes == 20) {
}); time = DateUtil.offsetMinute(time, -10);
excutorService.submit(()->{ format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
commonServiceImpl.healthWarningMinuteByPv(); }
latch.countDown(); }
}); redisUtils.set(JXIOP_ANALYSE_TIME, format);
System.out.println(format);
System.out.println("等待所有任务完成.."); final Date timeF = time;
latch.await();
System.out.println("所有任务完成");
//区域 全域最后统一生成 CompletableFuture<String> fan=CompletableFuture.supplyAsync(()->{
tdengineTimeService.insertMomentDataAll(format); commonServiceImpl.healthWarningMinuteByFan(timeF);
String fanResult = "风电任务完成..";
System.out.println(fanResult);
return fanResult;
});
CompletableFuture<String> pv=CompletableFuture.supplyAsync(()->{
commonServiceImpl.healthWarningMinuteByPv(timeF);
String pvResult = "光伏任务完成..";
System.out.println(pvResult);
return pvResult;
});
try {
String fanResult = fan.get();
String pvResult = pv.get();
// 区域 全域最后统一生成
tdengineTimeService.insertMomentDataAll(format);
} catch (InterruptedException | ExecutionException e) {
System.out.println("任务执行异常");
e.printStackTrace();
}
//
// ExecutorService excutorService = Executors.newFixedThreadPool(10);
// int taskCount = 2;
// final CountDownLatch latch = new CountDownLatch(taskCount);
// excutorService.submit(() -> {
// commonServiceImpl.healthWarningMinuteByFan(timeF);
// System.out.println("风电任务完成..");
// latch.countDown();
// });
// excutorService.submit(() -> {
// commonServiceImpl.healthWarningMinuteByPv(timeF);
// System.out.println("光伏任务完成..");
// latch.countDown();
// });
//
// try {
// System.out.println("等待所有任务完成..");
// latch.await();
// System.out.println("所有任务完成");
// } catch (InterruptedException e) {
// System.out.println("任务执行异常");
// e.printStackTrace();
// Thread.currentThread().interrupt();
// }
// // 结束线程池
// excutorService.shutdown();
// 区域 全域最后统一生成
// tdengineTimeService.insertMomentDataAll(format);
// // 开始异步计算光伏的健康指数算法 // // 开始异步计算光伏的健康指数算法
// new Thread(() -> { // new Thread(() -> {
// // 调用光伏的健康指数算法 // // 调用光伏的健康指数算法
...@@ -77,19 +141,19 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener { ...@@ -77,19 +141,19 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener {
// commonServiceImpl.healthWarningMinuteByFan(); // commonServiceImpl.healthWarningMinuteByFan();
// }).start(); // }).start();
} }
if ("pvsuccess".equals(flag)) { // if ("pvsuccess".equals(flag)) {
// 开始异步计算光伏的健康指数算法 // // 开始异步计算光伏的健康指数算法
new Thread(() -> { // new Thread(() -> {
// 调用光伏的健康指数算法 // // 调用光伏的健康指数算法
commonServiceImpl.healthWarningMinuteByPv(); // commonServiceImpl.healthWarningMinuteByPv();
}).start(); // }).start();
} // }
if ("fansuccess".equals(flag)) { // if ("fansuccess".equals(flag)) {
// 开始异步计算光伏的健康指数算法 // // 开始异步计算光伏的健康指数算法
new Thread(() -> { // new Thread(() -> {
// 调用光伏的健康指数算法 // // 调用光伏的健康指数算法
commonServiceImpl.healthWarningMinuteByFan(); // commonServiceImpl.healthWarningMinuteByFan();
}).start(); // }).start();
} // }
} }
} }
package com.yeejoin.amos.boot.module.jxiop.biz.mapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthIndexLatest;
/**
* Mapper 接口
*
* @author system_generator
* @date 2023-08-15
*/
public interface IdxBizFanHealthIndexLatestMapper extends BaseMapper<IdxBizFanHealthIndexLatest> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.mapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthIndexLatest;
/**
* Mapper 接口
*
* @author system_generator
* @date 2023-08-15
*/
public interface IdxBizPvHealthIndexLatestMapper extends BaseMapper<IdxBizPvHealthIndexLatest> {
}
...@@ -1828,15 +1828,15 @@ public class CommonServiceImpl { ...@@ -1828,15 +1828,15 @@ public class CommonServiceImpl {
// @Scheduled(cron = "0 0/10 * * * ?") // @Scheduled(cron = "0 0/10 * * * ?")
// @Async("async") // @Async("async")
public void healthWarningMinuteByFan() { public void healthWarningMinuteByFan(Date time) {
if (!openHealth) { if (!openHealth) {
return; return;
} }
Date time = new Date(); // Date time = new Date();
time = DateUtil.offsetMinute(time, -DateUtil.minute(time) % 10); // time = DateUtil.offsetMinute(time, -DateUtil.minute(time) % 10);
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00"); String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00"); // time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00");
logger.info("风机---------------------健康指数时间----" + time); logger.info("风机---------------------健康指数时间----" + time);
// Calendar calendar = Calendar.getInstance(); // Calendar calendar = Calendar.getInstance();
List<IdxBizFanPointProcessVariableClassificationDto> data = idxBizFanPointProcessVariableClassificationMapper List<IdxBizFanPointProcessVariableClassificationDto> data = idxBizFanPointProcessVariableClassificationMapper
...@@ -2455,15 +2455,15 @@ public class CommonServiceImpl { ...@@ -2455,15 +2455,15 @@ public class CommonServiceImpl {
// @Scheduled(cron = "0 0/10 * * * ?") // @Scheduled(cron = "0 0/10 * * * ?")
// @Async("async") // @Async("async")
public void healthWarningMinuteByPv() { public void healthWarningMinuteByPv(Date time) {
if (!openHealth) { if (!openHealth) {
return; return;
} }
// Calendar calendar = Calendar.getInstance(); // Calendar calendar = Calendar.getInstance();
Date time = new Date(); // Date time = new Date();
time = DateUtil.offsetMinute(time, -DateUtil.minute(time) % 10); // time = DateUtil.offsetMinute(time, -DateUtil.minute(time) % 10);
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00"); String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00"); //time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00");
logger.info("光伏---------------------健康指数时间----" + time); logger.info("光伏---------------------健康指数时间----" + time);
List<IdxBizPvPointProcessVariableClassificationDto> data = idxBizPvPointProcessVariableClassificationMapper List<IdxBizPvPointProcessVariableClassificationDto> data = idxBizPvPointProcessVariableClassificationMapper
.getInfluxDBData(); .getInfluxDBData();
......
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