微调
This commit is contained in:
@@ -34,10 +34,10 @@ public class ZuTaiDTO {
|
||||
private String svgColor;
|
||||
|
||||
@SerializedName("svgPositionX")
|
||||
private Integer svgPositionX;
|
||||
private Double svgPositionX;
|
||||
|
||||
@SerializedName("svgPositionY")
|
||||
private Integer svgPositionY;
|
||||
private Double svgPositionY;
|
||||
|
||||
@SerializedName("echartsOption")
|
||||
private String echartsOption;
|
||||
@@ -49,10 +49,10 @@ public class ZuTaiDTO {
|
||||
private String tableHeader;
|
||||
|
||||
@SerializedName("size")
|
||||
private Integer size;
|
||||
private Double size;
|
||||
|
||||
@SerializedName("angle")
|
||||
private Integer angle;
|
||||
private Double angle;
|
||||
|
||||
@SerializedName("lineId")
|
||||
private String lineId;
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.njcn.csharmonic.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.njcn.common.utils.serializer.InstantDateSerializer;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.influxdb.annotation.Column;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/6/25 13:31
|
||||
*/
|
||||
@Data
|
||||
public class CsRtDataVO {
|
||||
|
||||
@ApiModelProperty("图元id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("最新数据时间")
|
||||
@JsonSerialize(using = InstantDateSerializer.class)
|
||||
private Instant time;
|
||||
|
||||
@ApiModelProperty("监测点id")
|
||||
private String lineId;
|
||||
|
||||
@ApiModelProperty("相别")
|
||||
private String phaseType;
|
||||
|
||||
@ApiModelProperty("数据类型")
|
||||
private String valueType;
|
||||
|
||||
@ApiModelProperty("实时数据值,3.1415926则显示暂无数据")
|
||||
private Double value;
|
||||
|
||||
@ApiModelProperty("指标显示名称")
|
||||
private String statisticalName;
|
||||
|
||||
@ApiModelProperty("指标名称")
|
||||
private String target;
|
||||
|
||||
@ApiModelProperty("指标最大值")
|
||||
private Double maxValue;
|
||||
|
||||
@ApiModelProperty("指标最小值")
|
||||
private Double minValue;
|
||||
|
||||
}
|
||||
@@ -121,7 +121,7 @@
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.2.2</version>
|
||||
<executions>
|
||||
<!--执行mvn package,即执行 mvn clean package docker:build-->
|
||||
<execution>
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
|
||||
import com.github.tocrhz.mqtt.annotation.NamedValue;
|
||||
import com.github.tocrhz.mqtt.annotation.Payload;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.csharmonic.pojo.vo.CsRtDataVO;
|
||||
import com.njcn.csharmonic.service.ILineTargetService;
|
||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -33,7 +34,7 @@ public class MqttMessageHandler {
|
||||
*/
|
||||
@MqttSubscribe(value = "/zl/askRtData/{pageId}",qos = 1)
|
||||
public void responseRtData(String topic, @NamedValue("pageId") String pageId, MqttMessage message, @Payload String payload) {
|
||||
List<StatisticalDataDTO> list = lineTargetService.getLineData(pageId);
|
||||
List<CsRtDataVO> list = lineTargetService.getLineData(pageId);
|
||||
Gson gson = new Gson();
|
||||
publisher.send("/zl/rtData/"+pageId,gson.toJson(list),1,false);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.csharmonic.service;
|
||||
|
||||
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
|
||||
import com.njcn.csharmonic.pojo.vo.CsRtDataVO;
|
||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -21,6 +22,6 @@ public interface ILineTargetService {
|
||||
* 获取绑定指标的数据
|
||||
* @param id
|
||||
*/
|
||||
List<StatisticalDataDTO> getLineData(String id);
|
||||
List<CsRtDataVO> getLineData(String id);
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.njcn.csdevice.pojo.po.CsDevModelRelationPO;
|
||||
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
|
||||
import com.njcn.csdevice.pojo.vo.LineTargetVO;
|
||||
import com.njcn.csharmonic.pojo.dto.ZuTaiDTO;
|
||||
import com.njcn.csharmonic.pojo.vo.CsRtDataVO;
|
||||
import com.njcn.csharmonic.service.CsPagePOService;
|
||||
import com.njcn.csharmonic.service.ILineTargetService;
|
||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||
@@ -16,6 +17,7 @@ import com.njcn.influx.service.CommonService;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.system.api.EpdFeignClient;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -76,14 +78,13 @@ public class LineTargetServiceImpl implements ILineTargetService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StatisticalDataDTO> getLineData(String id) {
|
||||
List<StatisticalDataDTO> result = new ArrayList<>();
|
||||
public List<CsRtDataVO> getLineData(String id) {
|
||||
List<CsRtDataVO> result = new ArrayList<>();
|
||||
String path = csPagePOService.queryById(id).getPath();
|
||||
InputStream inputStream = fileStorageUtil.getFileStream(path);
|
||||
List<ZuTaiDTO> list = analysisJson(inputStream);
|
||||
list.forEach(item->{
|
||||
if (!Objects.isNull(item.getTarget())){
|
||||
String lineId = item.getLineId();
|
||||
String targetTag = item.getTarget().split("\\$")[0];
|
||||
String phasic = item.getTarget().split("\\$")[1];
|
||||
String dataType = item.getTarget().split("\\$")[2];
|
||||
@@ -91,7 +92,7 @@ public class LineTargetServiceImpl implements ILineTargetService {
|
||||
String targetName = dataArray.getAnotherName();
|
||||
String dataId = dataArray.getDataId();
|
||||
String classId = epdFeignClient.selectById(dataId).getData().getClassId();
|
||||
result.add(getLineRtData(lineId,classId,targetTag,phasic,dataType,targetName));
|
||||
result.add(getLineRtData(item.getId(),item.getLineId(),classId,targetTag,phasic,dataType,targetName));
|
||||
}
|
||||
});
|
||||
return result;
|
||||
@@ -111,6 +112,7 @@ public class LineTargetServiceImpl implements ILineTargetService {
|
||||
|
||||
/**
|
||||
* 通过orm框架获取数据
|
||||
* @param id 图元Id
|
||||
* @param lineId 监测点Id
|
||||
* @param tableName 表名称
|
||||
* @param columnName 字段名称
|
||||
@@ -119,7 +121,8 @@ public class LineTargetServiceImpl implements ILineTargetService {
|
||||
* @param target 数据名称
|
||||
* @return
|
||||
*/
|
||||
public StatisticalDataDTO getLineRtData(String lineId, String tableName, String columnName, String phasic, String dataType, String target) {
|
||||
public CsRtDataVO getLineRtData(String id,String lineId, String tableName, String columnName, String phasic, String dataType, String target) {
|
||||
CsRtDataVO csRtDataVO = new CsRtDataVO();
|
||||
StatisticalDataDTO statisticalDataDTO = commonService.getLineRtData(lineId,tableName,columnName,phasic,dataType);
|
||||
if(Objects.isNull(statisticalDataDTO)){
|
||||
statisticalDataDTO = new StatisticalDataDTO();
|
||||
@@ -132,6 +135,8 @@ public class LineTargetServiceImpl implements ILineTargetService {
|
||||
}
|
||||
statisticalDataDTO.setStatisticalName(target);
|
||||
statisticalDataDTO.setTarget(columnName + "$" + phasic + "$" + dataType);
|
||||
return statisticalDataDTO;
|
||||
BeanUtils.copyProperties(statisticalDataDTO,csRtDataVO);
|
||||
csRtDataVO.setId(id);
|
||||
return csRtDataVO;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,13 +30,13 @@ public class InfluxDbTest {
|
||||
for (String item2 : dataType) {
|
||||
Map<String, String> tags = new HashMap<>();
|
||||
Map<String, Object> fields = new HashMap<>();
|
||||
tags.put("line_id","7f6753c721dbf1ce37117073eddf2215");
|
||||
tags.put("line_id","4aea410500fc0cea5a62790e8d493542");
|
||||
tags.put("phasic_type",item1);
|
||||
tags.put("value_type",item2);
|
||||
fields.put("W",new Random().nextDouble());
|
||||
fields.put("Hz",new Random().nextDouble());
|
||||
fields.put("PhV",new Random().nextDouble());
|
||||
Point point = influxDbUtils.pointBuilder("pqd_data", time, TimeUnit.MILLISECONDS, tags, fields);
|
||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName ()).tag(InfluxDBPublicParam.LINE_ID, "7f6753c721dbf1ce37117073eddf2215").tag(InfluxDBPublicParam.PHASIC_TYPE,item1).tag(InfluxDBPublicParam.VALUE_TYPE,item2).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
Point point = influxDbUtils.pointBuilder("data_v", time, TimeUnit.MILLISECONDS, tags, fields);
|
||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName ()).tag(InfluxDBPublicParam.LINE_ID, "4aea410500fc0cea5a62790e8d493542").tag(InfluxDBPublicParam.PHASIC_TYPE,item1).tag(InfluxDBPublicParam.VALUE_TYPE,item2).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
records.add(batchPoints.lineProtocol());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user