新增云前置相关功能
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.njcn.csdevice.pojo.vo;
|
||||
|
||||
import com.njcn.csdevice.pojo.po.AppProjectPO;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/ //台账信息
|
||||
@Data
|
||||
public class CldLedgerVo implements Serializable {
|
||||
|
||||
@ApiModelProperty("工程id")
|
||||
private String engineeringId;
|
||||
|
||||
@ApiModelProperty(value = "工程名称")
|
||||
private String engineeringName;
|
||||
|
||||
@ApiModelProperty(value = "省")
|
||||
private String province;
|
||||
|
||||
@ApiModelProperty(value = "市")
|
||||
private String city;
|
||||
|
||||
@ApiModelProperty(value = "工程描述")
|
||||
private String engineeringDescription;
|
||||
|
||||
@ApiModelProperty(value = "项目信息")
|
||||
private List<AppProjectPO> projectInfoList;
|
||||
|
||||
@ApiModelProperty(value = "设备信息")
|
||||
private List<CsEquipmentDeliveryPO> deviceInfoList;
|
||||
|
||||
@ApiModelProperty(value = "监测点信息")
|
||||
private List<CsLinePO> lineInfoList;
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.njcn.csdevice.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.param.IcdLedgerParam;
|
||||
import com.njcn.csdevice.param.IcdParam;
|
||||
import com.njcn.csdevice.pojo.vo.CldLedgerVo;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceInfo;
|
||||
import com.njcn.csdevice.service.IcdService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -16,10 +17,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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 org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -56,4 +54,14 @@ public class IcdController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getLedgerById")
|
||||
@ApiOperation("根据Id获取台账信息")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true)
|
||||
public HttpResult<CldLedgerVo> getLedgerById(@RequestParam String id){
|
||||
String methodDescribe = getMethodDescribe("getLedgerById");
|
||||
CldLedgerVo vo = icdService.getLedgerById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -171,8 +171,9 @@ public class CslineController extends BaseController {
|
||||
@PostMapping("/updateCldLine")
|
||||
@ApiOperation("修改云前置监测点")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true)
|
||||
public HttpResult<List<CsLinePO>> updateCldLine(@RequestParam("id") String id) {
|
||||
public HttpResult<List<CsLinePO>> updateCldLine(@RequestBody CsLineParam param) {
|
||||
String methodDescribe = getMethodDescribe("updateCldLine");
|
||||
csLinePOService.updateCldLine(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -182,6 +183,7 @@ public class CslineController extends BaseController {
|
||||
@ApiImplicitParam(name = "id", value = "监测点id", required = true)
|
||||
public HttpResult<List<CsLinePO>> delCldLine(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("delCldLine");
|
||||
csLinePOService.deleteCldLine(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,10 +40,8 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
public class EngineeringController extends BaseController {
|
||||
|
||||
|
||||
private final CsEngineeringService csEngineeringService;
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/addEngineering")
|
||||
@ApiOperation("新增工程")
|
||||
|
||||
@@ -178,4 +178,9 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
|
||||
*/
|
||||
void flipCldDevStatus(String devId, Integer status);
|
||||
|
||||
/**
|
||||
* 根据项目id获取设备列表
|
||||
*/
|
||||
List<CsEquipmentDeliveryPO> getDevListByProjectId(String projectId);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.csdevice.service;
|
||||
|
||||
import com.njcn.csdevice.param.IcdLedgerParam;
|
||||
import com.njcn.csdevice.param.IcdParam;
|
||||
import com.njcn.csdevice.pojo.vo.CldLedgerVo;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceInfo;
|
||||
|
||||
import java.util.List;
|
||||
@@ -12,4 +13,6 @@ public interface IcdService {
|
||||
|
||||
void addLedgerInfo(IcdLedgerParam param);
|
||||
|
||||
CldLedgerVo getLedgerById(String id);
|
||||
|
||||
}
|
||||
|
||||
@@ -927,6 +927,15 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsEquipmentDeliveryPO> getDevListByProjectId(String projectId) {
|
||||
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper();
|
||||
csLedgerQueryWrapper.lambda().eq(CsLedger::getPid, projectId).eq(CsLedger::getState,1);
|
||||
List<CsLedger> csLedgers = csLedgerMapper.selectList(csLedgerQueryWrapper);
|
||||
List<String> collect = csLedgers.stream().map(CsLedger::getId).collect(Collectors.toList());
|
||||
return this.lambdaQuery().in(CsEquipmentDeliveryPO::getId,collect).list();
|
||||
}
|
||||
|
||||
//根据前置机id获取装置数量
|
||||
public List<CsEquipmentDeliveryPO> getListByNodeId(String nodeId) {
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
@@ -169,8 +169,10 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteCldLine(String id) {
|
||||
|
||||
this.removeById(id);
|
||||
csLedgerMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.access.utils.ChannelObjectUtil;
|
||||
@@ -12,6 +13,7 @@ import com.njcn.csdevice.pojo.param.AppProjectAddParm;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAddParm;
|
||||
import com.njcn.csdevice.pojo.param.CsLineParam;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.pojo.vo.CldLedgerVo;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceInfo;
|
||||
import com.njcn.csdevice.service.*;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
@@ -19,6 +21,7 @@ import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -27,6 +30,7 @@ import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class IcdServiceImpl implements IcdService {
|
||||
@@ -38,6 +42,7 @@ class IcdServiceImpl implements IcdService {
|
||||
private final AppProjectService appProjectService;
|
||||
private final CsEquipmentDeliveryService csEquipmentDeliveryService;
|
||||
private final CsLinePOService csLinePOService;
|
||||
private final ICsLedgerService csLedgerService;
|
||||
private final MqttPublisher publisher;
|
||||
|
||||
@Override
|
||||
@@ -119,12 +124,126 @@ class IcdServiceImpl implements IcdService {
|
||||
// 第四种:从设备创建
|
||||
else if (CollectionUtil.isNotEmpty(param.getDevice())) {
|
||||
handleFromDeviceCreation(param);
|
||||
//新增完监测点后,需要通知前置修改台账信息
|
||||
|
||||
//todo 新增完监测点后,需要通知前置修改台账信息
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CldLedgerVo getLedgerById(String id) {
|
||||
CldLedgerVo vo = new CldLedgerVo();
|
||||
CsLedger csLedger = csLedgerService.findDataById(id);
|
||||
if (ObjectUtil.isNull(csLedger)) {
|
||||
return vo;
|
||||
}
|
||||
Integer level = csLedger.getLevel();
|
||||
String[] pids = csLedger.getPids().split(StrUtil.COMMA);
|
||||
// 设置工程信息(所有级别都需要)
|
||||
setEngineeringInfo(vo, level, pids, id);
|
||||
// 根据级别设置不同的业务数据
|
||||
switch (level) {
|
||||
case 0:
|
||||
handleLevel0(vo, id);
|
||||
break;
|
||||
case 1:
|
||||
handleLevel1(vo, id, pids);
|
||||
break;
|
||||
case 2:
|
||||
handleLevel2(vo, id, pids);
|
||||
break;
|
||||
case 3:
|
||||
handleLevel3(vo, id, pids);
|
||||
break;
|
||||
default:
|
||||
log.warn("Unknown ledger level: {}", level);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置工程信息
|
||||
*/
|
||||
private void setEngineeringInfo(CldLedgerVo vo, Integer level, String[] pids, String id) {
|
||||
String engineeringId;
|
||||
|
||||
if (level == 0) {
|
||||
// 0级本身就是工程
|
||||
engineeringId = id;
|
||||
} else if (level >= 1 && pids.length > 1) {
|
||||
// 1-3级的工程ID在pids[1]位置
|
||||
engineeringId = pids[1];
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
CsEngineeringPO po = csEngineeringService.queryEngineeringById(engineeringId);
|
||||
if (po != null) {
|
||||
vo.setEngineeringId(po.getId());
|
||||
vo.setEngineeringName(po.getName());
|
||||
vo.setProvince(po.getProvince());
|
||||
vo.setCity(po.getCity());
|
||||
vo.setEngineeringDescription(po.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理0级数据(工程级别)
|
||||
*/
|
||||
private void handleLevel0(CldLedgerVo vo, String id) {
|
||||
List<AppProjectPO> projectInfoList = appProjectService.getProjectByEngineering(Collections.singletonList(id));
|
||||
vo.setProjectInfoList(projectInfoList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理1级数据(项目级别)
|
||||
*/
|
||||
private void handleLevel1(CldLedgerVo vo, String id, String[] pids) {
|
||||
// 设置项目信息
|
||||
List<AppProjectPO> appProjectPOS = appProjectService.listByIds(Collections.singletonList(id));
|
||||
vo.setProjectInfoList(appProjectPOS);
|
||||
// 设置设备信息
|
||||
List<CsEquipmentDeliveryPO> devList = csEquipmentDeliveryService.getDevListByProjectId(id);
|
||||
vo.setDeviceInfoList(devList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理2级数据(设备级别)
|
||||
*/
|
||||
private void handleLevel2(CldLedgerVo vo, String id, String[] pids) {
|
||||
// 设置项目信息(项目ID在pids[2]位置)
|
||||
if (pids.length > 2) {
|
||||
String projectId = pids[2];
|
||||
List<AppProjectPO> project = appProjectService.listByIds(Collections.singletonList(projectId));
|
||||
vo.setProjectInfoList(project);
|
||||
}
|
||||
// 设置设备信息
|
||||
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.listByIds(Collections.singletonList(id));
|
||||
vo.setDeviceInfoList(csEquipmentDeliveryPOS);
|
||||
// 设置线路信息
|
||||
List<CsLinePO> list = csLinePOService.queryByDevId(id);
|
||||
vo.setLineInfoList(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理3级数据(线路级别)
|
||||
*/
|
||||
private void handleLevel3(CldLedgerVo vo, String id, String[] pids) {
|
||||
// 设置项目信息(项目ID在pids[2]位置)
|
||||
if (pids.length > 2) {
|
||||
String projectId = pids[2];
|
||||
List<AppProjectPO> appProjectPOS = appProjectService.listByIds(Collections.singletonList(projectId));
|
||||
vo.setProjectInfoList(appProjectPOS);
|
||||
}
|
||||
// 设置设备信息(设备ID在pids[3]位置)
|
||||
if (pids.length > 3) {
|
||||
String deviceId = pids[3];
|
||||
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.listByIds(Collections.singletonList(deviceId));
|
||||
vo.setDeviceInfoList(csEquipmentDeliveryPOS);
|
||||
}
|
||||
// 设置线路信息
|
||||
List<CsLinePO> line = csLinePOService.listByIds(Collections.singletonList(id));
|
||||
vo.setLineInfoList(line);
|
||||
}
|
||||
|
||||
public void sendFrontLedger() {
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -23,10 +24,9 @@ import java.util.stream.Stream;
|
||||
public class InfluxDbParamUtil {
|
||||
|
||||
private final CsLineFeignClient csLineFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
|
||||
/*表名换成了id本方法做转换*/
|
||||
public String getTableNameByClassId(String classId){
|
||||
@@ -50,6 +50,11 @@ public class InfluxDbParamUtil {
|
||||
if(DataParam.portableDevType.equals(csEquipmentDeliveryDTOList.get(0).getDevType())){
|
||||
return finalCsLinePOList.get(0).getClDid()+"";
|
||||
}
|
||||
//如果是云前置设备,直接返回clDid
|
||||
boolean isCLdDevice = DicDataEnum.DEV_CLD.getCode().equals(dictTreeFeignClient.queryById(csEquipmentDeliveryDTOList.get(0).getDevType()).getData().getCode());
|
||||
if(isCLdDevice){
|
||||
return String.valueOf(finalCsLinePOList.get(0).getLineNo());
|
||||
}
|
||||
//之后的逻辑还是按照原来的不变
|
||||
String position = csLineFeignClient.getPositionById(lineId).getData();
|
||||
if (Objects.isNull(position)){
|
||||
|
||||
@@ -119,7 +119,6 @@ public class EventDetailVO {
|
||||
@ApiModelProperty("子模块编号")
|
||||
private String moduleNo;
|
||||
|
||||
|
||||
@ApiModelProperty("逻辑子设备编码")
|
||||
private Integer clDid;
|
||||
|
||||
|
||||
@@ -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