|
@@ -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<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);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|