新增云前置相关功能
This commit is contained in:
@@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -35,8 +36,10 @@ import com.njcn.event.file.pojo.bo.WaveDataDetail;
|
||||
import com.njcn.event.file.pojo.dto.WaveDataDTO;
|
||||
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
|
||||
import com.njcn.event.file.utils.WaveUtil;
|
||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||
import com.njcn.influx.pojo.dto.EventDataSetDTO;
|
||||
import com.njcn.influx.service.EvtDataService;
|
||||
import com.njcn.influx.utils.InfluxDbUtils;
|
||||
import com.njcn.minioss.config.MinIossProperties;
|
||||
import com.njcn.oss.constant.GeneralConstant;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
@@ -49,6 +52,9 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.influxdb.InfluxDB;
|
||||
import org.influxdb.dto.BatchPoints;
|
||||
import org.influxdb.dto.Point;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -59,8 +65,10 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -86,6 +94,7 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
private final EleEvtFeignClient eleEvtFeignClient;
|
||||
private final WavePicComponent wavePicComponent;
|
||||
private final MinIossProperties minIossProperties;
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
@Override
|
||||
public List<EventDetailVO> queryEventList(CsEventUserQueryParam csEventUserQueryParam) {
|
||||
@@ -241,6 +250,7 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addCldEvent(CldEventParam param) {
|
||||
//校验是新增时间还是更新文件信息
|
||||
LambdaQueryWrapper<CsEventPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
@@ -251,6 +261,8 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
//根据监测点获取装置信息
|
||||
CsLinePO po = csLineFeignClient.getById(param.getMonitorId()).getData();
|
||||
CsEventPO eventPo = new CsEventPO();
|
||||
String uuid = IdUtil.simpleUUID();
|
||||
eventPo.setId(uuid);
|
||||
eventPo.setLineId(param.getMonitorId());
|
||||
eventPo.setDeviceId(po.getDeviceId());
|
||||
LocalDateTime time = LocalDateTime.parse(param.getStartTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_MS_PATTERN));
|
||||
@@ -260,9 +272,24 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
eventPo.setClDid(Integer.parseInt(param.getMonitorId().substring(param.getMonitorId().length() - 1)));
|
||||
eventPo.setLevel(2);
|
||||
eventPo.setProcess(4);
|
||||
eventPo.setPersistTime(param.getDuration()/1000);
|
||||
eventPo.setAmplitude(param.getAmplitude());
|
||||
eventPo.setPersistTime(param.getDuration());
|
||||
eventPo.setAmplitude(param.getAmplitude() * 100);
|
||||
this.baseMapper.insert(eventPo);
|
||||
//influxDB数据录入
|
||||
List<String> records = new ArrayList<String>();
|
||||
Map<String, String> tags = new HashMap<>();
|
||||
tags.put(InfluxDBTableConstant.UUID,uuid);
|
||||
Map<String,Object> fields = new HashMap<>();
|
||||
fields.put("Evt_Param_Phase",param.getPhase());
|
||||
fields.put("Evt_Param_Tm",param.getDuration());
|
||||
fields.put("Evt_Param_VVaDepth",param.getAmplitude() * 100);
|
||||
Point point = influxDbUtils.pointBuilder("evt_data", time.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()/1000, TimeUnit.SECONDS, tags, fields);
|
||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
records.add(batchPoints.lineProtocol());
|
||||
if (CollectionUtil.isNotEmpty(records)) {
|
||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, records);
|
||||
}
|
||||
} else {
|
||||
if (StrUtil.isNotBlank(param.getWavePathCfg()) && StrUtil.isNotBlank(param.getWavePathDat())) {
|
||||
//更新文件信息
|
||||
|
||||
@@ -364,8 +364,6 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
@Override
|
||||
public Page<EventDetailVO> queryEventPageWeb(CsEventUserQueryPage csEventUserQueryPage) {
|
||||
Page<EventDetailVO> returnpage = new Page<> (csEventUserQueryPage.getPageNum ( ), csEventUserQueryPage.getPageSize ( ));
|
||||
|
||||
|
||||
List<CsLedgerVO> data = csLedgerFeignClient.getDeviceTree().getData();
|
||||
List<String> devIds = new ArrayList<>();
|
||||
data = data.stream().filter(temp -> StringUtils.isEmpty(csEventUserQueryPage.getDeviceTypeName() )||
|
||||
@@ -384,7 +382,6 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
temp -> StringUtils.isEmpty(csEventUserQueryPage.getDeviceId()) ||
|
||||
Objects.equals(temp.getId(), csEventUserQueryPage.getDeviceId())
|
||||
).map(CsLedgerVO::getId).collect(Collectors.toList());
|
||||
|
||||
List<String> governmentDevIds = governmentDevTree.stream().filter(temp->StringUtils.isEmpty(csEventUserQueryPage.getEngineeringid())||
|
||||
Objects.equals(temp.getId(), csEventUserQueryPage.getEngineeringid()))
|
||||
.map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter(
|
||||
@@ -397,16 +394,12 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
).
|
||||
map(CsLedgerVO::getId).
|
||||
collect(Collectors.toList());
|
||||
|
||||
devIds.addAll(portableDevIds);
|
||||
devIds.addAll(governmentDevIds);
|
||||
|
||||
if (CollectionUtils.isEmpty(devIds)){
|
||||
return returnpage;
|
||||
}
|
||||
|
||||
returnpage = this.getBaseMapper().queryEventPageWeb(returnpage,csEventUserQueryPage,devIds);
|
||||
|
||||
returnpage.getRecords().forEach(temp->{
|
||||
DevDetailDTO devDetail = csLedgerFeignClient.queryDevDetail(temp.getDeviceId()).getData();
|
||||
temp.setEquipmentName(devDetail.getEquipmentName());
|
||||
@@ -421,7 +414,6 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
temp.setModuleNo("模块" + temp.getClDid());
|
||||
}
|
||||
if(Objects.equals(csEventUserQueryPage.getType(),"0")){
|
||||
|
||||
List<EleEvtParm> data1 = eleEvtFeignClient.queryByPid(ele.getId()).getData();
|
||||
List<EventDataSetDTO> eventDataSetDTOS = new ArrayList<>();
|
||||
for (EleEvtParm eleEvtParm : data1) {
|
||||
@@ -429,32 +421,23 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
BeanUtils.copyProperties(eleEvtParm,eventDataSetDTO);
|
||||
if (Objects.equals(eventDataSetDTO.getName(),"Evt_Param_Position")) {
|
||||
continue;
|
||||
// eventDataSetDTO.setValue(Objects.equals(temp.getLocation(),"grid")?"电网侧":"负载侧");
|
||||
}
|
||||
EventDataSetDTO evtData = evtDataService.getEventDataSet("evt_data", temp.getId(), eleEvtParm.getName());
|
||||
if (evtData == null) {
|
||||
eventDataSetDTO.setValue("-");
|
||||
}else {
|
||||
eventDataSetDTO.setValue(Optional.ofNullable(evtData.getValue()).orElse("-"));
|
||||
|
||||
}
|
||||
// if (Objects.equals(eventDataSetDTO.getName(),"Evt_Param_Position")) {
|
||||
// eventDataSetDTO.setValue(Objects.equals(temp.getLocation(),"grid")?"电网侧":"负载侧");
|
||||
// }
|
||||
eventDataSetDTOS.add(eventDataSetDTO);
|
||||
}
|
||||
temp.setDataSet(eventDataSetDTOS);
|
||||
|
||||
List<EventDataSetDTO> evtParamVVaDepth = eventDataSetDTOS.stream().
|
||||
filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_VVaDepth")).
|
||||
collect(Collectors.toList());
|
||||
|
||||
if(CollectionUtil.isEmpty(evtParamVVaDepth)){
|
||||
temp.setEvtParamVVaDepth("-");
|
||||
|
||||
}else {
|
||||
temp.setEvtParamVVaDepth(evtParamVVaDepth.get(0).getValue()+(Objects.isNull(evtParamVVaDepth.get(0).getUnit())?"":evtParamVVaDepth.get(0).getUnit()));
|
||||
|
||||
}
|
||||
|
||||
List<EventDataSetDTO> evtParamPosition = eventDataSetDTOS.stream().
|
||||
@@ -462,9 +445,7 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
collect(Collectors.toList());
|
||||
if(CollectionUtil.isEmpty(evtParamPosition)){
|
||||
temp.setEvtParamPosition("-");
|
||||
|
||||
}else {
|
||||
//temp.setEvtParamPosition(evtParamPosition.get(0).getValue()+(Objects.isNull(evtParamPosition.get(0).getUnit())?"":evtParamPosition.get(0).getUnit()));
|
||||
temp.setEvtParamPosition(evtParamPosition.get(0).getValue());
|
||||
}
|
||||
if (Objects.equals(temp.getEvtParamPosition(),"-")) {
|
||||
@@ -478,10 +459,8 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
collect(Collectors.toList());
|
||||
if(CollectionUtil.isEmpty(evtParamTm)){
|
||||
temp.setEvtParamTm("-");
|
||||
|
||||
}else {
|
||||
temp.setEvtParamTm(evtParamTm.get(0).getValue()+(Objects.isNull(evtParamTm.get(0).getUnit())?"":evtParamTm.get(0).getUnit()));
|
||||
|
||||
}
|
||||
|
||||
List<EventDataSetDTO> evtParamPhase = eventDataSetDTOS.stream().
|
||||
@@ -489,18 +468,11 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
collect(Collectors.toList());
|
||||
if(CollectionUtil.isEmpty(evtParamPhase)){
|
||||
temp.setEvtParamPhase("-");
|
||||
|
||||
}else {
|
||||
temp.setEvtParamPhase(evtParamPhase.get(0).getValue()+(Objects.isNull(evtParamPhase.get(0).getUnit())?"":evtParamPhase.get(0).getUnit()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
return returnpage;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,11 +53,13 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -639,6 +641,23 @@ public class DataServiceImpl implements IDataService {
|
||||
|
||||
//数据格式处理
|
||||
public List<RealTimeDataVo> channelData(List<RealTimeDataVo> list) {
|
||||
AtomicReference<Instant> time = new AtomicReference<>();
|
||||
list.forEach(item->{
|
||||
if (Objects.equals(item.getName(),"Pq_Freq")) {
|
||||
time.set(item.getTime());
|
||||
}
|
||||
});
|
||||
if (Objects.nonNull(time.get())) {
|
||||
list.forEach(item->{
|
||||
if (ObjectUtil.isNotNull(item.getTime()) && item.getTime().isBefore(time.get())) {
|
||||
item.setAvgValue(3.14159);
|
||||
item.setValueA(3.14159);
|
||||
item.setValueB(3.14159);
|
||||
item.setValueC(3.14159);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
List<RealTimeDataVo> result = new ArrayList<>();
|
||||
//将list 排序,并按照排序后的结果进行有序分组
|
||||
LinkedHashMap<String, List<RealTimeDataVo>> map = list.stream().sorted(Comparator.comparing(RealTimeDataVo::getSort)).collect(Collectors.groupingBy(RealTimeDataVo::getName, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
Reference in New Issue
Block a user