Commit a4daf459 authored by qinhu's avatar qinhu

波形图 频谱分析 趋势图报警阈值

parent 604464f5
......@@ -35,6 +35,24 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="Maven: com.simplename:jna:5.6.0">
<CLASSES>
<root url="jar://$MODULE_DIR$/src/main/resources/jna-5.6.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="Maven: com.simplename:jna-platform:5.6.0">
<CLASSES>
<root url="jar://$MODULE_DIR$/src/main/resources/jna-platform-5.6.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-jpa:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.9.5" level="project" />
......
......@@ -77,7 +77,7 @@ public class CharacterParamController {
}
@PostMapping("/oscillogram")
public BaseResponse<List<Oscillogram>> oscillogram(@RequestBody List<String> kksCodes) {
public BaseResponse<Map<String,String>> oscillogram(@RequestBody List<String> kksCodes) {
return BaseResponse.okData(iCharacterParamService.getOscillogram(kksCodes));
}
......
......@@ -11,7 +11,6 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......
......@@ -4,6 +4,7 @@ package cn.wise.sc.energy.power.plant.business.domain;
import cn.wise.sc.energy.power.plant.business.domain.eum.SignalTypeEnum;
import cn.wise.sc.energy.power.plant.business.domain.vo.CharacterParamInfoVo;
import cn.wise.sc.energy.power.plant.business.domain.vo.EntityVo;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
......@@ -36,7 +37,7 @@ public class CharacterParamInfo extends AbstractEntity<String> {
@Override
public EntityVo toVo() {
CharacterParamInfoVo characterParamInfoVo = new CharacterParamInfoVo();
BeanUtils.copyProperties(this,characterParamInfoVo);
BeanUtils.copyProperties(this, characterParamInfoVo);
return characterParamInfoVo;
}
......@@ -104,12 +105,12 @@ public class CharacterParamInfo extends AbstractEntity<String> {
@Column(name = "protectrulevalid")
private Integer protectRuleValid;
/**
* 特征参数保护(一级报警)限值
* 特征参数保护(一级报警)限值
*/
@Column(name = "protectrulemaxvalue")
private Float protectRuleMaxValue;
/**
* 特征参数保护(一级报警)限值
* 特征参数保护(一级报警)限值
*/
@Column(name = "protectruleminvalue")
private Float protectRuleMinValue;
......@@ -150,4 +151,41 @@ public class CharacterParamInfo extends AbstractEntity<String> {
public String getId() {
return getKksCode();
}
/**
* 报警值对象
*/
@Data
public static class Alert {
/**
* 一级报警上限值
*/
private Float protectRuleMaxValue;
/**
* 一级报警下限值
*/
private Float protectRuleMinValue;
/**
* 特征参数保护(一级报警)规则阈值范围是否是排除范围
* 1: 是排除范围 0:是限定范围
* 1表示这个范围内的为不报警的
* 0表示这个范围内为报警的
*/
private Integer protectRuleExclude;
/**
* 二级报警下限值
*/
private Float alertRuleMinValue;
/**
* 二级报警上限值
*/
private Float alertRuleMaxValue;
/**
* 特征参数保护(二级报警)规则阈值范围是否是排除范围
* 1: 是排除范围 0:是限定范围
* 1表示这个范围内的为不报警的
* 0表示这个范围内为报警的
*/
private Integer alertRuleExclude;
}
}
......@@ -12,30 +12,25 @@ import java.util.List;
**/
@Data
public class FrequencyQuery {
/**
* 开始时间
*/
@JSONField(name = "StartTime")
private Long startTime;
/**
* 时间间隔
*/
@JSONField(name = "TimeSpan")
private Long timeSpan;
@JSONField(name = "Record")
private Record record;
@lombok.Data
public static class Record{
@JSONField(name = "Record")
public static class Record {
@JSONField(name = "Data")
private DataOut data;
}
@lombok.Data
public static class DataOut{
public static class DataOut {
/**
* 键相类型为波形数据数组下标
*/
......@@ -46,19 +41,16 @@ public class FrequencyQuery {
*/
@JSONField(name = "PoleNum")
private Integer poleNum;
/**
* 发电机频率单位(Hz)
*/
@JSONField(name = "GenerationFreq")
private String generationFreq;
private Integer generationFreq;
/**
* 旋转方向(0:顺时针,1:逆时针)
*/
@JSONField(name = "Direction")
private Integer direction;
/**
* 记录类型(0:连续采样,1定时采样:)
*/
......@@ -68,31 +60,28 @@ public class FrequencyQuery {
private List<DataIn> data;
}
@Data
public static class DataIn{
@Data
public static class DataIn {
/**
* 测点对应KKS编码
*/
@JSONField(name = "KKSCode")
private String kKSCode;
/**
* 样包采样周期数
*/
@JSONField(name = "Period")
private Integer period;
/**
* 各键相点相对起始时间偏移
*/
@JSONField(name = "KeyPhaseOffset")
private String keyPhaseOffset;
private List<Float> keyPhaseOffset;
/**
* 数据区域
*/
@JSONField(name = "Data")
private String data;
private List<Float> data;
}
}
......@@ -25,12 +25,12 @@ public class Oscillogram {
/**
* 数据
*/
private String mapData;
private List<Float> mapData;
/**
* 偏移量
*/
private String mapKeyPhaseOffset;
private List<Float> mapKeyPhaseOffset;
/**
* 特征信息
......@@ -40,7 +40,7 @@ public class Oscillogram {
/**
* 特征偏移
*/
private String noVersionKeyPhaseOffset;
private List<Float> noVersionKeyPhaseOffset;
/**
* 时间间隔
......@@ -54,7 +54,7 @@ public class Oscillogram {
private String rowKey;
private Integer Period;
private String GenerationFreq;
private Integer GenerationFreq;
private String KeyPhaseTyped;
private Integer PoleNum;
}
......@@ -3,6 +3,7 @@ package cn.wise.sc.energy.power.plant.business.domain;
import cn.hutool.core.codec.Base64Decoder;
import cn.hutool.core.codec.Base64Encoder;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.spring4all.spring.boot.starter.hbase.api.RowMapper;
import org.apache.hadoop.hbase.client.Result;
......@@ -55,12 +56,12 @@ public class OscillogramRowMapper implements RowMapper<Oscillogram> {
oscillogram.setStart(firstKey);
byte[] mapDataByte = longNavigableMapData.get(firstKey);
String mapData = Base64Decoder.decodeStr(Base64Encoder.encode(mapDataByte));
oscillogram.setMapData(mapData);
oscillogram.setMapData(JSON.parseArray(mapData, Float.class));
//获取偏移量
NavigableMap<Long, byte[]> longNavigableMapOffset = navigableMapNavigableMap1.get(OFFSET);
Long firstOffsetKey = longNavigableMapOffset.firstKey();
byte[] offSetByte = longNavigableMapOffset.get(firstOffsetKey);
oscillogram.setNoVersionKeyPhaseOffset(Base64Decoder.decodeStr(Base64Encoder.encode(offSetByte)));
oscillogram.setNoVersionKeyPhaseOffset(JSON.parseArray(Base64Decoder.decodeStr(Base64Encoder.encode(offSetByte)), Float.class));
return oscillogram;
......
......@@ -2,6 +2,7 @@ package cn.wise.sc.energy.power.plant.business.domain;
import cn.hutool.core.codec.Base64Decoder;
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;
......@@ -47,7 +48,7 @@ public class OscillogramTagsMapper implements RowMapper<Oscillogram> {
oscillogram.setRecordFlag(Integer.parseInt(recordFlag));
oscillogram.setRowKey(Base64Encoder.encode(result.getRow()));
oscillogram.setPeriod(0);
oscillogram.setGenerationFreq(generationFreq);
oscillogram.setGenerationFreq(Integer.parseInt(generationFreq));
oscillogram.setPoleNum(Integer.parseInt(poleNum));
return oscillogram;
}
......
......@@ -8,6 +8,7 @@ import cn.wise.sc.energy.power.plant.business.domain.Oscillogram;
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.common.core.bean.BaseResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -106,11 +107,12 @@ public interface ICharacterParamService extends IBaseService<String, CharacterPa
* @param toJSONString 波形图JSON
* @return list
*/
List<Frequency> getFrequency(String toJSONString);
String getFrequency(String toJSONString);
/**
* 获取波形图
*
* @param kksCodes kkscode
*/
List<Oscillogram> getOscillogram(List<String> kksCodes);
Map<String, String> getOscillogram(List<String> kksCodes);
}
......@@ -4,7 +4,6 @@ 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.TimeModelQuery;
import cn.wise.sc.energy.power.plant.business.domain.CharacterParamInfo;
import cn.wise.sc.energy.power.plant.business.domain.Frequency;
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.OscillogramRowMapper;
......@@ -23,6 +22,7 @@ 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.exception.ResponseEnum;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.google.common.collect.Lists;
import com.spring4all.spring.boot.starter.hbase.api.HbaseTemplate;
import lombok.extern.slf4j.Slf4j;
......@@ -40,7 +40,6 @@ import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Example;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;
......@@ -332,19 +331,13 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
}
@Override
public List<Frequency> getFrequency(String toJSONString) {
System.out.println("参数:");
System.out.println(toJSONString);
public String getFrequency(String toJSONString) {
String s = WaveAnalysis.INSTANCE.WaveAnalysisModel(toJSONString);
System.out.println(s);
return null;
return WaveAnalysis.INSTANCE.WaveAnalysisModel(toJSONString);
}
@Override
public List<Oscillogram> getOscillogram(List<String> kksCodes) {
public Map<String, String> getOscillogram(List<String> kksCodes) {
//添加过滤器 过滤名字中包含kkscode
List<Filter> filters = new ArrayList<>(kksCodes.size());
......@@ -353,6 +346,7 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
, new SubstringComparator(StrUtil.swapCase(kkscode)));
filters.add(filter);
}
FilterList filterList = new FilterList(filters);
Scan scanRow = new Scan();
scanRow.setCaching(10000);
......@@ -372,25 +366,15 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
OscillogramTagsMapper oscillogramRowMapper2 = new OscillogramTagsMapper();
List<Oscillogram> oscillogramsTags = hbaseTemplate.find("thermalpower-plant-wave-data",
scanTags, oscillogramRowMapper2);
System.out.println("=================波形图数据====================");
System.out.println(oscillograms.size());
System.out.println(oscillogramsTags.size());
//关联tags 这会很慢!!!
long start = System.currentTimeMillis();
System.out.println(start);
oscillogramsTags.forEach(opt -> {
oscillograms.forEach(arg -> {
if (opt.getRowKey().equals(arg.getRowKey())) {
arg.setTimeSpan(opt.getTimeSpan());
arg.getMapData();
arg.setRecordFlag(opt.getRecordFlag());
arg.setGenerationFreq(opt.getGenerationFreq());
arg.setPoleNum(opt.getPoleNum());
arg.setPeriod(opt.getPeriod());
}
});
});
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());
......@@ -409,19 +393,18 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
}
});
}
List<Oscillogram> rts = new ArrayList<>(oscillogramLastMap.size());
List<Oscillogram> oscillogramList = new ArrayList<>(oscillogramLastMap.size());
for (String key : oscillogramLastMap.keySet()) {
rts.add(oscillogramLastMap.get(key));
oscillogramList.add(oscillogramLastMap.get(key));
}
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 : rts) {
for (Oscillogram oscillogram : oscillogramList) {
frequencyQuery.setStartTime(oscillogram.getStart());
frequencyQuery.setTimeSpan(oscillogram.getTimeSpan());
FrequencyQuery.DataIn dataIn = new FrequencyQuery.DataIn();
......@@ -436,7 +419,12 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
frequencyQuery.getRecord().getData().getData().add(dataIn);
}
getFrequency(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;
}
......@@ -453,10 +441,15 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
CharacterParamInfo characterParamInfo = characterParamInfos.stream()
.filter(arg -> arg.getKksCode().equals(queryResult.getMetric()))
.findFirst().get();
String cpName = characterParamInfo.getCpName();
DataPower.PowerPoints powerPoints = new DataPower.PowerPoints();
dataPower.getDataList().add(powerPoints);
powerPoints.setName(cpName);
//关联报警点数
CharacterParamInfo.Alert alert = buildAlert(characterParamInfo);
powerPoints.setColor(JSON.toJSONString(alert, SerializerFeature.IgnoreNonFieldGetter));
queryResult.getDps().keySet().forEach(arg ->
powerPoints.getValue().add(queryResult.getDps().get(arg).toString()));
if (powerPoints.getValue().size() == 0) {
......@@ -468,6 +461,33 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
return dataPower;
}
/**
* 拼装报警点
*
* @param characterParamInfo 测点参数
* @return 报警点儿
*/
private CharacterParamInfo.Alert buildAlert(CharacterParamInfo characterParamInfo) {
ResponseEnum.LICENCE_NOT_FOUND.assertNotNull(characterParamInfo);
CharacterParamInfo.Alert alert = new CharacterParamInfo.Alert();
//一级报警是否生效
if (characterParamInfo.getProtectRuleValid() == 1) {
alert.setProtectRuleMinValue(characterParamInfo.getProtectRuleMinValue());
alert.setProtectRuleMaxValue(characterParamInfo.getProtectRuleMaxValue());
alert.setProtectRuleExclude(characterParamInfo.getProtectRuleExclude());
}
//二级报警是否是否生效
if (characterParamInfo.getAlertRuleValid() == 1) {
alert.setAlertRuleMinValue(characterParamInfo.getAlertRuleMinValue());
alert.setAlertRuleMaxValue(characterParamInfo.getAlertRuleMaxValue());
alert.setAlertRuleExclude(characterParamInfo.getAlertRuleExclude());
}
return alert;
}
private Map<String, Number> cutOneDataAnd2Map(List<QueryResult> results,
List<CharacterParamInfo> characterParamInfos) {
ResponseEnum.COLLECTION_NOT_ILLEGAL.assertCollectionNotILLEGAL(results);
......@@ -495,6 +515,7 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
return rts;
}
/**
* 拆分测点文件名
*
......@@ -567,7 +588,8 @@ public class CharacterParamServiceImpl extends BaseServiceImpl<String, Character
Map<String, HashMap<Long, Number>> characterData = new HashMap<>();
rts.put(key, characterData);
}
rts.get(key).put(opt.getCpName(), arg.getDps() != null && arg.getDps().size() != 0 ? arg.getDps() : new HashMap(1) {
rts.get(key).put(opt.getCpName(), arg.getDps() != null && arg.getDps().size() != 0 ?
arg.getDps() : new HashMap(1) {
{
put("1", 0);
}
......
......@@ -48,7 +48,7 @@ public class DetectionServiceImpl implements IDetectionService {
RQueue<DetectionItem> queue = redissonClient.getQueue(sessionId);
DetectionItem poll = queue.poll();
//判断是否为最后一个
if (queue.size() == 0) {
if (queue.size() == 0 && poll != null) {
//判断是否存在交互
String interactionKey = sessionId + "_Interaction";
RBucket<String> bucket = redissonClient.getBucket(interactionKey);
......
......@@ -52,12 +52,12 @@ public class PlantInfoServiceImpl extends BaseServiceImpl<String, PlantInfo> imp
return BaseResponse.okData(10D);
} else {
//设备不为空
Double totalPower = 0D;
double totalPower = 0D;
for (DeviceInfo deviceInfo : deviceInfos) {
ResponseEnum.LICENCE_NOT_FOUND.assertNotEmpty(deviceInfo.getDeviceParam());
DeviceParam deviceParam = JSON.parseObject(deviceInfo.getDeviceParam(), DeviceParam.class);
ResponseEnum.LICENCE_NOT_FOUND.assertNotEmpty(deviceParam.getRatepower());
Double power = Double.parseDouble(deviceParam.getRatepower().replace("MW", ""));
double power = Double.parseDouble(deviceParam.getRatepower().replace("MW", ""));
totalPower += power;
}
return BaseResponse.okData(totalPower);
......@@ -112,9 +112,7 @@ public class PlantInfoServiceImpl extends BaseServiceImpl<String, PlantInfo> imp
List<QueryResult> results = response.getResults();
//添加时间轴
if (results.size() > 0) {
results.get(0).getDps().keySet().forEach(arg -> {
times.add(arg);
});
times.addAll(results.get(0).getDps().keySet());
}
//关联kksCode和名字
for (QueryResult queryResult : results) {
......
......@@ -9,9 +9,7 @@ import cn.wise.sc.energy.power.plant.business.repository.UserInfoRepository;
import cn.wise.sc.energy.power.plant.business.service.IUserInfoService;
import cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse;
import cn.wise.sc.energy.power.plant.common.core.exception.ResponseEnum;
import jdk.nashorn.internal.ir.annotations.Ignore;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
......@@ -20,7 +18,6 @@ import org.springframework.data.jpa.domain.Specification;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;
import java.util.List;
......@@ -47,12 +44,11 @@ public class UserInfoServiceImpl implements IUserInfoService {
public List<UserInfo> getSysUserByUsername(String username) {
ResponseEnum.LICENCE_NOT_FOUND.assertNotEmpty(username);
List<UserInfo> userInfos = userInfoRepository.findAll((root, query, criteriaBuilder) -> {
return userInfoRepository.findAll((root, query, criteriaBuilder) -> {
Path<String> username1 = root.get("username");
return criteriaBuilder.equal(username1, username);
});
return userInfos;
}
@Override
......
......@@ -82,8 +82,9 @@ public class HydrogenSystemWebSocketServer {
}
/**
* @param session
* @param error
* 错误
* @param session 会话
* @param error 错误异常
*/
@OnError
public void onError(Session session, Throwable error) {
......@@ -101,6 +102,9 @@ public class HydrogenSystemWebSocketServer {
/**
* 发送自定义消息
* @param message 消息
* @param userId 用户
* @throws IOException 异常
*/
public static void sendInfo(String message, @PathParam("userId") String userId) throws IOException {
log.info("发送消息到:" + userId + ",报文:" + message);
......
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