Sfoglia il codice sorgente

[0920] 通道开启、关闭

taosj 2 mesi fa
parent
commit
e59b5d3169
16 ha cambiato i file con 618 aggiunte e 2 eliminazioni
  1. 42 0
      forecast-backend-server/src/main/java/com/ufo/project/config/controller/ConfigChannelController.java
  2. 89 0
      forecast-backend-server/src/main/java/com/ufo/project/config/controller/ConfigPointController.java
  3. 30 0
      forecast-backend-server/src/main/java/com/ufo/project/config/domain/vo/ChannelDeviceNestVo.java
  4. 2 0
      forecast-backend-server/src/main/java/com/ufo/project/config/mapper/ConfigDeviceMapper.java
  5. 2 0
      forecast-backend-server/src/main/java/com/ufo/project/config/service/IConfigDeviceService.java
  6. 6 0
      forecast-backend-server/src/main/java/com/ufo/project/config/service/impl/ConfigDeviceServiceImpl.java
  7. 31 0
      forecast-backend-server/src/main/java/com/ufo/project/gatewayapp/domain/PointInfo.java
  8. 45 0
      forecast-backend-server/src/main/java/com/ufo/project/gatewayapp/domain/PointInfoQueryRequest.java
  9. 41 0
      forecast-backend-server/src/main/java/com/ufo/project/gatewayapp/util/GatewayAppUtils.java
  10. 11 1
      forecast-backend-server/src/main/resources/mybatis/config/ConfigDeviceMapper.xml
  11. 3 1
      forecast-backend-server/src/main/resources/mybatis/config/ConfigPointMapper.xml
  12. 63 0
      forecast-backend-server/src/main/resources/mybatis/data/DataFileSyncFilesMapper.xml
  13. 4 0
      forecast-backend-vue/src/api/config/channel.js
  14. 4 0
      forecast-backend-vue/src/api/config/point.js
  15. 232 0
      forecast-backend-vue/src/views/ufo/electricity/realtime/PointMonitor.vue
  16. 13 0
      release_note/20260924/20260924_dp.sql

+ 42 - 0
forecast-backend-server/src/main/java/com/ufo/project/config/controller/ConfigChannelController.java

@@ -1,12 +1,15 @@
 package com.ufo.project.config.controller;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
+import org.springframework.beans.BeanUtils;
 import javax.servlet.http.HttpServletResponse;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,9 +24,12 @@ import org.springframework.web.bind.annotation.RestController;
 import com.ufo.base.framework.aspectj.lang.annotation.Log;
 import com.ufo.base.framework.aspectj.lang.enums.BusinessType;
 import com.ufo.project.config.domain.ConfigChannel;
+import com.ufo.project.config.domain.ConfigDevice;
 import com.ufo.project.config.domain.ConfigProtocol;
 import com.ufo.project.config.domain.ConfigTransmit;
+import com.ufo.project.config.domain.vo.ChannelDeviceNestVo;
 import com.ufo.project.config.service.IConfigChannelService;
+import com.ufo.project.config.service.IConfigDeviceService;
 import com.ufo.project.config.service.IConfigProtocolService;
 import com.ufo.project.config.service.IConfigTransmitService;
 import com.ufo.base.framework.web.controller.BaseController;
@@ -44,6 +50,9 @@ public class ConfigChannelController extends BaseController
     @Autowired
     private IConfigChannelService configChannelService;
 
+    @Autowired
+    private IConfigDeviceService configDeviceService;
+
     @Autowired
     private IConfigProtocolService configProtocolService;
 
@@ -60,6 +69,39 @@ public class ConfigChannelController extends BaseController
         return getDataTable(list);
     }
 
