|
@@ -11,6 +11,8 @@ import com.gyee.alarm.util.realtimesource.IEdosUtil;
|
|
|
import com.gyee.alarm.websocket.PushParams;
|
|
|
import com.gyee.alarm.websocket.WebSocket;
|
|
|
import com.gyee.common.model.PointData;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -31,16 +33,21 @@ public class AlarmInService {
|
|
|
private IProEconAlarmInfoService proEconAlarmInfoService;
|
|
|
@Value("${initialcode}")
|
|
|
private String initialcode;
|
|
|
+
|
|
|
@Value("${pushinterval}")
|
|
|
private Double pushinterval;
|
|
|
@Resource
|
|
|
private WebSocket webSocket;
|
|
|
@Resource
|
|
|
private PushDataSevice pushDataSevice;
|
|
|
+
|
|
|
@Value("${read-rows}")
|
|
|
private Integer readRows;
|
|
|
+
|
|
|
@Resource
|
|
|
private IEdosUtil edosUtil;
|
|
|
+
|
|
|
+ private static Logger logger = LoggerFactory.getLogger(AlarmWtService.class);
|
|
|
public void dropSuperTable()
|
|
|
{
|
|
|
alarmTsService.dropSuperTable(AlarmSuperTalbeType.WT.getCode());
|
|
@@ -58,34 +65,7 @@ public class AlarmInService {
|
|
|
List<AlarmVo> alarmVoList=CacheContext.alarmInList;
|
|
|
List<AlarmTag> alarmTags=new ArrayList<>();
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
if(!alarmVoList.isEmpty())
|
|
|
{
|
|
|
for(AlarmVo vo: alarmVoList)
|
|
@@ -107,20 +87,7 @@ public class AlarmInService {
|
|
|
vo.getName(),
|
|
|
vo.getNemCode(),vo.getFaultCause(),vo.getResolvent(),vo.getFaultType(),vo.getAname());
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -132,19 +99,28 @@ public class AlarmInService {
|
|
|
public List<AlarmVo> initalAlarmVo() throws Exception {
|
|
|
|
|
|
List<AlarmVo> alarmVoList=new ArrayList<>();
|
|
|
- Map<String, List<ProEconAlarmConfiguration>> wtAlarmMap = CacheContext.wtAlarmMap;
|
|
|
+ Map<String, List<ProEconAlarmConfiguration>> wtAlarmMap = CacheContext.inAlarmMap;
|
|
|
Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
|
|
|
for (ProBasicEquipment wt : CacheContext.wtls) {
|
|
|
|
|
|
+ if(wt.getId().contains("_F_"))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if (wtpAimap.containsKey(wt.getId())) {
|
|
|
Map<String, ProBasicEquipmentPoint> pointMap = wtpAimap.get(wt.getId());
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
sb.append(wt.getWindpowerstationId() + wt.getModelId());
|
|
|
+
|
|
|
+
|
|
|
if (StringUtils.notEmp(pointMap) && wtAlarmMap.containsKey(String.valueOf(sb))) {
|
|
|
List<ProEconAlarmConfiguration> alarmls = wtAlarmMap.get(String.valueOf(sb));
|
|
|
|
|
|
if (!alarmls.isEmpty()) {
|
|
|
+
|
|
|
for (ProEconAlarmConfiguration alarm : alarmls) {
|
|
|
if (pointMap.containsKey(alarm.getUniformCode())) {
|
|
|
ProBasicEquipmentPoint equipmentPoint = pointMap.get(alarm.getUniformCode());
|
|
@@ -154,7 +130,11 @@ public class AlarmInService {
|
|
|
!equipmentPoint.getNemCode().equals(initialcode) &&
|
|
|
alarm.getAlarmType().equals(AlarmTypeValue.IN.getCode())
|
|
|
)
|
|
|
+
|
|
|
+
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
AlarmVo vo=new AlarmVo();
|
|
|
StringBuilder tbName = new StringBuilder();
|
|
|
tbName.append(wt.getId()).append("_").append(alarm.getId());
|
|
@@ -195,71 +175,23 @@ public class AlarmInService {
|
|
|
vo.setTriggertype(alarm.getTriggerType());
|
|
|
vo.setUniformcode(alarm.getUniformCode());
|
|
|
vo.setSuperTableName(AlarmSuperTalbeType.WT.getCode());
|
|
|
+ vo.setFaultType(alarm.getDeviceId());
|
|
|
+ vo.setAname(alarm.getSuffix());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vo.setVal(null);
|
|
|
vo.setOval(null);
|
|
|
- vo.setFaultType(alarm.getDeviceId());
|
|
|
- vo.setAname(alarm.getSuffix());
|
|
|
vo.setName(alarm.getName());
|
|
|
vo.setNemCode(alarm.getNemCode());
|
|
|
vo.setFaultCause(alarm.getFaultCause());
|
|
|
vo.setResolvent(alarm.getResolvent());
|
|
|
-
|
|
|
alarmVoList.add(vo);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -272,27 +204,25 @@ public class AlarmInService {
|
|
|
|
|
|
|
|
|
|
|
|
- public List<AlarmTag> findTags(String stbaleName)
|
|
|
+ public List<AlarmTag> findTags()
|
|
|
{
|
|
|
+
|
|
|
List<AlarmTag> ls=new ArrayList<>();
|
|
|
- if(StringUtils.notEmp(stbaleName))
|
|
|
+ if(!CacheContext.alarmInList.isEmpty())
|
|
|
{
|
|
|
-
|
|
|
- List<AlarmVo> vos= CacheContext.alarmWtList;
|
|
|
- if(!vos.isEmpty())
|
|
|
+ for(AlarmVo vo:CacheContext.alarmInList)
|
|
|
{
|
|
|
- for(AlarmVo vo:vos)
|
|
|
- {
|
|
|
- AlarmTag po=new AlarmTag();
|
|
|
- po.setId(vo.getTbName());
|
|
|
- po.setOval(null);
|
|
|
- po.setTriggerType(vo.getTriggertype());
|
|
|
- po.setTagId(vo.getTagid());
|
|
|
- po.setVal(null);
|
|
|
- po.setRank(vo.getRank());
|
|
|
- po.setAlarmType(vo.getAlarmtype());
|
|
|
- ls.add(po);
|
|
|
- }
|
|
|
+ AlarmTag po=new AlarmTag();
|
|
|
+ po.setId(vo.getTbName());
|
|
|
+ po.setOval(null);
|
|
|
+ po.setTriggerType(vo.getTriggertype());
|
|
|
+ po.setTagId(vo.getTagid());
|
|
|
+ po.setVal(null);
|
|
|
+ po.setRank(vo.getRank());
|
|
|
+ po.setAlarmType(vo.getAlarmtype());
|
|
|
+ po.setUniformCode(vo.getUniformcode());
|
|
|
+ po.setWpId(vo.getStationid());
|
|
|
+ ls.add(po);
|
|
|
}
|
|
|
}
|
|
|
return ls;
|
|
@@ -303,15 +233,19 @@ public class AlarmInService {
|
|
|
|
|
|
if(StringUtils.notEmp(ls) && !ls.isEmpty()) {
|
|
|
|
|
|
- alarmTsService.insertList(ls);
|
|
|
+ for (AlarmTag alarm : ls) {
|
|
|
+ alarm.setConfirmed(false);
|
|
|
|
|
|
+ }
|
|
|
+ alarmTsService.insertList(ls);
|
|
|
Map<String,ProEconAlarmInfo> tempmap=new HashMap<>();
|
|
|
+
|
|
|
if (StringUtils.notEmp(ls) && !ls.isEmpty()) {
|
|
|
|
|
|
List<ProEconAlarmInfo> valuels = new ArrayList<>();
|
|
|
for (AlarmTag alarm : ls) {
|
|
|
- if (CacheContext.alarmWtMap.containsKey(alarm.getId())) {
|
|
|
- AlarmVo vo = CacheContext.alarmWtMap.get(alarm.getId());
|
|
|
+ if (CacheContext.alarmInMap.containsKey(alarm.getId())) {
|
|
|
+ AlarmVo vo = CacheContext.alarmInMap.get(alarm.getId());
|
|
|
ProEconAlarmInfo po = new ProEconAlarmInfo();
|
|
|
po.setTbname(vo.getTbName());
|
|
|
po.setLastUpdateTime(new Date(alarm.getTs()));
|
|
@@ -354,17 +288,18 @@ public class AlarmInService {
|
|
|
alarm.setIsClose(false);
|
|
|
alarm.setDeviceId(vo.getDeviceid());
|
|
|
alarm.setAlarmId(vo.getAlarmid());
|
|
|
+
|
|
|
if(StringUtils.notEmp(vo.getDeviceid()) && CacheContext.wtmap.containsKey(vo.getDeviceid()))
|
|
|
{
|
|
|
alarm.setCode(CacheContext.wtmap.get(vo.getDeviceid()).getNemCode());
|
|
|
}
|
|
|
+
|
|
|
if(CacheContext.wpmap.containsKey(vo.getStationid()))
|
|
|
{
|
|
|
alarm.setWpName(CacheContext.wpmap.get(vo.getStationid()).getName());
|
|
|
}
|
|
|
|
|
|
alarm.setWpId(vo.getStationid());
|
|
|
-
|
|
|
pushDataSevice.pushWtData(alarm);
|
|
|
|
|
|
|
|
@@ -389,7 +324,7 @@ public class AlarmInService {
|
|
|
List<ProEconAlarmInfo> templs = new ArrayList<>();
|
|
|
for (ProEconAlarmInfo vo : valuels) {
|
|
|
templs.add(vo);
|
|
|
- if (templs.size() == 100) {
|
|
|
+ if (templs.size() == 500) {
|
|
|
proEconAlarmInfoService.saveBatch(templs);
|
|
|
templs = new ArrayList<>();
|
|
|
}
|
|
@@ -398,12 +333,14 @@ public class AlarmInService {
|
|
|
if (!templs.isEmpty()) {
|
|
|
proEconAlarmInfoService.saveBatch(templs);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- public synchronized void updateAlarms(List<AlarmTag> ls) throws EncodeException, IOException {
|
|
|
+ public synchronized void updateAlarms(List<AlarmTag> ls) throws EncodeException, IOException {
|
|
|
|
|
|
if (StringUtils.notEmp(ls) && !ls.isEmpty()) {
|
|
|
|
|
@@ -412,7 +349,7 @@ public class AlarmInService {
|
|
|
for (AlarmTag alarm : ls) {
|
|
|
if (CacheContext.alarmInMap.containsKey(alarm.getId())) {
|
|
|
AlarmVo vo = CacheContext.alarmInMap.get(alarm.getId());
|
|
|
- if(vo.getAlarmtype().equals(AlarmTypeValue.WT.getCode()) )
|
|
|
+ if(vo.getAlarmtype().equals(AlarmTypeValue.IN.getCode()) )
|
|
|
{
|
|
|
sb.append("'").append(alarm.getId().toLowerCase()).append("',");
|
|
|
}
|
|
@@ -439,10 +376,13 @@ public class AlarmInService {
|
|
|
}
|
|
|
List<AlarmTag> alarmTagls=new ArrayList<>();
|
|
|
for (AlarmTag alarm : ls) {
|
|
|
+
|
|
|
+
|
|
|
if(map.containsKey(alarm.getId().toLowerCase()))
|
|
|
{
|
|
|
AlarmSimpleVo tag=map.get(alarm.getId().toLowerCase());
|
|
|
- if(StringUtils.notEmp(tag.getTs()))
|
|
|
+
|
|
|
+ if(null !=tag.getTs())
|
|
|
{
|
|
|
alarm.setTs(tag.getTs());
|
|
|
Date begin = new Date(alarm.getEndts());
|
|
@@ -454,6 +394,8 @@ public class AlarmInService {
|
|
|
alarm.setSuperTalbe(AlarmSuperTalbeType.WT.getCode());
|
|
|
|
|
|
alarmTagls.add(alarm);
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -461,14 +403,15 @@ public class AlarmInService {
|
|
|
if (StringUtils.notEmp(alarmTagls) && !alarmTagls.isEmpty()) {
|
|
|
alarmTsService.insertList(alarmTagls);
|
|
|
}
|
|
|
- Map<String,ProEconAlarmInfo> tempmap=new HashMap<>();
|
|
|
|
|
|
+ Map<String,ProEconAlarmInfo> tempmap=new HashMap<>();
|
|
|
if (StringUtils.notEmp(alarmTagls) && !alarmTagls.isEmpty()) {
|
|
|
|
|
|
List<ProEconAlarmInfo> valuels = new ArrayList<>();
|
|
|
for (AlarmTag alarm : alarmTagls) {
|
|
|
- if (CacheContext.alarmWtMap.containsKey(alarm.getId())) {
|
|
|
- AlarmVo vo = CacheContext.alarmWtMap.get(alarm.getId());
|
|
|
+ if (CacheContext.alarmInMap.containsKey(alarm.getId())) {
|
|
|
+ AlarmVo vo = CacheContext.alarmInMap.get(alarm.getId());
|
|
|
+
|
|
|
ProEconAlarmInfo po = new ProEconAlarmInfo();
|
|
|
po.setTbname(vo.getTbName());
|
|
|
po.setLastUpdateTime(new Date(alarm.getEndts()));
|
|
@@ -517,16 +460,18 @@ public class AlarmInService {
|
|
|
{
|
|
|
alarm.setCode(CacheContext.wtmap.get(vo.getDeviceid()).getNemCode());
|
|
|
}
|
|
|
+
|
|
|
if(CacheContext.wpmap.containsKey(vo.getStationid()))
|
|
|
{
|
|
|
alarm.setWpName(CacheContext.wpmap.get(vo.getStationid()).getName());
|
|
|
}
|
|
|
+
|
|
|
pushDataSevice.pushWtData(alarm);
|
|
|
|
|
|
+
|
|
|
tempmap.put(po.getTbname(),po);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
for (Map.Entry<String, ProEconAlarmInfo> entry : tempmap.entrySet()) {
|
|
|
valuels.add(entry.getValue());
|
|
|
}
|
|
@@ -542,7 +487,7 @@ public class AlarmInService {
|
|
|
List<ProEconAlarmInfo> templs = new ArrayList<>();
|
|
|
for (ProEconAlarmInfo vo : valuels) {
|
|
|
templs.add(vo);
|
|
|
- if (templs.size() == 1000) {
|
|
|
+ if (templs.size() == 500) {
|
|
|
proEconAlarmInfoService.saveBatch(templs);
|
|
|
templs = new ArrayList<>();
|
|
|
}
|
|
@@ -557,43 +502,6 @@ public class AlarmInService {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
+
|