|
@@ -10,12 +10,16 @@ import com.gyee.alarm.service.auto.IAlarmTsService;
|
|
|
import com.gyee.common.model.PointData;
|
|
|
import com.gyee.alarm.util.realtimesource.IEdosUtil;
|
|
|
import com.gyee.common.model.StringUtils;
|
|
|
+import org.apache.logging.log4j.spi.CopyOnWrite;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.Callable;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import java.util.concurrent.CopyOnWriteArrayList;
|
|
|
+import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
|
|
public class AlarmThreadPool implements Callable<Integer>, Serializable {
|
|
|
|
|
@@ -59,11 +63,11 @@ public class AlarmThreadPool implements Callable<Integer>, Serializable {
|
|
|
// while (runStarted)
|
|
|
// {
|
|
|
|
|
|
- List<AlarmTag> saveAlarmTags = new ArrayList<>();
|
|
|
- List<AlarmTag> updateAlarmTags = new ArrayList<>();
|
|
|
+ List<AlarmTag> saveAlarmTags = new CopyOnWriteArrayList<>();
|
|
|
+ List<AlarmTag> updateAlarmTags = new CopyOnWriteArrayList<>();
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
- Map<String, AlarmSimpleVo> map = new HashMap<>();
|
|
|
+ Map<String, AlarmSimpleVo> map = new ConcurrentHashMap<>();
|
|
|
for (AlarmCustomTag alarm : alarmVoList) {
|
|
|
sb.append("'").append(alarm.getId().toLowerCase()).append("',");
|
|
|
}
|
|
@@ -71,7 +75,7 @@ public class AlarmThreadPool implements Callable<Integer>, Serializable {
|
|
|
if (sb.length() > 0) {
|
|
|
ids = sb.substring(0, sb.length() - 1);
|
|
|
}
|
|
|
- List<AlarmSimpleVo> alarmls = new ArrayList<>();
|
|
|
+ List<AlarmSimpleVo> alarmls = new CopyOnWriteArrayList<>();
|
|
|
if (null != ids) {
|
|
|
alarmls = alarmTsService.selectLastRowByTbname(AlarmSuperTalbeType.CT.getCode(), ids);
|
|
|
}
|
|
@@ -87,8 +91,6 @@ public class AlarmThreadPool implements Callable<Integer>, Serializable {
|
|
|
|
|
|
checkRule(saveAlarmTags, updateAlarmTags, vo,map);
|
|
|
|
|
|
- logger.info( "新增报警数量:" + saveAlarmTags.size());
|
|
|
- logger.info( "结束报警数量:" + updateAlarmTags.size());
|
|
|
}
|
|
|
|
|
|
if (!saveAlarmTags.isEmpty()) {
|
|
@@ -106,7 +108,8 @@ public class AlarmThreadPool implements Callable<Integer>, Serializable {
|
|
|
// throw new RuntimeException(e);
|
|
|
// }
|
|
|
// }
|
|
|
-
|
|
|
+ logger.info(str+ "新增报警数量:" + saveAlarmTags.size());
|
|
|
+ logger.info(str+ "结束报警数量:" + updateAlarmTags.size());
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
@@ -131,41 +134,48 @@ public class AlarmThreadPool implements Callable<Integer>, Serializable {
|
|
|
alarmFunction = new AlarmFunction(alarmExpression, DeviceTypeValue.WT, ar.getDeviceid());
|
|
|
|
|
|
|
|
|
+ }else if (ar.getDevicetype().equals(DeviceTypeValue.IN.getCode())) {
|
|
|
+ alarmFunction = new AlarmFunction(alarmExpression, DeviceTypeValue.IN, ar.getDeviceid());
|
|
|
+
|
|
|
+
|
|
|
} else if (ar.getDevicetype().equals(DeviceTypeValue.BT.getCode())) {
|
|
|
alarmFunction = new AlarmFunction(alarmExpression, DeviceTypeValue.BT, ar.getStationid());
|
|
|
-
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
|
|
|
Object obj = alarmFunction.explain();
|
|
|
+
|
|
|
if (obj instanceof Boolean) {
|
|
|
|
|
|
- Boolean endStatus=null;
|
|
|
+
|
|
|
+ AtomicBoolean endStatus = new AtomicBoolean(true);
|
|
|
+
|
|
|
if(map.containsKey(ar.getId().toLowerCase()))
|
|
|
{
|
|
|
AlarmSimpleVo vo=map.get(ar.getId().toLowerCase());
|
|
|
|
|
|
- if(StringUtils.notEmp(vo.getEndts()))
|
|
|
- {
|
|
|
- endStatus=true;
|
|
|
- }else
|
|
|
+ if(StringUtils.notEmp(vo.getEndts()))
|
|
|
+ {
|
|
|
+ endStatus.getAndSet(true);
|
|
|
+ }else
|
|
|
{
|
|
|
- endStatus=false;
|
|
|
+ endStatus.getAndSet(false);
|
|
|
}
|
|
|
}else
|
|
|
{
|
|
|
- endStatus=true;
|
|
|
+ endStatus.getAndSet(true);
|
|
|
}
|
|
|
if (true == (boolean) obj) {
|
|
|
|
|
|
- if(endStatus)
|
|
|
+ if(endStatus.get())
|
|
|
{
|
|
|
AlarmTag po = new AlarmTag();
|
|
|
po.setId(ar.getId());
|
|
|
po.setTs(new Date().getTime());
|
|
|
po.setEndts(null);
|
|
|
po.setVal(1.0);
|
|
|
+ po.setOval(1.0);
|
|
|
po.setTimeLong(0.0);
|
|
|
|
|
|
saveAlarmTags.add(po);
|
|
@@ -173,13 +183,14 @@ public class AlarmThreadPool implements Callable<Integer>, Serializable {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- if(StringUtils.notEmp(endStatus) && !endStatus)
|
|
|
+ if(!endStatus.get())
|
|
|
{
|
|
|
AlarmTag po = new AlarmTag();
|
|
|
po.setId(ar.getId());
|
|
|
po.setTs(new Date().getTime());
|
|
|
po.setEndts(new Date().getTime());
|
|
|
po.setVal(0.0);
|
|
|
+ po.setOval(0.0);
|
|
|
po.setTimeLong(0.0);
|
|
|
|
|
|
updateAlarmTags.add(po);
|