提交代码
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
package com.njcn.csdevice.pojo.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.bo.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||||
|
* Date: 2023/3/27 10:18【需求编号】
|
||||||
|
*
|
||||||
|
* @author clam
|
||||||
|
* @version V1.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目拓扑图关系表
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AppLineTopologyDiagramVO {
|
||||||
|
/**
|
||||||
|
* 拓扑图Id
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点ID
|
||||||
|
*/
|
||||||
|
private String lineId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0:删除 1:正常
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
private Double lng;
|
||||||
|
|
||||||
|
private Double lat;
|
||||||
|
|
||||||
|
private String linePostion;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -60,7 +60,7 @@ public class AppTopologyDiagramVO extends BaseEntity {
|
|||||||
|
|
||||||
private List<CsLineTopologyTemplateVO> csLineTopologyTemplateVOList;
|
private List<CsLineTopologyTemplateVO> csLineTopologyTemplateVOList;
|
||||||
|
|
||||||
private List<AppLineTopologyDiagramPO> appsLineTopologyDiagramPO;
|
private List<AppLineTopologyDiagramVO> appsLineTopologyDiagramPO;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,10 @@ package com.njcn.csdevice.mapper;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
|
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
|
||||||
|
import com.njcn.csdevice.pojo.vo.AppLineTopologyDiagramVO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -13,4 +17,5 @@ import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
|
|||||||
* @version V1.0.0
|
* @version V1.0.0
|
||||||
*/
|
*/
|
||||||
public interface AppLineTopologyDiagramMapper extends BaseMapper<AppLineTopologyDiagramPO> {
|
public interface AppLineTopologyDiagramMapper extends BaseMapper<AppLineTopologyDiagramPO> {
|
||||||
|
List<AppLineTopologyDiagramVO> queryByTopoId(@Param("id") String id);
|
||||||
}
|
}
|
||||||
@@ -16,4 +16,8 @@
|
|||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
id, line_id, `status`, create_by, create_time, update_by, update_time
|
id, line_id, `status`, create_by, create_time, update_by, update_time
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<select id="queryByTopoId" resultType="com.njcn.csdevice.pojo.vo.AppLineTopologyDiagramVO">
|
||||||
|
select a.*,b.position linePostion from cs_line_topology_diagram a LEFT JOIN cs_line b on a.line_id=b.line_id where a.id=#{id}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -2,6 +2,7 @@ package com.njcn.csdevice.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
|
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
|
||||||
|
import com.njcn.csdevice.pojo.vo.AppLineTopologyDiagramVO;
|
||||||
import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO;
|
import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO;
|
||||||
import com.njcn.csdevice.pojo.vo.CsLineTopologyTemplateVO;
|
import com.njcn.csdevice.pojo.vo.CsLineTopologyTemplateVO;
|
||||||
|
|
||||||
@@ -21,5 +22,5 @@ public interface AppLineTopologyDiagramService extends IService<AppLineTopologyD
|
|||||||
|
|
||||||
AppTopologyDiagramVO query(String devId);
|
AppTopologyDiagramVO query(String devId);
|
||||||
|
|
||||||
List<AppLineTopologyDiagramPO> queryByTopoId(String id);
|
List<AppLineTopologyDiagramVO> queryByTopoId(String id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.njcn.csdevice.mapper.AppLineTopologyDiagramMapper;
|
|||||||
import com.njcn.csdevice.pojo.param.AppTopologyDiagramQueryParm;
|
import com.njcn.csdevice.pojo.param.AppTopologyDiagramQueryParm;
|
||||||
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
|
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
|
||||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||||
|
import com.njcn.csdevice.pojo.vo.AppLineTopologyDiagramVO;
|
||||||
import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO;
|
import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO;
|
||||||
import com.njcn.csdevice.pojo.vo.CsLineTopologyTemplateVO;
|
import com.njcn.csdevice.pojo.vo.CsLineTopologyTemplateVO;
|
||||||
import com.njcn.csdevice.service.AppLineTopologyDiagramService;
|
import com.njcn.csdevice.service.AppLineTopologyDiagramService;
|
||||||
@@ -16,6 +17,7 @@ import com.njcn.csdevice.service.CsLinePOService;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -55,8 +57,9 @@ public class AppLineTopologyDiagramServiceImpl extends ServiceImpl<AppLineTopolo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AppLineTopologyDiagramPO> queryByTopoId(String id) {
|
public List<AppLineTopologyDiagramVO> queryByTopoId(String id) {
|
||||||
List<AppLineTopologyDiagramPO> list = this.lambdaQuery().eq(AppLineTopologyDiagramPO::getId, id).list();
|
List<AppLineTopologyDiagramVO> result = new ArrayList<>();
|
||||||
return list;
|
result = this.getBaseMapper().queryByTopoId( id);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.njcn.csharmonic.handler;
|
package com.njcn.csharmonic.handler;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||||
import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
|
import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
|
||||||
import com.github.tocrhz.mqtt.annotation.NamedValue;
|
import com.github.tocrhz.mqtt.annotation.NamedValue;
|
||||||
@@ -15,10 +16,16 @@ import com.njcn.system.pojo.po.EleEpdPqd;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xuyang
|
* @author xuyang
|
||||||
@@ -35,6 +42,7 @@ public class MqttMessageHandler {
|
|||||||
private final ILineTargetService lineTargetService;
|
private final ILineTargetService lineTargetService;
|
||||||
private final CsStatisticalSetFeignClient csStatisticalSetFeignClient;
|
private final CsStatisticalSetFeignClient csStatisticalSetFeignClient;
|
||||||
private final StableDataService stableDataService;
|
private final StableDataService stableDataService;
|
||||||
|
private final DecimalFormat df = new DecimalFormat("#0.00");
|
||||||
/**
|
/**
|
||||||
* 实时数据应答
|
* 实时数据应答
|
||||||
*/
|
*/
|
||||||
@@ -51,16 +59,61 @@ public class MqttMessageHandler {
|
|||||||
@MqttSubscribe(value = "/zl/askDevData/{devId}",qos = 1)
|
@MqttSubscribe(value = "/zl/askDevData/{devId}",qos = 1)
|
||||||
public void responseTopoData(String topic, @NamedValue("devId") String devId, MqttMessage message, @Payload String payload) {
|
public void responseTopoData(String topic, @NamedValue("devId") String devId, MqttMessage message, @Payload String payload) {
|
||||||
List<ThdDataVO> result = new ArrayList<>();
|
List<ThdDataVO> result = new ArrayList<>();
|
||||||
|
List<ThdDataVO> tempList = new ArrayList<>();
|
||||||
|
|
||||||
//1.查询拓扑图配置的指标:拓扑图扑图配置:7677f94c749dedaff30f911949cbd724
|
//1.查询拓扑图配置的指标:拓扑图扑图配置:7677f94c749dedaff30f911949cbd724
|
||||||
List<EleEpdPqd> data = csStatisticalSetFeignClient.queryStatisticalSelect("7677f94c749dedaff30f911949cbd724").getData();
|
List<EleEpdPqd> data = csStatisticalSetFeignClient.queryStatisticalSelect("7677f94c749dedaff30f911949cbd724").getData();
|
||||||
data.forEach(temp->{
|
data.forEach(temp->{
|
||||||
CommonStatisticalQueryParam commonStatisticalQueryParam = new CommonStatisticalQueryParam();
|
CommonStatisticalQueryParam commonStatisticalQueryParam = new CommonStatisticalQueryParam();
|
||||||
commonStatisticalQueryParam.setDevId(devId);
|
commonStatisticalQueryParam.setDevId(devId);
|
||||||
commonStatisticalQueryParam.setStatisticalId(temp.getId());
|
commonStatisticalQueryParam.setStatisticalId(temp.getId());
|
||||||
commonStatisticalQueryParam.setValueType("cp95");
|
commonStatisticalQueryParam.setValueType("avg");
|
||||||
List<ThdDataVO> thdDataVOS = stableDataService.queryFisrtCommonStatistical(commonStatisticalQueryParam);
|
List<ThdDataVO> thdDataVOS = stableDataService.queryFisrtCommonStatistical(commonStatisticalQueryParam);
|
||||||
result.addAll(thdDataVOS);
|
tempList.addAll(thdDataVOS);
|
||||||
});
|
});
|
||||||
|
//过滤M相
|
||||||
|
List<ThdDataVO> m = tempList.stream().filter(temp -> Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList());
|
||||||
|
m.stream().forEach(temp->{
|
||||||
|
Stream.of("A","B","C").forEach(phase->{
|
||||||
|
ThdDataVO thdDataVO = new ThdDataVO();
|
||||||
|
BeanUtils.copyProperties(temp,thdDataVO);
|
||||||
|
thdDataVO.setPhase(phase);
|
||||||
|
result.add(thdDataVO);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//过滤谐波电流,谐波电压畸变率求平均值
|
||||||
|
List<ThdDataVO> thdI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "ThdPhI(%)")).collect(Collectors.toList());
|
||||||
|
Map<String, List<ThdDataVO>> collect = thdI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
|
||||||
|
collect.forEach((k,v)->{
|
||||||
|
if(!CollectionUtil.isEmpty(v)){
|
||||||
|
double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
|
||||||
|
ThdDataVO thdDataVO = new ThdDataVO();
|
||||||
|
BeanUtils.copyProperties(v.get(0),thdDataVO);
|
||||||
|
thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
|
||||||
|
thdDataVO.setPhase("avg");
|
||||||
|
result.add(thdDataVO);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
List<ThdDataVO> thdV = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "ThdPhV(%)")).collect(Collectors.toList());
|
||||||
|
Map<String, List<ThdDataVO>> collect1 = thdV.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId));
|
||||||
|
collect1.forEach((k,v)->{
|
||||||
|
if(!CollectionUtil.isEmpty(v)){
|
||||||
|
double asDouble = v.stream().mapToDouble(ThdDataVO::getStatisticalData).average().getAsDouble();
|
||||||
|
ThdDataVO thdDataVO = new ThdDataVO();
|
||||||
|
BeanUtils.copyProperties(v.get(0),thdDataVO);
|
||||||
|
thdDataVO.setStatisticalData(Double.valueOf(df.format(asDouble)));
|
||||||
|
thdDataVO.setPhase("avg");
|
||||||
|
result.add(thdDataVO);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
List<ThdDataVO> notM = tempList.stream().filter(temp -> !Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList());
|
||||||
|
|
||||||
|
result.addAll(notM);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
|
|||||||
@@ -154,11 +154,22 @@ public class StableDataServiceImpl implements StableDataService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ThdDataVO> queryFisrtCommonStatistical(CommonStatisticalQueryParam commonStatisticalQueryParam) {
|
public List<ThdDataVO> queryFisrtCommonStatistical(CommonStatisticalQueryParam commonStatisticalQueryParam) {
|
||||||
Optional.ofNullable(commonStatisticalQueryParam.getDevId()).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.DEVICE_LOSE));
|
List<String> collect = new ArrayList<>();
|
||||||
|
List<CsLinePO> csLinePOList = new ArrayList<>();
|
||||||
|
if(Objects.isNull(commonStatisticalQueryParam.getDevId())){
|
||||||
|
if(!CollectionUtil.isEmpty(commonStatisticalQueryParam.getLineList())){
|
||||||
|
collect =commonStatisticalQueryParam.getLineList();
|
||||||
|
csLinePOList = csLineFeignClient.queryLineById(collect).getData();
|
||||||
|
}else {
|
||||||
|
throw new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
csLinePOList = csLineFeignClient.queryLineByDevId(commonStatisticalQueryParam.getDevId()).getData();
|
||||||
|
|
||||||
List<CsLinePO> csLinePOList = csLineFeignClient.queryLineByDevId(commonStatisticalQueryParam.getDevId()).getData();
|
}
|
||||||
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
||||||
List<String> collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData();
|
EleEpdPqd data = epdFeignClient.selectById(commonStatisticalQueryParam.getStatisticalId()).getData();
|
||||||
@@ -166,17 +177,18 @@ public class StableDataServiceImpl implements StableDataService {
|
|||||||
String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse("");
|
String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse("");
|
||||||
|
|
||||||
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtData(collect, data.getClassId(), data.getName()+frequency, data.getPhase(), commonStatisticalQueryParam.getValueType());
|
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtData(collect, data.getClassId(), data.getName()+frequency, data.getPhase(), commonStatisticalQueryParam.getValueType());
|
||||||
|
List<CsLinePO> finalCsLinePOList = csLinePOList;
|
||||||
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
||||||
ThdDataVO vo = new ThdDataVO();
|
ThdDataVO vo = new ThdDataVO();
|
||||||
vo.setLineId(temp.getLineId());
|
vo.setLineId(temp.getLineId());
|
||||||
vo.setPhase(temp.getPhaseType());
|
vo.setPhase(temp.getPhaseType());
|
||||||
String position = csLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
||||||
vo.setPosition(position);
|
vo.setPosition(position);
|
||||||
vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
vo.setTime(temp.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
||||||
vo.setStatMethod(temp.getValueType());
|
vo.setStatMethod(temp.getValueType());
|
||||||
vo.setStatisticalData(BigDecimal.valueOf(temp.getValue()).setScale(4, RoundingMode.UP).doubleValue());
|
vo.setStatisticalData(BigDecimal.valueOf(temp.getValue()).setScale(4, RoundingMode.UP).doubleValue());
|
||||||
vo.setStatisticalIndex(data.getId());
|
vo.setStatisticalIndex(data.getId());
|
||||||
vo.setStatisticalName(temp.getStatisticalName());
|
vo.setStatisticalName(data.getName()+"("+data.getUnit()+")");
|
||||||
return vo;
|
return vo;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user