|
@@ -137,8 +137,14 @@ public class AlarmHistoryService {
|
|
|
// alarm.setVal(tag.getVal().doubleValue());
|
|
|
// }
|
|
|
//
|
|
|
- alarm.setEndts(null!=tag.getEndts()?tag.getEndts().getTime():null);
|
|
|
- alarm.setTimeLong(null!=tag.getTimelong()?tag.getTimelong():null);
|
|
|
+ alarm.setEndts(null!=tag.getEndts()?tag.getEndts().getTime():new Date().getTime());
|
|
|
+
|
|
|
+ Date begin = new Date(alarm.getEndts());
|
|
|
+ Date end = new Date(alarm.getTs());
|
|
|
+
|
|
|
+ double value = DateUtils.secondsDiff(begin, end);
|
|
|
+ alarm.setTimeLong(value);
|
|
|
+// alarm.setTimeLong(null!=tag.getTimelong()?tag.getTimelong():null);
|
|
|
// alarm.setConfirmed(true);
|
|
|
// savels.add(alarm);
|
|
|
}
|
|
@@ -289,13 +295,21 @@ public class AlarmHistoryService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ String characteristic=null;
|
|
|
//
|
|
|
if(StringUtils.notEmp(description) )
|
|
|
{
|
|
|
descriptionSql.append("%").append(description).append("%");
|
|
|
description=String.valueOf(descriptionSql);
|
|
|
+
|
|
|
+ if(alarmType.equals(AlarmTypeValue.CT.getCode()))
|
|
|
+ {
|
|
|
+ characteristic=description;
|
|
|
+ description=null;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
if(StringUtils.empty(deviceid) )
|
|
|
{
|
|
|
deviceid=null;
|
|
@@ -323,7 +337,7 @@ public class AlarmHistoryService {
|
|
|
components=null;
|
|
|
}else
|
|
|
{
|
|
|
- StringBuilder componentsList=new StringBuilder();
|
|
|
+ StringBuilder componentsList=new StringBuilder();
|
|
|
String [] componentsStr=components.split(",");
|
|
|
for(String c:componentsStr)
|
|
|
{
|
|
@@ -362,7 +376,7 @@ public class AlarmHistoryService {
|
|
|
{
|
|
|
isclose=null;
|
|
|
}
|
|
|
- vos = alarmTsMapper.selectByWtLimit(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType,components, alarmId,isclose,pageNum*pageSize, pageSize,subcomponents);
|
|
|
+ vos = alarmTsMapper.selectByWtLimit(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType,components, alarmId,isclose,pageNum*pageSize, pageSize,subcomponents,characteristic);
|
|
|
|
|
|
for(AlarmVo vo:vos)
|
|
|
{
|
|
@@ -390,12 +404,19 @@ public class AlarmHistoryService {
|
|
|
{
|
|
|
vo.setDescription(CacheContext.alarmMap.get(vo.getAlarmId()).getDescription());
|
|
|
}
|
|
|
+ StringBuilder sb=new StringBuilder();
|
|
|
+ sb.append(vo.getDeviceId()+"_"+vo.getAlarmId());
|
|
|
+ if(CacheContext.alarmCtMap.containsKey(String.valueOf(sb).toUpperCase()))
|
|
|
+ {
|
|
|
+ vo.setCharacteristic(CacheContext.alarmCtMap.get(String.valueOf(sb).toUpperCase()).getCharacteristic());
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
map.put("ls",vos);
|
|
|
- List<Integer> total=alarmTsMapper.selectByWtCount(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType,components,alarmId,isclose,subcomponents);
|
|
|
+ List<Integer> total=alarmTsMapper.selectByWtCount(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType,components,alarmId,isclose,subcomponents,characteristic);
|
|
|
|
|
|
if(!total.isEmpty())
|
|
|
{
|
|
@@ -408,6 +429,7 @@ public class AlarmHistoryService {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 查询报警信息接口
|
|
|
* @param begin 开始时间
|
|
@@ -478,15 +500,15 @@ public class AlarmHistoryService {
|
|
|
Date beginDate = DateUtils.truncate(endDate);
|
|
|
if(type.equals(AlarmTypeValue.BT.getCode()))
|
|
|
{
|
|
|
- vos = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.BT.getCode(), AlarmTypeValue.BT.getCode(), null, null, null,null,null, null,null,1, home_pagep_size,null);
|
|
|
+ vos = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.BT.getCode(), AlarmTypeValue.BT.getCode(), null, null, null,null,null, null,null,1, home_pagep_size,null,null);
|
|
|
|
|
|
}else if(type.equals(AlarmTypeValue.WT.getCode()))
|
|
|
{
|
|
|
- vos = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.WT.getCode(), AlarmTypeValue.WT.getCode(), null, null, null,null, null,null,null,1, home_pagep_size,null);
|
|
|
+ vos = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.WT.getCode(), AlarmTypeValue.WT.getCode(), null, null, null,null, null,null,null,1, home_pagep_size,null,null);
|
|
|
|
|
|
}else if(type.equals(AlarmTypeValue.CT.getCode()))
|
|
|
{
|
|
|
- vos = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.CT.getCode(), AlarmTypeValue.CT.getCode(), null, null, null,null, null,null,null,1, home_pagep_size,null);
|
|
|
+ vos = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.CT.getCode(), AlarmTypeValue.CT.getCode(), null, null, null,null, null,null,null,1, home_pagep_size,null,null);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -515,21 +537,21 @@ public class AlarmHistoryService {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- if(StringUtils.notEmp(alarmIds))
|
|
|
- {
|
|
|
- String [] alarmIdStr=alarmIds.split(",");
|
|
|
- for(String c:alarmIdStr)
|
|
|
- {
|
|
|
- alarmIdList.append("'").append(c).append("',");
|
|
|
- alarmIdMap.put(c,c);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- String alarmId=null;
|
|
|
+// if(StringUtils.notEmp(alarmIds))
|
|
|
+// {
|
|
|
+// String [] alarmIdStr=alarmIds.split(",");
|
|
|
+// for(String c:alarmIdStr)
|
|
|
+// {
|
|
|
+// alarmIdList.append("'").append(c).append("',");
|
|
|
+// alarmIdMap.put(c,c);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+ String alarmId=alarmIds;
|
|
|
String component=null;
|
|
|
if(alarmIdList.length()>0)
|
|
|
{
|
|
|
- alarmId=String.valueOf(alarmIdList.substring(0,alarmIdList.length()-1));
|
|
|
+ alarmId=String.valueOf(alarmIdList.substring(0,alarmIdList.length()-1));
|
|
|
}
|
|
|
if(componentsList.length()>0)
|
|
|
{
|
|
@@ -547,7 +569,16 @@ public class AlarmHistoryService {
|
|
|
{
|
|
|
fsls = alarmTsMapper.findWtFeatureStat(AlarmSuperTalbeType.WT.getCode(),startTime.getTime(), endTime.getTime(),stationId,modelId,component,alarmId, alarmType);
|
|
|
}
|
|
|
+ List<ProBasicFeatureStat> templs= new ArrayList<>();
|
|
|
+ for(ProBasicFeatureStat fs:fsls)
|
|
|
+ {
|
|
|
+ if(StringUtils.notEmp(fs.getTotalSeconds()) && StringUtils.notEmp(fs.getTotal()) && fs.getTotal()>0)
|
|
|
+ {
|
|
|
+ templs.add(fs);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ fsls=templs;
|
|
|
Map<String, ProBasicFeatureStat> map = new HashMap<>();
|
|
|
Date statDate=DateUtils.truncate(new Date());
|
|
|
|
|
@@ -564,8 +595,46 @@ public class AlarmHistoryService {
|
|
|
map.put(String.valueOf(sb), fs);
|
|
|
}
|
|
|
}
|
|
|
- List<ProBasicFeatureStat> vos = new ArrayList<>();
|
|
|
|
|
|
+
|
|
|
+// if(CacheContext.wpwtmap.containsKey(stationId))
|
|
|
+// {
|
|
|
+// List<ProBasicEquipment> wtls=CacheContext.wpwtmap.get(stationId);
|
|
|
+// for (ProBasicEquipment wt : wtls) {
|
|
|
+//
|
|
|
+// StringBuilder sb=new StringBuilder();
|
|
|
+// sb.append(wt.getWindpowerstationId()).append(wt.getModelId());
|
|
|
+// if(CacheContext.wtAlarmMap.containsKey(String.valueOf(sb))) {
|
|
|
+// List<ProEconAlarmConfiguration> ls = CacheContext.wtAlarmMap.get(String.valueOf(sb));
|
|
|
+// for (ProEconAlarmConfiguration at : ls) {
|
|
|
+// if(StringUtils.notEmp(components) )
|
|
|
+// {
|
|
|
+// if(componentsMap.containsKey(at.getComponents()) )
|
|
|
+// {
|
|
|
+// if(StringUtils.notEmp(alarmIdMap) && !alarmIdMap.isEmpty())
|
|
|
+// {
|
|
|
+// if( alarmIdMap.containsKey(at.getId()))
|
|
|
+// {
|
|
|
+// setWtValues(statDate, map, vos, wt, at);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }else
|
|
|
+// {
|
|
|
+// setWtValues(statDate, map, vos, wt, at);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }else
|
|
|
+// {
|
|
|
+// setWtValues(statDate, map, vos, wt, at);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ List<ProBasicFeatureStat> vos = new ArrayList<>();
|
|
|
if(CacheContext.wpwtmap.containsKey(stationId))
|
|
|
{
|
|
|
List<ProBasicEquipment> wtls=CacheContext.wpwtmap.get(stationId);
|
|
@@ -602,6 +671,51 @@ public class AlarmHistoryService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if(vos.size()<10)
|
|
|
+ {
|
|
|
+ if(CacheContext.wpwtmap.containsKey(stationId))
|
|
|
+ {
|
|
|
+ List<ProBasicEquipment> wtls=CacheContext.wpwtmap.get(stationId);
|
|
|
+ for (ProBasicEquipment wt : wtls) {
|
|
|
+
|
|
|
+ StringBuilder sb=new StringBuilder();
|
|
|
+ sb.append(wt.getWindpowerstationId()).append(wt.getModelId());
|
|
|
+ if(CacheContext.wtAlarmMap.containsKey(String.valueOf(sb))) {
|
|
|
+ List<ProEconAlarmConfiguration> ls = CacheContext.wtAlarmMap.get(String.valueOf(sb));
|
|
|
+ for (ProEconAlarmConfiguration at : ls) {
|
|
|
+ if(vos.size()>=10)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if(StringUtils.notEmp(components) )
|
|
|
+ {
|
|
|
+ if(componentsMap.containsKey(at.getComponents()) )
|
|
|
+ {
|
|
|
+ if(StringUtils.notEmp(alarmIdMap) && !alarmIdMap.isEmpty())
|
|
|
+ {
|
|
|
+ if( alarmIdMap.containsKey(at.getId()))
|
|
|
+ {
|
|
|
+ setWtValues2(statDate, map, vos, wt, at);
|
|
|
+ }
|
|
|
+
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ setWtValues2(statDate, map, vos, wt, at);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ setWtValues2(statDate, map, vos, wt, at);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
Map<String,List<AlarmStatVo>> vomap=new HashMap<>();
|
|
|
for(ProBasicFeatureStat fs:vos)
|
|
@@ -685,6 +799,35 @@ public class AlarmHistoryService {
|
|
|
}
|
|
|
private static void setWtValues(Date statDate,Map<String, ProBasicFeatureStat> map, List<ProBasicFeatureStat> vos, ProBasicEquipment wt, ProEconAlarmConfiguration at) {
|
|
|
|
|
|
+// ProBasicFeatureStat fs = new ProBasicFeatureStat();
|
|
|
+//
|
|
|
+// StringBuilder sb = new StringBuilder();
|
|
|
+// sb.append(wt.getId()).append("_").append(at.getId());
|
|
|
+// if (map.containsKey(String.valueOf(sb))) {
|
|
|
+// ProBasicFeatureStat old = map.get(String.valueOf(sb));
|
|
|
+// BeanUtil.copyProperties(old, fs);
|
|
|
+// }
|
|
|
+// else {
|
|
|
+// fs.setStatDate(new Timestamp(statDate.getTime()));
|
|
|
+// fs.setId(String.valueOf(SnowflakeGenerator.generateId()));
|
|
|
+// fs.setWtId(wt.getId());
|
|
|
+// fs.setStationId(wt.getWindpowerstationId());
|
|
|
+// fs.setTypeCode(at.getComponents());
|
|
|
+// if(CacheContext.alarmTypeMap.containsKey(at.getComponents()))
|
|
|
+// {
|
|
|
+// fs.setTypeName(CacheContext.alarmTypeMap.get(at.getComponents()).getName());
|
|
|
+// }
|
|
|
+// fs.setAlarmid(at.getId());
|
|
|
+// fs.setDescription(at.getDescription());
|
|
|
+// fs.setTotal(0L);
|
|
|
+// fs.setAvgSeconds(0.0);
|
|
|
+// fs.setMaxSeconds(0.0);
|
|
|
+// fs.setMinSeconds(0.0);
|
|
|
+// fs.setTotalSeconds(0.0);
|
|
|
+//
|
|
|
+// }
|
|
|
+// vos.add(fs);
|
|
|
+
|
|
|
ProBasicFeatureStat fs = new ProBasicFeatureStat();
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
@@ -692,26 +835,44 @@ public class AlarmHistoryService {
|
|
|
if (map.containsKey(String.valueOf(sb))) {
|
|
|
ProBasicFeatureStat old = map.get(String.valueOf(sb));
|
|
|
BeanUtil.copyProperties(old, fs);
|
|
|
- } else {
|
|
|
- fs.setStatDate(new Timestamp(statDate.getTime()));
|
|
|
- fs.setId(String.valueOf(SnowflakeGenerator.generateId()));
|
|
|
- fs.setWtId(wt.getId());
|
|
|
- fs.setStationId(wt.getWindpowerstationId());
|
|
|
- fs.setTypeCode(at.getComponents());
|
|
|
- if(CacheContext.alarmTypeMap.containsKey(at.getComponents()))
|
|
|
- {
|
|
|
- fs.setTypeName(CacheContext.alarmTypeMap.get(at.getComponents()).getName());
|
|
|
- }
|
|
|
- fs.setAlarmid(at.getId());
|
|
|
- fs.setDescription(at.getDescription());
|
|
|
- fs.setTotal(0L);
|
|
|
- fs.setAvgSeconds(0.0);
|
|
|
- fs.setMaxSeconds(0.0);
|
|
|
- fs.setMinSeconds(0.0);
|
|
|
- fs.setTotalSeconds(0.0);
|
|
|
+ vos.add(fs);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void setWtValues2(Date statDate,Map<String, ProBasicFeatureStat> map, List<ProBasicFeatureStat> vos, ProBasicEquipment wt, ProEconAlarmConfiguration at) {
|
|
|
+
|
|
|
+ ProBasicFeatureStat fs = new ProBasicFeatureStat();
|
|
|
+
|
|
|
+ if(vos.size()<10)
|
|
|
+ {
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ sb.append(wt.getId()).append("_").append(at.getId());
|
|
|
+ if (!map.containsKey(String.valueOf(sb))) {
|
|
|
+ fs.setStatDate(new Timestamp(statDate.getTime()));
|
|
|
+ fs.setId(String.valueOf(SnowflakeGenerator.generateId()));
|
|
|
+ fs.setWtId(wt.getId());
|
|
|
+ fs.setStationId(wt.getWindpowerstationId());
|
|
|
+ fs.setTypeCode(at.getComponents());
|
|
|
+ if(CacheContext.alarmTypeMap.containsKey(at.getComponents()))
|
|
|
+ {
|
|
|
+ fs.setTypeName(CacheContext.alarmTypeMap.get(at.getComponents()).getName());
|
|
|
+ }
|
|
|
+ fs.setAlarmid(at.getId());
|
|
|
+ fs.setDescription(at.getDescription());
|
|
|
+ fs.setTotal(0L);
|
|
|
+ fs.setAvgSeconds(0.0);
|
|
|
+ fs.setMaxSeconds(0.0);
|
|
|
+ fs.setMinSeconds(0.0);
|
|
|
+ fs.setTotalSeconds(0.0);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
vos.add(fs);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public List<AlarmStatVo> findCtFeatureStat(String stationId,String modelId, Date startTime, Date endTime,String components,String deviceType,String alarmIds,String timeType) {
|