提交一次接线图实时调试
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
package com.njcn.csharmonic.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description:
|
||||||
|
* Date: 2025/09/18 下午 2:00【需求编号】
|
||||||
|
*
|
||||||
|
* @author clam
|
||||||
|
* @version V1.0.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class RealTimeDataDTO {
|
||||||
|
private Integer code;
|
||||||
|
private String message;
|
||||||
|
private Integer type =1;
|
||||||
|
// private List<RealTimeDataVo> realTimeDataVoList;
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.njcn.csharmonic.pojo.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/6/14 20:07
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public class ZuTaiNewDTO {
|
||||||
|
|
||||||
|
private List<DiagramElement> json;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public static class DiagramElement{
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String title;
|
||||||
|
private String keyId;
|
||||||
|
private String type;
|
||||||
|
private boolean resize;
|
||||||
|
private boolean rotate;
|
||||||
|
private boolean lock;
|
||||||
|
private boolean active;
|
||||||
|
private boolean hide;
|
||||||
|
private String tag;
|
||||||
|
private boolean use_proportional_scaling;
|
||||||
|
private String lineId;
|
||||||
|
private List<String> lineList;
|
||||||
|
private String lineName;
|
||||||
|
@JsonProperty("UID")
|
||||||
|
private List<List<String>> uid;
|
||||||
|
@JsonProperty("UIDNames")
|
||||||
|
|
||||||
|
private List<String> uidNames;
|
||||||
|
private List<String> unit;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -42,6 +42,9 @@ public class CsRtDataVO {
|
|||||||
@ApiModelProperty("指标显示名称")
|
@ApiModelProperty("指标显示名称")
|
||||||
private String statisticalName;
|
private String statisticalName;
|
||||||
|
|
||||||
|
@ApiModelProperty("指标单位")
|
||||||
|
private String unit;
|
||||||
|
|
||||||
@ApiModelProperty("指标名称")
|
@ApiModelProperty("指标名称")
|
||||||
private String target;
|
private String target;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.njcn.csharmonic.pojo.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组态下事件描述实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CsWarnDescVO implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称,比如监测点名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发生时间
|
||||||
|
*/
|
||||||
|
private String timeId;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事件描述eventDesc
|
||||||
|
*/
|
||||||
|
private String eventDesc;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 持续时间
|
||||||
|
*/
|
||||||
|
private Double persistTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂降幅值
|
||||||
|
*/
|
||||||
|
private Double amplitude;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -13,10 +13,7 @@ import io.swagger.annotations.ApiImplicitParam;
|
|||||||
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;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.csharmonic.handler;
|
package com.njcn.csharmonic.handler;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
|
import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
|
||||||
@@ -16,8 +17,11 @@ import com.njcn.csdevice.api.EquipmentFeignClient;
|
|||||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||||
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
|
import com.njcn.csharmonic.param.CommonStatisticalQueryParam;
|
||||||
import com.njcn.csharmonic.param.FrequencyStatisticalQueryParam;
|
import com.njcn.csharmonic.param.FrequencyStatisticalQueryParam;
|
||||||
|
import com.njcn.csharmonic.pojo.dto.RealTimeDataDTO;
|
||||||
import com.njcn.csharmonic.pojo.vo.CsRtDataVO;
|
import com.njcn.csharmonic.pojo.vo.CsRtDataVO;
|
||||||
|
import com.njcn.csharmonic.pojo.vo.CsWarnDescVO;
|
||||||
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
||||||
|
import com.njcn.csharmonic.service.CsEventPOService;
|
||||||
import com.njcn.csharmonic.service.ILineTargetService;
|
import com.njcn.csharmonic.service.ILineTargetService;
|
||||||
import com.njcn.csharmonic.service.StableDataService;
|
import com.njcn.csharmonic.service.StableDataService;
|
||||||
import com.njcn.csharmonic.service.TemperatureService;
|
import com.njcn.csharmonic.service.TemperatureService;
|
||||||
@@ -34,12 +38,10 @@ import org.apache.commons.lang.StringUtils;
|
|||||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@@ -72,6 +74,8 @@ public class MqttMessageHandler {
|
|||||||
private static Integer mid = 1;
|
private static Integer mid = 1;
|
||||||
private final FileFeignClient fileFeignClient;
|
private final FileFeignClient fileFeignClient;
|
||||||
|
|
||||||
|
CsEventPOService csEventPOService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实时数据应答
|
* 实时数据应答
|
||||||
*/
|
*/
|
||||||
@@ -92,6 +96,39 @@ public class MqttMessageHandler {
|
|||||||
publisher.send("/zl/TemperData/" + devId, gson.toJson(statisticalDataDTOS), 1, false);
|
publisher.send("/zl/TemperData/" + devId, gson.toJson(statisticalDataDTOS), 1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物联平台的组态实时数据调试
|
||||||
|
*/
|
||||||
|
@MqttSubscribe(value = "/zl/askCSConfigRtData/{pageId}", qos = 1)
|
||||||
|
public void responseCSConfigRtData(String topic, @NamedValue("pageId") String pageId, MqttMessage message, @Payload String payload) {
|
||||||
|
List<String> lineIdList = Arrays.stream(payload.substring(1, payload.length() - 1).split(","))
|
||||||
|
.map(String::trim)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
List<CsRtDataVO> lineData = lineTargetService.getLineDataNew(pageId);
|
||||||
|
List<CsRtDataVO> collect = lineData.stream().filter(temp -> (!CollectionUtils.isEmpty(lineIdList)) && lineIdList.contains(temp.getLineId())).collect(Collectors.toList());
|
||||||
|
RealTimeDataDTO recallReplyDTO = new RealTimeDataDTO();
|
||||||
|
recallReplyDTO.setCode(200);
|
||||||
|
recallReplyDTO.setMessage(JSONObject.toJSONString(collect));
|
||||||
|
Gson gson = new Gson();
|
||||||
|
publisher.send("/zl/csConfigRtData/" + pageId, gson.toJson(recallReplyDTO), 1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MqttSubscribe(value = "/zl/askCSConfigWarnData/{pageId}", qos = 1)
|
||||||
|
public void responseCSConfigWarnData(String topic, @NamedValue("pageId") String pageId, MqttMessage message, @Payload String payload) {
|
||||||
|
List<String> lineIdList = Arrays.stream(payload.substring(1, payload.length() - 1).split(","))
|
||||||
|
.map(String::trim)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 目前暂且查最近的60条记录
|
||||||
|
List<CsWarnDescVO> csWarnDescVOList = csEventPOService.getEventDesc(lineIdList);
|
||||||
|
RealTimeDataDTO recallReplyDTO = new RealTimeDataDTO();
|
||||||
|
recallReplyDTO.setCode(200);
|
||||||
|
recallReplyDTO.setMessage(JSONObject.toJSONString(csWarnDescVOList));
|
||||||
|
Gson gson = new Gson();
|
||||||
|
publisher.send("/zl/TemperData/" + pageId, gson.toJson(recallReplyDTO), 1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实时数据应答
|
* 实时数据应答
|
||||||
*/
|
*/
|
||||||
@@ -195,6 +232,7 @@ public class MqttMessageHandler {
|
|||||||
// }
|
// }
|
||||||
// publisher.send("/zl/devData/"+devId,topoDataJson,1,false);
|
// publisher.send("/zl/devData/"+devId,topoDataJson,1,false);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实时数据应答
|
* 实时数据应答
|
||||||
*/
|
*/
|
||||||
@@ -305,7 +343,6 @@ public class MqttMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getCldidName(String cldid) {
|
public String getCldidName(String cldid) {
|
||||||
|
|
||||||
switch (cldid) {
|
switch (cldid) {
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ package com.njcn.csharmonic.mapper;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||||
|
import com.njcn.csharmonic.pojo.vo.CsWarnDescVO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -12,4 +16,5 @@ import com.njcn.csharmonic.pojo.po.CsEventPO;
|
|||||||
* @version V1.0.0
|
* @version V1.0.0
|
||||||
*/
|
*/
|
||||||
public interface CsEventPOMapper extends BaseMapper<CsEventPO> {
|
public interface CsEventPOMapper extends BaseMapper<CsEventPO> {
|
||||||
|
List<CsWarnDescVO> getEventDesc(@Param("lineIdList")List<String> lineIdList, @Param("count")int count);
|
||||||
}
|
}
|
||||||
@@ -15,4 +15,26 @@
|
|||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
id, line_id, device_id, start_time, tag, wave_id
|
id, line_id, device_id, start_time, tag, wave_id
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="getEventDesc" resultType="com.njcn.csharmonic.pojo.vo.CsWarnDescVO">
|
||||||
|
SELECT
|
||||||
|
t1.line_id id,
|
||||||
|
t2.NAME,
|
||||||
|
t1.start_time timeId,
|
||||||
|
t1.amplitude,
|
||||||
|
t1.persist_time
|
||||||
|
FROM
|
||||||
|
cs_event t1,
|
||||||
|
cs_line t2
|
||||||
|
WHERE
|
||||||
|
t1.line_id = t2.line_id
|
||||||
|
and t1.line_id in
|
||||||
|
<foreach collection="lineIdList" item="lineId" separator="," open="(" close=")">
|
||||||
|
#{lineId}
|
||||||
|
</foreach>
|
||||||
|
and t1.type = 0
|
||||||
|
LIMIT 60
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -10,6 +10,7 @@ import com.njcn.csharmonic.param.DataParam;
|
|||||||
import com.njcn.csharmonic.pojo.param.EventStatisticParam;
|
import com.njcn.csharmonic.pojo.param.EventStatisticParam;
|
||||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||||
import com.njcn.csharmonic.pojo.vo.CsEventVO;
|
import com.njcn.csharmonic.pojo.vo.CsEventVO;
|
||||||
|
import com.njcn.csharmonic.pojo.vo.CsWarnDescVO;
|
||||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||||
import com.njcn.csharmonic.pojo.vo.EventStatisticsVo;
|
import com.njcn.csharmonic.pojo.vo.EventStatisticsVo;
|
||||||
import com.njcn.event.file.pojo.dto.WaveDataDTO;
|
import com.njcn.event.file.pojo.dto.WaveDataDTO;
|
||||||
@@ -69,4 +70,5 @@ public interface CsEventPOService extends IService<CsEventPO>{
|
|||||||
|
|
||||||
List<EventStatisticsVo> getEventStatistics(CsEventUserQueryParam param);
|
List<EventStatisticsVo> getEventStatistics(CsEventUserQueryParam param);
|
||||||
|
|
||||||
|
List<CsWarnDescVO> getEventDesc(List<String> lineIdList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,4 +23,9 @@ public interface ILineTargetService {
|
|||||||
*/
|
*/
|
||||||
List<CsRtDataVO> getLineData(String id);
|
List<CsRtDataVO> getLineData(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取绑定指标的数据
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
List<CsRtDataVO> getLineDataNew(String id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import com.njcn.csharmonic.param.DataParam;
|
|||||||
import com.njcn.csharmonic.pojo.param.EventStatisticParam;
|
import com.njcn.csharmonic.pojo.param.EventStatisticParam;
|
||||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||||
import com.njcn.csharmonic.pojo.vo.CsEventVO;
|
import com.njcn.csharmonic.pojo.vo.CsEventVO;
|
||||||
|
import com.njcn.csharmonic.pojo.vo.CsWarnDescVO;
|
||||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||||
import com.njcn.csharmonic.pojo.vo.EventStatisticsVo;
|
import com.njcn.csharmonic.pojo.vo.EventStatisticsVo;
|
||||||
import com.njcn.csharmonic.service.CsEventPOService;
|
import com.njcn.csharmonic.service.CsEventPOService;
|
||||||
@@ -401,6 +402,23 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CsWarnDescVO> getEventDesc(List<String> lineIdList) {
|
||||||
|
List<CsWarnDescVO> csWarnDescVOList = new ArrayList<>();
|
||||||
|
if(CollUtil.isEmpty(lineIdList)){
|
||||||
|
return csWarnDescVOList;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* todo.. 目前且先查最近的60条
|
||||||
|
*/
|
||||||
|
csWarnDescVOList = this.baseMapper.getEventDesc(lineIdList,60);
|
||||||
|
// 处理下描述
|
||||||
|
for (CsWarnDescVO csWarnDescVO : csWarnDescVOList) {
|
||||||
|
csWarnDescVO.setEventDesc("电压暂态事件,持续时间"+csWarnDescVO.getPersistTime()+"秒,电压降至"+csWarnDescVO.getAmplitude()+"%。");
|
||||||
|
}
|
||||||
|
return csWarnDescVOList;
|
||||||
|
}
|
||||||
|
|
||||||
public String getTag(Integer type) {
|
public String getTag(Integer type) {
|
||||||
String tag;
|
String tag;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package com.njcn.csharmonic.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.csdevice.api.*;
|
import com.njcn.csdevice.api.*;
|
||||||
@@ -12,10 +15,12 @@ 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.enums.CsHarmonicResponseEnum;
|
import com.njcn.csharmonic.enums.CsHarmonicResponseEnum;
|
||||||
import com.njcn.csharmonic.pojo.dto.ZuTaiDTO;
|
import com.njcn.csharmonic.pojo.dto.ZuTaiDTO;
|
||||||
|
import com.njcn.csharmonic.pojo.dto.ZuTaiNewDTO;
|
||||||
import com.njcn.csharmonic.pojo.vo.CsRtDataVO;
|
import com.njcn.csharmonic.pojo.vo.CsRtDataVO;
|
||||||
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.csharmonic.util.InfluxDbParamUtil;
|
import com.njcn.csharmonic.util.InfluxDbParamUtil;
|
||||||
|
import com.njcn.cssystem.enums.CsSystemResponseEnum;
|
||||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||||
import com.njcn.influx.service.CommonService;
|
import com.njcn.influx.service.CommonService;
|
||||||
import com.njcn.oss.utils.FileStorageUtil;
|
import com.njcn.oss.utils.FileStorageUtil;
|
||||||
@@ -34,10 +39,7 @@ 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.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,6 +139,50 @@ public class LineTargetServiceImpl implements ILineTargetService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CsRtDataVO> getLineDataNew(String id) {
|
||||||
|
List<CsRtDataVO> result = new ArrayList<>();
|
||||||
|
String path = csPagePOService.queryById(id).getPath();
|
||||||
|
InputStream inputStream = fileStorageUtil.getFileStream(path);
|
||||||
|
ZuTaiNewDTO zuTaiDto = analysisJsonNew(inputStream);
|
||||||
|
|
||||||
|
zuTaiDto.getJson().forEach(item->{
|
||||||
|
if (!CollectionUtils.isEmpty(item.getUidNames())){
|
||||||
|
for (int i = 0; i < item.getUidNames().size(); i++) {
|
||||||
|
String temp = item.getUidNames().get(i);
|
||||||
|
String targetTag = null;
|
||||||
|
String phasic = null;
|
||||||
|
String dataType = null;
|
||||||
|
// String[] tmepUidName = temp.split(" / ");
|
||||||
|
// if(tmepUidName.length==2){
|
||||||
|
// targetTag = tmepUidName[0];
|
||||||
|
// phasic = "T";
|
||||||
|
// dataType = tmepUidName[1];
|
||||||
|
// }else if (tmepUidName.length==3){
|
||||||
|
// targetTag = tmepUidName[0];
|
||||||
|
// phasic = tmepUidName[1];
|
||||||
|
// dataType = tmepUidName[2];
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(item.getUid()) || org.springframework.util.StringUtils.isEmpty(item.getLineId())){
|
||||||
|
throw new BusinessException(CsSystemResponseEnum.BIND_TARGET_ERROR);
|
||||||
|
}
|
||||||
|
List<String> tempUid = item.getUid().get(i);
|
||||||
|
String s = tempUid.get(tempUid.size() - 1);
|
||||||
|
String[] tempTable = s.replace("$", "").split("#");
|
||||||
|
result.add(getLineRtDataNew(item.getId(),item.getLineId(),tempTable[3],tempTable[0],tempTable[1],tempTable[2].toUpperCase(),temp,item.getUnit().get(i)));
|
||||||
|
// result.add(getLineRtData(item.getId(),item.getLineId(),tempUid.get(3),tempUid.get(0),tempUid.get(1),tempUid.get(2).toUpperCase(),temp,"%"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析json文件
|
* 解析json文件
|
||||||
*/
|
*/
|
||||||
@@ -149,6 +195,28 @@ public class LineTargetServiceImpl implements ILineTargetService {
|
|||||||
return gson.fromJson(text, new TypeToken<ZuTaiDTO>(){}.getType());
|
return gson.fromJson(text, new TypeToken<ZuTaiDTO>(){}.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析json文件
|
||||||
|
*/
|
||||||
|
public ZuTaiNewDTO analysisJsonNew(InputStream inputStream) {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
|
String text = new BufferedReader(
|
||||||
|
new InputStreamReader(inputStream, StandardCharsets.UTF_8))
|
||||||
|
.lines()
|
||||||
|
.collect(Collectors.joining("\n"));
|
||||||
|
|
||||||
|
|
||||||
|
ZuTaiNewDTO config = null;
|
||||||
|
try {
|
||||||
|
config = mapper.readValue(text, ZuTaiNewDTO.class);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过orm框架获取数据
|
* 通过orm框架获取数据
|
||||||
* @param id 图元Id
|
* @param id 图元Id
|
||||||
@@ -179,4 +247,74 @@ public class LineTargetServiceImpl implements ILineTargetService {
|
|||||||
csRtDataVO.setId(id);
|
csRtDataVO.setId(id);
|
||||||
return csRtDataVO;
|
return csRtDataVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过orm框架获取数据
|
||||||
|
* @param id 图元Id
|
||||||
|
* @param lineId 监测点Id
|
||||||
|
* @param tableName 表名称
|
||||||
|
* @param columnName 字段名称
|
||||||
|
* @param phasic 相别
|
||||||
|
* @param dataType 数据类型
|
||||||
|
* @param target 数据名称
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public CsRtDataVO getLineRtDataNew(String id,String lineId, String tableName, String columnName, String phasic, String dataType, String target,String uint) {
|
||||||
|
CsRtDataVO csRtDataVO = new CsRtDataVO();
|
||||||
|
StatisticalDataDTO statisticalDataDTO = commonService.getLineRtData(lineId,tableName,columnName,phasic,dataType,null);
|
||||||
|
if(Objects.isNull(statisticalDataDTO)){
|
||||||
|
statisticalDataDTO = new StatisticalDataDTO();
|
||||||
|
statisticalDataDTO.setLineId(lineId);
|
||||||
|
statisticalDataDTO.setPhaseType(phasic);
|
||||||
|
statisticalDataDTO.setValueType(dataType);
|
||||||
|
statisticalDataDTO.setValue(3.1415926);
|
||||||
|
} else {
|
||||||
|
statisticalDataDTO.setValue(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
}
|
||||||
|
String targetTag = null;
|
||||||
|
String targetPhasic = null;
|
||||||
|
String targetDataType = null;
|
||||||
|
|
||||||
|
String[] tmepUidName = target.split(" / ");
|
||||||
|
if(tmepUidName.length==2){
|
||||||
|
targetTag = tmepUidName[0];
|
||||||
|
targetDataType = getDataType(tmepUidName[1]) ;
|
||||||
|
}else if (tmepUidName.length==3){
|
||||||
|
targetTag = tmepUidName[0];
|
||||||
|
targetPhasic = tmepUidName[1];
|
||||||
|
targetDataType =getDataType(tmepUidName[2]) ;
|
||||||
|
} else if (tmepUidName.length==4) {
|
||||||
|
targetTag = tmepUidName[1];
|
||||||
|
targetPhasic = tmepUidName[2];
|
||||||
|
targetDataType =getDataType(tmepUidName[3]) ;
|
||||||
|
}
|
||||||
|
statisticalDataDTO.setStatisticalName((Objects.isNull(targetPhasic)?"":targetPhasic+"相_")+targetTag+"_"+targetDataType);
|
||||||
|
statisticalDataDTO.setTarget(columnName + "$" + phasic + "$" + dataType);
|
||||||
|
BeanUtils.copyProperties(statisticalDataDTO,csRtDataVO);
|
||||||
|
csRtDataVO.setId(id);
|
||||||
|
csRtDataVO.setUnit(uint);
|
||||||
|
return csRtDataVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDataType(String statItem){
|
||||||
|
String valueTypeName = "";
|
||||||
|
switch (statItem) {
|
||||||
|
case "max":
|
||||||
|
valueTypeName = "最大值";
|
||||||
|
break;
|
||||||
|
case "min":
|
||||||
|
valueTypeName = "最小值";
|
||||||
|
break;
|
||||||
|
case "avg":
|
||||||
|
valueTypeName = "平均值";
|
||||||
|
break;
|
||||||
|
case "cp95":
|
||||||
|
valueTypeName = "cp95值";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return valueTypeName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public enum CsSystemResponseEnum {
|
|||||||
SAME_DATA_ERROR("A0301","数据重复"),
|
SAME_DATA_ERROR("A0301","数据重复"),
|
||||||
|
|
||||||
CS_SYSTEM_COMMON_ERROR("A00302","治理系统模块异常"),
|
CS_SYSTEM_COMMON_ERROR("A00302","治理系统模块异常"),
|
||||||
|
BIND_TARGET_ERROR("A00601","指标参数绑定异常"),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -146,5 +146,35 @@ public class EleEpdPqd {
|
|||||||
*/
|
*/
|
||||||
private String defaultValue;
|
private String defaultValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态(0:删除 1:正常)
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报表数据来源(mysql表名)
|
||||||
|
*/
|
||||||
|
private String resourcesId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限值名称
|
||||||
|
*/
|
||||||
|
private String limitName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限值表名
|
||||||
|
*/
|
||||||
|
private String limitTable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 超标判断方式
|
||||||
|
*/
|
||||||
|
private String formula;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二次值转一次值公式
|
||||||
|
*/
|
||||||
|
private String primaryFormula;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.njcn.cssystem.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class EleEpdTreeVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "id",value = "模板索引")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "name",value = "模板字段名")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "showName",value = "模板中文展示名")
|
||||||
|
private String showName;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "flag",value = "用于标识最底层对象 1.表示已经没有子级")
|
||||||
|
private Integer flag;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "unit",value = "单位")
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
private List<EleEpdTreeVO> children;
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.njcn.cssystem.controller.zutai;
|
||||||
|
|
||||||
|
|
||||||
|
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.cssystem.pojo.vo.EleEpdTreeVO;
|
||||||
|
import com.njcn.cssystem.service.IEleEpdPqdService;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-05-24
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/csDictData")
|
||||||
|
@Api(tags = "指标数据字典")
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class EleEpdPqdController extends BaseController {
|
||||||
|
|
||||||
|
private final IEleEpdPqdService eleEpdPqdService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取电能质量指标模板树
|
||||||
|
* @author cdf
|
||||||
|
* @date 2022/8/16
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@GetMapping("/eleEpdChooseTree")
|
||||||
|
@ApiOperation("获取电能质量指标模板树")
|
||||||
|
public HttpResult<List<EleEpdTreeVO>> eleEpdChooseTree(){
|
||||||
|
String methodDescribe = getMethodDescribe("eleEpdChooseTree");
|
||||||
|
List<EleEpdTreeVO> res = eleEpdPqdService.eleEpdChooseTree();
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.njcn.cssystem.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.njcn.cssystem.pojo.po.EleEpdPqd;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-05-24
|
||||||
|
*/
|
||||||
|
public interface EleEpdPqdMapper extends BaseMapper<EleEpdPqd> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.njcn.cssystem.mapper.EleEpdPqdMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.njcn.cssystem.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.cssystem.pojo.po.EleEpdPqd;
|
||||||
|
import com.njcn.cssystem.pojo.vo.EleEpdTreeVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-05-24
|
||||||
|
*/
|
||||||
|
public interface IEleEpdPqdService extends IService<EleEpdPqd> {
|
||||||
|
|
||||||
|
|
||||||
|
List<EleEpdTreeVO> eleEpdChooseTree();
|
||||||
|
}
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
package com.njcn.cssystem.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.cssystem.mapper.EleEpdPqdMapper;
|
||||||
|
import com.njcn.cssystem.pojo.po.EleEpdPqd;
|
||||||
|
import com.njcn.cssystem.pojo.vo.EleEpdTreeVO;
|
||||||
|
import com.njcn.cssystem.service.IEleEpdPqdService;
|
||||||
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
|
import com.njcn.system.enums.DicDataEnum;
|
||||||
|
import com.njcn.system.enums.DicDataTypeEnum;
|
||||||
|
import com.njcn.system.pojo.po.DictData;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-05-24
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class EleEpdPqdServiceImpl extends ServiceImpl<EleEpdPqdMapper, EleEpdPqd> implements IEleEpdPqdService {
|
||||||
|
|
||||||
|
private final DicDataFeignClient dicDataFeignClient;
|
||||||
|
|
||||||
|
private final String STR_ONE = "#";
|
||||||
|
|
||||||
|
private final String STR_TWO = "$";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<EleEpdTreeVO> eleEpdChooseTree() {
|
||||||
|
DictData dic = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.CS_DATA_TYPE.getName(), DicDataEnum.EPD.getName()).getData();
|
||||||
|
LambdaQueryWrapper<EleEpdPqd> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.eq(EleEpdPqd::getDataType, dic.getId()).orderByAsc(EleEpdPqd::getSort);
|
||||||
|
List<EleEpdPqd> list = this.getBaseMapper().selectList(lambdaQueryWrapper);
|
||||||
|
Map<String, List<EleEpdPqd>> map = list.stream().collect(Collectors.groupingBy(EleEpdPqd::getName, LinkedHashMap::new, Collectors.toList()));
|
||||||
|
|
||||||
|
List<EleEpdTreeVO> tree = new ArrayList<>();
|
||||||
|
map.forEach((key, value) -> {
|
||||||
|
|
||||||
|
EleEpdTreeVO reportTreeVO = new EleEpdTreeVO();
|
||||||
|
reportTreeVO.setName(value.get(0).getOtherName());
|
||||||
|
reportTreeVO.setShowName(value.get(0).getShowName());
|
||||||
|
|
||||||
|
//存在1-50次 2-50次情况
|
||||||
|
if (Objects.nonNull(value.get(0).getHarmStart()) && Objects.nonNull(value.get(0).getHarmEnd())) {
|
||||||
|
List<EleEpdTreeVO> reHarm = new ArrayList<>();
|
||||||
|
for (int i = value.get(0).getHarmStart(); i <= value.get(0).getHarmEnd(); i++) {
|
||||||
|
EleEpdTreeVO reportTreeCount = new EleEpdTreeVO();
|
||||||
|
reportTreeCount.setName(value.get(0).getOtherName() + "_" + i);
|
||||||
|
reportTreeCount.setShowName(i + "次" + value.get(0).getShowName());
|
||||||
|
reportTreeVO.setFlag(1);
|
||||||
|
assPhase(value, reportTreeCount, reportTreeCount.getName());
|
||||||
|
reHarm.add(reportTreeCount);
|
||||||
|
}
|
||||||
|
reportTreeVO.setChildren(reHarm);
|
||||||
|
} else {
|
||||||
|
assPhase(value, reportTreeVO, value.get(0).getOtherName());
|
||||||
|
}
|
||||||
|
tree.add(reportTreeVO);
|
||||||
|
});
|
||||||
|
return tree;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*组装相别*/
|
||||||
|
private void assPhase(List<EleEpdPqd> value, EleEpdTreeVO reportTreeItem, String key) {
|
||||||
|
List<EleEpdTreeVO> phaseTree = new ArrayList<>();
|
||||||
|
value.forEach(item -> {
|
||||||
|
if (Objects.nonNull(item.getPhase()) && !"M".equals(item.getPhase())) {
|
||||||
|
List<EleEpdTreeVO> statTree = new ArrayList<>();
|
||||||
|
EleEpdTreeVO reportTreePhase = new EleEpdTreeVO();
|
||||||
|
reportTreePhase.setName(item.getPhase());
|
||||||
|
reportTreePhase.setShowName(item.getPhase());
|
||||||
|
// reportTreePhase.setUnit(item.getUnit());
|
||||||
|
assStatMethod(item, statTree, key, item.getPhase());
|
||||||
|
reportTreePhase.setChildren(statTree);
|
||||||
|
phaseTree.add(reportTreePhase);
|
||||||
|
reportTreeItem.setChildren(phaseTree);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
List<EleEpdTreeVO> statTree = new ArrayList<>();
|
||||||
|
assStatMethod(item, statTree, key, "T");
|
||||||
|
reportTreeItem.setChildren(statTree);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assStatMethod(EleEpdPqd item, List<EleEpdTreeVO> statTree, String oneKey, String twoKey) {
|
||||||
|
//存在向别为M但是Stat_Method不为空
|
||||||
|
if (StrUtil.isNotBlank(item.getStatMethod())) {
|
||||||
|
String[] arr = item.getStatMethod().split(",");
|
||||||
|
List<String> stat = Stream.of(arr).collect(Collectors.toList());
|
||||||
|
if (CollUtil.isNotEmpty(stat)) {
|
||||||
|
stat.forEach(statItem -> {
|
||||||
|
EleEpdTreeVO reportTreeStat = new EleEpdTreeVO();
|
||||||
|
reportTreeStat.setUnit(item.getUnit());
|
||||||
|
String tem = "";
|
||||||
|
if (Objects.nonNull(item.getLimitName())) {
|
||||||
|
tem = STR_ONE + item.getLimitName();
|
||||||
|
} else {
|
||||||
|
tem = "#NO";
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(twoKey)) {
|
||||||
|
reportTreeStat.setName(STR_TWO + oneKey + STR_ONE + twoKey + STR_ONE + statItem + STR_ONE + item.getClassId().trim() + tem.trim() + STR_TWO);
|
||||||
|
} else {
|
||||||
|
reportTreeStat.setName(STR_TWO + oneKey + STR_ONE + statItem + STR_ONE + item.getClassId().trim() + tem.trim() + STR_TWO);
|
||||||
|
}
|
||||||
|
|
||||||
|
reportTreeStat.setShowName(statItem);
|
||||||
|
statTree.add(reportTreeStat);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user