+    /**
+     * 通道-设备级联菜单(测点监控), 返回未禁用通道及其下属设备
+     */
+    @PreAuthorize("@ss.hasPermi('config:stationChannel:list')")
+    @GetMapping("/cascadeMonitor")
+    public AjaxResult cascadeMonitor()
+    {
+        ConfigChannel query = new ConfigChannel();
+        query.setDisabled("0");
+        List<ConfigChannel> channelList = configChannelService.selectConfigChannelList(query);
+        channelList.sort(Comparator.comparing(ConfigChannel::getId));
+        List<ChannelDeviceNestVo> nestList = new ArrayList<>();
+        if (channelList.isEmpty())
+        {
+            return success(nestList);
+        }
+        Long[] configChannelIds = channelList.stream().map(ConfigChannel::getId).toArray(Long[]::new);
+        List<ConfigDevice> deviceList = configDeviceService.selectConfigDeviceByChannelIds(configChannelIds);
+        Map<Long, List<ConfigDevice>> groupDeviceMap = deviceList.stream()
+                .collect(Collectors.groupingBy(ConfigDevice::getConfigChannelId));
+        for (ConfigChannel channel : channelList)
+        {
+            ChannelDeviceNestVo vo = new ChannelDeviceNestVo();
+            BeanUtils.copyProperties(channel, vo);
+            List<ConfigDevice> groupDeviceList = new ArrayList<>(
+                    groupDeviceMap.getOrDefault(channel.getId(), Collections.emptyList()));
+            groupDeviceList.sort(Comparator.comparing(ConfigDevice::getId));
+            vo.setDeviceList(groupDeviceList);
+            nestList.add(vo);
+        }
+        return success(nestList);
+    }
+
     @PreAuthorize("@ss.hasPermi('config:stationChannel:export')")
     @Log(title = "通道配置", businessType = BusinessType.EXPORT)
     @PostMapping("/export")

+ 89 - 0
forecast-backend-server/src/main/java/com/ufo/project/config/controller/ConfigPointController.java

@@ -4,6 +4,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,10 +18,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import com.ufo.base.framework.aspectj.lang.annotation.Log;
 import com.ufo.base.framework.aspectj.lang.enums.BusinessType;
+import com.ufo.base.common.utils.StringUtils;
 import com.ufo.project.config.domain.ConfigDevice;
 import com.ufo.project.config.domain.ConfigPoint;
 import com.ufo.project.config.service.IConfigDeviceService;
 import com.ufo.project.config.service.IConfigPointService;
+import com.ufo.project.gatewayapp.domain.PointInfo;
+import com.ufo.project.gatewayapp.domain.PointInfoQueryRequest;
+import com.ufo.project.gatewayapp.util.GatewayAppUtils;
 import com.ufo.base.framework.web.controller.BaseController;
 import com.ufo.base.framework.web.domain.AjaxResult;
 import com.ufo.base.common.utils.poi.ExcelUtil;
@@ -73,6 +78,90 @@ public class ConfigPointController extends BaseController
         return getDataTable(list);
     }
 
