|
@@ -61,19 +61,19 @@ public class AlarmHistoryService {
|
|
|
//
|
|
|
// whereSql.append(" and alarmtype=CONCAT('',").append(alarmType).append(",'')");
|
|
|
|
|
|
- if(AlarmTypeValue.BT.getCode().equals(alarmType))
|
|
|
- {
|
|
|
- superTableName= AlarmSuperTalbeType.BT.getCode();
|
|
|
+ if(AlarmTypeValue.BT.getCode().equals(alarmType))
|
|
|
+ {
|
|
|
+ superTableName= AlarmSuperTalbeType.BT.getCode();
|
|
|
|
|
|
- }else if(AlarmTypeValue.WT.getCode().equals(alarmType))
|
|
|
- {
|
|
|
- superTableName= AlarmSuperTalbeType.WT.getCode();
|
|
|
+ }else if(AlarmTypeValue.WT.getCode().equals(alarmType))
|
|
|
+ {
|
|
|
+ superTableName= AlarmSuperTalbeType.WT.getCode();
|
|
|
|
|
|
- }else if(AlarmTypeValue.CT.getCode().equals(alarmType))
|
|
|
- {
|
|
|
- superTableName= AlarmSuperTalbeType.CT.getCode();
|
|
|
+ }else if(AlarmTypeValue.CT.getCode().equals(alarmType))
|
|
|
+ {
|
|
|
+ superTableName= AlarmSuperTalbeType.CT.getCode();
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// if(StringUtils.notEmp(stationid) )
|
|
@@ -115,13 +115,10 @@ public class AlarmHistoryService {
|
|
|
{
|
|
|
components=null;
|
|
|
}
|
|
|
- int limit = (pageNum - 1) * pageSize;
|
|
|
- int offset = pageSize;
|
|
|
- vos = alarmTsMapper.selectByWtLimit(begin, end, modelId, superTableName, alarmType, stationid, deviceid, description, deviceType, components, limit, offset);
|
|
|
-// vos = alarmTsMapper.selectByWtLimit(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType,components, pageNum*pageSize, (pageNum*pageSize+pageSize));
|
|
|
+ vos = alarmTsMapper.selectByWtLimit(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType,components, pageNum*pageSize, (pageNum*pageSize+pageSize));
|
|
|
map.put("ls",vos);
|
|
|
- int total=alarmTsMapper.selectByWtCount(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType,components);
|
|
|
- map.put("total",total);
|
|
|
+ List<Integer> total=alarmTsMapper.selectByWtCount(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType,components);
|
|
|
+ map.put("total",total.size());
|
|
|
return map;
|
|
|
}
|
|
|
|
|
@@ -136,24 +133,19 @@ public class AlarmHistoryService {
|
|
|
if(StringUtils.notEmp(type) )
|
|
|
{
|
|
|
Date endDate = new Date();
|
|
|
- Date beginDate = DateUtils.addHours(endDate,-1);
|
|
|
-
|
|
|
-// Calendar calendar = Calendar.getInstance();
|
|
|
-// calendar.setTime(endDate);
|
|
|
-// calendar.set(Calendar.MONTH, Calendar.AUGUST);
|
|
|
-// calendar.set(Calendar.DAY_OF_MONTH, 18);
|
|
|
-// Date beginDate = calendar.getTime();
|
|
|
+// Date beginDate = DateUtils.addHours(endDate,-1);
|
|
|
+ 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, 0, home_pagep_size);
|
|
|
+ vos = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.BT.getCode(), AlarmTypeValue.BT.getCode(), null, null, null,null,null, 1, home_pagep_size);
|
|
|
|
|
|
}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,0, home_pagep_size);
|
|
|
+ vos = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.WT.getCode(), AlarmTypeValue.WT.getCode(), null, null, null,null, null,1, home_pagep_size);
|
|
|
|
|
|
}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,0, home_pagep_size);
|
|
|
+ vos = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.CT.getCode(), AlarmTypeValue.CT.getCode(), null, null, null,null, null,1, home_pagep_size);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -163,12 +155,37 @@ public class AlarmHistoryService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public List<AlarmStatVo> findWtFeatureStat(String stationId,String modelId, Date startTime, Date endTime,String components) {
|
|
|
+ public List<AlarmStatVo> findWtFeatureStat(String stationId,String modelId, Date startTime, Date endTime,String components,String alarmIds) {
|
|
|
List<AlarmStatVo> resultList = new ArrayList<>();
|
|
|
|
|
|
+ List<String> alarmIdList=new ArrayList();
|
|
|
+ List<String> componentsList=new ArrayList();
|
|
|
|
|
|
+ Map<String,String> alarmIdMap=new HashMap<>();
|
|
|
+ Map<String,String> componentsMap=new HashMap();
|
|
|
|
|
|
- List<ProBasicFeatureStat> fsls = alarmTsMapper.findWtFeatureStat(startTime.getTime(), endTime.getTime(),stationId,modelId,components);
|
|
|
+ if(StringUtils.notEmp(components))
|
|
|
+ {
|
|
|
+ String [] componentsStr=components.split(",");
|
|
|
+ for(String c:componentsStr)
|
|
|
+ {
|
|
|
+ componentsList.add(c);
|
|
|
+ componentsMap.put(c,c);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if(StringUtils.notEmp(alarmIds))
|
|
|
+ {
|
|
|
+ String [] alarmIdStr=alarmIds.split(",");
|
|
|
+ for(String c:alarmIdStr)
|
|
|
+ {
|
|
|
+ alarmIdList.add(c);
|
|
|
+ alarmIdMap.put(c,c);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ProBasicFeatureStat> fsls = alarmTsMapper.findWtFeatureStat(startTime.getTime(), endTime.getTime(),stationId,modelId,componentsList,alarmIdList);
|
|
|
|
|
|
|
|
|
Map<String, ProBasicFeatureStat> map = new HashMap<>();
|
|
@@ -176,7 +193,7 @@ public class AlarmHistoryService {
|
|
|
|
|
|
if (!fsls.isEmpty()) {
|
|
|
for (ProBasicFeatureStat fs : fsls) {
|
|
|
- if (com.gyee.alarm.util.StringUtils.notEmp(fs.getTypeCode()) && CacheContext.alarmTypeMap.containsKey(fs.getTypeCode())) {
|
|
|
+ if (StringUtils.notEmp(fs.getTypeCode()) && CacheContext.alarmTypeMap.containsKey(fs.getTypeCode())) {
|
|
|
ProEconAlarmType at = CacheContext.alarmTypeMap.get(fs.getTypeCode());
|
|
|
fs.setTypeName(at.getName());
|
|
|
}
|
|
@@ -199,9 +216,9 @@ public class AlarmHistoryService {
|
|
|
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(StringUtils.notEmp(components) && StringUtils.notEmp(alarmIdMap))
|
|
|
{
|
|
|
- if( components.equals(at.getComponents()))
|
|
|
+ if( componentsMap.containsKey(at.getComponents()) && alarmIdMap.containsKey(at.getId()))
|
|
|
{
|
|
|
setWtValues(statDate, map, vos, wt, at);
|
|
|
}
|
|
@@ -217,38 +234,38 @@ public class AlarmHistoryService {
|
|
|
|
|
|
|
|
|
Map<String,List<AlarmStatVo>> vomap=new HashMap<>();
|
|
|
- for(ProBasicFeatureStat fs:vos)
|
|
|
- {
|
|
|
- AlarmStatVo d = new AlarmStatVo();
|
|
|
- d.setRelateParts(fs.getTypeCode());
|
|
|
- d.setRelatePartsText(fs.getTypeName());
|
|
|
- d.setAlertText(fs.getDescription());
|
|
|
- d.setCount(fs.getTotal());
|
|
|
- d.setTime(fs.getTotalSeconds());
|
|
|
- d.setStationId(fs.getStationId());
|
|
|
- d.setSnapId(SnowflakeGenerator.generateId());
|
|
|
- d.setWindturbineId(fs.getWtId());
|
|
|
- if(CacheContext.wtmap.containsKey(fs.getWtId()))
|
|
|
- {
|
|
|
- ProBasicEquipment wt= CacheContext.wtmap.get(fs.getWtId());
|
|
|
- d.setWindturbineCode(wt.getNemCode());
|
|
|
- }
|
|
|
-
|
|
|
- StringBuilder sb=new StringBuilder();
|
|
|
- sb.append(fs.getWtId()).append("_").append(fs.getTypeCode()).append("_").append(fs.getAlarmid());
|
|
|
-
|
|
|
- if(map.containsKey(String.valueOf(sb)))
|
|
|
- {
|
|
|
- List<AlarmStatVo> ls=vomap.get(String.valueOf(sb));
|
|
|
- ls.add(d);
|
|
|
- }else
|
|
|
- {
|
|
|
- List<AlarmStatVo> ls=new ArrayList<>();
|
|
|
- ls.add(d);
|
|
|
- vomap.put(String.valueOf(sb),ls);
|
|
|
- }
|
|
|
- resultList.add(d);
|
|
|
- }
|
|
|
+ for(ProBasicFeatureStat fs:vos)
|
|
|
+ {
|
|
|
+ AlarmStatVo d = new AlarmStatVo();
|
|
|
+ d.setRelateParts(fs.getTypeCode());
|
|
|
+ d.setRelatePartsText(fs.getTypeName());
|
|
|
+ d.setAlertText(fs.getDescription());
|
|
|
+ d.setCount(fs.getTotal());
|
|
|
+ d.setTime(fs.getTotalSeconds());
|
|
|
+ d.setStationId(fs.getStationId());
|
|
|
+ d.setSnapId(SnowflakeGenerator.generateId());
|
|
|
+ d.setWindturbineId(fs.getWtId());
|
|
|
+ if(CacheContext.wtmap.containsKey(fs.getWtId()))
|
|
|
+ {
|
|
|
+ ProBasicEquipment wt= CacheContext.wtmap.get(fs.getWtId());
|
|
|
+ d.setWindturbineCode(wt.getNemCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuilder sb=new StringBuilder();
|
|
|
+ sb.append(fs.getWtId()).append("_").append(fs.getTypeCode()).append("_").append(fs.getAlarmid());
|
|
|
+
|
|
|
+ if(map.containsKey(String.valueOf(sb)))
|
|
|
+ {
|
|
|
+ List<AlarmStatVo> ls=vomap.get(String.valueOf(sb));
|
|
|
+ ls.add(d);
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ List<AlarmStatVo> ls=new ArrayList<>();
|
|
|
+ ls.add(d);
|
|
|
+ vomap.put(String.valueOf(sb),ls);
|
|
|
+ }
|
|
|
+ resultList.add(d);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
for (Map.Entry<String,List<AlarmStatVo>> entry : vomap.entrySet()) {
|
|
@@ -307,12 +324,37 @@ public class AlarmHistoryService {
|
|
|
vos.add(fs);
|
|
|
}
|
|
|
|
|
|
- public List<AlarmStatVo> findCtFeatureStat(String stationId,String modelId, Date startTime, Date endTime,String description) {
|
|
|
+ public List<AlarmStatVo> findCtFeatureStat(String stationId,String modelId, Date startTime, Date endTime,String components,String alarmIds) {
|
|
|
List<AlarmStatVo> resultList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
+ List<String> alarmIdList=new ArrayList();
|
|
|
+ List<String> componentsList=new ArrayList();
|
|
|
|
|
|
- List<ProBasicFeatureStat> fsls = alarmTsMapper.findCtFeatureStat(startTime.getTime(), endTime.getTime(),stationId,modelId,description);
|
|
|
+ Map<String,String> alarmIdMap=new HashMap<>();
|
|
|
+ Map<String,String> componentsMap=new HashMap();
|
|
|
+
|
|
|
+ if(StringUtils.notEmp(components))
|
|
|
+ {
|
|
|
+ String [] componentsStr=components.split(",");
|
|
|
+ for(String c:componentsStr)
|
|
|
+ {
|
|
|
+ componentsList.add(c);
|
|
|
+ componentsMap.put(c,c);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if(StringUtils.notEmp(alarmIds))
|
|
|
+ {
|
|
|
+ String [] alarmIdStr=alarmIds.split(",");
|
|
|
+ for(String c:alarmIdStr)
|
|
|
+ {
|
|
|
+ alarmIdList.add(c);
|
|
|
+ alarmIdMap.put(c,c);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ List<ProBasicFeatureStat> fsls = alarmTsMapper.findCtFeatureStat(startTime.getTime(), endTime.getTime(),stationId,modelId,componentsList,alarmIdList);
|
|
|
|
|
|
|
|
|
Map<String, ProBasicFeatureStat> map = new HashMap<>();
|
|
@@ -344,19 +386,20 @@ public class AlarmHistoryService {
|
|
|
List<ProEconAlarmRule> wtCustomls=CacheContext.alarmRulesMap.get(AlarmCustomType.WT.getCode());
|
|
|
|
|
|
for (ProEconAlarmRule at : wtCustomls) {
|
|
|
- if(StringUtils.notEmp(description) && description.equals(at.getDescription()))
|
|
|
+
|
|
|
+
|
|
|
+ if(StringUtils.notEmp(components) && StringUtils.notEmp(alarmIdMap))
|
|
|
{
|
|
|
- if(description.equals(at.getDescription()))
|
|
|
+ if(componentsMap.containsKey(at.getRelatedParts()) && alarmIdMap.containsKey(at.getId()))
|
|
|
{
|
|
|
setCtValues(statDate, map, vos, wt, at);
|
|
|
}
|
|
|
-
|
|
|
}else
|
|
|
{
|
|
|
setCtValues(statDate, map, vos, wt, at);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|