From 770b707b8471ec134411410af454cc6a04c14630 Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Tue, 16 Jun 2026 09:58:24 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=89=8D=E7=BD=AE=E4=BA=A4=E4=BA=92=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=89=A9=E5=B1=95=E6=A8=A1=E7=B3=8A=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=202.=E8=A7=A3=E5=86=B3=E6=9A=82=E6=80=81=E6=97=B6=E9=97=B412?= =?UTF-8?q?=E5=B0=8F=E6=97=B6=E5=88=B6=E7=9A=84=E9=97=AE=E9=A2=98=203.?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E4=BB=B6=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/bootstrap.yml | 2 +- .../com/njcn/oss/utils/FileStorageUtil.java | 7 +- .../pq/pojo/vo/LineIntegrityDataVO.java | 2 + .../mapping/LineIntegrityDataMapper.xml | 1 + .../njcn/device/line/service/LineService.java | 6 ++ .../service/impl/DeptLineServiceImpl.java | 3 +- .../line/service/impl/LineServiceImpl.java | 78 +++++++++++++++++++ .../event/pojo/vo/AdvanceEventDetailVO.java | 2 +- .../service/impl/PqFrontLogsServiceImpl.java | 44 +++++++---- 9 files changed, 123 insertions(+), 22 deletions(-) diff --git a/pqs-advance/advance-boot/src/main/resources/bootstrap.yml b/pqs-advance/advance-boot/src/main/resources/bootstrap.yml index 39055dcd9..f724f8097 100644 --- a/pqs-advance/advance-boot/src/main/resources/bootstrap.yml +++ b/pqs-advance/advance-boot/src/main/resources/bootstrap.yml @@ -1,3 +1,3 @@ spring: profiles: - active: sjzx \ No newline at end of file + active: @spring.profiles.active@ \ No newline at end of file diff --git a/pqs-common/common-oss/src/main/java/com/njcn/oss/utils/FileStorageUtil.java b/pqs-common/common-oss/src/main/java/com/njcn/oss/utils/FileStorageUtil.java index b787c69a8..3e7002ed7 100644 --- a/pqs-common/common-oss/src/main/java/com/njcn/oss/utils/FileStorageUtil.java +++ b/pqs-common/common-oss/src/main/java/com/njcn/oss/utils/FileStorageUtil.java @@ -102,8 +102,11 @@ public class FileStorageUtil { throw new BusinessException(OssResponseEnum.UPLOAD_FILE_ERROR); } } else if (generalInfo.getBusinessFileStorage() == GeneralConstant.AliYUN_OSS) { - filePath = dir; - aliYunOssUtils.uploadFile(dir, multipartFile); + filePath = dir.endsWith("/")?dir+getFileNameWithoutPath(multipartFile):dir+"/"+getFileNameWithoutPath(multipartFile); + if (filePath.charAt(0) == '/') { + filePath= filePath.substring(1); + } + aliYunOssUtils.uploadFile(filePath, multipartFile); } else { try { // 构建完整目录:基准目录 + dir子目录 diff --git a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/vo/LineIntegrityDataVO.java b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/vo/LineIntegrityDataVO.java index c17059f35..6ccde837d 100644 --- a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/vo/LineIntegrityDataVO.java +++ b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/vo/LineIntegrityDataVO.java @@ -125,6 +125,8 @@ public class LineIntegrityDataVO implements Serializable { private Integer algoDescribe; + @ApiModelProperty(name = "devType",value = "终端型号") + private String devType; @ApiModelProperty(name = "loadType",value = "干扰源类型") private String loadType; diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/LineIntegrityDataMapper.xml b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/LineIntegrityDataMapper.xml index f12d598e2..586df63db 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/LineIntegrityDataMapper.xml +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/mapper/mapping/LineIntegrityDataMapper.xml @@ -84,6 +84,7 @@ pldsdd.id AS lineGrade, pldsdd.Algo_Describe AS algoDescribe, pld.Load_Type AS loadType, + pd.Dev_Type AS devType, pld.obj_id as objId FROM pq_line AS line diff --git a/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/service/LineService.java b/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/service/LineService.java index 83557be18..ef3540f8c 100644 --- a/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/service/LineService.java +++ b/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/service/LineService.java @@ -235,4 +235,10 @@ public interface LineService extends IService { * 终端运行状态修改时,同时调整监测点的运行状态 */ void updateLineRunFlag(String id, Integer status); + + /** + * 自动修改验证pids是否正确 + */ + void updatePids(); + } diff --git a/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/service/impl/DeptLineServiceImpl.java b/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/service/impl/DeptLineServiceImpl.java index 846fc77f4..38684f7a2 100644 --- a/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/service/impl/DeptLineServiceImpl.java +++ b/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/service/impl/DeptLineServiceImpl.java @@ -83,10 +83,9 @@ public class DeptLineServiceImpl extends ServiceImpl i List deptList = Arrays.asList("130700000000", "130300000000", "130800000000", "130200000000", "131000000000"); Dept data = deptFeignClient.getDeptById(deptLineParam.getId()).getData(); if (deptList.contains(data.getArea())) { - List lineIds = list.stream().map(LineDetail::getId).collect(Collectors.toList()); detailMapper.update(null, new LambdaUpdateWrapper() .set(LineDetail::getActualArea, data.getArea()) - .in(LineDetail::getId, lineIds)); + .in(LineDetail::getId, ids)); } } } diff --git a/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/service/impl/LineServiceImpl.java b/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/service/impl/LineServiceImpl.java index 707a700bb..88b8714a6 100644 --- a/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/service/impl/LineServiceImpl.java +++ b/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/service/impl/LineServiceImpl.java @@ -6,9 +6,11 @@ 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.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.common.pojo.enums.common.DataStateEnum; @@ -840,6 +842,82 @@ public class LineServiceImpl extends ServiceImpl implements Li } } + @Override + public void updatePids() { + List list = this.list(); + List strings = this.checkPidsError(list); + if(CollUtil.isNotEmpty(strings)){ + for (String msg : strings) { + // 1. 按 | 分割成三部分 + String[] parts = msg.split(" \\| "); + // 2. 提取节点 ID + String id = parts[0].replace("节点ID:", "").trim(); + // 3. 提取正确 pids(去掉括号) + String newPids = parts[2].replace("正确pids:[", "").replace("]", "").trim(); + this.update(new LambdaUpdateWrapper() + .set(Line::getPids, newPids) + .eq(Line::getId, id)); + + + } + } + } + /** + * 校验所有节点 pids 是否正确 + * 正确规则:去掉开头0 + 去掉自身ID,只保留祖先链 + */ + public List checkPidsError(List allList) { + List errorList = new ArrayList<>(); + Map idMap = allList.stream().collect(Collectors.toMap(Line::getId,Function.identity())); + for (Line node : allList) { + // 1. 生成正确格式的 pids(你的规则) + String correctPids = getCorrectPids(node.getId(), idMap); + // 2. 数据库存储的 pids + String dbPids = node.getPids() == null ? "" : node.getPids().trim(); + // 3. 对比,不一致就是错误 + if (!correctPids.equals(dbPids)) { + errorList.add("节点ID:" + node.getId() + + " | 数据库pids:[" + dbPids + + "] | 正确pids:[" + correctPids + "]"); + } + } + return errorList; + } + + /** + * 核心:生成【你要求】的正确 pids + * 规则: + * 1. 向上遍历所有祖先 + * 2. 去掉开头 0 + * 3. 去掉最后一位自身ID + * 4. 用逗号拼接 + */ + private String getCorrectPids(String nodeId, Map idMap) { + Deque pathDeque = new LinkedList<>(); + String currentId = nodeId; + // 向上收集所有节点(包含自身 + 所有祖先 + 0) + while (currentId != null && !currentId.isEmpty()) { + Line node = idMap.get(currentId); + if (ObjectUtil.isNotNull(node)) { + // 头插,保证顺序正确 + pathDeque.addFirst(currentId); + currentId = node.getPid(); + } + } + // 转列表 + List path = new ArrayList<>(pathDeque); + + // 1. 去掉开头的 0 + if (!path.isEmpty() && "0".equals(path.get(0))) { + path.remove(0); + } + // 2. 去掉最后一位(自身ID) + if (!path.isEmpty()) { + path.remove(path.size() - 1); + } + // 拼接成最终正确 pids + return String.join(",", path); + } @Override public List getOverLimitByList(PollutionParamDTO pollutionParamDTO) { diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AdvanceEventDetailVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AdvanceEventDetailVO.java index 947620d17..dec953a98 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AdvanceEventDetailVO.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AdvanceEventDetailVO.java @@ -76,7 +76,7 @@ public class AdvanceEventDetailVO { private String sagsource; @ApiModelProperty(value = "开始时间") - @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss.SSS") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS",timezone = "GMT+8") private LocalDateTime startTime; @ApiModelProperty(value = "持续时间,单位秒") diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/PqFrontLogsServiceImpl.java b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/PqFrontLogsServiceImpl.java index f7bcc1b76..f5d67d302 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/PqFrontLogsServiceImpl.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/PqFrontLogsServiceImpl.java @@ -1,29 +1,22 @@ package com.njcn.system.service.impl; -import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.njcn.common.pojo.dto.LogInfoDTO; -import com.njcn.device.pq.pojo.vo.TerminalAlarmVO; import com.njcn.system.mapper.PqFrontLogsMapper; -import com.njcn.system.mapper.UserLogMapper; import com.njcn.system.pojo.dto.PqFrontLogsDTO; import com.njcn.system.pojo.param.PqFrontLogsChildParam; import com.njcn.system.pojo.param.PqFrontLogsParam; -import com.njcn.system.pojo.po.PqDashboardPage; import com.njcn.system.pojo.po.PqFrontLogs; import com.njcn.system.pojo.po.PqFrontLogsChild; -import com.njcn.system.pojo.po.UserLog; import com.njcn.system.pojo.vo.PqFrontLogsVO; -import com.njcn.system.service.IUserLogService; import com.njcn.system.service.PqFrontLogsChildService; import com.njcn.system.service.PqFrontLogsService; import com.njcn.web.factory.PageFactory; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.apache.poi.util.StringUtil; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; @@ -99,19 +92,38 @@ public class PqFrontLogsServiceImpl extends ServiceImpl queryPage(PqFrontLogsParam baseParam) { QueryWrapper queryWrapper = new QueryWrapper<>(); if (StringUtils.isNotBlank(baseParam.getSearchBeginTime()) && StringUtils.isNotBlank(baseParam.getSearchEndTime())) { - queryWrapper.between("A.update_Time", baseParam.getSearchBeginTime()+" 00:00:00", baseParam.getSearchEndTime()+" 23:59:59"); + queryWrapper.between("A.update_Time", baseParam.getSearchBeginTime() + " 00:00:00", baseParam.getSearchEndTime() + " 23:59:59"); + } + String searchValue = baseParam.getSearchValue(); + String level; + if (StrUtil.equals(searchValue, "设备")) { + level = "terminal"; + } else if (StrUtil.equals(searchValue, "监测点")) { + level = "measurepoint"; + } else if (StrUtil.equals(searchValue, "进程")) { + level = "process"; + } else { + level = null; } - if(StringUtils.isNotBlank(baseParam.getSearchValue())){ - queryWrapper.like("line.name", baseParam.getSearchValue()); + if (StringUtils.isNotBlank(baseParam.getSearchValue())) { + queryWrapper.and(x -> { + x.like("line.name", baseParam.getSearchValue()) + .or() + .like(StrUtil.isNotBlank(level),"a.level", level) + .or() + .like("sys.name", baseParam.getSearchValue()); + } + ); } - queryWrapper.eq(StringUtils.isNotBlank(baseParam.getCode()),"A.code",baseParam.getCode()); - queryWrapper.eq(StringUtils.isNotBlank(baseParam.getFrontType()),"A.front_type",baseParam.getFrontType()) ; + + queryWrapper.eq(StringUtils.isNotBlank(baseParam.getCode()), "A.code", baseParam.getCode()); + queryWrapper.eq(StringUtils.isNotBlank(baseParam.getFrontType()), "A.front_type", baseParam.getFrontType()); queryWrapper.orderByDesc("A.update_Time"); - Page page = this.baseMapper.page(new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam)), queryWrapper); - page.getRecords().forEach(temp->{ - if(Objects.equals(temp.getLevel(),"terminal")){ + Page page = this.baseMapper.page(new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam)), queryWrapper); + page.getRecords().forEach(temp -> { + if (Objects.equals(temp.getLevel(), "terminal")) { temp.setLevel("设备"); }else if(Objects.equals(temp.getLevel(),"measurepoint")){ temp.setLevel("监测点");