+    /**
+     * 测点监控分页查询, 静态配置来自config_point, 实时状态来自网关服务
+     */
+    @PreAuthorize("@ss.hasPermi('config:stationPoint:list')")
+    @GetMapping("/monitList")
+    public TableDataInfo monitList(ConfigPoint configPoint)
+    {
+        startPage();
+        List<ConfigPoint> list = configPointService.selectConfigPointList(configPoint);
+        TableDataInfo dataTable = getDataTable(list);
+        if (list.isEmpty())
+        {
+            List<PointInfo> pointInfos = new ArrayList<>();
+            dataTable.setRows(pointInfos);
+            return dataTable;
+        }
+        // 收集设备id, 批量查询设备用于获取测点所属通道id
+        List<Long> deviceIds = new ArrayList<>();
+        for (ConfigPoint point : list)
+        {
+            if (point.getConfigDeviceId() != null && !deviceIds.contains(point.getConfigDeviceId()))
+            {
+                deviceIds.add(point.getConfigDeviceId());
+            }
+        }
+        Map<Long, ConfigDevice> deviceMap = new HashMap<>();
+        if (!deviceIds.isEmpty())
+        {
+            List<ConfigDevice> deviceList = configDeviceService.selectConfigDeviceByIds(deviceIds.toArray(new Long[deviceIds.size()]));
+            for (ConfigDevice device : deviceList)
+            {
+                deviceMap.put(device.getId(), device);
+            }
+        }
+        // 按测点封装参数, 调用网关服务查询实时状态
+        List<PointInfoQueryRequest> requestList = new ArrayList<>();
+        for (ConfigPoint point : list)
+        {
+            PointInfoQueryRequest request = new PointInfoQueryRequest();
+            ConfigDevice device = deviceMap.get(point.getConfigDeviceId());
+            if (device != null && device.getConfigChannelId() != null)
+            {
+                request.setChannelId(device.getConfigChannelId());
+            }
+            if (point.getConfigDeviceId() != null)
+            {
+                request.setDeviceId(point.getConfigDeviceId());
+            }
+            request.setPointType(point.getCategory());
+            request.setPointCode(point.getCode());
+            requestList.add(request);
+        }
+        List<PointInfo> gatewayList = GatewayAppUtils.queryPoinInfos(requestList);
+        Map<String, PointInfo> gatewayMap = gatewayList.stream()
+                .filter(info -> StringUtils.isNotEmpty(StringUtils.isNotEmpty(info.getPointCode()) ? info.getPointCode() : info.getCode()))
+                .collect(Collectors.toMap(
+                        info -> StringUtils.isNotEmpty(info.getPointCode()) ? info.getPointCode() : info.getCode(),
+                        info -> info, (v1, v2) -> v1));
+
+        // 以config_point为主, 按pointCode关联网关数据, 封装返回
+        List<PointInfo> pointInfos = list.stream().map(point -> {
+            PointInfo info = new PointInfo().setCode(point.getCode()).setName(point.getName()).setAddr(point.getAddr() == null ? null : point.getAddr().intValue())
+                .setPointCode(point.getCode()).setPointType(point.getCategory());
+            ConfigDevice device = deviceMap.get(point.getConfigDeviceId());
+            if (device != null && device.getConfigChannelId() != null)
+            {
+                info.setChannelId(device.getConfigChannelId());
+            }
+            if (point.getConfigDeviceId() != null)
+            {
+                info.setDeviceId(point.getConfigDeviceId());
+            }
+            PointInfo gateway = gatewayMap.get(point.getCode());
+            if (gateway != null)
+            {
+                info.setPointAttr(gateway.getPointAttr()).setValueAttr(gateway.getValueAttr()).setTmReport(gateway.getTmReport())
+                .setTmChange(gateway.getTmChange()).setIValue(gateway.getIValue()).setDValue(gateway.getDValue()).setStrValue(gateway.getStrValue());
+            }
+            return info;
+        }).collect(Collectors.toList());
+        dataTable.setRows(pointInfos);
+        return dataTable;
+    }
+
     @PreAuthorize("@ss.hasPermi('config:stationPoint:export')")
     @Log(title = "测点", businessType = BusinessType.EXPORT)
     @PostMapping("/export")

+ 30 - 0
forecast-backend-server/src/main/java/com/ufo/project/config/domain/vo/ChannelDeviceNestVo.java

@@ -0,0 +1,30 @@
+package com.ufo.project.config.domain.vo;
+
+import java.util.List;
+
+import com.ufo.project.config.domain.ConfigChannel;
+import com.ufo.project.config.domain.ConfigDevice;
+
+/**
+ * 通道-设备嵌套返回体(测点监控级联菜单)
+ *
+ * @author ufo
+ * @date 2026-09-18
+ */
+public class ChannelDeviceNestVo extends ConfigChannel
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 通道下的设备列表 */
+    private List<ConfigDevice> deviceList;
+
+    public List<ConfigDevice> getDeviceList()
+    {
+        return deviceList;
+    }
+
+    public void setDeviceList(List<ConfigDevice> deviceList)
+    {
+        this.deviceList = deviceList;
+    }
+}

+ 2 - 0
forecast-backend-server/src/main/java/com/ufo/project/config/mapper/ConfigDeviceMapper.java

@@ -17,6 +17,8 @@ public interface ConfigDeviceMapper
 
     public List<ConfigDevice> selectConfigDeviceByIds(Long[] ids);
 
+    public List<ConfigDevice> selectConfigDeviceByChannelIds(Long[] channelIds);
+
     public int insertConfigDevice(ConfigDevice configDevice);
 
     public int updateConfigDevice(ConfigDevice configDevice);

+ 2 - 0
forecast-backend-server/src/main/java/com/ufo/project/config/service/IConfigDeviceService.java

@@ -17,6 +17,8 @@ public interface IConfigDeviceService
 
     public List<ConfigDevice> selectConfigDeviceByIds(Long[] ids);
 
