Commit d70370e0 authored by qinhu's avatar qinhu

报警实时数据

parent a4daf459
package cn.wise.sc.energy.power.plant.business.controller;
import cn.wise.sc.energy.power.plant.business.domain.vo.AlertInfoVo;
import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @description: 阈值更新记录
* @author: qh
* @create: 2020-09-03 15:22
**/
@CrossOrigin
@RestController
@RequestMapping("alertinfo/")
public class AlertInfoController {
@GetMapping
public BaseResponse<List<AlertInfoVo>> list(){
return null;
}
}
package cn.wise.sc.energy.power.plant.business.controller; package cn.wise.sc.energy.power.plant.business.controller;
import cn.hutool.core.util.StrUtil;
import cn.wise.sc.energy.power.plant.business.bean.DataPower; import cn.wise.sc.energy.power.plant.business.bean.DataPower;
import cn.wise.sc.energy.power.plant.business.domain.CharacterParamInfo;
import cn.wise.sc.energy.power.plant.business.domain.Oscillogram;
import cn.wise.sc.energy.power.plant.business.domain.OscillogramRowMapper;
import cn.wise.sc.energy.power.plant.business.domain.OscillogramTagsMapper;
import cn.wise.sc.energy.power.plant.business.domain.TendencyQuery; import cn.wise.sc.energy.power.plant.business.domain.TendencyQuery;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo; import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import cn.wise.sc.energy.power.plant.business.service.ICharacterParamService; import cn.wise.sc.energy.power.plant.business.service.ICharacterParamService;
import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse; import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
import com.spring4all.spring.boot.starter.hbase.api.HbaseTemplate; import com.spring4all.spring.boot.starter.hbase.api.HbaseTemplate;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.filter.CompareFilter;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.filter.FilterList;
import org.apache.hadoop.hbase.filter.RowFilter;
import org.apache.hadoop.hbase.filter.SubstringComparator;
import org.apache.hadoop.hbase.util.Bytes;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -27,11 +15,11 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -27,11 +15,11 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList; import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -77,7 +65,7 @@ public class CharacterParamController { ...@@ -77,7 +65,7 @@ public class CharacterParamController {
} }
@PostMapping("/oscillogram") @PostMapping("/oscillogram")
public BaseResponse<Map<String,String>> oscillogram(@RequestBody List<String> kksCodes) { public BaseResponse<Map<String,String>> oscillogram(@RequestBody List<String> kksCodes) throws IOException {
return BaseResponse.okData(iCharacterParamService.getOscillogram(kksCodes)); return BaseResponse.okData(iCharacterParamService.getOscillogram(kksCodes));
} }
...@@ -86,7 +74,7 @@ public class CharacterParamController { ...@@ -86,7 +74,7 @@ public class CharacterParamController {
public BaseResponse<Boolean> uploadFile(MultipartFile file) { public BaseResponse<Boolean> uploadFile(MultipartFile file) {
try { try {
//将文件内容转成json //将文件内容转成json
InputStreamReader inputStreamReader = new InputStreamReader(file.getInputStream(), "utf-8"); InputStreamReader inputStreamReader = new InputStreamReader(file.getInputStream(), StandardCharsets.UTF_8);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader); BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String s; String s;
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
......
package cn.wise.sc.energy.power.plant.business.controller;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import cn.wise.sc.energy.power.plant.business.service.IEventInfoService;
import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @description: 报警事件
* @author: qh
* @create: 2020-09-03 14:21
**/
@CrossOrigin
@RestController
@RequestMapping("event/info/")
public class EventInfoController {
final
IEventInfoService iEventInfoService;
public EventInfoController(IEventInfoService iEventInfoService) {
this.iEventInfoService = iEventInfoService;
}
@GetMapping
public BaseResponse<List<EntityVo>> listByState(Integer state) {
List<EntityVo> entityVos = iEventInfoService.listByState(state);
if (entityVos.size() == 0){
return BaseResponse.errorMsg("没找着!");
}else {
return BaseResponse.okData(entityVos);
}
}
}
package cn.wise.sc.energy.power.plant.business.domain;
import cn.wise.sc.energy.power.plant.business.domain.vo.AlertInfoVo;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import cn.wise.sc.energy.power.plant.business.domain.vo.EventInfoVo;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @description: 预警值更新记录表
* @author: qh
* @create: 2020-09-03 09:52
**/
@Data
@Entity
@Table(name = "altinfo")
public class AlertInfo extends AbstractEntity<Long> {
@Override
public EntityVo toVo() {
AlertInfoVo entityVo = new AlertInfoVo();
BeanUtils.copyProperties(this, entityVo);
return entityVo;
}
@Id
private Long id;
/**
* 监测特征所属电站的标识
*/
@Column(name = "plantid")
private String plantId;
/**
* 监测特征所属设备的标识
*/
@Column(name = "deviceid")
private String deviceId;
/**
* 监测特征所属监测单元标识
*/
@Column(name = "unitcodeid")
private String unitCodeId;
/**
* 监测特征唯一标识编码(KKS编码
*/
@Column(name = "kkscode")
private String kKSCode;
/**
* 预警值
*/
@Column(name = "value")
private Float value;
/**
* 预警值
*/
@Column(name = "newvalue")
private Float newValue;
/**
* 记录更新时间
*/
@Column(name = "valuetime")
private Long valuetime;
/**
* 设置来源(角色或后台)
*/
@Column(name = "usr")
private String usr;
}
package cn.wise.sc.energy.power.plant.business.domain;
import cn.wise.sc.energy.power.plant.business.domain.vo.BtreeInfoVo;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
/**
* @description:
* @author: qh
* @create: 2020-09-03 10:00
**/
@Data
@Entity
@Table(name = "btreeinfo")
public class BtreeInfo extends AbstractEntity<Long> {
@Override
public EntityVo toVo() {
BtreeInfoVo entityVo = new BtreeInfoVo();
BeanUtils.copyProperties(this, entityVo);
return entityVo;
}
@Id
private Long id;
/**
* 监测特征所属电站的标识
*/
@Column(name = "plantid")
private String plantId;
/**
* 监测特征所属设备的标识
*/
@Column(name = "deviceid")
private String deviceId;
/**
* 监测特征所属监测单元标识
*/
@Column(name = "unitcodeid")
private String unitCodeId;
/**
* 二叉树诊断名称
*/
@Column(name = "btreename")
private String btreeName;
/**
* 0:正常,1:异常 2:其他
*/
@Column(name = "result")
private Integer result;
/**
* 诊断结论,json格式结论
*/
@Lob
@Column(name = "diagnosis")
private String diagnosis;
}
...@@ -40,7 +40,8 @@ public class CharacterParamInfo extends AbstractEntity<String> { ...@@ -40,7 +40,8 @@ public class CharacterParamInfo extends AbstractEntity<String> {
BeanUtils.copyProperties(this, characterParamInfoVo); BeanUtils.copyProperties(this, characterParamInfoVo);
return characterParamInfoVo; return characterParamInfoVo;
} }
@Column(name = "parentdir")
private String parentDir;
/** /**
* 监测特征所属电站的标识 * 监测特征所属电站的标识
*/ */
...@@ -165,6 +166,7 @@ public class CharacterParamInfo extends AbstractEntity<String> { ...@@ -165,6 +166,7 @@ public class CharacterParamInfo extends AbstractEntity<String> {
* 一级报警下限值 * 一级报警下限值
*/ */
private Float protectRuleMinValue; private Float protectRuleMinValue;
/** /**
* 特征参数保护(一级报警)规则阈值范围是否是排除范围 * 特征参数保护(一级报警)规则阈值范围是否是排除范围
* 1: 是排除范围 0:是限定范围 * 1: 是排除范围 0:是限定范围
......
package cn.wise.sc.energy.power.plant.business.domain;
import cn.wise.sc.energy.power.plant.business.domain.vo.DeviceInfoVo;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import cn.wise.sc.energy.power.plant.business.domain.vo.EventInfoVo;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @description: 事件记录
* @author: qh
* @create: 2020-09-03 09:36
**/
@Data
@Entity
@Table(name = "eventinfo")
public class EventInfo extends AbstractEntity<Long> {
@Override
public EntityVo toVo(){
EventInfoVo entityVo = new EventInfoVo();
BeanUtils.copyProperties(this,entityVo);
return entityVo;
}
@Id
private Long id;
/**
* 记录时间
*/
@Column(name = "valuetime")
private long valueTime;
/**
* 监测特征所属电站的标识
*/
@Column(name = "plantid")
private String plantId;
/**
* 监测特征所属设备的标识
*/
@Column(name = "deviceid")
private String deviceId;
/**监测特征所属监测单元标识
*
*/
@Column(name = "unitcodeid")
private String unitCodeId;
/**
* 监测特征唯一标识编码(KKS编码
*/
@Column(name = "kkscode")
private String kKSCode;
/**
* 实际测量值
*/
@Column(name = "value")
private Float value;
/**
* 信号状态:0-正常、1-无效、2-预警报警、
* 3-高报警、4-高高报警、5-上趋势报警、6-下趋势报警
*/
@Column(name = "alertstat")
private Integer alertStat;
/**
* 特征参数保护下限值
*/
@Column(name = "alertminvalue")
private Float alertMinvalue;
/**
* 特征参数保护上限值
*/
@Column(name = "alertmaxvalue")
private Float alertMaxvalue;
/**
* 预警范围:0-范围内 1-范围外
*/
@Column(name = "alertlimit")
private Integer alertLimit;
/**
* 预警值设置来源 (角色或后台)
*/
@Column(name = "altlimitusr")
private String altLimitUsr;
/**
* 监测特征的物理单位,如 um/mm 等
*/
@Column(name = "cpunit")
private String cpUnit;
/**
* 事件状态:0-未处理 1-已处理
*/
@Column(name = "eventinfo")
private Integer eventInfo;
}
...@@ -16,6 +16,7 @@ import java.util.NavigableMap; ...@@ -16,6 +16,7 @@ import java.util.NavigableMap;
* @author: qh * @author: qh
* @create: 2020-08-20 15:25 * @create: 2020-08-20 15:25
**/ **/
@Deprecated
public class OscillogramRowMapper implements RowMapper<Oscillogram> { public class OscillogramRowMapper implements RowMapper<Oscillogram> {
private static byte[] RECORDS = "records".getBytes(); private static byte[] RECORDS = "records".getBytes();
......
...@@ -15,6 +15,7 @@ import java.util.Set; ...@@ -15,6 +15,7 @@ import java.util.Set;
* @author: qh * @author: qh
* @create: 2020-08-24 16:37 * @create: 2020-08-24 16:37
**/ **/
@Deprecated
public class OscillogramTagsMapper implements RowMapper<Oscillogram> { public class OscillogramTagsMapper implements RowMapper<Oscillogram> {
private static byte[] COLUMNFAMILY = "tags".getBytes(); private static byte[] COLUMNFAMILY = "tags".getBytes();
......
package cn.wise.sc.energy.power.plant.business.domain;
import cn.hutool.core.codec.Base64Encoder;
import com.alibaba.fastjson.JSON;
import com.spring4all.spring.boot.starter.hbase.api.RowMapper;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;
import java.util.List;
/**
* @description: rowKey
* @author: qh
* @create: 2020-09-02 11:38
**/
public class RowKeyMapper implements RowMapper<Oscillogram> {
private static byte[] REORDSFAMILY = "records".getBytes();
private static byte[] DATA = "Data".getBytes();
private static byte[] TAGSFAMILY = "tags".getBytes();
private static byte[] TIMESPAN = "TimeSpan".getBytes();
private static byte[] DATATYPE = "DataType".getBytes();
private static byte[] DIRECTION = "Direction".getBytes();
private static byte[] GENERATIONFREQ = "GenerationFreq".getBytes();
private static byte[] KKSCODE = "KKSCode".getBytes();
private static byte[] PARTTYPE = "PartType".getBytes();
private static byte[] POLENUM = "PoleNum".getBytes();
private static byte[] RECORDFLAG = "RecordFlag".getBytes();
private static byte[] SIGNALTYPE = "Signaltype".getBytes();
private static byte[] STARTTIME = "StartTime".getBytes();
private static byte[] OFFSET = "KeyPhaseOffset".getBytes();
@Override
public Oscillogram mapRow(Result result, int rowNum) {
String timeSpan = Bytes.toString(result.getValue(TAGSFAMILY, TIMESPAN));
String dataType = Bytes.toString(result.getValue(TAGSFAMILY, DATATYPE));
String direction = Bytes.toString(result.getValue(TAGSFAMILY, DIRECTION));
String generationFreq = Bytes.toString(result.getValue(TAGSFAMILY, GENERATIONFREQ));
String kKSCode = Bytes.toString(result.getValue(TAGSFAMILY, KKSCODE));
String partType = Bytes.toString(result.getValue(TAGSFAMILY, PARTTYPE));
String poleNum = Bytes.toString(result.getValue(TAGSFAMILY, POLENUM));
String recordFlag = Bytes.toString(result.getValue(TAGSFAMILY, RECORDFLAG));
String signaltype = Bytes.toString(result.getValue(TAGSFAMILY, SIGNALTYPE));
String startTime = Bytes.toString(result.getValue(TAGSFAMILY, STARTTIME));
List<Float> data = JSON.parseArray(Bytes.toString(result.getValue(REORDSFAMILY, DATA)), Float.class);
Oscillogram oscillogram = new Oscillogram();
oscillogram.setRowKey(Base64Encoder.encode(result.getRow()));
oscillogram.setPeriod(0);
oscillogram.setKKsCode(kKSCode);
oscillogram.setMapData(data);
//获取偏移量
oscillogram.setNoVersionKeyPhaseOffset(JSON.parseArray(Bytes.toString(result.getValue(REORDSFAMILY, OFFSET)), Float.class));
try {
oscillogram.setTimeSpan(Long.parseLong(timeSpan));
} catch (NumberFormatException ex) {
oscillogram.setTimeSpan(0L);
}
try {
oscillogram.setRecordFlag(Integer.parseInt(recordFlag));
} catch (NumberFormatException ex) {
oscillogram.setRecordFlag(1);
}
try {
oscillogram.setGenerationFreq(Integer.parseInt(generationFreq));
} catch (NumberFormatException ex) {
oscillogram.setGenerationFreq(1);
}
try {
oscillogram.setPoleNum(Integer.parseInt(poleNum));
} catch (NumberFormatException ex) {
oscillogram.setPoleNum(0);
}
try {
oscillogram.setStart(Long.parseLong(startTime));
} catch (NumberFormatException ex) {
throw new RuntimeException("HBase这个波形图开始时间不为0");
}
return oscillogram;
}
}
package cn.wise.sc.energy.power.plant.business.domain.vo;
import lombok.Data;
/**
* @description:
* @author: qh
* @create: 2020-09-03 09:59
**/
@Data
public class AlertInfoVo extends EntityVo {
private Long id;
/**
* 监测特征所属电站的标识
*/
private String plantId;
/**
* 监测特征所属设备的标识
*/
private String deviceId;
/**监测特征所属监测单元标识
*
*/
private String unitCodeId;
/**
* 监测特征唯一标识编码(KKS编码
*/
private String kKSCode;
/**
* 预警值
*/
private Float value;
/**
* 预警值
*/
private Float newValue;
/**
* 记录更新时间
*/
private Long valuetime;
/**
* 设置来源(角色或后台)
*/
private String usr;
}
package cn.wise.sc.energy.power.plant.business.domain.vo;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Lob;
/**
* @description:
* @author: qh
* @create: 2020-09-03 10:06
**/
@Data
public class BtreeInfoVo extends EntityVo {
private Long id;
/**
* 监测特征所属电站的标识
*/
private String plantId;
/**
* 监测特征所属设备的标识
*/
private String deviceId;
/**
* 监测特征所属监测单元标识
*/
private String unitCodeId;
/**
* 二叉树诊断名称
*/
private String btreeName;
/**
* 0:正常,1:异常 2:其他
*/
private Integer result;
/**
* 诊断结论,json格式结论
*/
private String diagnosis;
}
...@@ -23,6 +23,7 @@ import java.util.List; ...@@ -23,6 +23,7 @@ import java.util.List;
@NoArgsConstructor @NoArgsConstructor
public class CharacterParamInfoVo extends EntityVo{ public class CharacterParamInfoVo extends EntityVo{
private String parentDir;
/** /**
* 监测特征所属电站的标识 * 监测特征所属电站的标识
*/ */
......
package cn.wise.sc.energy.power.plant.business.domain.vo;
import lombok.Data;
/**
* @description: 事件记录
* @author: qh
* @create: 2020-09-03 09:36
**/
@Data
public class EventInfoVo extends EntityVo {
private Long id;
/**
* 记录时间
*/
private long valueTime;
/**
* 监测特征所属电站的标识
*/
private String plantId;
/**
* 监测特征所属设备的标识
*/
private String deviceId;
/**监测特征所属监测单元标识
*
*/
private String unitCodeId;
/**
* 监测特征唯一标识编码(KKS编码
*/
private String kKSCode;
/**
* 实际测量值
*/
private Float value;
/**
* 信号状态:0-正常、1-无效、2-预警报警、
* 3-高报警、4-高高报警、5-上趋势报警、6-下趋势报警
*/
private String alertStat;
/**
* 特征参数保护下限值
*/
private String alertMinvalue;
/**
* 特征参数保护上限值
*/
private String alertMaxvalue;
/**
* 预警范围:0-范围内 1-范围外
*/
private String alertLimit;
/**
* 预警值设置来源 (角色或后台)
*/
private String altLimitUsr;
/**
* 监测特征的物理单位,如 um/mm 等
*/
private String cpUnit;
/**
* 事件状态:0-未处理 1-已处理
*/
private String eventInfo;
}
package cn.wise.sc.energy.power.plant.business.repository;
import cn.wise.sc.energy.power.plant.business.domain.AlertInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
/**
* @description: 阈值更新记录仓储
* @author: qh
* @create: 2020-09-03 14:41
**/
@Repository
public interface AlertInfoRepository extends
JpaRepository<AlertInfo, Long>,
JpaSpecificationExecutor<AlertInfo> {
}
package cn.wise.sc.energy.power.plant.business.repository; package cn.wise.sc.energy.power.plant.business.repository;
import cn.wise.sc.energy.power.plant.business.domain.CharacterParamInfo; import cn.wise.sc.energy.power.plant.business.domain.CharacterParamInfo;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.List;
import java.util.Map;
/** /**
* @description: 测点特征仓储 * @description: 测点特征仓储
* @author: qh * @author: qh
...@@ -14,5 +22,12 @@ import org.springframework.stereotype.Repository; ...@@ -14,5 +22,12 @@ import org.springframework.stereotype.Repository;
public interface CharacterParamRepository extends public interface CharacterParamRepository extends
JpaRepository<CharacterParamInfo, String>, JpaRepository<CharacterParamInfo, String>,
JpaSpecificationExecutor<CharacterParamInfo> { JpaSpecificationExecutor<CharacterParamInfo> {
/**
* 查询报警点数统计
*
* @return map
*/
@Query(value = "SELECT COUNT(deviceId),deviceId FROM CharacterParamInfo GROUP BY deviceId")
List<Object[]> countAlert();
} }
package cn.wise.sc.energy.power.plant.business.repository;
import cn.wise.sc.energy.power.plant.business.domain.EventInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* @description: 事件记录仓储
* @author: qh
* @create: 2020-09-03 10:26
**/
@Repository
public interface EventInfoRepository extends
JpaRepository<EventInfo, Long>,
JpaSpecificationExecutor<EventInfo> {
/**
* 查询报警点数统计
*
* @return list
*/
@Query(value = "SELECT COUNT(e.alertStat) as count, e.alertStat, e.deviceId FROM EventInfo as e" +
" where e.alertStat > 1 and e.alertStat < 5 GROUP BY e.alertStat,e.deviceId")
List<Object[]> countAlert();
}
package cn.wise.sc.energy.power.plant.business.service;
import cn.wise.sc.energy.power.plant.business.domain.AlertInfo;
/**
* @description: 阈值更新记录
* @author: qh
* @create: 2020-09-03 14:56
**/
public interface IAlertInfoService extends IBaseService<Long, AlertInfo> {
}
...@@ -9,6 +9,7 @@ import cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo; ...@@ -9,6 +9,7 @@ import cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo; import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse; import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -20,6 +21,8 @@ import java.util.Map; ...@@ -20,6 +21,8 @@ import java.util.Map;
**/ **/
public interface ICharacterParamService extends IBaseService<String, CharacterParamInfo> { public interface ICharacterParamService extends IBaseService<String, CharacterParamInfo> {
Object count();
/** /**
* 根据部件号 获取当前部件所有测点特征 * 根据部件号 获取当前部件所有测点特征
* *
...@@ -114,5 +117,5 @@ public interface ICharacterParamService extends IBaseService<String, CharacterPa ...@@ -114,5 +117,5 @@ public interface ICharacterParamService extends IBaseService<String, CharacterPa
* *
* @param kksCodes kkscode * @param kksCodes kkscode
*/ */
Map<String, String> getOscillogram(List<String> kksCodes); Map<String, String> getOscillogram(List<String> kksCodes) throws IOException;
} }
package cn.wise.sc.energy.power.plant.business.service;
import cn.wise.sc.energy.power.plant.business.domain.EventInfo;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import cn.wise.sc.energy.power.plant.business.domain.vo.EventInfoVo;
import cn.wise.sc.energy.power.plant.business.service.impl.EventInfoServiceImpl;
import java.util.List;
import java.util.Map;
/**
* @description: 事件记录服务层接口
* @author: qh
* @create: 2020-09-03 10:21
**/
public interface IEventInfoService extends IBaseService<Long, EventInfo> {
/**
* 获取报警记录统计
* @return list
*/
List<EventInfoServiceImpl.AlertCount> countAlert();
/**
* 根据报警等级获取报警记录
* @param state 等级
* @return list
*/
List<EntityVo> listByState(Integer state);
}
package cn.wise.sc.energy.power.plant.business.service.impl;
import cn.wise.sc.energy.power.plant.business.domain.AlertInfo;
import cn.wise.sc.energy.power.plant.business.service.IAlertInfoService;
import org.springframework.stereotype.Service;
/**
* @description: 阈值更新
* @author: qh
* @create: 2020-09-03 14:57
**/
@Service
public class AlertInfoServiceImpl extends
BaseServiceImpl<Long, AlertInfo>
implements IAlertInfoService {
}
...@@ -8,6 +8,7 @@ import cn.wise.sc.energy.power.plant.business.domain.FrequencyQuery; ...@@ -8,6 +8,7 @@ import cn.wise.sc.energy.power.plant.business.domain.FrequencyQuery;
import cn.wise.sc.energy.power.plant.business.domain.Oscillogram; import cn.wise.sc.energy.power.plant.business.domain.Oscillogram;
import cn.wise.sc.energy.power.plant.business.domain.OscillogramRowMapper; import cn.wise.sc.energy.power.plant.business.domain.OscillogramRowMapper;
import cn.wise.sc.energy.power.plant.business.domain.OscillogramTagsMapper; import cn.wise.sc.energy.power.plant.business.domain.OscillogramTagsMapper;
import cn.wise.sc.energy.power.plant.business.domain.RowKeyMapper;
import cn.wise.sc.energy.power.plant.business.domain.UnitInfo; import cn.wise.sc.energy.power.plant.business.domain.UnitInfo;
import cn.wise.sc.energy.power.plant.business.domain.eum.TendencyStatus; import cn.wise.sc.energy.power.plant.business.domain.eum.TendencyStatus;
import cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo; import cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo;
...@@ -29,17 +30,20 @@ import lombok.extern.slf4j.Slf4j; ...@@ -29,17 +30,20 @@ import lombok.extern.slf4j.Slf4j;
import net.opentsdb.client.api.query.response.QueryResponse; import net.opentsdb.client.api.query.response.QueryResponse;
import net.opentsdb.client.bean.Aggregator; import net.opentsdb.client.bean.Aggregator;
import net.opentsdb.client.bean.QueryResult; import net.opentsdb.client.bean.QueryResult;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.filter.CompareFilter; import org.apache.hadoop.hbase.filter.CompareFilter;
import org.apache.hadoop.hbase.filter.Filter; import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.filter.FilterList; import org.apache.hadoop.hbase.filter.FilterList;
import org.apache.hadoop.hbase.filter.RowFilter; import org.apache.hadoop.hbase.filter.RowFilter;
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
import org.apache.hadoop.hbase.filter.SubstringComparator; import org.apache.hadoop.hbase.filter.SubstringComparator;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Example; import org.springframework.data.domain.Example;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Path; import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
...@@ -81,6 +85,11 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character ...@@ -81,6 +85,11 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
this.hbaseTemplate = hbaseTemplate; this.hbaseTemplate = hbaseTemplate;
} }
@Override
public List<Object[]> count(){
return characterParamRepository.countAlert();
}
@Override @Override
public List<EntityVo> getUnitAllCharacterParams(String unitNo) { public List<EntityVo> getUnitAllCharacterParams(String unitNo) {
...@@ -337,67 +346,25 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character ...@@ -337,67 +346,25 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
} }
@Override @Override
public Map<String, String> getOscillogram(List<String> kksCodes) { public Map<String, String> getOscillogram(List<String> kksCodes) throws IOException {
//添加过滤器 过滤名字中包含kkscode final String tableName = "thermalpower-plant-wave-data";
List<Filter> filters = new ArrayList<>(kksCodes.size()); final String records = "records";
for (String kkscode : kksCodes) { final String data = "Data";
RowFilter filter = new RowFilter(CompareFilter.CompareOp.EQUAL final String tags = "tags";
, new SubstringComparator(StrUtil.swapCase(kkscode))); List<Oscillogram> oscillogramList = new ArrayList<>(kksCodes.size());
filters.add(filter); ResponseEnum.COLLECTION_NOT_ILLEGAL.assertCollectionNotILLEGAL(kksCodes);
} List<String> rowKeys = new ArrayList<>(kksCodes.size());
//拼接rowKey获取最新数据rowKey
FilterList filterList = new FilterList(filters); System.out.println("============rowKey=============");
Scan scanRow = new Scan(); for (String kKSCode : kksCodes) {
scanRow.setCaching(10000); System.out.println(getRowKey(kKSCode));
scanRow.setFilter(filterList); Oscillogram oscillogram = hbaseTemplate.get(tableName, getRowKey(kKSCode),
scanRow.addFamily(Bytes.toBytes("records")); new RowKeyMapper());
scanRow.setReversed(true); if (oscillogram != null){
oscillogramList.add(oscillogram);
Scan scanTags = new Scan();
scanTags.setCaching(10000);
scanTags.setFilter(filterList);
scanTags.addFamily(Bytes.toBytes("tags"));
scanTags.setReversed(true);
OscillogramRowMapper oscillogramRowMapper = new OscillogramRowMapper();
List<Oscillogram> oscillograms = hbaseTemplate.find("thermalpower-plant-wave-data",
scanRow, oscillogramRowMapper);
OscillogramTagsMapper oscillogramRowMapper2 = new OscillogramTagsMapper();
List<Oscillogram> oscillogramsTags = hbaseTemplate.find("thermalpower-plant-wave-data",
scanTags, oscillogramRowMapper2);
oscillogramsTags.forEach(opt -> oscillograms.forEach(arg -> {
if (opt.getRowKey().equals(arg.getRowKey())) {
arg.setTimeSpan(opt.getTimeSpan());
arg.setRecordFlag(opt.getRecordFlag());
arg.setGenerationFreq(opt.getGenerationFreq());
arg.setPoleNum(opt.getPoleNum());
arg.setPeriod(opt.getPeriod());
}
}));
//筛选最新的一条数据
List<CharacterParamInfo> characterParamInfos = this.getByKksCodes(kksCodes);
Map<String, Oscillogram> oscillogramLastMap = new HashMap<>(characterParamInfos.size());
for (Oscillogram oscillogram : oscillograms) {
characterParamInfos.forEach(arg -> {
String kKSCode = oscillogram.getKKsCode();
if (kKSCode.equals(arg.getKksCode())) {
if (oscillogramLastMap.containsKey(kKSCode)) {
//比较已存在的startTime大小
if (oscillogramLastMap.get(kKSCode).getStart() < oscillogram.getStart()) {
oscillogramLastMap.put(kKSCode, oscillogram);
}
} else {
oscillogramLastMap.put(kKSCode, oscillogram);
}
}
});
} }
List<Oscillogram> oscillogramList = new ArrayList<>(oscillogramLastMap.size());
for (String key : oscillogramLastMap.keySet()) {
oscillogramList.add(oscillogramLastMap.get(key));
} }
FrequencyQuery frequencyQuery = new FrequencyQuery(); FrequencyQuery frequencyQuery = new FrequencyQuery();
FrequencyQuery.Record record = new FrequencyQuery.Record(); FrequencyQuery.Record record = new FrequencyQuery.Record();
FrequencyQuery.DataOut dataOut = new FrequencyQuery.DataOut(); FrequencyQuery.DataOut dataOut = new FrequencyQuery.DataOut();
...@@ -408,7 +375,7 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character ...@@ -408,7 +375,7 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
frequencyQuery.setStartTime(oscillogram.getStart()); frequencyQuery.setStartTime(oscillogram.getStart());
frequencyQuery.setTimeSpan(oscillogram.getTimeSpan()); frequencyQuery.setTimeSpan(oscillogram.getTimeSpan());
FrequencyQuery.DataIn dataIn = new FrequencyQuery.DataIn(); FrequencyQuery.DataIn dataIn = new FrequencyQuery.DataIn();
dataIn.setKKSCode(StrUtil.swapCase(oscillogram.getKKsCode())); dataIn.setKKSCode(oscillogram.getKKsCode());
dataIn.setData(oscillogram.getMapData()); dataIn.setData(oscillogram.getMapData());
dataIn.setKeyPhaseOffset(oscillogram.getNoVersionKeyPhaseOffset()); dataIn.setKeyPhaseOffset(oscillogram.getNoVersionKeyPhaseOffset());
dataIn.setPeriod(oscillogram.getPeriod()); dataIn.setPeriod(oscillogram.getPeriod());
...@@ -421,11 +388,116 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character ...@@ -421,11 +388,116 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
String frequency = getFrequency(JSON.toJSONString(frequencyQuery)); String frequency = getFrequency(JSON.toJSONString(frequencyQuery));
Map<String, String> rts = new HashMap<>(2); Map<String, String> rts = new HashMap<>(2);
System.out.println();
rts.put("oscillogram", JSON.toJSONString(oscillogramList)); rts.put("oscillogram", JSON.toJSONString(oscillogramList));
rts.put("frequency", frequency); rts.put("frequency", frequency);
System.out.println("============rowKey=============");
System.out.println(JSON.toJSONString(rowKeys));
return rts; return rts;
//
////==================================================================================================
//添加过滤器 过滤名字中包含kkscode
// List<Filter> filters = new ArrayList<>(kksCodes.size());
// for (String kkscode : kksCodes) {
// RowFilter filter = new RowFilter(CompareFilter.CompareOp.EQUAL
// , new SubstringComparator(StrUtil.swapCase(kkscode)));
// filters.add(filter);
// }
//
// FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ONE, filters);
// Scan scanRow = new Scan();
// scanRow.setFilter(filterList);
// scanRow.addFamily(Bytes.toBytes("records"));
// scanRow.setReversed(true);
// scanRow.setBatch(50);
// scanRow.setMaxResultSize(50);
// scanRow.setTimeRange(1596252170L, System.currentTimeMillis());
//
// Scan scanTags = new Scan();
// scanTags.setFilter(filterList);
// scanTags.addFamily(Bytes.toBytes("tags"));
// scanTags.setReversed(true);
// scanTags.setBatch(50);
// scanTags.setMaxResultSize(50);
// scanRow.setTimeRange(1596252170L, System.currentTimeMillis());
// System.out.println("============get--start=================");
// long start = System.currentTimeMillis();
// OscillogramRowMapper oscillogramRowMapper = new OscillogramRowMapper();
// List<Oscillogram> oscillograms = hbaseTemplate.find(tableName,
// scanRow, oscillogramRowMapper);
//
// OscillogramTagsMapper oscillogramRowMapper2 = new OscillogramTagsMapper();
// List<Oscillogram> oscillogramsTags = hbaseTemplate.find(tableName,
// scanTags, oscillogramRowMapper2);
// long end = System.currentTimeMillis() - start;
// System.out.println(end);
//
// oscillogramsTags.forEach(opt -> oscillograms.forEach(arg -> {
// if (opt.getRowKey().equals(arg.getRowKey())) {
// arg.setTimeSpan(opt.getTimeSpan());
// arg.setRecordFlag(opt.getRecordFlag());
// arg.setGenerationFreq(opt.getGenerationFreq());
// arg.setPoleNum(opt.getPoleNum());
// arg.setPeriod(opt.getPeriod());
// }
// }));
// //筛选最新的一条数据
// List<CharacterParamInfo> characterParamInfos = this.getByKksCodes(kksCodes);
// Map<String, Oscillogram> oscillogramLastMap = new HashMap<>(characterParamInfos.size());
// for (Oscillogram oscillogram : oscillograms) {
// characterParamInfos.forEach(arg -> {
// String kKSCode = oscillogram.getKKsCode();
// if (kKSCode.equals(arg.getKksCode())) {
// if (oscillogramLastMap.containsKey(kKSCode)) {
// //比较已存在的startTime大小
// if (oscillogramLastMap.get(kKSCode).getStart() < oscillogram.getStart()) {
// oscillogramLastMap.put(kKSCode, oscillogram);
// }
// } else {
// oscillogramLastMap.put(kKSCode, oscillogram);
// }
// }
// });
// }
// List<Oscillogram> oscillogramList = new ArrayList<>(oscillogramLastMap.size());
// for (String key : oscillogramLastMap.keySet()) {
// oscillogramList.add(oscillogramLastMap.get(key));
// }
//
// System.out.println("oscillograms长度:" + oscillograms.size());
// System.out.println("oscillograms长度:" + oscillogramsTags.size());
// System.out.println("oscillogramList长度:" + oscillogramList.size());
// FrequencyQuery frequencyQuery = new FrequencyQuery();
// FrequencyQuery.Record record = new FrequencyQuery.Record();
// FrequencyQuery.DataOut dataOut = new FrequencyQuery.DataOut();
// frequencyQuery.setRecord(record);
// frequencyQuery.getRecord().setData(dataOut);
// frequencyQuery.getRecord().getData().setData(new ArrayList<>());
// for (Oscillogram oscillogram : oscillogramList) {
// frequencyQuery.setStartTime(oscillogram.getStart());
// frequencyQuery.setTimeSpan(oscillogram.getTimeSpan());
// FrequencyQuery.DataIn dataIn = new FrequencyQuery.DataIn();
// dataIn.setKKSCode(StrUtil.swapCase(oscillogram.getKKsCode()));
// dataIn.setData(oscillogram.getMapData());
// dataIn.setKeyPhaseOffset(oscillogram.getNoVersionKeyPhaseOffset());
// dataIn.setPeriod(oscillogram.getPeriod());
// dataOut.setDirection(0);
// dataOut.setGenerationFreq(oscillogram.getGenerationFreq());
// dataOut.setRecordFlag(oscillogram.getRecordFlag());
// dataOut.setPoleNum(oscillogram.getPoleNum());
// frequencyQuery.getRecord().getData().getData().add(dataIn);
// }
//
// System.out.println(JSON.toJSONString(frequencyQuery));
//
// String frequency = getFrequency(JSON.toJSONString(frequencyQuery));
// Map<String, String> rts = new HashMap<>(2);
//
// rts.put("oscillogram", JSON.toJSONString(oscillogramList));
// rts.put("frequency", frequency);
//
// return rts;
} }
private DataPower buildDataPower(List<QueryResult> results, private DataPower buildDataPower(List<QueryResult> results,
...@@ -461,6 +533,23 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character ...@@ -461,6 +533,23 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
return dataPower; return dataPower;
} }
/**
* 获取存最新Data的RowKey数据的RowKey
* 规则:kKSCode+kKSCode
*
* @param kKSCode kKSCode
* @return rowKey
*/
private String getRowKey(String kKSCode) {
ResponseEnum.LICENCE_NOT_FOUND.assertNotEmpty(kKSCode);
String substring = kKSCode.substring(kKSCode.length() - 1);
return StrUtil.swapCase(substring + kKSCode);
}
public static void main(String[] args) {
String s = "abcd";
System.out.println(s.substring(s.length() - 1));
}
/** /**
* 拼装报警点 * 拼装报警点
......
package cn.wise.sc.energy.power.plant.business.service.impl;
import cn.wise.sc.energy.power.plant.business.domain.DeviceInfo;
import cn.wise.sc.energy.power.plant.business.domain.EventInfo;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import cn.wise.sc.energy.power.plant.business.repository.DeviceInfoRepository;
import cn.wise.sc.energy.power.plant.business.repository.EventInfoRepository;
import cn.wise.sc.energy.power.plant.business.service.IEventInfoService;
import lombok.Data;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import javax.persistence.criteria.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* @description: 事件记录服务层实现类
* @author: qh
* @create: 2020-09-03 10:22
**/
@Service
public class EventInfoServiceImpl extends BaseServiceImpl<Long, EventInfo> implements IEventInfoService {
final
DeviceInfoRepository deviceInfoRepository;
final
EventInfoRepository eventInfoRepository;
public EventInfoServiceImpl(EventInfoRepository eventInfoRepository,
DeviceInfoRepository deviceInfoRepository) {
this.eventInfoRepository = eventInfoRepository;
this.deviceInfoRepository = deviceInfoRepository;
}
@Override
public List<AlertCount> countAlert() {
List<Object[]> objects = eventInfoRepository.countAlert();
List<AlertCount> rts = new ArrayList<>();
for (Object[] objs : objects) {
//countAlert()查询2个字段 count()、alertState
if (objs.length != 2) {
continue;
}
Long count = (long) objs[0];
Integer state = (int) objs[1];
String deviceId = (String) objs[2];
Optional<DeviceInfo> byId = deviceInfoRepository.findById(deviceId);
if (byId.isPresent()) {
continue;
}
String deviceName = byId.get().getDeviceName();
AlertCount alertCount;
if (state == 2) {
alertCount = new AlertCount("preAlert", deviceName, count);
} else if (state == 3) {
alertCount = new AlertCount("tallAlert", deviceName, count);
} else {
alertCount = new AlertCount("tooTallAlert", deviceName, count);
}
rts.add(alertCount);
}
return rts;
}
@Override
public List<EntityVo> listByState(Integer state) {
if (state < 2 || state > 4) {
return null;
}
List<EventInfo> list = eventInfoRepository.findAll((Specification<EventInfo>) (root, query, criteriaBuilder) -> {
Path<Integer> alertStat = root.get("alertStat");
return criteriaBuilder.equal(alertStat, state);
});
List<EntityVo> rts = new ArrayList<>(list.size());
for (EventInfo eventInfo : list) {
EntityVo entityVo = eventInfo.toVo();
rts.add(entityVo);
}
return rts;
}
@Data
public static class AlertCount {
public AlertCount(String alertLevel, String deviceName, Long count) {
this.alertLevel = alertLevel;
this.deviceName = deviceName;
this.count = count;
}
/**
* 报警级别
*/
private String alertLevel;
/**
* 对应设备名字
*/
private String deviceName;
/**
* 对应报警次数
*/
private Long count;
}
}
package cn.wise.sc.energy.power.plant.business.task; package cn.wise.sc.energy.power.plant.business.task;
import cn.wise.sc.energy.power.plant.business.bean.DataPower; import cn.wise.sc.energy.power.plant.business.bean.DataPower;
import cn.wise.sc.energy.power.plant.business.domain.Frequency;
import cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo; import cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo;
import cn.wise.sc.energy.power.plant.business.service.ICharacterParamService; import cn.wise.sc.energy.power.plant.business.service.ICharacterParamService;
import cn.wise.sc.energy.power.plant.business.service.IEventInfoService;
import cn.wise.sc.energy.power.plant.business.service.impl.EventInfoServiceImpl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -26,14 +32,17 @@ public class ScheduledModel { ...@@ -26,14 +32,17 @@ public class ScheduledModel {
WebSocketServer webSocketServer; WebSocketServer webSocketServer;
final final
ICharacterParamService iCharacterParamService; ICharacterParamService iCharacterParamService;
final
IEventInfoService iEventInfoService;
public ScheduledModel(WebSocketServer webSocketServer, public ScheduledModel(WebSocketServer webSocketServer,
ICharacterParamService iCharacterParamService) { ICharacterParamService iCharacterParamService,
IEventInfoService iEventInfoService) {
this.webSocketServer = webSocketServer; this.webSocketServer = webSocketServer;
this.iCharacterParamService = iCharacterParamService; this.iCharacterParamService = iCharacterParamService;
this.iEventInfoService = iEventInfoService;
} }
@Scheduled(cron = "0/1 * * * * ? ") @Scheduled(cron = "0/1 * * * * ? ")
public void indexRealTimeData() throws IOException { public void indexRealTimeData() throws IOException {
ConcurrentHashMap<String, WebSocketServer> webSocketMap = ConcurrentHashMap<String, WebSocketServer> webSocketMap =
...@@ -103,6 +112,44 @@ public class ScheduledModel { ...@@ -103,6 +112,44 @@ public class ScheduledModel {
rts.add(dataPower1); rts.add(dataPower1);
rts.add(dataPower2); rts.add(dataPower2);
//添加报警点
DataPower dataPower4 = new DataPower();
List<EventInfoServiceImpl.AlertCount> alertCounts = iEventInfoService.countAlert();
DataPower.PowerPoints powerPoints = new DataPower.PowerPoints();
powerPoints.setName("预报警");
DataPower.PowerPoints powerPoints1 = new DataPower.PowerPoints();
powerPoints1.setName("高报警");
DataPower.PowerPoints powerPoints2 = new DataPower.PowerPoints();
powerPoints2.setName("高高报警");
dataPower4.getDataList().add(powerPoints);
dataPower4.getDataList().add(powerPoints1);
dataPower4.getDataList().add(powerPoints2);
//获取设备长度
Set<String> deviceNames = new HashSet<>();
alertCounts.forEach(arg -> deviceNames.add(arg.getDeviceName()));
int idx = 0;
for (String deviceName : deviceNames) {
dataPower4.getXAxis().add(deviceName);
int finalIdx = idx;
alertCounts.forEach(arg -> {
//处理名字报警
if ("preAlert".equals(arg.getAlertLevel())) {
//预报警
dataPower4.getDataList().get(0).getValue().add(finalIdx, arg.getCount() + "");
} else if ("tallAlert".equals(arg.getAlertLevel())) {
//高报
dataPower4.getDataList().get(1).getValue().add(finalIdx, arg.getCount() + "");
} else {
//高高报
dataPower4.getDataList().get(2).getValue().add(finalIdx, arg.getCount() + "");
}
});
idx++;
}
rts.add(dataPower4);
webSocket.sendMessage(JSON.toJSONString(rts)); webSocket.sendMessage(JSON.toJSONString(rts));
} }
} }
...@@ -189,6 +236,9 @@ public class ScheduledModel { ...@@ -189,6 +236,9 @@ public class ScheduledModel {
characterNames.add("发电机定子CA线电压"); characterNames.add("发电机定子CA线电压");
characterNames.add("励端轴承排油温度"); characterNames.add("励端轴承排油温度");
characterNames.add("汽端轴承排油温度"); characterNames.add("汽端轴承排油温度");
characterNames.add("定子上下线棒层间温度");
characterNames.add("定子上层线棒出水温度");
characterNames.add("定子下层线棒出水温度");
List<CharacterParamInfoVo> characterParamInfoVos = List<CharacterParamInfoVo> characterParamInfoVos =
iCharacterParamService.getCharacterByName(characterNames, "", deviceId); iCharacterParamService.getCharacterByName(characterNames, "", deviceId);
List<String> KKsCodes = characterParamInfoVos.stream() List<String> KKsCodes = characterParamInfoVos.stream()
...@@ -242,17 +292,78 @@ public class ScheduledModel { ...@@ -242,17 +292,78 @@ public class ScheduledModel {
dataPower4.getDataList().add(powerPoints); dataPower4.getDataList().add(powerPoints);
} }
} }
//处理首页雷达图 超麻烦
DataPower dataPower5 = new DataPower();
DataPower.PowerPoints powerPoints = new DataPower.PowerPoints();
powerPoints.setName("层间温度");
powerPoints.setValue(initList());
DataPower.PowerPoints powerPoints1 = new DataPower.PowerPoints();
powerPoints1.setName("上层线棒出水");
powerPoints1.setValue(initList());
DataPower.PowerPoints powerPoints2 = new DataPower.PowerPoints();
powerPoints2.setName("下层线棒出水");
powerPoints2.setValue(initList());
dataPower5.getDataList().add(powerPoints);
dataPower5.getDataList().add(powerPoints1);
dataPower5.getDataList().add(powerPoints2);
for (String key : realTimeDataAndCpName.keySet()) {
//只取A结尾的数据
if (key.contains("定子上下线棒层间温度") && !key.contains("B")) {
//解析末尾数字
String indexStr = key.split("定子上下线棒层间温度")[1]
.replace("A", "");
int index;
try {
index = Integer.parseInt(indexStr);
} catch (NumberFormatException ex) {
throw new RuntimeException("测定名字不符合命名规范!");
}
powerPoints.getValue().set(index-1, realTimeDataAndCpName.get(key).toString());
}
if (key.contains("定子上层线棒出水温度")) {
//解析末尾数字
String indexStr = key.split("上层线棒出水温度")[1];
int index;
try {
index = Integer.parseInt(indexStr);
} catch (NumberFormatException ex) {
throw new RuntimeException("测定名字不符合命名规范!");
}
powerPoints1.getValue().set(index-1, realTimeDataAndCpName.get(key).toString());
}
if (key.contains("定子下层线棒出水温度")) {
//解析末尾数字
String indexStr = key.split("下层线棒出水温度")[1];
int index;
try {
index = Integer.parseInt(indexStr);
} catch (NumberFormatException ex) {
throw new RuntimeException("测定名字不符合命名规范!");
}
powerPoints2.getValue().set(index-1, realTimeDataAndCpName.get(key).toString());
}
}
List<DataPower> rts = new ArrayList<>(4); List<DataPower> rts = new ArrayList<>(6);
rts.add(dataPower); rts.add(dataPower);
rts.add(dataPower1); rts.add(dataPower1);
rts.add(dataPower2); rts.add(dataPower2);
rts.add(dataPower3); rts.add(dataPower3);
rts.add(dataPower4); rts.add(dataPower4);
rts.add(dataPower5);
webSocket.sendMessage(JSON.toJSONString(rts)); webSocket.sendMessage(JSON.toJSONString(rts));
} }
} }
private List<String> initList() {
List<String> rts = new ArrayList<>(54);
for (int i = 0; i < 54; i++) {
rts.add("");
}
return rts;
}
/** /**
* 首页实时数据:功率趋势图-->单个机组 小时级 * 首页实时数据:功率趋势图-->单个机组 小时级
*/ */
...@@ -294,7 +405,6 @@ public class ScheduledModel { ...@@ -294,7 +405,6 @@ public class ScheduledModel {
} }
} }
/** /**
* 氢系统实时数据 * 氢系统实时数据
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment