From 0d1c142885e26bf0bec1df1c30a5c6c82dd9f595 Mon Sep 17 00:00:00 2001 From: xy <748613696@qq.com> Date: Wed, 17 Sep 2025 20:15:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=91=E5=89=8D=E7=BD=AE?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../njcn/csdevice/pojo/vo/CldLedgerVo.java | 42 ++++++ .../com/njcn/csdevice/pojo/vo/DeviceInfo.java | 1 - .../controller/icd/IcdController.java | 16 ++- .../controller/line/CslineController.java | 4 +- .../project/EngineeringController.java | 2 - .../service/CsEquipmentDeliveryService.java | 5 + .../com/njcn/csdevice/service/IcdService.java | 3 + .../impl/CsEquipmentDeliveryServiceImpl.java | 9 ++ .../service/impl/CsLinePOServiceImpl.java | 4 +- .../csdevice/service/impl/IcdServiceImpl.java | 123 +++++++++++++++++- .../njcn/csdevice/util/InfluxDbParamUtil.java | 9 +- .../csharmonic/pojo/vo/EventDetailVO.java | 1 - .../service/impl/CsEventPOServiceImpl.java | 31 ++++- .../impl/CsEventUserPOServiceImpl.java | 28 ---- .../service/impl/DataServiceImpl.java | 19 +++ 15 files changed, 253 insertions(+), 44 deletions(-) create mode 100644 cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/CldLedgerVo.java diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/CldLedgerVo.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/CldLedgerVo.java new file mode 100644 index 0000000..845373c --- /dev/null +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/CldLedgerVo.java @@ -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 projectInfoList; + + @ApiModelProperty(value = "设备信息") + private List deviceInfoList; + + @ApiModelProperty(value = "监测点信息") + private List lineInfoList; + +} \ No newline at end of file diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DeviceInfo.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DeviceInfo.java index 0e89288..6d61e78 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DeviceInfo.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DeviceInfo.java @@ -1,6 +1,5 @@ package com.njcn.csdevice.pojo.vo; -import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/icd/IcdController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/icd/IcdController.java index 3d66daf..22249d0 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/icd/IcdController.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/icd/IcdController.java @@ -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 getLedgerById(@RequestParam String id){ + String methodDescribe = getMethodDescribe("getLedgerById"); + CldLedgerVo vo = icdService.getLedgerById(id); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe); + } + } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/line/CslineController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/line/CslineController.java index 48b4d40..f356c8d 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/line/CslineController.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/line/CslineController.java @@ -171,8 +171,9 @@ public class CslineController extends BaseController { @PostMapping("/updateCldLine") @ApiOperation("修改云前置监测点") @ApiImplicitParam(name = "id", value = "id", required = true) - public HttpResult> updateCldLine(@RequestParam("id") String id) { + public HttpResult> 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> delCldLine(@RequestParam("id") String id) { String methodDescribe = getMethodDescribe("delCldLine"); + csLinePOService.deleteCldLine(id); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/project/EngineeringController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/project/EngineeringController.java index 48e3976..b626354 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/project/EngineeringController.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/project/EngineeringController.java @@ -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("新增工程") diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsEquipmentDeliveryService.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsEquipmentDeliveryService.java index d6a09f6..c2694ea 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsEquipmentDeliveryService.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsEquipmentDeliveryService.java @@ -178,4 +178,9 @@ public interface CsEquipmentDeliveryService extends IService getDevListByProjectId(String projectId); + } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IcdService.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IcdService.java index 37f2b51..6c0888f 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IcdService.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IcdService.java @@ -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); + } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java index 1d189ff..c7f68a7 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java @@ -927,6 +927,15 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl getDevListByProjectId(String projectId) { + QueryWrapper csLedgerQueryWrapper = new QueryWrapper(); + csLedgerQueryWrapper.lambda().eq(CsLedger::getPid, projectId).eq(CsLedger::getState,1); + List csLedgers = csLedgerMapper.selectList(csLedgerQueryWrapper); + List collect = csLedgers.stream().map(CsLedger::getId).collect(Collectors.toList()); + return this.lambdaQuery().in(CsEquipmentDeliveryPO::getId,collect).list(); + } + //根据前置机id获取装置数量 public List getListByNodeId(String nodeId) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsLinePOServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsLinePOServiceImpl.java index c0ba769..961b2f0 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsLinePOServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsLinePOServiceImpl.java @@ -169,8 +169,10 @@ public class CsLinePOServiceImpl extends ServiceImpl i } @Override + @Transactional(rollbackFor = Exception.class) public void deleteCldLine(String id) { - + this.removeById(id); + csLedgerMapper.deleteById(id); } @Override diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/IcdServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/IcdServiceImpl.java index fd67659..0f368d1 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/IcdServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/IcdServiceImpl.java @@ -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 projectInfoList = appProjectService.getProjectByEngineering(Collections.singletonList(id)); + vo.setProjectInfoList(projectInfoList); + } + + /** + * 处理1级数据(项目级别) + */ + private void handleLevel1(CldLedgerVo vo, String id, String[] pids) { + // 设置项目信息 + List appProjectPOS = appProjectService.listByIds(Collections.singletonList(id)); + vo.setProjectInfoList(appProjectPOS); + // 设置设备信息 + List 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 project = appProjectService.listByIds(Collections.singletonList(projectId)); + vo.setProjectInfoList(project); + } + // 设置设备信息 + List csEquipmentDeliveryPOS = csEquipmentDeliveryService.listByIds(Collections.singletonList(id)); + vo.setDeviceInfoList(csEquipmentDeliveryPOS); + // 设置线路信息 + List 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 appProjectPOS = appProjectService.listByIds(Collections.singletonList(projectId)); + vo.setProjectInfoList(appProjectPOS); + } + // 设置设备信息(设备ID在pids[3]位置) + if (pids.length > 3) { + String deviceId = pids[3]; + List csEquipmentDeliveryPOS = csEquipmentDeliveryService.listByIds(Collections.singletonList(deviceId)); + vo.setDeviceInfoList(csEquipmentDeliveryPOS); + } + // 设置线路信息 + List line = csLinePOService.listByIds(Collections.singletonList(id)); + vo.setLineInfoList(line); + } + public void sendFrontLedger() { diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/util/InfluxDbParamUtil.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/util/InfluxDbParamUtil.java index e6b3c9c..99bcb2c 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/util/InfluxDbParamUtil.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/util/InfluxDbParamUtil.java @@ -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)){ diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/vo/EventDetailVO.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/vo/EventDetailVO.java index 32d25c5..81cea6e 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/vo/EventDetailVO.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/vo/EventDetailVO.java @@ -119,7 +119,6 @@ public class EventDetailVO { @ApiModelProperty("子模块编号") private String moduleNo; - @ApiModelProperty("逻辑子设备编码") private Integer clDid; diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventPOServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventPOServiceImpl.java index 5294459..c26711b 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventPOServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventPOServiceImpl.java @@ -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 queryEventList(CsEventUserQueryParam csEventUserQueryParam) { @@ -241,6 +250,7 @@ public class CsEventPOServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); @@ -251,6 +261,8 @@ public class CsEventPOServiceImpl extends ServiceImpl records = new ArrayList(); + Map tags = new HashMap<>(); + tags.put(InfluxDBTableConstant.UUID,uuid); + Map 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())) { //更新文件信息 diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventUserPOServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventUserPOServiceImpl.java index 42969f4..5f9179e 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventUserPOServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventUserPOServiceImpl.java @@ -364,8 +364,6 @@ public class CsEventUserPOServiceImpl extends ServiceImpl queryEventPageWeb(CsEventUserQueryPage csEventUserQueryPage) { Page returnpage = new Page<> (csEventUserQueryPage.getPageNum ( ), csEventUserQueryPage.getPageSize ( )); - - List data = csLedgerFeignClient.getDeviceTree().getData(); List devIds = new ArrayList<>(); data = data.stream().filter(temp -> StringUtils.isEmpty(csEventUserQueryPage.getDeviceTypeName() )|| @@ -384,7 +382,6 @@ public class CsEventUserPOServiceImpl extends ServiceImpl StringUtils.isEmpty(csEventUserQueryPage.getDeviceId()) || Objects.equals(temp.getId(), csEventUserQueryPage.getDeviceId()) ).map(CsLedgerVO::getId).collect(Collectors.toList()); - List 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{ DevDetailDTO devDetail = csLedgerFeignClient.queryDevDetail(temp.getDeviceId()).getData(); temp.setEquipmentName(devDetail.getEquipmentName()); @@ -421,7 +414,6 @@ public class CsEventUserPOServiceImpl extends ServiceImpl data1 = eleEvtFeignClient.queryByPid(ele.getId()).getData(); List eventDataSetDTOS = new ArrayList<>(); for (EleEvtParm eleEvtParm : data1) { @@ -429,32 +421,23 @@ public class CsEventUserPOServiceImpl extends ServiceImpl 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 evtParamPosition = eventDataSetDTOS.stream(). @@ -462,9 +445,7 @@ public class CsEventUserPOServiceImpl extends ServiceImpl evtParamPhase = eventDataSetDTOS.stream(). @@ -489,18 +468,11 @@ public class CsEventUserPOServiceImpl extends ServiceImpl channelData(List list) { + AtomicReference 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 result = new ArrayList<>(); //将list 排序,并按照排序后的结果进行有序分组 LinkedHashMap> map = list.stream().sorted(Comparator.comparing(RealTimeDataVo::getSort)).collect(Collectors.groupingBy(RealTimeDataVo::getName, LinkedHashMap::new, Collectors.toList()));