From ff7b05bbb6935c6a6013d6cef8202be6fb257fb3 Mon Sep 17 00:00:00 2001 From: xy <748613696@qq.com> Date: Mon, 25 May 2026 19:59:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(device):=20=E4=BE=BF=E6=90=BA=E5=BC=8F?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=95=B0=E6=8D=AE=E8=A1=A5=E5=8F=AC=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E9=87=8D=E6=9E=84=EF=BC=8C=E8=A1=A5=E5=8F=AC=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=8B=86=E5=88=86=E5=88=B013=E5=BC=A0=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E6=95=B0=E6=8D=AE=E8=A1=A8=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cs-device/cs-device-boot/pom.xml | 5 + .../AppLineTopologyDiagramServiceImpl.java | 17 ++- .../impl/PortableOfflLogServiceImpl.java | 103 ++++++++++++++++- .../service/impl/PqdDataSplitServiceImpl.java | 1 + .../handler/MqttMessageHandler.java | 107 ------------------ 5 files changed, 119 insertions(+), 114 deletions(-) diff --git a/cs-device/cs-device-boot/pom.xml b/cs-device/cs-device-boot/pom.xml index 2566b8c..75ea87f 100644 --- a/cs-device/cs-device-boot/pom.xml +++ b/cs-device/cs-device-boot/pom.xml @@ -167,6 +167,11 @@ message-api 1.0.0 + + com.njcn + event-common + 1.0.0 + diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/AppLineTopologyDiagramServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/AppLineTopologyDiagramServiceImpl.java index 26820a0..aa51cc4 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/AppLineTopologyDiagramServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/AppLineTopologyDiagramServiceImpl.java @@ -16,6 +16,10 @@ import com.njcn.csdevice.service.AppLineTopologyDiagramService; import com.njcn.csdevice.service.AppTopologyDiagramService; import com.njcn.csdevice.service.CsLinePOService; import com.njcn.csdevice.service.ICsLedgerService; +import com.njcn.redis.utils.RedisUtil; +import com.njcn.system.api.DicDataFeignClient; +import com.njcn.system.api.DictTreeFeignClient; +import com.njcn.system.pojo.vo.DictTreeVO; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -39,6 +43,9 @@ public class AppLineTopologyDiagramServiceImpl extends ServiceImpl queryPage(BaseParam baseParam) { @@ -356,9 +364,9 @@ public class PortableOfflLogServiceImpl extends ServiceImpl> partition = ListUtils.partition(pqdData, 1500); for (List sliceList : partition) { List sublistAsOriginalListType = new ArrayList<>(sliceList); -// Map map = pqdDataSplitService.splitPqdData(sublistAsOriginalListType); -// insertData(map); - pqdDataMapper.insertBatch(sublistAsOriginalListType); + Map map = pqdDataSplitService.splitPqdData(sublistAsOriginalListType); + insertData(map); +// pqdDataMapper.insertBatch(sublistAsOriginalListType); } //min结果集解析入库后就不需要在解析了 minFlag = false; @@ -386,6 +394,8 @@ public class PortableOfflLogServiceImpl extends ServiceImpl newTaglogbuffers = (List) response.getObj(); if(newTaglogbuffers != null && !newTaglogbuffers.isEmpty()){ + List list1 = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_REASON.getCode()).getData(); + List list2 = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_TYPE.getCode()).getData(); //否则正常标记为成功解析 portableOfflLog.setState(1); portableOfflLog.setAllCount(newTaglogbuffers.size()); @@ -456,14 +466,32 @@ public class PortableOfflLogServiceImpl extends ServiceImpl Objects.equals(item.getAlgoDescribe(), dto.getCause())) + .map(DictData::getId) + .findFirst() + .orElse(null); + csEventPO.setAdvanceReason(id1); + + String id2 = list2.stream() + .filter(item -> Objects.equals(item.getAlgoDescribe(), dto.getType())) + .map(DictData::getId) + .findFirst() + .orElse(null); + csEventPO.setAdvanceType(id2); + } + //默认暂态事件 csEventPO.setType(0); String clDid = influxDbParamUtil.getClDidByLineId(uploadDataParam.getLineId()); csEventPO.setClDid(clDid == null ? null : Integer.parseInt(clDid)); - - csEventPO.setProcess(csEquipmentDeliveryDTO.getProcess()); - csEventPOS.add(csEventPO); + + EntData entData = new EntData(); entData.setUuid(csEventPO.getId()); entData.setTime(new Date().toInstant()); @@ -508,12 +536,19 @@ public class PortableOfflLogServiceImpl extends ServiceImpl queryMainLogPage(BaseParam baseParam) { Page returnpage = new Page<> (baseParam.getPageNum(), baseParam.getPageSize ()); diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/PqdDataSplitServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/PqdDataSplitServiceImpl.java index 53cc6ff..0518ed8 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/PqdDataSplitServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/PqdDataSplitServiceImpl.java @@ -73,6 +73,7 @@ public class PqdDataSplitServiceImpl implements IPqdDataSplitService { for (int i = item.getHarmStart(); i <= item.getHarmEnd(); i++) { EleEpdPqd newItem = copyEleEpdPqd(item); newItem.setName(item.getName() + "_" + i); + newItem.setOtherName(item.getOtherName() + "_" + i); expandedList.add(newItem); } return expandedList.stream(); diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/handler/MqttMessageHandler.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/handler/MqttMessageHandler.java index a0e7a31..067253c 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/handler/MqttMessageHandler.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/handler/MqttMessageHandler.java @@ -10,8 +10,6 @@ import com.github.tocrhz.mqtt.publisher.MqttPublisher; import com.njcn.csdevice.api.CsLineFeignClient; import com.njcn.csdevice.api.CsLineTopologyFeignClient; import com.njcn.csdevice.api.DevCapacityFeignClient; -import com.njcn.csdevice.api.fallback.CsLineTopologyClientFallbackFactory; -import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO; import com.njcn.csharmonic.param.CommonStatisticalQueryParam; import com.njcn.csharmonic.param.FrequencyStatisticalQueryParam; @@ -122,111 +120,6 @@ public class MqttMessageHandler { publisher.send("/zl/TemperData/" + pageId, gson.toJson(recallReplyDTO), 1, false); } - - /** - * 实时数据应答 - */ -// @MqttSubscribe(value = "/zl/askDevData/{devId}",qos = 1) -// public void responseTopoData(String topic, @NamedValue("devId") String devId, MqttMessage message, @Payload String payload) { -// String topoDataJson =redisUtil.getStringByKey (devId); -// if(StringUtils.isEmpty(topoDataJson)){ -// List result = new ArrayList<>(); -// List tempList = new ArrayList<>(); -// -// //1.查询拓扑图配置的指标:拓扑图扑图配置:7677f94c749dedaff30f911949cbd724 -// List data = csStatisticalSetFeignClient.queryStatisticalSelect("b934664f9592d1c5e92caa90695b7103").getData(); -// data.forEach(temp->{ -// if(Objects.nonNull(temp.getHarmStart())&&Objects.nonNull(temp.getHarmEnd())){ -// FrequencyStatisticalQueryParam frequencyStatisticalQueryParam = new FrequencyStatisticalQueryParam(); -// frequencyStatisticalQueryParam.setDevId(devId); -// frequencyStatisticalQueryParam.setStatisticalId(temp.getId()); -// frequencyStatisticalQueryParam.setValueType("avg"); -// frequencyStatisticalQueryParam.setFrequencyStart(temp.getHarmStart()); -// frequencyStatisticalQueryParam.setFrequencyEnd(temp.getHarmEnd()); -// List thdDataVOList = stableDataService.QuerySqlData(frequencyStatisticalQueryParam); -// tempList.addAll(thdDataVOList); -// -// }else { -// CommonStatisticalQueryParam commonStatisticalQueryParam = new CommonStatisticalQueryParam(); -// commonStatisticalQueryParam.setDevId(devId); -// commonStatisticalQueryParam.setStatisticalId(temp.getId()); -// commonStatisticalQueryParam.setValueType("avg"); -// List listFuture= stableDataService.queryFisrtCommonStatistical(commonStatisticalQueryParam); -// tempList.addAll(listFuture); -// } -// -// }); -// //过滤M相 -// List 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 apfThdI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_ThdA_Load(%)")).collect(Collectors.toList()); -// Map> collect3 = apfThdI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId)); -// collect3.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 apfRmsI = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_RmsI_TolOut(A)")).collect(Collectors.toList()); -// Map> collect2 = apfRmsI.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId)); -// collect2.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 apfThdISys = tempList.stream().filter(temp -> Objects.equals(temp.getStatisticalName(), "Apf_ThdA_Sys(%)")).collect(Collectors.toList()); -// Map> collect4 = apfThdISys.stream().collect(Collectors.groupingBy(ThdDataVO::getLineId)); -// collect4.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); -// -// } -// }); -// Double capacity = devCapacityFeignClient.getDevCapacity(devId).getData(); -// apfRmsI.forEach(temp->{ -// ThdDataVO thdDataVO = new ThdDataVO(); -// BeanUtils.copyProperties(temp,thdDataVO); -// thdDataVO.setUnit("%"); -// thdDataVO.setStatisticalName("load_Rate"); -// thdDataVO.setAnotherName("负载率"); -// if (capacity<=0){ -// thdDataVO.setStatisticalData(3.1415926); -// }else { -// double v = temp.getStatisticalData()*100 / capacity; -// thdDataVO.setStatisticalData(Double.valueOf(df.format(v))); -// } -// result.add(thdDataVO); -// }); -// List notM = tempList.stream().filter(temp -> !Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList()); -// result.addAll(notM); -// Gson gson = new Gson(); -// topoDataJson = gson.toJson(result); -// redisUtil.saveByKeyWithExpire(devId, (Object) topoDataJson, 30L); -// } -// publisher.send("/zl/devData/"+devId,topoDataJson,1,false); -// } - /** * 实时数据应答 */