|
@@ -1,16 +1,15 @@
|
|
|
package com.gyee.alarm.service;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
|
+import com.gyee.alarm.init.CacheContext;
|
|
|
import com.gyee.alarm.mapper.auto.AlarmTsMapper;
|
|
|
-import com.gyee.alarm.model.auto.ProEconElectricaltestPoint;
|
|
|
-import com.gyee.alarm.model.vo.AlarmSuperTalbeType;
|
|
|
-import com.gyee.alarm.model.vo.AlarmTsVo;
|
|
|
-import com.gyee.alarm.model.vo.AlarmTypeValue;
|
|
|
-import com.gyee.alarm.model.vo.AlarmVo;
|
|
|
+import com.gyee.alarm.model.auto.*;
|
|
|
+import com.gyee.alarm.model.vo.*;
|
|
|
import com.gyee.alarm.util.DateUtils;
|
|
|
import com.gyee.alarm.util.SnowflakeGenerator;
|
|
|
import com.gyee.common.model.StringUtils;
|
|
@@ -20,6 +19,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.sql.Timestamp;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -32,6 +32,8 @@ public class AlarmHistoryService {
|
|
|
@Resource
|
|
|
private AlarmTsMapper alarmTsMapper;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Value("${home_pagep_size}")
|
|
|
private int home_pagep_size;
|
|
|
/**
|
|
@@ -45,7 +47,7 @@ public class AlarmHistoryService {
|
|
|
* @param pageSize 每页多少条
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map<String,Object> findAlarmlist(String modelId, long begin,long end ,String alarmType,String stationid,String deviceid,String description,String deviceType, int pageNum, int pageSize) {
|
|
|
+ public Map<String,Object> findAlarmlist(String modelId, long begin,long end ,String alarmType,String stationid,String deviceid,String description,String deviceType,String components, int pageNum, int pageSize) {
|
|
|
|
|
|
Map<String,Object> map=new HashMap<>();
|
|
|
|
|
@@ -108,9 +110,14 @@ public class AlarmHistoryService {
|
|
|
{
|
|
|
deviceType=null;
|
|
|
}
|
|
|
- vos = alarmTsMapper.selectByWtLimit(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType, pageNum*pageSize, (pageNum*pageSize+pageSize));
|
|
|
+
|
|
|
+ if(StringUtils.empty(components) )
|
|
|
+ {
|
|
|
+ components=null;
|
|
|
+ }
|
|
|
+ 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,deviceType, deviceid, description);
|
|
|
+ int total=alarmTsMapper.selectByWtCount(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType,components);
|
|
|
map.put("total",total);
|
|
|
return map;
|
|
|
}
|
|
@@ -122,120 +129,158 @@ public class AlarmHistoryService {
|
|
|
Map<String,Object> map=new HashMap<>();
|
|
|
|
|
|
|
|
|
- SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+
|
|
|
Date endDate = new Date();
|
|
|
Date beginDate = DateUtils.truncate(endDate);
|
|
|
|
|
|
|
|
|
- List<AlarmVo> btls = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.BT.getCode(), AlarmTypeValue.BT.getCode(), 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);
|
|
|
|
|
|
- List<AlarmVo> wtls = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.WT.getCode(), AlarmTypeValue.WT.getCode(), 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, 0, home_pagep_size);
|
|
|
+ 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;
|
|
|
}
|
|
|
-//
|
|
|
-//
|
|
|
-// public List<AlarmStat1> findByCondition(String stationId, Date startTime, Date endTime) {
|
|
|
-// List<AlarmStat1> resultList = new ArrayList<>();
|
|
|
-//
|
|
|
-// List<FeatureStat> lst = featurePressureStatMapper.searchByCondition(stationId, startTime, endTime);
|
|
|
-//
|
|
|
-// //根据统计类型分组 YYBYX,LWYC,ZPH,YPH
|
|
|
-// Map<String, List<FeatureStat>> typeGorupMap = lst.stream().collect(Collectors.groupingBy(FeatureStat::getTypeCode));
|
|
|
-//
|
|
|
-//
|
|
|
-// // region 存储偏航类统计,将左偏航和右偏航进行合并
|
|
|
-// Map<String, List<FeatureStat>> yawStatMap = new HashMap<>();
|
|
|
-//
|
|
|
-// for (Map.Entry<String, List<FeatureStat>> entry : typeGorupMap.entrySet()) {
|
|
|
-//
|
|
|
-// //如果统计信息不是左偏航和右偏航
|
|
|
-// if (!entry.getKey().contains("ZPH") && !entry.getKey().contains("YPH")) {
|
|
|
-// //根据风机编号分组
|
|
|
-// Map<String, List<FeatureStat>> groupMap = entry.getValue().stream().collect(Collectors.groupingBy(FeatureStat::getWtId));
|
|
|
-//
|
|
|
-// for (Map.Entry<String, List<FeatureStat>> item : groupMap.entrySet()) {
|
|
|
-// AlarmStat1 d = new AlarmStat1();
|
|
|
-// if(entry.getKey().equals("JLDZ")){
|
|
|
-// d.setRelateParts("PHXT");
|
|
|
-// d.setRelatePartsText("偏航系统");
|
|
|
-// }else{
|
|
|
-// d.setRelateParts("YYXT");
|
|
|
-// d.setRelatePartsText("液压系统");
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (item.getValue() != null && item.getValue().size() > 0) {
|
|
|
-// FeatureStat stat = item.getValue().get(0);
|
|
|
-// d.setAlertText(stat.getTypeName());
|
|
|
-// } else {
|
|
|
-// if (entry.getKey().equals("YYBYX")) {
|
|
|
-// d.setAlertText("液压泵运行");
|
|
|
-// } else if (entry.getKey().equals("LWYC")) {
|
|
|
-// d.setAlertText("滤网压差");
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// double time = 0;
|
|
|
-// int count = 0;
|
|
|
-// time = item.getValue().stream().mapToDouble(FeatureStat::getTotalSeconds).sum();
|
|
|
-// count = item.getValue().stream().mapToInt(FeatureStat::getTotal).sum();
|
|
|
-// d.setCount(count);
|
|
|
-// //总时长以分钟为单位,不到一分钟则记为一分钟
|
|
|
-// double finalTime = Math.ceil(time / 60.0);
|
|
|
-//
|
|
|
-// d.setTime(finalTime);
|
|
|
-// d.setWindturbineId(item.getKey());
|
|
|
-// d.setStationId(stationId);
|
|
|
-// d.setSnapId(SnowflakeGenerator.generateId());
|
|
|
-// resultList.add(d);
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// if (!yawStatMap.containsKey("PH")) {
|
|
|
-// yawStatMap.put("PH", entry.getValue());
|
|
|
-// } else {
|
|
|
-// List<FeatureStat> yawList = yawStatMap.get("PH");
|
|
|
-// yawList.addAll(entry.getValue());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// //endregion
|
|
|
-// //针对偏航类信息再次进行整合并将结果合并到resultList
|
|
|
-//
|
|
|
-// for (Map.Entry<String, List<FeatureStat>> entry : yawStatMap.entrySet()) {
|
|
|
-// //根据风机编号进行分组
|
|
|
-// Map<String, List<FeatureStat>> groupMapByWindturbineId = entry.getValue().stream().collect(Collectors.groupingBy(FeatureStat::getWtId));
|
|
|
-// for (Map.Entry<String, List<FeatureStat>> item : groupMapByWindturbineId.entrySet()) {
|
|
|
-// AlarmStat1 d = new AlarmStat1();
|
|
|
-// d.setRelateParts("PHXT");
|
|
|
-// d.setRelatePartsText("偏航系统");
|
|
|
-// if (entry.getKey().equals("PH")) {
|
|
|
-// d.setAlertText("偏航");
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// double time = 0;
|
|
|
-// int count = 0;
|
|
|
-// time = item.getValue().stream().mapToDouble(FeatureStat::getTotalSeconds).sum();
|
|
|
-// count = item.getValue().stream().mapToInt(FeatureStat::getTotal).sum();
|
|
|
-// d.setCount(count);
|
|
|
-// //总时长以分钟为单位,不到一分钟则记为一分钟
|
|
|
-// double finalTime = Math.ceil(time / 60.0);
|
|
|
-//
|
|
|
-// d.setTime(finalTime);
|
|
|
-// d.setWindturbineId(item.getKey());
|
|
|
-// d.setStationId(stationId);
|
|
|
-// d.setSnapId(SnowflakeGenerator.generateId());
|
|
|
-// resultList.add(d);
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// return resultList;
|
|
|
-// }
|
|
|
+
|
|
|
+
|
|
|
+ public List<AlarmStatVo> findByCondition(String stationId, Date startTime, Date endTime,String components) {
|
|
|
+ List<AlarmStatVo> resultList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<ProBasicFeatureStat> fsls = alarmTsMapper.findFeatureStatList(startTime.getTime(), endTime.getTime(),stationId,components);
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, ProBasicFeatureStat> map = new HashMap<>();
|
|
|
+ Date statDate=DateUtils.truncate(new Date());
|
|
|
+
|
|
|
+ if (!fsls.isEmpty()) {
|
|
|
+ for (ProBasicFeatureStat fs : fsls) {
|
|
|
+ if (com.gyee.alarm.util.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<ProEconAlarmConfiguration> ls = CacheContext.wtAlarmMap.get(String.valueOf(sb));
|
|
|
+ for (ProEconAlarmConfiguration at : ls) {
|
|
|
+ if(StringUtils.notEmp(components) && components.equals(at.getComponents()))
|
|
|
+ {
|
|
|
+ setValues(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 setValues(Date statDate,Map<String, ProBasicFeatureStat> map, List<ProBasicFeatureStat> vos, ProBasicEquipment wt, ProEconAlarmConfiguration 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.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);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|