组态数据传输功能
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
|
||||
<select id="getData" resultType="DataArrayDTO">
|
||||
select
|
||||
t1.id dataSetId,
|
||||
t1.another_name dataSetName,
|
||||
t0.name dataArrayName,
|
||||
t0.another_name dataArrayShowName,
|
||||
@@ -36,7 +37,7 @@
|
||||
<foreach collection='list' item='item' index="index" open='(' separator=',' close=')'>
|
||||
#{item}
|
||||
</foreach>
|
||||
group by t1.another_name,t0.name,t0.another_name
|
||||
group by t1.id,t1.another_name,t0.name,t0.another_name
|
||||
order by convert (substring_index(group_concat(distinct t0.sort),',',-1),unsigned)
|
||||
</select>
|
||||
|
||||
|
||||
@@ -39,10 +39,10 @@ public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDat
|
||||
map.forEach((k,v)->{
|
||||
List<DataArrayTreeVO> list2 = new ArrayList<>();
|
||||
DataArrayTreeVO vo1 = new DataArrayTreeVO();
|
||||
vo1.setId("0");
|
||||
vo1.setName(k);
|
||||
vo1.setShowName(k);
|
||||
v.forEach(item->{
|
||||
vo1.setId(item.getDataSetId());
|
||||
DataArrayTreeVO vo2 = new DataArrayTreeVO();
|
||||
List<DataArrayTreeVO> list3 = new ArrayList<>();
|
||||
vo2.setId("1");
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.njcn.csharmonic.pojo.dto;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/6/14 20:07
|
||||
*/
|
||||
@Data
|
||||
public class ZuTaiDTO {
|
||||
|
||||
@SerializedName("id")
|
||||
private String id;
|
||||
|
||||
@SerializedName("title")
|
||||
private String title;
|
||||
|
||||
@SerializedName("type")
|
||||
private String type;
|
||||
|
||||
@SerializedName("display")
|
||||
private Boolean display;
|
||||
|
||||
@SerializedName("typeName")
|
||||
private String typeName;
|
||||
|
||||
@SerializedName("svgColor")
|
||||
private String svgColor;
|
||||
|
||||
@SerializedName("svgPositionX")
|
||||
private Integer svgPositionX;
|
||||
|
||||
@SerializedName("svgPositionY")
|
||||
private Integer svgPositionY;
|
||||
|
||||
@SerializedName("echartsOption")
|
||||
private String echartsOption;
|
||||
|
||||
@SerializedName("list")
|
||||
private String list;
|
||||
|
||||
@SerializedName("tableHeader")
|
||||
private String tableHeader;
|
||||
|
||||
@SerializedName("size")
|
||||
private Integer size;
|
||||
|
||||
@SerializedName("angle")
|
||||
private Integer angle;
|
||||
|
||||
@SerializedName("lineId")
|
||||
private String lineId;
|
||||
|
||||
@SerializedName("UID")
|
||||
private List<String> uId;
|
||||
|
||||
@SerializedName("UName")
|
||||
private String target;
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
|
||||
import com.njcn.csharmonic.service.ILineTargetService;
|
||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.njcn.csharmonic.service.impl;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.njcn.csdevice.api.*;
|
||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||
import com.njcn.csdevice.pojo.po.CsDevModelPO;
|
||||
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.service.CsPagePOService;
|
||||
import com.njcn.csharmonic.service.ILineTargetService;
|
||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||
@@ -14,9 +18,12 @@ import com.njcn.system.api.EpdFeignClient;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -73,10 +80,35 @@ public class LineTargetServiceImpl implements ILineTargetService {
|
||||
List<StatisticalDataDTO> 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];
|
||||
CsDataArray dataArray = dataArrayFeignClient.getDataArrayById(item.getUId().get(0),targetTag).getData().get(0);
|
||||
String targetName = dataArray.getAnotherName();
|
||||
String dataId = dataArray.getDataId();
|
||||
String classId = epdFeignClient.selectById(dataId).getData().getClassId();
|
||||
result.add(getLineRtData(lineId,classId,targetTag,phasic,dataType,targetName));
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析json文件
|
||||
*/
|
||||
public List<ZuTaiDTO> analysisJson(InputStream inputStream) {
|
||||
Gson gson = new Gson();
|
||||
String text = new BufferedReader(
|
||||
new InputStreamReader(inputStream, StandardCharsets.UTF_8))
|
||||
.lines()
|
||||
.collect(Collectors.joining("\n"));
|
||||
return gson.fromJson(text, new TypeToken<List<ZuTaiDTO>>(){}.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过orm框架获取数据
|
||||
* @param lineId 监测点Id
|
||||
@@ -99,6 +131,7 @@ public class LineTargetServiceImpl implements ILineTargetService {
|
||||
statisticalDataDTO.setValue(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.UP).doubleValue());
|
||||
}
|
||||
statisticalDataDTO.setStatisticalName(target);
|
||||
statisticalDataDTO.setTarget(columnName + "$" + phasic + "$" + dataType);
|
||||
return statisticalDataDTO;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user