+    public List<ConfigDevice> selectConfigDeviceByChannelIds(Long[] channelIds);
+
     public int insertConfigDevice(ConfigDevice configDevice);
 
     public int updateConfigDevice(ConfigDevice configDevice);

+ 6 - 0
forecast-backend-server/src/main/java/com/ufo/project/config/service/impl/ConfigDeviceServiceImpl.java

@@ -37,6 +37,12 @@ public class ConfigDeviceServiceImpl implements IConfigDeviceService
         return configDeviceMapper.selectConfigDeviceByIds(ids);
     }
 
+    @Override
+    public List<ConfigDevice> selectConfigDeviceByChannelIds(Long[] channelIds)
+    {
+        return configDeviceMapper.selectConfigDeviceByChannelIds(channelIds);
+    }
+
     @Override
     public int insertConfigDevice(ConfigDevice configDevice)
     {

+ 31 - 0
forecast-backend-server/src/main/java/com/ufo/project/gatewayapp/domain/PointInfo.java

@@ -0,0 +1,31 @@
+package com.ufo.project.gatewayapp.domain;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+public class PointInfo {
+    private String code;
+    private String name;
+    private Integer addr;
+    
+    private long channelId = -1;
+    private long deviceId = -1;
+    private String pointCode;
+    private String pointType;
+    //测点的属性     NORMAL("NORMAL"), LOCK("LOCK"),  INVALID("INVALID");
+    private String pointAttr = "NORMAL";
+    // 测点值的属性     NORMAL("NORMAL"),INVALID("INVALID"),LAZY("LAZY"), U1("U1"), U2("U2"), D1("D1"), D2("D2");
+    private String valueAttr = "NORMAL";
+    // 数据上来时间
+    private long tmReport = 0;
+    // 数据值发生改变的时间
+    private long tmChange = 0;
+    // 遥信数据值
+    private Integer iValue;
+    // 遥测数据值
+    private Double dValue;
+    //待用
+    private String strValue;
+}

+ 45 - 0
forecast-backend-server/src/main/java/com/ufo/project/gatewayapp/domain/PointInfoQueryRequest.java

@@ -0,0 +1,45 @@
+package com.ufo.project.gatewayapp.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+public class PointInfoQueryRequest {
+    private long channelId = -1;
+    private long deviceId = -1;
+    private String pointCode;
+    private String pointType;
+	public long getChannelId() {
+		return channelId;
+	}
+	public void setChannelId(long channelId) {
+		this.channelId = channelId;
+	}
+	public long getDeviceId() {
+		return deviceId;
+	}
+	public void setDeviceId(long deviceId) {
+		this.deviceId = deviceId;
+	}
+	public String getPointCode() {
+		return pointCode;
+	}
+	public void setPointCode(String pointCode) {
+		this.pointCode = pointCode;
+	}
+	public String getPointType() {
+		return pointType;
+	}
+	public void setPointType(String pointType) {
+		this.pointType = pointType;
+	}
+
+        @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("channelId", getChannelId())
+            .append("pointType", getPointType())
+            .append("deviceId", getDeviceId())
+            .append("pointCode", getPointCode())
+            .toString();
+    }
+}

+ 41 - 0
forecast-backend-server/src/main/java/com/ufo/project/gatewayapp/util/GatewayAppUtils.java

@@ -20,6 +20,8 @@ import com.ufo.base.common.utils.spring.SpringUtils;
 import com.ufo.module.system.domain.SysDictData;
 import com.ufo.module.system.service.ISysDictTypeService;
 import com.ufo.project.gatewayapp.domain.ChannelStatus;
+import com.ufo.project.gatewayapp.domain.PointInfo;
+import com.ufo.project.gatewayapp.domain.PointInfoQueryRequest;
 
 import cn.hutool.http.Header;
 import cn.hutool.http.HttpRequest;
@@ -75,6 +77,45 @@ public final class GatewayAppUtils
     {
     }
 
