|
@@ -2,6 +2,7 @@ package com.persagy.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
import com.googlecode.aviator.AviatorEvaluator;
|
|
import com.googlecode.aviator.AviatorEvaluator;
|
|
@@ -88,6 +89,9 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
String dateTime = split[i * 4];
|
|
String dateTime = split[i * 4];
|
|
String meterId = split[i * 4 + 1];
|
|
String meterId = split[i * 4 + 1];
|
|
String funcId = split[i * 4 + 2];
|
|
String funcId = split[i * 4 + 2];
|
|
|
|
+ if("1001".equals(meterId) && "102".equals(funcId)){
|
|
|
|
+ System.out.println("-----"+split[i * 4 + 3]);
|
|
|
|
+ }
|
|
double value = Double.parseDouble(split[i * 4 + 3]);
|
|
double value = Double.parseDouble(split[i * 4 + 3]);
|
|
|
|
|
|
if (alarmInfoCache.hasKey(meterId, funcId)) {
|
|
if (alarmInfoCache.hasKey(meterId, funcId)) {
|
|
@@ -183,6 +187,7 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
alarmRecordDO.setDefinitionId(defineId);
|
|
alarmRecordDO.setDefinitionId(defineId);
|
|
alarmRecordDO.setObjId(alarmDefine.getObjId());
|
|
alarmRecordDO.setObjId(alarmDefine.getObjId());
|
|
alarmRecordDO.setItemCode(alarmDefine.getItemCode());
|
|
alarmRecordDO.setItemCode(alarmDefine.getItemCode());
|
|
|
|
+ alarmRecordDO.setTargetId(alarmDefine.getTargetId());
|
|
alarmRecordDO.setState("2");
|
|
alarmRecordDO.setState("2");
|
|
alarmRecordDO.setEndTime(DateUtils.parseDate(dateTime));
|
|
alarmRecordDO.setEndTime(DateUtils.parseDate(dateTime));
|
|
alarmRecordDO.setEndInfo(JSONObject.toJSONString(paramMap));
|
|
alarmRecordDO.setEndInfo(JSONObject.toJSONString(paramMap));
|
|
@@ -257,26 +262,25 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
private void handlerNowDataAlarm(AlarmDefine alarmDefine, AlarmState alarmState, String dateTime, Condition condition, String defineId, HashMap paramMap) throws SchedulerException, InterruptedException {
|
|
private void handlerNowDataAlarm(AlarmDefine alarmDefine, AlarmState alarmState, String dateTime, Condition condition, String defineId, HashMap paramMap) throws SchedulerException, InterruptedException {
|
|
alarmState.setLatestDataNormalstate(false);
|
|
alarmState.setLatestDataNormalstate(false);
|
|
JSONObject effectTime = condition.getEffectTime();
|
|
JSONObject effectTime = condition.getEffectTime();
|
|
- boolean inEffectTime = false;
|
|
|
|
- boolean hasExpire = true;
|
|
|
|
- //生效时间段,有误过期时间判断
|
|
|
|
- if (StringUtil.isEmpty(effectTime) || StringUtil.isEmpty(effectTime.getString("type"))) {
|
|
|
|
- //无生效时间设置,则任何时间生效
|
|
|
|
- inEffectTime = true;
|
|
|
|
- //没有设置生效时间,所以也没有设置过期时间
|
|
|
|
- hasExpire = false;
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- if ("period".equals(effectTime.getJSONObject("period").getString("type")) && "000000".equals(effectTime.getJSONObject("period").getString("startTime").substring(0, 6)) && "235959".equals(effectTime.getJSONObject("period").getString("endTime").substring(0, 6))) {
|
|
|
|
- //架构师w确认 00:00-23:59的生效时间为一值生效,23:59分不过期
|
|
|
|
- hasExpire = false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ("period".equals(effectTime.getString("type")) && effectTime.getJSONObject("period").getString("startTime").compareTo(DateUtils.getSdfTimeNotDate(dateTime)) <= 0 && effectTime.getJSONObject("period").getString("endTime").compareTo(DateUtils.getSdfTimeNotDate(dateTime)) >= 0) {
|
|
|
|
- //在生效时间
|
|
|
|
- inEffectTime = true;
|
|
|
|
- } else {
|
|
|
|
- log.info("[{}]不在设置的生效时间段", dateTime);
|
|
|
|
|
|
+ //无生效时间设置,则任何时间生效
|
|
|
|
+ boolean inEffectTime = true;
|
|
|
|
+ //没有设置生效时间,所以也没有设置过期时间
|
|
|
|
+ boolean hasExpire = false;
|
|
|
|
+ JSONObject period = effectTime.getJSONObject("period");
|
|
|
|
+ if(ObjectUtil.isAllNotEmpty(effectTime,effectTime.getString("type"))) {
|
|
|
|
+ if ("period".equals(effectTime.getString("type"))) {
|
|
|
|
+ //开始结束时间都不为空
|
|
|
|
+ String startTime = period.getString("startTime");
|
|
|
|
+ String endTime = period.getString("endTime");
|
|
|
|
+ String dateTimeFormat = DateUtils.getSdfTimeNotDate(dateTime);
|
|
|
|
+ if(ObjectUtil.isAllNotEmpty(startTime, endTime)){
|
|
|
|
+ if(!"000000".equals(startTime) || !"235959".equals(endTime)){
|
|
|
|
+ hasExpire = true;
|
|
|
|
+ }
|
|
|
|
+ if(startTime.compareTo(dateTimeFormat) > 0 && endTime.compareTo(DateUtils.getSdfTimeNotDate(dateTime)) < 0){
|
|
|
|
+ inEffectTime = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (inEffectTime) {
|
|
if (inEffectTime) {
|
|
@@ -294,7 +298,7 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
Date expireDate = null;
|
|
Date expireDate = null;
|
|
if (hasExpire && "period".equals(effectTime.getString("type"))) {
|
|
if (hasExpire && "period".equals(effectTime.getString("type"))) {
|
|
//过期时间
|
|
//过期时间
|
|
- String expireTime = effectTime.getJSONObject("period").getString("endTime");
|
|
|
|
|
|
+ String expireTime = period.getString("endTime");
|
|
LocalTime localTime = LocalTime.parse(expireTime, DateTimeFormatter.ofPattern(DateUtils.sdfTimeNotDate));
|
|
LocalTime localTime = LocalTime.parse(expireTime, DateTimeFormatter.ofPattern(DateUtils.sdfTimeNotDate));
|
|
expireDateTime = LocalDateTime.of(LocalDate.now(), localTime);
|
|
expireDateTime = LocalDateTime.of(LocalDate.now(), localTime);
|
|
expireDate = DateUtils.localDateTime2Date(expireDateTime);
|
|
expireDate = DateUtils.localDateTime2Date(expireDateTime);
|
|
@@ -316,6 +320,7 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
.groupCode(groupCode)
|
|
.groupCode(groupCode)
|
|
.itemCode(alarmDefine.getItemCode())
|
|
.itemCode(alarmDefine.getItemCode())
|
|
.objId(alarmDefine.getObjId())
|
|
.objId(alarmDefine.getObjId())
|
|
|
|
+ .targetId(alarmDefine.getTargetId())
|
|
.classCode(alarmDefine.getClassCode())
|
|
.classCode(alarmDefine.getClassCode())
|
|
.createUser(systemId)
|
|
.createUser(systemId)
|
|
.build();
|
|
.build();
|
|
@@ -327,6 +332,7 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
zktAlarmRecordDO.setDefinitionId(defineId);
|
|
zktAlarmRecordDO.setDefinitionId(defineId);
|
|
zktAlarmRecordDO.setObjId(alarmDefine.getObjId());
|
|
zktAlarmRecordDO.setObjId(alarmDefine.getObjId());
|
|
zktAlarmRecordDO.setItemCode(alarmDefine.getItemCode());
|
|
zktAlarmRecordDO.setItemCode(alarmDefine.getItemCode());
|
|
|
|
+ zktAlarmRecordDO.setTargetId(alarmDefine.getTargetId());
|
|
zktAlarmRecordDO.setState("1");
|
|
zktAlarmRecordDO.setState("1");
|
|
alarmRecordRepository.save(zktAlarmRecordDO);
|
|
alarmRecordRepository.save(zktAlarmRecordDO);
|
|
alarmState.setState(AlarmState.State.NOT_DEAL.getType());
|
|
alarmState.setState(AlarmState.State.NOT_DEAL.getType());
|
|
@@ -342,6 +348,7 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
.itemCode(alarmDefine.getItemCode())
|
|
.itemCode(alarmDefine.getItemCode())
|
|
.name(alarmDefine.getName())
|
|
.name(alarmDefine.getName())
|
|
.objId(alarmDefine.getObjId())
|
|
.objId(alarmDefine.getObjId())
|
|
|
|
+ .targetId(alarmDefine.getTargetId())
|
|
.state("3") //要变成已过期
|
|
.state("3") //要变成已过期
|
|
.alarmId(alarmId)
|
|
.alarmId(alarmId)
|
|
.build();
|
|
.build();
|