|
@@ -137,7 +137,7 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
|
|
|
|
|
|
|
|
|
|
private AsyncResult<String> computeProjectIndicatorData(ProjectDTO projectDTO, ProjectIndicatorCompute projectIndicatorCompute) throws Exception {
|
|
private AsyncResult<String> computeProjectIndicatorData(ProjectDTO projectDTO, ProjectIndicatorCompute projectIndicatorCompute) throws Exception {
|
|
-// log.info(Thread.currentThread().getName() + "开始计算[{}]的设备运行诊断监测指标", projectDTO.getProjectId());
|
|
|
|
|
|
+ // log.info(Thread.currentThread().getName() + "开始计算[{}]的设备运行诊断监测指标", projectDTO.getProjectId());
|
|
|
|
|
|
//判断当前计算轮次是否大于缓存中最新计算轮次,如果是,则证明已经被计算过,则略过
|
|
//判断当前计算轮次是否大于缓存中最新计算轮次,如果是,则证明已经被计算过,则略过
|
|
if (checkProjectIsCalcd(projectDTO.getProjectId(), projectIndicatorCompute)) {
|
|
if (checkProjectIsCalcd(projectDTO.getProjectId(), projectIndicatorCompute)) {
|
|
@@ -157,7 +157,7 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
|
|
}
|
|
}
|
|
|
|
|
|
Set<String> objIdAndIndicatorId = getObjIdAndInfoCodeFromRules(projectAlarmRules);
|
|
Set<String> objIdAndIndicatorId = getObjIdAndInfoCodeFromRules(projectAlarmRules);
|
|
-// log.debug(Thread.currentThread().getName() + "共有{}个监测指标需要计算", objIdAndIndicatorId.size());
|
|
|
|
|
|
+ // log.debug(Thread.currentThread().getName() + "共有{}个监测指标需要计算", objIdAndIndicatorId.size());
|
|
if (CollectionUtils.isEmpty(objIdAndIndicatorId)) {
|
|
if (CollectionUtils.isEmpty(objIdAndIndicatorId)) {
|
|
return new AsyncResult<>("【监测指标数据计算线程】当前项目:" + projectDTO.getProjectId() + "报警规则未关联对象");
|
|
return new AsyncResult<>("【监测指标数据计算线程】当前项目:" + projectDTO.getProjectId() + "报警规则未关联对象");
|
|
}
|
|
}
|
|
@@ -179,12 +179,12 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
|
|
String methodId = energyAlarmService.queryObjIndicatorMethodId(projectDTO.getProjectId(), objId, indicatorId);
|
|
String methodId = energyAlarmService.queryObjIndicatorMethodId(projectDTO.getProjectId(), objId, indicatorId);
|
|
if (StringUtils.isBlank(methodId)) {
|
|
if (StringUtils.isBlank(methodId)) {
|
|
log.error("【监测指标数据计算线程】:项目监控指标未设置公式:" + projectDTO.getProjectId() + ";" + objId + ";" + indicatorId);
|
|
log.error("【监测指标数据计算线程】:项目监控指标未设置公式:" + projectDTO.getProjectId() + ";" + objId + ";" + indicatorId);
|
|
- return;
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
CalculateMethodDTO calculateMethodDTO = methodIdAndMethodDTO.get(methodId);
|
|
CalculateMethodDTO calculateMethodDTO = methodIdAndMethodDTO.get(methodId);
|
|
if (calculateMethodDTO == null) {
|
|
if (calculateMethodDTO == null) {
|
|
log.error("【监测指标数据计算线程】:项目监控指标设置公式为null:" + projectDTO.getProjectId() + ";" + objId + ";" + indicatorId);
|
|
log.error("【监测指标数据计算线程】:项目监控指标设置公式为null:" + projectDTO.getProjectId() + ";" + objId + ";" + indicatorId);
|
|
- return;
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
if (lastComputeTime == null) {
|
|
if (lastComputeTime == null) {
|
|
lastComputeTime = getDefultStartTime();
|
|
lastComputeTime = getDefultStartTime();
|
|
@@ -193,7 +193,7 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
|
|
String formula = calculateMethodDTO.getFormula();
|
|
String formula = calculateMethodDTO.getFormula();
|
|
if (StringUtils.isBlank(formula)) {
|
|
if (StringUtils.isBlank(formula)) {
|
|
log.error("【监测指标数据计算线程】:项目监控指标设置公式为null:" + projectDTO.getProjectId() + ";" + objId + ";" + indicatorId);
|
|
log.error("【监测指标数据计算线程】:项目监控指标设置公式为null:" + projectDTO.getProjectId() + ";" + objId + ";" + indicatorId);
|
|
- return;
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
Date computeTime = computeIndicatorData(projectDTO, objId, lastComputeTime, computeEndTime, indicatorId, formula);
|
|
Date computeTime = computeIndicatorData(projectDTO, objId, lastComputeTime, computeEndTime, indicatorId, formula);
|
|
if (computeTime == null) {
|
|
if (computeTime == null) {
|
|
@@ -204,7 +204,6 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
|
|
|
|
|
|
/**
|
|
/**
|
|
* 判断项目是否已经被计算
|
|
* 判断项目是否已经被计算
|
|
- *
|
|
|
|
*/
|
|
*/
|
|
private Boolean checkProjectIsCalcd(String projectId, ProjectIndicatorCompute projectIndicatorCompute) {
|
|
private Boolean checkProjectIsCalcd(String projectId, ProjectIndicatorCompute projectIndicatorCompute) {
|
|
Object redisComputeRound = redisUtil.hget(DiAgnoseConst.RedisConstants.TargetComputeTime, projectId);
|
|
Object redisComputeRound = redisUtil.hget(DiAgnoseConst.RedisConstants.TargetComputeTime, projectId);
|
|
@@ -381,16 +380,16 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void cleanAlarmConfigSendTime(CleanAlarmConfigDTO cleanAlarmConfigDTO) {
|
|
public void cleanAlarmConfigSendTime(CleanAlarmConfigDTO cleanAlarmConfigDTO) {
|
|
-// if (StringUtils.isBlank(cleanAlarmConfigDTO.getProjectId())) {
|
|
|
|
-// //清除所有
|
|
|
|
-// redisUtil.del(DiAgnoseConst.RedisConstants.PROJECT_ITEM_SEND_TIME);
|
|
|
|
-// } else if (StringUtils.isBlank(cleanAlarmConfigDTO.getAlarmConfigItemId())) {
|
|
|
|
-// //清除项目
|
|
|
|
-// redisUtil.del(DiAgnoseConst.RedisConstants.PROJECT_ALARM_ITEM + ":" + cleanAlarmConfigDTO.getProjectId());
|
|
|
|
-// } else {
|
|
|
|
-// //清除指定
|
|
|
|
-// redisUtil.hdel(DiAgnoseConst.RedisConstants.PROJECT_ALARM_ITEM + ":" + cleanAlarmConfigDTO.getProjectId(), cleanAlarmConfigDTO.getAlarmConfigItemId());
|
|
|
|
-// }
|
|
|
|
|
|
+ // if (StringUtils.isBlank(cleanAlarmConfigDTO.getProjectId())) {
|
|
|
|
+ // //清除所有
|
|
|
|
+ // redisUtil.del(DiAgnoseConst.RedisConstants.PROJECT_ITEM_SEND_TIME);
|
|
|
|
+ // } else if (StringUtils.isBlank(cleanAlarmConfigDTO.getAlarmConfigItemId())) {
|
|
|
|
+ // //清除项目
|
|
|
|
+ // redisUtil.del(DiAgnoseConst.RedisConstants.PROJECT_ALARM_ITEM + ":" + cleanAlarmConfigDTO.getProjectId());
|
|
|
|
+ // } else {
|
|
|
|
+ // //清除指定
|
|
|
|
+ // redisUtil.hdel(DiAgnoseConst.RedisConstants.PROJECT_ALARM_ITEM + ":" + cleanAlarmConfigDTO.getProjectId(), cleanAlarmConfigDTO.getAlarmConfigItemId());
|
|
|
|
+ // }
|
|
// 清除所有iot数据发送时间
|
|
// 清除所有iot数据发送时间
|
|
clearAllIotDataSendTime();
|
|
clearAllIotDataSendTime();
|
|
// 删除报警条件状态缓存
|
|
// 删除报警条件状态缓存
|
|
@@ -432,7 +431,7 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
|
|
private void sendIndicatorDataToAlarmServer(ProjectDTO projectDTO) throws Exception {
|
|
private void sendIndicatorDataToAlarmServer(ProjectDTO projectDTO) throws Exception {
|
|
//通过报警服务查询报警规则
|
|
//通过报警服务查询报警规则
|
|
List<AlarmRuleDTO> projectAlarmRules = energyAlarmService.getProjectAlarmRules(projectDTO.getProjectId());
|
|
List<AlarmRuleDTO> projectAlarmRules = energyAlarmService.getProjectAlarmRules(projectDTO.getProjectId());
|
|
-// log.error("获取到的项目报警规则:" + projectDTO.getProjectId() + ";" + projectAlarmRules);
|
|
|
|
|
|
+ // log.error("获取到的项目报警规则:" + projectDTO.getProjectId() + ";" + projectAlarmRules);
|
|
if (CollectionUtils.isEmpty(projectAlarmRules)) {
|
|
if (CollectionUtils.isEmpty(projectAlarmRules)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -441,7 +440,7 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
|
|
if (CollectionUtils.isEmpty(objIdAlarmItemCodeAndInfoCodes) || objIdAlarmItemCodeAndInfoCodes.size() == 0) {
|
|
if (CollectionUtils.isEmpty(objIdAlarmItemCodeAndInfoCodes) || objIdAlarmItemCodeAndInfoCodes.size() == 0) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-// log.error("获取到的设备与监测点位映射关系:" + objIdAlarmItemCodeAndInfoCodes);
|
|
|
|
|
|
+ // log.error("获取到的设备与监测点位映射关系:" + objIdAlarmItemCodeAndInfoCodes);
|
|
for (Map.Entry<String, List<String>> entry : objIdAlarmItemCodeAndInfoCodes.entrySet()) {
|
|
for (Map.Entry<String, List<String>> entry : objIdAlarmItemCodeAndInfoCodes.entrySet()) {
|
|
String objIdAndAlarmItemCode = entry.getKey();
|
|
String objIdAndAlarmItemCode = entry.getKey();
|
|
int indexOf = objIdAndAlarmItemCode.indexOf("_");
|
|
int indexOf = objIdAndAlarmItemCode.indexOf("_");
|
|
@@ -449,7 +448,7 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
|
|
String alarmItemCode = objIdAndAlarmItemCode.substring(indexOf + 1);
|
|
String alarmItemCode = objIdAndAlarmItemCode.substring(indexOf + 1);
|
|
String lockKey = AlarmConstants.alarmDataLockPrefix + objId + "-" + alarmItemCode;
|
|
String lockKey = AlarmConstants.alarmDataLockPrefix + objId + "-" + alarmItemCode;
|
|
Object isLock = redisUtil.get(lockKey);
|
|
Object isLock = redisUtil.get(lockKey);
|
|
-// log.error("是否获取到锁:" + isLock);
|
|
|
|
|
|
+ // log.error("是否获取到锁:" + isLock);
|
|
if (null != isLock) {
|
|
if (null != isLock) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -460,12 +459,12 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
|
|
|
|
|
|
//通过redis查询对象该报警类型下的发数截止时间
|
|
//通过redis查询对象该报警类型下的发数截止时间
|
|
ConfigItemDataSendTimeDTO configItemSendTimeDTO = getConfigItemSendTimeDTO(projectDTO, objIdAndAlarmItemCode);
|
|
ConfigItemDataSendTimeDTO configItemSendTimeDTO = getConfigItemSendTimeDTO(projectDTO, objIdAndAlarmItemCode);
|
|
-// log.error("发数截止时间:" + objIdAndAlarmItemCode + "," + configItemSendTimeDTO);
|
|
|
|
|
|
+ // log.error("发数截止时间:" + objIdAndAlarmItemCode + "," + configItemSendTimeDTO);
|
|
Date lastSendTime = configItemSendTimeDTO.getLastSendTime();
|
|
Date lastSendTime = configItemSendTimeDTO.getLastSendTime();
|
|
Date endTime = getSendEndTime(lastSendTime);
|
|
Date endTime = getSendEndTime(lastSendTime);
|
|
|
|
|
|
Map<String, List<MonitorIndicatorRecord>> timeKeyAndRecordList = getTimekeyAndRecordListGteLt(projectDTO, objId, infCodeList, lastSendTime, endTime);
|
|
Map<String, List<MonitorIndicatorRecord>> timeKeyAndRecordList = getTimekeyAndRecordListGteLt(projectDTO, objId, infCodeList, lastSendTime, endTime);
|
|
-// log.error("本次需要发的数:" + timeKeyAndRecordList);
|
|
|
|
|
|
+ // log.error("本次需要发的数:" + timeKeyAndRecordList);
|
|
if (timeKeyAndRecordList == null) {
|
|
if (timeKeyAndRecordList == null) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -478,6 +477,11 @@ public class MonitorIndicatorRecordServiceImpl implements IMonitorIndicatorRecor
|
|
sendTimeKeyAndDataList.put(dateListEntry.getKey(), value);
|
|
sendTimeKeyAndDataList.put(dateListEntry.getKey(), value);
|
|
endTime = DateUtils.str2Date(dateListEntry.getKey(), DateUtils.SDFSECOND);
|
|
endTime = DateUtils.str2Date(dateListEntry.getKey(), DateUtils.SDFSECOND);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (sendTimeKeyAndDataList.size() == 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
JSONArray sendArray = CollectDataUtil.batchBuildSendJsonParam(sendTimeKeyAndDataList, alarmItemCode);
|
|
JSONArray sendArray = CollectDataUtil.batchBuildSendJsonParam(sendTimeKeyAndDataList, alarmItemCode);
|
|
|
|
|
|
try {
|
|
try {
|