Commit a4daf459 authored by qinhu's avatar qinhu

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

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