|
@@ -124,32 +124,43 @@ public class AlarmHistoryService {
|
|
|
|
|
|
|
|
|
|
|
|
- public Map<String,Object> findAlarmByTypelist() {
|
|
|
+ public List<AlarmVo> findAlarmByTypelist(String type) {
|
|
|
|
|
|
- Map<String,Object> map=new HashMap<>();
|
|
|
|
|
|
+ List<AlarmVo> vos=new ArrayList<>();
|
|
|
|
|
|
|
|
|
+ if(StringUtils.notEmp(type) )
|
|
|
+ {
|
|
|
Date endDate = new Date();
|
|
|
- Date beginDate = DateUtils.truncate(endDate);
|
|
|
+ Date beginDate = DateUtils.addHours(endDate,-1);
|
|
|
+
|
|
|
+ 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);
|
|
|
|
|
|
+ }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);
|
|
|
|
|
|
- List<AlarmVo> btls = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.BT.getCode(), AlarmTypeValue.BT.getCode(), null, null, null,null,null, 0, home_pagep_size);
|
|
|
- map.put("btls",btls);
|
|
|
+ }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);
|
|
|
|
|
|
- List<AlarmVo> wtls = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.WT.getCode(), AlarmTypeValue.WT.getCode(), null, null, null,null, null,0, home_pagep_size);
|
|
|
- map.put("wtls",wtls);
|
|
|
+ }
|
|
|
|
|
|
- List<AlarmVo> ctls = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.CT.getCode(), AlarmTypeValue.CT.getCode(), null, null, null,null, null,0, home_pagep_size);
|
|
|
- map.put("ctls",ctls);
|
|
|
- return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ return vos;
|
|
|
}
|
|
|
|
|
|
|
|
|
- public List<AlarmStatVo> findByCondition(String stationId, Date startTime, Date endTime,String components) {
|
|
|
+ public List<AlarmStatVo> findWtFeatureStat(String stationId,String modelId, Date startTime, Date endTime,String components) {
|
|
|
List<AlarmStatVo> resultList = new ArrayList<>();
|
|
|
|
|
|
- List<ProBasicFeatureStat> fsls = alarmTsMapper.findFeatureStatList(startTime.getTime(), endTime.getTime(),stationId,components);
|
|
|
+
|
|
|
+
|
|
|
+ List<ProBasicFeatureStat> fsls = alarmTsMapper.findWtFeatureStat(startTime.getTime(), endTime.getTime(),stationId,modelId,components);
|
|
|
|
|
|
|
|
|
Map<String, ProBasicFeatureStat> map = new HashMap<>();
|
|
@@ -180,9 +191,15 @@ 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) && components.equals(at.getComponents()))
|
|
|
+ if(StringUtils.notEmp(components) )
|
|
|
{
|
|
|
- setValues(statDate, map, vos, wt, at);
|
|
|
+ if( components.equals(at.getComponents()))
|
|
|
+ {
|
|
|
+ setWtValues(statDate, map, vos, wt, at);
|
|
|
+ }
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ setWtValues(statDate, map, vos, wt, at);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -251,7 +268,7 @@ public class AlarmHistoryService {
|
|
|
|
|
|
return resultList;
|
|
|
}
|
|
|
- private static void setValues(Date statDate,Map<String, ProBasicFeatureStat> map, List<ProBasicFeatureStat> vos, ProBasicEquipment wt, ProEconAlarmConfiguration at) {
|
|
|
+ private static void setWtValues(Date statDate,Map<String, ProBasicFeatureStat> map, List<ProBasicFeatureStat> vos, ProBasicEquipment wt, ProEconAlarmConfiguration at) {
|
|
|
|
|
|
ProBasicFeatureStat fs = new ProBasicFeatureStat();
|
|
|
|
|
@@ -282,5 +299,149 @@ public class AlarmHistoryService {
|
|
|
vos.add(fs);
|
|
|
}
|
|
|
|
|
|
+ public List<AlarmStatVo> findCtFeatureStat(String stationId,String modelId, Date startTime, Date endTime,String description) {
|
|
|
+ List<AlarmStatVo> resultList = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ List<ProBasicFeatureStat> fsls = alarmTsMapper.findCtFeatureStat(startTime.getTime(), endTime.getTime(),stationId,modelId,description);
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, ProBasicFeatureStat> map = new HashMap<>();
|
|
|
+ Date statDate=DateUtils.truncate(new Date());
|
|
|
+
|
|
|
+ if (!fsls.isEmpty()) {
|
|
|
+ for (ProBasicFeatureStat fs : fsls) {
|
|
|
+ if (StringUtils.notEmp(fs.getTypeCode()) && CacheContext.alarmTypeMap.containsKey(fs.getTypeCode())) {
|
|
|
+ ProEconAlarmType at = CacheContext.alarmTypeMap.get(fs.getTypeCode());
|
|
|
+ fs.setTypeName(at.getName());
|
|
|
+ }
|
|
|
+ fs.setStatDate(new Timestamp(statDate.getTime()));
|
|
|
+ fs.setId(String.valueOf(SnowflakeGenerator.generateId()));
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ sb.append(fs.getWtId()).append("_").append(fs.getAlarmid());
|
|
|
+ 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<ProEconAlarmRule> wtCustomls=CacheContext.alarmRulesMap.get(AlarmCustomType.WT.getCode());
|
|
|
+
|
|
|
+ for (ProEconAlarmRule at : wtCustomls) {
|
|
|
+ if(StringUtils.notEmp(description) && description.equals(at.getDescription()))
|
|
|
+ {
|
|
|
+ if(description.equals(at.getDescription()))
|
|
|
+ {
|
|
|
+ setCtValues(statDate, map, vos, wt, at);
|
|
|
+ }
|
|
|
+
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ setCtValues(statDate, map, vos, wt, at);
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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 (Map.Entry<String,List<AlarmStatVo>> entry : vomap.entrySet()) {
|
|
|
+
|
|
|
+ AlarmStatVo d = new AlarmStatVo();
|
|
|
+ List<AlarmStatVo> templs=entry.getValue();
|
|
|
+ if(!templs.isEmpty())
|
|
|
+ {
|
|
|
+ BeanUtil.copyProperties(templs.get(0),d);
|
|
|
+
|
|
|
+ double time = 0;
|
|
|
+ long count = 0;
|
|
|
+ time = templs.stream().mapToDouble(AlarmStatVo::getTime).sum();
|
|
|
+ count = templs.stream().mapToLong(AlarmStatVo::getCount).sum();
|
|
|
+ d.setCount(count);
|
|
|
+ //总时长以分钟为单位,不到一分钟则记为一分钟
|
|
|
+ double finalTime = Math.ceil(time / 60.0);
|
|
|
+
|
|
|
+ d.setTime(finalTime);
|
|
|
+ resultList.add(d);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+ private static void setCtValues(Date statDate,Map<String, ProBasicFeatureStat> map, List<ProBasicFeatureStat> vos, ProBasicEquipment wt, ProEconAlarmRule at) {
|
|
|
+
|
|
|
+ ProBasicFeatureStat fs = new ProBasicFeatureStat();
|
|
|
+
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ sb.append(fs.getWtId()).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.getCategory());
|
|
|
+ if(CacheContext.alarmTypeMap.containsKey(at.getCategory()))
|
|
|
+ {
|
|
|
+ fs.setTypeName(CacheContext.alarmTypeMap.get(at.getCategory()).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);
|
|
|
+ }
|
|
|
}
|