组态图元入库、查询功能
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.njcn.csdevice.service.impl;
|
package com.njcn.csdevice.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.csdevice.mapper.CsDataArrayMapper;
|
import com.njcn.csdevice.mapper.CsDataArrayMapper;
|
||||||
import com.njcn.csdevice.pojo.dto.DataArrayDTO;
|
import com.njcn.csdevice.pojo.dto.DataArrayDTO;
|
||||||
@@ -49,21 +50,21 @@ public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDat
|
|||||||
vo2.setShowName(item.getDataArrayShowName());
|
vo2.setShowName(item.getDataArrayShowName());
|
||||||
List<String> statMethodList = Arrays.asList(item.getStatMethod().split(","));
|
List<String> statMethodList = Arrays.asList(item.getStatMethod().split(","));
|
||||||
List<String> phaseList = Arrays.asList(item.getPhase().split(","));
|
List<String> phaseList = Arrays.asList(item.getPhase().split(","));
|
||||||
statMethodList.forEach(item2->{
|
phaseList.forEach(item2->{
|
||||||
List<DataArrayTreeVO> list4 = new ArrayList<>();
|
List<DataArrayTreeVO> list4 = new ArrayList<>();
|
||||||
DataArrayTreeVO vo3 = new DataArrayTreeVO();
|
DataArrayTreeVO vo3 = new DataArrayTreeVO();
|
||||||
vo3.setId("2");
|
vo3.setId("2");
|
||||||
vo3.setName(item2);
|
vo3.setName(item2);
|
||||||
vo3.setShowName(item2);
|
if (Objects.equals(item2,"M")){
|
||||||
phaseList.forEach(item3->{
|
vo3.setShowName("无相别");
|
||||||
DataArrayTreeVO vo4 = new DataArrayTreeVO();
|
|
||||||
vo4.setId("3");
|
|
||||||
vo4.setName(item3);
|
|
||||||
if (Objects.equals(item3,"M")){
|
|
||||||
vo4.setShowName("无相别");
|
|
||||||
} else {
|
} else {
|
||||||
vo4.setShowName(item3);
|
vo3.setShowName(item2);
|
||||||
}
|
}
|
||||||
|
statMethodList.forEach(item3->{
|
||||||
|
DataArrayTreeVO vo4 = new DataArrayTreeVO();
|
||||||
|
vo4.setId(IdUtil.simpleUUID()+IdUtil.simpleUUID());
|
||||||
|
vo4.setName(item3);
|
||||||
|
vo4.setShowName(item3);
|
||||||
list4.add(vo4);
|
list4.add(vo4);
|
||||||
});
|
});
|
||||||
vo3.setChildren(list4);
|
vo3.setChildren(list4);
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.njcn.csharmonic.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.bo.BaseEntity;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 组态图元库
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-06-14
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@TableName("cs_element")
|
||||||
|
public class CsElement extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图元文件路径
|
||||||
|
*/
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.njcn.csharmonic.pojo.vo;
|
|
||||||
|
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类的介绍:
|
|
||||||
*
|
|
||||||
* @author xuyang
|
|
||||||
* @version 1.0.0
|
|
||||||
* @createTime 2023/6/2 15:30
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class ConditionVO implements Serializable {
|
|
||||||
|
|
||||||
@SerializedName("pic")
|
|
||||||
private String pic;
|
|
||||||
|
|
||||||
@SerializedName("value")
|
|
||||||
private String value;
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
package com.njcn.csharmonic.pojo.vo;
|
package com.njcn.csharmonic.pojo.vo;
|
||||||
|
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类的介绍:
|
* 类的介绍:
|
||||||
@@ -16,52 +14,8 @@ import java.util.List;
|
|||||||
@Data
|
@Data
|
||||||
public class ElementsVO implements Serializable {
|
public class ElementsVO implements Serializable {
|
||||||
|
|
||||||
@SerializedName("type")
|
private String id;
|
||||||
private String type;
|
|
||||||
|
|
||||||
@SerializedName("lineId")
|
private String json;
|
||||||
private List<String> lineId;
|
|
||||||
|
|
||||||
@SerializedName("lineName")
|
|
||||||
private String lineName;
|
|
||||||
|
|
||||||
@SerializedName("targetId")
|
|
||||||
private List<String> targetId;
|
|
||||||
|
|
||||||
@SerializedName("targetPid")
|
|
||||||
private String targetPid;
|
|
||||||
|
|
||||||
@SerializedName("targetName")
|
|
||||||
private String targetName;
|
|
||||||
|
|
||||||
@SerializedName("dataType")
|
|
||||||
private String dataType;
|
|
||||||
|
|
||||||
@SerializedName("phasic")
|
|
||||||
private String phasic;
|
|
||||||
|
|
||||||
@SerializedName("defaultPic")
|
|
||||||
private String defaultPic;
|
|
||||||
|
|
||||||
@SerializedName("width")
|
|
||||||
private String width;
|
|
||||||
|
|
||||||
@SerializedName("height")
|
|
||||||
private Integer height;
|
|
||||||
|
|
||||||
@SerializedName("top")
|
|
||||||
private Integer top;
|
|
||||||
|
|
||||||
@SerializedName("left")
|
|
||||||
private Integer left;
|
|
||||||
|
|
||||||
@SerializedName("condition")
|
|
||||||
private List<ConditionVO> condition;
|
|
||||||
|
|
||||||
@SerializedName("color")
|
|
||||||
private String color;
|
|
||||||
|
|
||||||
@SerializedName("fontSize")
|
|
||||||
private Integer fontSize;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
package com.njcn.csharmonic.pojo.vo;
|
|
||||||
|
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类的介绍:
|
|
||||||
*
|
|
||||||
* @author xuyang
|
|
||||||
* @version 1.0.0
|
|
||||||
* @createTime 2023/6/2 15:39
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class ZuTaiVo implements Serializable {
|
|
||||||
|
|
||||||
@SerializedName("background")
|
|
||||||
private String background;
|
|
||||||
|
|
||||||
@SerializedName("elements")
|
|
||||||
private List<ElementsVO> elements;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.njcn.csharmonic.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
|
import com.njcn.csharmonic.param.CsPageParm;
|
||||||
|
import com.njcn.csharmonic.pojo.vo.CsPageVO;
|
||||||
|
import com.njcn.csharmonic.pojo.vo.ElementsVO;
|
||||||
|
import com.njcn.csharmonic.service.ICsElementService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 组态图元库 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-06-14
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/csElement")
|
||||||
|
@Api(tags = "组态图元")
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CsElementController extends BaseController {
|
||||||
|
|
||||||
|
private final ICsElementService csElementService;
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/add")
|
||||||
|
@ApiOperation("组态图元新增")
|
||||||
|
@ApiImplicitParam(name = "param", value = "组态图元", required = true)
|
||||||
|
public HttpResult<String> add(@RequestBody @Validated CsPageParm param){
|
||||||
|
String methodDescribe = getMethodDescribe("add");
|
||||||
|
csElementService.addElement(param.getJsonFile());
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, CommonResponseEnum.SUCCESS.getMessage(), methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/find")
|
||||||
|
@ApiOperation("查询组态图元数据")
|
||||||
|
public HttpResult<ElementsVO> find(){
|
||||||
|
String methodDescribe = getMethodDescribe("find");
|
||||||
|
ElementsVO elementsVo = csElementService.findElement();
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, elementsVo, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -6,14 +6,10 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.HttpResultUtil;
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
|
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
|
||||||
import com.njcn.csdevice.pojo.vo.LineTargetVO;
|
|
||||||
import com.njcn.csharmonic.pojo.vo.TargetDetailVO;
|
|
||||||
import com.njcn.csharmonic.service.ILineTargetService;
|
import com.njcn.csharmonic.service.ILineTargetService;
|
||||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -50,28 +46,4 @@ public class LineTargetController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@PostMapping("/targetDetail")
|
|
||||||
@ApiOperation("获取指标数据类型和相别")
|
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "pid", value = "数据集id", required = true),
|
|
||||||
@ApiImplicitParam(name = "name", value = "名称", required = true)
|
|
||||||
})
|
|
||||||
public HttpResult<TargetDetailVO> getTargetDetail(@RequestParam("pid") String pid, @RequestParam("name") String name) {
|
|
||||||
String methodDescribe = getMethodDescribe("getTargetDetail");
|
|
||||||
TargetDetailVO list = lineTargetService.getTargetDetail(pid,name);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@PostMapping("/lineData")
|
|
||||||
@ApiOperation("获取指标数据")
|
|
||||||
@ApiImplicitParam(name = "id", value = "组态页面id", required = true)
|
|
||||||
@Deprecated
|
|
||||||
public HttpResult<List<StatisticalDataDTO>> getLineData(@RequestParam("id") String id) {
|
|
||||||
String methodDescribe = getMethodDescribe("getLineData");
|
|
||||||
List<StatisticalDataDTO> list = lineTargetService.getLineData(id);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.njcn.csharmonic.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.njcn.csharmonic.pojo.po.CsElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 组态图元库 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-06-14
|
||||||
|
*/
|
||||||
|
public interface CsElementMapper extends BaseMapper<CsElement> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.njcn.csharmonic.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.csharmonic.param.CsPageParm;
|
||||||
|
import com.njcn.csharmonic.pojo.po.CsElement;
|
||||||
|
import com.njcn.csharmonic.pojo.vo.ElementsVO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 组态图元库 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-06-14
|
||||||
|
*/
|
||||||
|
public interface ICsElementService extends IService<CsElement> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增组态图元
|
||||||
|
* @param json 参数
|
||||||
|
*/
|
||||||
|
void addElement(String json);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组态图元数据查询
|
||||||
|
*/
|
||||||
|
ElementsVO findElement();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
package com.njcn.csharmonic.service;
|
package com.njcn.csharmonic.service;
|
||||||
|
|
||||||
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
|
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
|
||||||
import com.njcn.csdevice.pojo.vo.LineTargetVO;
|
|
||||||
import com.njcn.csharmonic.pojo.vo.TargetDetailVO;
|
|
||||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -19,14 +17,6 @@ public interface ILineTargetService {
|
|||||||
*/
|
*/
|
||||||
List<DataArrayTreeVO> getLineTarget(String lineId);
|
List<DataArrayTreeVO> getLineTarget(String lineId);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取指标的数据类型和相别
|
|
||||||
* @param pid
|
|
||||||
* @param name
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
TargetDetailVO getTargetDetail(String pid, String name);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取绑定指标的数据
|
* 获取绑定指标的数据
|
||||||
* @param id
|
* @param id
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package com.njcn.csharmonic.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.common.utils.FileUtil;
|
||||||
|
import com.njcn.csharmonic.mapper.CsElementMapper;
|
||||||
|
import com.njcn.csharmonic.pojo.po.CsElement;
|
||||||
|
import com.njcn.csharmonic.pojo.vo.ElementsVO;
|
||||||
|
import com.njcn.csharmonic.service.ICsElementService;
|
||||||
|
import com.njcn.oss.constant.OssPath;
|
||||||
|
import com.njcn.oss.utils.FileStorageUtil;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 组态图元库 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-06-14
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CsElementServiceImpl extends ServiceImpl<CsElementMapper, CsElement> implements ICsElementService {
|
||||||
|
|
||||||
|
private final FileStorageUtil fileStorageUtil;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void addElement(String json) {
|
||||||
|
CsElement csElement = new CsElement();
|
||||||
|
if (Objects.isNull(json)){
|
||||||
|
throw new BusinessException("组态图元json缺失");
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<CsElement> lambdaQueryWrapper = new LambdaQueryWrapper<CsElement>();
|
||||||
|
csElement = this.baseMapper.selectOne(lambdaQueryWrapper);
|
||||||
|
if (!Objects.isNull(csElement)){
|
||||||
|
fileStorageUtil.deleteFile(csElement.getPath());
|
||||||
|
} else {
|
||||||
|
csElement = new CsElement();
|
||||||
|
}
|
||||||
|
InputStream inputStream = this.writeJsonStringToInputStream(json);
|
||||||
|
String path = fileStorageUtil.uploadStream(inputStream, OssPath.ELEMENT, FileUtil.generateFileName("json"));
|
||||||
|
csElement.setPath(path);
|
||||||
|
this.saveOrUpdate(csElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ElementsVO findElement() {
|
||||||
|
ElementsVO elementsVo = new ElementsVO();
|
||||||
|
LambdaQueryWrapper<CsElement> lambdaQueryWrapper = new LambdaQueryWrapper<CsElement>();
|
||||||
|
CsElement csElement = this.baseMapper.selectOne(lambdaQueryWrapper);
|
||||||
|
if (!Objects.isNull(csElement)){
|
||||||
|
InputStream inputStream = fileStorageUtil.getFileStream(csElement.getPath());
|
||||||
|
String text = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n"));
|
||||||
|
elementsVo.setId(csElement.getId());
|
||||||
|
elementsVo.setJson(text);
|
||||||
|
}
|
||||||
|
return elementsVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将json转成流
|
||||||
|
* @param jsonString
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public InputStream writeJsonStringToInputStream(String jsonString) {
|
||||||
|
return new ByteArrayInputStream(jsonString.getBytes(StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,16 +1,10 @@
|
|||||||
package com.njcn.csharmonic.service.impl;
|
package com.njcn.csharmonic.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
|
||||||
import com.njcn.csdevice.api.*;
|
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.CsDevModelPO;
|
||||||
import com.njcn.csdevice.pojo.po.CsDevModelRelationPO;
|
import com.njcn.csdevice.pojo.po.CsDevModelRelationPO;
|
||||||
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
|
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
|
||||||
import com.njcn.csdevice.pojo.vo.LineTargetVO;
|
import com.njcn.csdevice.pojo.vo.LineTargetVO;
|
||||||
import com.njcn.csharmonic.pojo.vo.ElementsVO;
|
|
||||||
import com.njcn.csharmonic.pojo.vo.TargetDetailVO;
|
|
||||||
import com.njcn.csharmonic.pojo.vo.ZuTaiVo;
|
|
||||||
import com.njcn.csharmonic.service.CsPagePOService;
|
import com.njcn.csharmonic.service.CsPagePOService;
|
||||||
import com.njcn.csharmonic.service.ILineTargetService;
|
import com.njcn.csharmonic.service.ILineTargetService;
|
||||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||||
@@ -20,12 +14,9 @@ import com.njcn.system.api.EpdFeignClient;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -77,60 +68,15 @@ public class LineTargetServiceImpl implements ILineTargetService {
|
|||||||
return dataArrayList;
|
return dataArrayList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TargetDetailVO getTargetDetail(String pid, String name) {
|
|
||||||
TargetDetailVO vo = new TargetDetailVO();
|
|
||||||
List<CsDataArray> dataArrayList = dataArrayFeignClient.getDataArrayById(pid,name).getData();
|
|
||||||
List<String> dataType = dataArrayList.stream().map(CsDataArray::getStatMethod).distinct().collect(Collectors.toList());
|
|
||||||
List<String> phasic = dataArrayList.stream().map(CsDataArray::getPhase).distinct().collect(Collectors.toList());
|
|
||||||
vo.setDataTypeList(dataType);
|
|
||||||
vo.setPhasicList(phasic);
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StatisticalDataDTO> getLineData(String id) {
|
public List<StatisticalDataDTO> getLineData(String id) {
|
||||||
List<StatisticalDataDTO> result = new ArrayList<>();
|
List<StatisticalDataDTO> result = new ArrayList<>();
|
||||||
String path = csPagePOService.queryById(id).getPath();
|
String path = csPagePOService.queryById(id).getPath();
|
||||||
InputStream inputStream = fileStorageUtil.getFileStream(path);
|
InputStream inputStream = fileStorageUtil.getFileStream(path);
|
||||||
List<ElementsVO> list = analysisJson(inputStream);
|
|
||||||
if (CollectionUtil.isNotEmpty(list)){
|
|
||||||
list.forEach(item->{
|
|
||||||
String targetTag = item.getTargetId().stream().reduce((first, second) -> second).orElse("no last element");
|
|
||||||
if (CollectionUtil.isNotEmpty(dataArrayFeignClient.getDataArrayById(item.getTargetPid(),targetTag).getData())){
|
|
||||||
String targetName = dataArrayFeignClient.getDataArrayById(item.getTargetPid(),targetTag).getData().get(0).getAnotherName();
|
|
||||||
String dataId = dataArrayFeignClient.getDataArrayById(item.getTargetPid(),targetTag).getData().get(0).getDataId();
|
|
||||||
String classId = epdFeignClient.selectById(dataId).getData().getClassId();
|
|
||||||
String lineId = item.getLineId().stream().reduce((first, second) -> second).orElse("no last element");
|
|
||||||
String dataType = item.getDataType();
|
|
||||||
String phasic = item.getPhasic();
|
|
||||||
result.add(getLineRtData(lineId,classId,targetTag,phasic,dataType,targetName));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取子节点
|
|
||||||
*/
|
|
||||||
public List<LineTargetVO> getChildren(LineTargetVO item, List<LineTargetVO> all) {
|
|
||||||
return all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析json文件
|
|
||||||
*/
|
|
||||||
public List<ElementsVO> analysisJson(InputStream inputStream) {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
String text = new BufferedReader(
|
|
||||||
new InputStreamReader(inputStream, StandardCharsets.UTF_8))
|
|
||||||
.lines()
|
|
||||||
.collect(Collectors.joining("\n"));
|
|
||||||
ZuTaiVo zuTai = gson.fromJson(text, ZuTaiVo.class);
|
|
||||||
return zuTai.getElements();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过orm框架获取数据
|
* 通过orm框架获取数据
|
||||||
* @param lineId 监测点Id
|
* @param lineId 监测点Id
|
||||||
|
|||||||
Reference in New Issue
Block a user