+    /**
+     * 批量查询通道运行状态
+     *
+     * @param list 参数列表
+     * @return 测点信息列表
+     */
+    public static List<PointInfo> queryPoinInfos(List<PointInfoQueryRequest> list)
+    {
+        List<PointInfo> dataList = new ArrayList<>();
+        if (list == null || list.isEmpty())
+        {
+            return dataList;
+        }
+        try
+        {
+            GatewayAppConfig config = loadConfig();
+            List<Map<String, Object>> body = new ArrayList<>();
+            for (PointInfoQueryRequest request : list)
+            {
+                Map<String, Object> item = new LinkedHashMap<>();
+                item.put("channelId", request.getChannelId());
+                item.put("deviceId", request.getDeviceId());
+                item.put("pointType", request.getPointType());
+                item.put("pointCode", request.getPointCode());
+                body.add(item);
+            }
+            log.info("[GatewayAppUtils] queryPoinInfos, baseUrl={}, pointStateUrl={}, body={}",
+                    config.getBaseUrl(), config.getPointStateUrl(), JSON.toJSONString(body));
+            String responseText = sendRequest(config.getBaseUrl(), config.getPointStateUrl(), JSON.toJSONString(body));
+            log.info("[GatewayAppUtils] queryPoinInfos, responseText={}", responseText);
+            dataList.addAll(JSON.parseArray(responseText, PointInfo.class));
+        }
+        catch (Exception e)
+        {
+            log.error("[GatewayAppUtils] queryPoinInfos error {}", e);
+        }
+        return dataList;
+    }
+
     /**
      * 批量查询通道运行状态
      *

+ 11 - 1
forecast-backend-server/src/main/resources/mybatis/config/ConfigDeviceMapper.xml

@@ -35,12 +35,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectConfigDeviceByIds" parameterType="Long" resultMap="ConfigDeviceResult">
-        select id, name from config_device where id in
+        <include refid="selectConfigDeviceVo"/>
+        where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </select>
 
+    <select id="selectConfigDeviceByChannelIds" parameterType="Long" resultMap="ConfigDeviceResult">
+        <include refid="selectConfigDeviceVo"/>
+        where config_channel_id in
+        <foreach item="channelId" collection="array" open="(" separator="," close=")">
+            #{channelId}
+        </foreach>
+        order by id asc
+    </select>
+
     <insert id="insertConfigDevice" parameterType="ConfigDevice" useGeneratedKeys="true" keyProperty="id">
         insert into config_device
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 3 - 1
forecast-backend-server/src/main/resources/mybatis/config/ConfigPointMapper.xml

@@ -38,7 +38,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectConfigPointList" parameterType="ConfigPoint" resultMap="ConfigPointResult">
         <include refid="selectConfigPointVo"/>
         <where>
-            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
+            <if test="name != null  and name != ''"> 
+             and name like '%' || #{name}::varchar || '%'
+            </if>
             <if test="code != null  and code != ''"> and code = #{code}</if>
             <if test="addr != null"> and addr = #{addr}</if>
             <if test="category != null  and category != ''"> and category = #{category}</if>

+ 63 - 0
forecast-backend-server/src/main/resources/mybatis/data/DataFileSyncFilesMapper.xml

@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ufo.project.data.mapper.DataFileSyncFilesMapper">
+
+    <resultMap type="DataFileSyncFiles" id="DataFileSyncFilesResult">
+        <result property="id"    column="id"    />
+        <result property="type"    column="type"    />
+        <result property="file"    column="file"    />
+        <result property="status"    column="status"    />
+        <result property="handler"    column="handler"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="failReason"    column="fail_reason"    />
+        <result property="processTimes"    column="process_times"    />
+        <result property="priority"    column="priority"    />
+    </resultMap>
+
+    <sql id="selectDataFileSyncFilesVo">
+        select id, type, file, status, handler, create_time, update_time, fail_reason, process_times, priority from data_file_sync_files
+    </sql>
+
+    <select id="selectDataFileSyncFilesList" parameterType="DataFileSyncFiles" resultMap="DataFileSyncFilesResult">
+        <include refid="selectDataFileSyncFilesVo"/>
+        <where>
+            <if test="type != null  and type != ''"> and type = #{type}</if>
+            <if test="file != null  and file != ''"> and file like concat('%', #{file}, '%')</if>
+            <if test="status != null "> and status = #{status}</if>
+            <if test="handler != null  and handler != ''"> and handler = #{handler}</if>
+            <if test="priority != null "> and priority = #{priority}</if>
+        </where>
+    </select>
+
+    <select id="selectDataFileSyncFilesById" parameterType="Long" resultMap="DataFileSyncFilesResult">
+        <include refid="selectDataFileSyncFilesVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertDataFileSyncFilesIfAbsent" parameterType="DataFileSyncFiles">
+        insert into data_file_sync_files
+            (type, file, status, handler, create_time, update_time, process_times, priority)
+        select
+            #{type}, #{file}, #{status}, #{handler}, now(), now(), #{processTimes}, #{priority}
+        where not exists (select 1 from data_file_sync_files t where t.file = #{file})
+    </insert>
+
+    <update id="updateDataFileSyncFiles" parameterType="DataFileSyncFiles">
+        update data_file_sync_files
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="type != null">type = #{type},</if>
+            <if test="file != null">file = #{file},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="handler != null">handler = #{handler},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="failReason != null">fail_reason = #{failReason},</if>
+            <if test="processTimes != null">process_times = #{processTimes},</if>
+            <if test="priority != null">priority = #{priority},</if>
+        </trim>
+        where id = #{id}
+    </update>
+</mapper>

+ 4 - 0
forecast-backend-vue/src/api/config/channel.js

@@ -27,3 +27,7 @@ export function queryChannelState(data) {
 export function controllerChannel(params) {
   return request({ url: '/gatewayapp/channel/controllerChannel', method: 'get', params })
 }
+
+export function cascadeMonitorChannel() {
+  return request({ url: '/config/channel/cascadeMonitor', method: 'get' })
+}

+ 4 - 0
forecast-backend-vue/src/api/config/point.js

@@ -4,6 +4,10 @@ export function listPoint(query) {
   return request({ url: '/config/point/list', method: 'get', params: query })
 }
 
+export function pointMonitor(query) {
+  return request({ url: '/config/point/monitList', method: 'get', params: query })
+}
+
 export function getPoint(id) {
   return request({ url: '/config/point/' + id, method: 'get' })
 }

+ 232 - 0
forecast-backend-vue/src/views/ufo/electricity/realtime/PointMonitor.vue

@@ -0,0 +1,232 @@
+<template>
+  <div class="point-monitor-page">
+    <div class="monitor-layout">
+      <a-card :bordered="false" class="menu-panel" :body-style="{ padding: '8px 0' }">
+        <a-menu :open-keys="openKeys" v-model:selectedKeys="selectedKeys" mode="inline" @title-click="handleChannelClick" @click="handleDeviceClick">
+          <a-sub-menu v-for="channel in channels" :key="'c-' + channel.id">
+            <template #title>{{ channel.name }}</template>
+            <a-menu-item v-for="device in channel.deviceList || []" :key="'d-' + device.id">{{ device.name }}</a-menu-item>
+          </a-sub-menu>
+        </a-menu>
+      </a-card>
+
+      <div class="content-panel">
+        <a-card :bordered="false">
+          <a-form :model="queryParams" layout="inline">
+            <a-form-item label="名称">
+              <a-input v-model:value="queryParams.name" allow-clear placeholder="请输入名称" />
+            </a-form-item>
+            <a-form-item label="编码">
+              <a-input v-model:value="queryParams.code" allow-clear placeholder="请输入编码" />
+            </a-form-item>
+            <a-form-item label="地址">
+              <a-input-number v-model:value="queryParams.addr" :precision="0" :controls="false" placeholder="请输入地址" class="query-number" />
+            </a-form-item>
+            <a-form-item label="分类">
+              <a-select v-model:value="queryParams.category" class="query-select" :options="categoryOptions" @change="handleCategoryChange" />
+            </a-form-item>
+            <a-form-item>
+              <a-space>
+                <a-button type="primary" :loading="loading" @click="handleQuery"><BearJiaIcon icon="SearchOutlined"/>查询</a-button>
+                <a-button @click="resetQuery"><BearJiaIcon icon="ReloadOutlined"/>重置</a-button>
+              </a-space>
+            </a-form-item>
+          </a-form>
+        </a-card>
+
+        <a-card :bordered="false" class="section">
+          <a-table
+            :columns="columns"
+            :data-source="rows"
+            :loading="loading"
+            :pagination="pagination"
+            row-key="code"
+            size="middle"
+            :scroll="tableScroll"
+            @change="handleTableChange"
+          >
+            <template #bodyCell="{ column, record }">
+              <template v-if="column.key === 'tmReport'">{{ formatTime(record.tmReport) }}</template>
+              <template v-else-if="column.key === 'tmChange'">{{ formatTime(record.tmChange) }}</template>
+            </template>
+          </a-table>
+        </a-card>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script setup name="PointMonitor">
+import { computed, reactive, ref } from 'vue';
+import dayjs from 'dayjs';
+import { cascadeMonitorChannel } from '@/api/config/channel';
+import { pointMonitor } from '@/api/config/point';
+import { BearJiaIcon } from '@/utils/BearJiaIcon.js';
+
+const CATEGORY_FIRST = 'YX';
+const categoryOptions = [
+  { label: '遥信', value: 'YX' },
+  { label: '遥测', value: 'YC' },
+  { label: '遥脉', value: 'YM' },
+  { label: '遥控', value: 'YK' },
+  { label: '遥调', value: 'YT' }
+];
+
+const loading = ref(false);
+const rows = ref([]);
+const channels = ref([]);
+const openKeys = ref([]);
+const selectedKeys = ref([]);
+const currentDeviceId = ref(undefined);
+
+const queryParams = reactive({
+  pageNum: 1,
+  pageSize: 10,
+  category: CATEGORY_FIRST,
+  name: undefined,
+  code: undefined,
+  addr: undefined
+});
+const pagination = reactive({ current: 1, pageSize: 10, total: 0, showSizeChanger: true });
+
+const columns = [
+  { title: '名称', dataIndex: 'name', width: 180, ellipsis: true },
+  { title: '编码', dataIndex: 'code', width: 140, ellipsis: true },
+  { title: '地址', dataIndex: 'addr', width: 100 },
+  { title: '测点属性', dataIndex: 'pointAttr', width: 110 },
+  { title: '值', dataIndex: 'dValue', width: 120 },
+  { title: '值属性', dataIndex: 'valueAttr', width: 110 },
+  { title: '上报时间', dataIndex: 'tmReport', key: 'tmReport', width: 170 },
+  { title: '变化时间', dataIndex: 'tmChange', key: 'tmChange', width: 170 }
+];
+const tableScroll = computed(() => ({ x: columns.reduce((sum, col) => sum + (col.width || 140), 0) + 40 }));
+
+// 计算2: 时间计算, timestamp 转 date(yyyy-MM-dd HH:mm:ss)
+const formatTime = (timestamp) => (timestamp && Number(timestamp) > 0 ? dayjs(Number(timestamp)).format('YYYY-MM-DD HH:mm:ss') : '');
+
+const getList = async () => {
+  if (currentDeviceId.value === undefined) {
+    rows.value = [];
+    pagination.total = 0;
+    return;
+  }
+  loading.value = true;
+  try {
+    const res = await pointMonitor({ ...queryParams, configDeviceId: currentDeviceId.value });
+    rows.value = res?.rows || [];
+    pagination.total = res?.total || 0;
+    pagination.current = queryParams.pageNum;
+    pagination.pageSize = queryParams.pageSize;
+  } finally {
+    loading.value = false;
+  }
+};
+
+// 重置右侧筛选条件: 分类回到第一个option, 清空名称/编码/地址
+const resetFilter = () => {
+  queryParams.category = CATEGORY_FIRST;
+  queryParams.name = undefined;
+  queryParams.code = undefined;
+  queryParams.addr = undefined;
+  queryParams.pageNum = 1;
+};
+
+// 选中设备并刷新数据
+const selectDevice = (device) => {
+  currentDeviceId.value = device?.id;
+  selectedKeys.value = device ? ['d-' + device.id] : [];
+  resetFilter();
+  getList();
+};
+
+// 事件1: 点击1级菜单 — 展开选中的通道、收起其他、选中第一个二级菜单、重置筛选并刷新
+const handleChannelClick = ({ key }) => {
+  openKeys.value = [key];
+  const channel = channels.value.find((item) => 'c-' + item.id === key);
+  selectDevice(channel?.deviceList?.[0]);
+};
+
+// 事件2: 点击2级菜单 — 切换设备、分类回到第一个option、清空条件、重新加载
+const handleDeviceClick = ({ key }) => {
+  if (!key.startsWith('d-')) return;
+  const deviceId = Number(key.slice(2));
+  const device = channels.value.flatMap((channel) => channel.deviceList || []).find((item) => item.id === deviceId);
+  currentDeviceId.value = deviceId;
+  resetFilter();
+  getList();
+};
+
+// 事件4: 切换分类 — 条件分类置为当前选中值、清空名称/编码/地址、重新加载
+const handleCategoryChange = () => {
+  queryParams.name = undefined;
+  queryParams.code = undefined;
+  queryParams.addr = undefined;
+  queryParams.pageNum = 1;
+  getList();
+};
+
+// 事件5: 查询数据
+const handleQuery = () => {
+  queryParams.pageNum = 1;
+  getList();
+};
+
+// 事件6: 重制搜索条件 — 清空名称/编码/地址
+const resetQuery = () => {
+  queryParams.name = undefined;
+  queryParams.code = undefined;
+  queryParams.addr = undefined;
+};
+
+// 事件3: 分页查询
+const handleTableChange = (page) => {
+  queryParams.pageNum = page.current;
+  queryParams.pageSize = page.pageSize;
+  getList();
+};
+
+const loadCascades = async () => {
+  const res = await cascadeMonitorChannel();
+  channels.value = res?.data || [];
+  // 默认选中第一个一级菜单的第一个二级菜单
+  const firstChannel = channels.value[0];
+  if (firstChannel) {
+    openKeys.value = ['c-' + firstChannel.id];
+    selectDevice(firstChannel.deviceList?.[0]);
+  } else {
+    getList();
+  }
+};
+
+loadCascades();
+</script>
+
+<style lang="less" scoped>
+.point-monitor-page {
+  .monitor-layout {
+    display: flex;
+    align-items: flex-start;
+  }
+  .menu-panel {
+    flex: 0 0 200px;
+    width: 200px;
+    margin-right: 12px;
+    :deep(.ant-menu) {
+      border-inline-end: none;
+    }
+  }
+  .content-panel {
+    flex: 1;
+    min-width: 0;
+  }
+  .section {
+    margin-top: 12px;
+  }
+  .query-select {
+    width: 140px;
+  }
+  .query-number {
+    width: 120px;
+  }
+}
+</style>

+ 13 - 0
release_note/20260924/20260924_dp.sql

@@ -23,3 +23,16 @@ SELECT
 nextval(pg_get_serial_sequence('sys_dict_data', 'dict_code')),
 1, '网关服务配置项', '{"baseUrl":"http://xxx","pointStateUrl":"/biz/point-state/real","channelStateExpressions":"#iValue != null and #iValue == 1","channelOperationUrl":"/biz/channel/control"}', 'gateway_app_config', '', '', 'Y', '0', 'admin', now(), 'JSON: baseUrl/pointStateUrl/channelStateExpressions/channelOperationUrl'
 WHERE NOT EXISTS (SELECT 1 FROM sys_dict_data t WHERE t.dict_type = 'gateway_app_config');
+
+
+-- 测点监测
+INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
+SELECT nextval(pg_get_serial_sequence('sys_menu', 'menu_id')),
+'测点监测', 
+(select menu_id from sys_menu t where t.menu_name = '实时监控')
+, 3, 'point-monitor', 'ufo/electricity/realtime/PointMonitor', '', 'PointMonitor', 1, 0, 'C', '0', '0', 'data:oointMonitor', 'MonitorOutlined', 'admin', now(), '', NULL, '测点监测页面'
+WHERE NOT EXISTS (SELECT 1 FROM sys_menu t WHERE t.menu_name = '测点监测');
+
+INSERT INTO sys_role_menu (role_id, menu_id)
+SELECT 1, (SELECT menu_id FROM sys_menu t WHERE t.menu_name = '测点监测')
+WHERE NOT EXISTS (SELECT 1 FROM sys_role_menu t WHERE t.role_id = 1 AND t.menu_id = (SELECT menu_id FROM sys_menu t WHERE t.menu_name = '测点监测'));