tjf 2 тижнів тому
батько
коміт
57ecc7191e

+ 7 - 9
ruoyi-admin/src/main/resources/application.yml

@@ -19,8 +19,8 @@ spring:
     # 国际化资源文件路径
     basename: i18n/messages
   profiles:
-#          active: druid
-          active: prod
+          active: druid
+#          active: prod
   # 文件上传
   servlet:
     multipart:
@@ -76,17 +76,15 @@ xss:
 
 # MQTT配置
 mqtt:
-#  server-uri: tcp://13.229.167.76:1883
-  server-uri: tcp://60.171.161.56:20009
+  server-uri: tcp://13.229.167.76:1883
+#  server-uri: tcp://60.171.161.56:20009
 #  server-uri: tcp://127.0.0.1:1883
 #  server-uri: tcp://192.168.101.147:1883
 #  server-uri: tcp://127.0.0.1:1883
   client-id: JavaClientBoMan
-  username: admin
-  password: 1qaz!QAZ
-#  username:
-#  password:
-  default-topic: toServer_leaveStat,toServer_playStat
+  username:
+  password:
+  default-topic: toServer_leaveStat,toServer_playStat,toServer_picPos
   default-qos: 1
   timeout: 30
   keep-alive: 60

+ 6 - 0
ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java

@@ -190,6 +190,12 @@ public class Constants {
     public static final String DETECTION_PLAYRATE = "detection/playrate";
     //rtsp地址
     public static final String DETECTION_RTSP = "detection/rtsp";
+    //离岗告警接收
+    public static final String TO_SERVER_LEAVE_STAT = "toServer_leaveStat";
+    //玩手机告警接收
+    public static final String TO_SERVER_PLAY_STAT = "toServer_playStat";
+    //获取通道画框图片
+    public static final String TO_SERVER_PIC_POS= "toServer_picPos";
     //首页统计折线图往期年份数据
     public static final String WARN_MANAGE_LAST_YEAR = "warn_manage_last_year:";
 }

+ 11 - 0
ruoyi-system/src/main/java/com/ruoyi/manage/domain/ChannelNumber.java

@@ -55,6 +55,8 @@ public class ChannelNumber extends BaseEntity {
      */
     @Excel(name = "视频地址")
     private String videoAddress;
+    @Excel(name = "图片地址摄像头")
+    private String photoAddress;
     /**
      * 账号
      */
@@ -90,6 +92,14 @@ public class ChannelNumber extends BaseEntity {
      */
     private ParameterSet parameterSet;
 
+    public String getPhotoAddress() {
+        return photoAddress;
+    }
+
+    public void setPhotoAddress(String photoAddress) {
+        this.photoAddress = photoAddress;
+    }
+
     public String getEquipmentIp() {
         return equipmentIp;
     }
@@ -221,6 +231,7 @@ public class ChannelNumber extends BaseEntity {
                 ", channelNum='" + channelNum + '\'' +
                 ", port='" + port + '\'' +
                 ", videoAddress='" + videoAddress + '\'' +
+                ", photoAddress='" + photoAddress + '\'' +
                 ", account='" + account + '\'' +
                 ", password='" + password + '\'' +
                 ", protocolType='" + protocolType + '\'' +

+ 241 - 0
ruoyi-system/src/main/java/com/ruoyi/manage/domain/ChannelNumberVo.java

@@ -0,0 +1,241 @@
+package com.ruoyi.manage.domain;
+
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 通道管理对象 channel_number
+ *
+ * @author boman
+ * @date 2025-05-07
+ */
+public class ChannelNumberVo extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 通道ID
+     */
+    private Long channelId;
+    /**
+     * 设备Ip
+     */
+    private String equipmentIp;
+    /**
+     * 设备ID
+     */
+
+    private Long equipmentId;
+    /**
+     * 设备编号
+     */
+    @Excel(name = "设备编号")
+    private String equipmentNum;
+
+    /**
+     * 设备名称
+     */
+    @Excel(name = "设备名称")
+    private String equipmentName;
+    /**
+     * 通道编号
+     */
+    @Excel(name = "通道编号")
+    private String channelNum;
+
+    /**
+     * 预览端口
+     */
+    private String port;
+
+    /**
+     * 视频地址
+     */
+    @Excel(name = "视频地址")
+    private String videoAddress;
+    @Excel(name = "图片地址摄像头")
+    private String photoAddress;
+    /**
+     * 账号
+     */
+    private String account;
+    /**
+     * 密码
+     */
+    private String password;
+
+    /**
+     * 探测协议类型
+     */
+    @Excel(name = "探测协议类型")
+    private String protocolType;
+
+    /**
+     * 通道描述
+     */
+    @Excel(name = "通道描述")
+    private String channelDetails;
+
+    /**
+     * 删除标志(0代表存在 1代表删除)
+     */
+    private String delFlag;
+    /**
+     * 是否设置过参数 N Y 不在数据库中
+     */
+    private String isChannel;
+
+    /**
+     * 参数设置
+     */
+    private ParameterSet parameterSet;
+
+    public String getPhotoAddress() {
+        return photoAddress;
+    }
+
+    public void setPhotoAddress(String photoAddress) {
+        this.photoAddress = photoAddress;
+    }
+
+    public String getEquipmentIp() {
+        return equipmentIp;
+    }
+
+    public void setEquipmentIp(String equipmentIp) {
+        this.equipmentIp = equipmentIp;
+    }
+
+    public ParameterSet getParameterSet() {
+        return parameterSet;
+    }
+
+    public void setParameterSet(ParameterSet parameterSet) {
+        this.parameterSet = parameterSet;
+    }
+
+    public String getPort() {
+        return port;
+    }
+
+    public void setPort(String port) {
+        this.port = port;
+    }
+
+    public String getIsChannel() {
+        return isChannel;
+    }
+
+    public void setIsChannel(String isChannel) {
+        this.isChannel = isChannel;
+    }
+
+    public String getEquipmentNum() {
+        return equipmentNum;
+    }
+
+    public void setEquipmentNum(String equipmentNum) {
+        this.equipmentNum = equipmentNum;
+    }
+
+    public String getEquipmentName() {
+        return equipmentName;
+    }
+
+    public void setEquipmentName(String equipmentName) {
+        this.equipmentName = equipmentName;
+    }
+
+    public Long getEquipmentId() {
+        return equipmentId;
+    }
+
+    public void setEquipmentId(Long equipmentId) {
+        this.equipmentId = equipmentId;
+    }
+
+    public String getAccount() {
+        return account;
+    }
+
+    public void setAccount(String account) {
+        this.account = account;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public void setChannelId(Long channelId) {
+        this.channelId = channelId;
+    }
+
+    public Long getChannelId() {
+        return channelId;
+    }
+
+    public void setChannelNum(String channelNum) {
+        this.channelNum = channelNum;
+    }
+
+    public String getChannelNum() {
+        return channelNum;
+    }
+
+    public void setVideoAddress(String videoAddress) {
+        this.videoAddress = videoAddress;
+    }
+
+    public String getVideoAddress() {
+        return videoAddress;
+    }
+
+    public void setProtocolType(String protocolType) {
+        this.protocolType = protocolType;
+    }
+
+    public String getProtocolType() {
+        return protocolType;
+    }
+
+    public void setChannelDetails(String channelDetails) {
+        this.channelDetails = channelDetails;
+    }
+
+    public String getChannelDetails() {
+        return channelDetails;
+    }
+
+    public void setDelFlag(String delFlag) {
+        this.delFlag = delFlag;
+    }
+
+    public String getDelFlag() {
+        return delFlag;
+    }
+
+    @Override
+    public String toString() {
+        return "ChannelNumber{" +
+                "channelId=" + channelId +
+                ", equipmentIp='" + equipmentIp + '\'' +
+                ", equipmentId=" + equipmentId +
+                ", equipmentNum='" + equipmentNum + '\'' +
+                ", equipmentName='" + equipmentName + '\'' +
+                ", channelNum='" + channelNum + '\'' +
+                ", port='" + port + '\'' +
+                ", videoAddress='" + videoAddress + '\'' +
+                ", photoAddress='" + photoAddress + '\'' +
+                ", account='" + account + '\'' +
+                ", password='" + password + '\'' +
+                ", protocolType='" + protocolType + '\'' +
+                ", channelDetails='" + channelDetails + '\'' +
+                ", delFlag='" + delFlag + '\'' +
+                ", isChannel='" + isChannel + '\'' +
+                ", parameterSet=" + parameterSet +
+                '}';
+    }
+}

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/manage/mapper/ChannelNumberMapper.java

@@ -1,6 +1,8 @@
 package com.ruoyi.manage.mapper;
 
 import com.ruoyi.manage.domain.ChannelNumber;
+import com.ruoyi.manage.domain.ChannelNumberVo;
+
 import java.util.List;
 
 /**
@@ -43,6 +45,7 @@ public interface ChannelNumberMapper
      * @return 结果
      */
     public int updateChannelNumber(ChannelNumber channelNumber);
+    public int updateChannelNumberByChannelId(ChannelNumberVo channelNumber);
 
     /**
      * 删除通道管理

+ 13 - 0
ruoyi-system/src/main/java/com/ruoyi/manage/service/impl/ChannelNumberServiceImpl.java

@@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.manage.domain.ChannelNumber;
+import com.ruoyi.manage.domain.ChannelNumberVo;
 import com.ruoyi.manage.domain.EquipmentManage;
 import com.ruoyi.manage.domain.ParameterSet;
 import com.ruoyi.manage.mapper.ChannelNumberMapper;
@@ -116,6 +117,18 @@ public class ChannelNumberServiceImpl implements IChannelNumberService {
         return AjaxResult.success();
     }
 
+
+    /**
+     * 修改通道管理
+     *
+     * @param channelNumber 通道管理
+     * @return 结果
+     */
+
+    public void updateChannelNumberByChannelId(ChannelNumberVo channelNumber) {
+        channelNumberMapper.updateChannelNumberByChannelId(channelNumber);
+    }
+
     /**
      * 修改通道管理
      *

+ 26 - 4
ruoyi-system/src/main/java/com/ruoyi/mqtt/service/MqttMessageListener.java

@@ -1,12 +1,17 @@
 package com.ruoyi.mqtt.service;
 
 import com.ruoyi.common.model.MqttMessage;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.manage.domain.ChannelNumberVo;
+import com.ruoyi.manage.service.impl.ChannelNumberServiceImpl;
 import com.ruoyi.manage.service.impl.WarnManageServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.event.EventListener;
 import org.springframework.stereotype.Component;
 
+import static com.ruoyi.common.constant.Constants.*;
+
 /**
  * MQTT消息监听器
  *
@@ -23,6 +28,8 @@ public class MqttMessageListener {
 
     @Autowired
     private WarnManageServiceImpl warnManageService;
+    @Autowired
+    private ChannelNumberServiceImpl channelNumberService;
 
 
     /**
@@ -47,13 +54,28 @@ public class MqttMessageListener {
           "videoUrl":"违规视频URL"
          }
          */
-        if(message.getTopic().equals("toServer_leaveStat")){
+        if(message.getTopic().equals(TO_SERVER_LEAVE_STAT)){
             //插入告警信息
-            warnManageService.addWarnManage(message,"0");
+            warnManageService.addWarnManage(message,ZERO);
         }
-        else if(message.getTopic().equals("toServer_playStat")){
+        else if(message.getTopic().equals(TO_SERVER_PLAY_STAT)){
             //插入告警信息
-            warnManageService.addWarnManage(message,"1");
+            warnManageService.addWarnManage(message,ONE);
+        }else if(message.getTopic().equals(TO_SERVER_PIC_POS)){
+            try {
+                //返回值为photoAddress_channelId
+                String payload = message.getPayload();
+                if (StringUtils.isNotEmpty(payload)) {
+                    String[] messageResult = payload.split("_");
+                    //插入通道画框图片
+                    ChannelNumberVo channelNumber = new ChannelNumberVo();
+                    channelNumber.setChannelId(Long.valueOf(messageResult[0]));
+                    channelNumber.setPhotoAddress(messageResult[1]);
+                    channelNumberService.updateChannelNumberByChannelId(channelNumber);
+                }
+            } catch (NumberFormatException e) {
+                log.info("新增通道画框异常:{}", e.getMessage());
+            }
         }
 
         // 例如:解析JSON消息内容,更新数据库,触发其他操作等

+ 12 - 1
ruoyi-system/src/main/resources/mapper/manage/ChannelNumberMapper.xml

@@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="channelNum"    column="channel_num"    />
         <result property="port"    column="port"    />
         <result property="videoAddress"    column="video_address"    />
+        <result property="photoAddress"    column="photo_address"    />
         <result property="account"    column="account"    />
         <result property="password"    column="password"    />
         <result property="protocolType"    column="protocol_type"    />
@@ -25,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectChannelNumberVo">
-        select channel_id, channel_num,equipment_id, equipment_num, equipment_name, video_address,port, account,password,protocol_type, channel_details, del_flag, create_by, create_time, update_by, update_time, remark from channel_number
+        select channel_id, channel_num,equipment_id, equipment_num, equipment_name, video_address,photo_address,port, account,password,protocol_type, channel_details, del_flag, create_by, create_time, update_by, update_time, remark from channel_number
     </sql>
 
     <select id="selectChannelNumberList" parameterType="ChannelNumber" resultMap="ChannelNumberResult">
@@ -61,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="equipmentName != null">equipment_name,</if>
             <if test="channelNum != null">channel_num,</if>
             <if test="videoAddress != null">video_address,</if>
+            <if test="photoAddress != null">photo_address,</if>
             <if test="account != null">account,</if>
             <if test="port != null">port,</if>
             <if test="password != null">password,</if>
@@ -79,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="equipmentName != null">#{equipmentName},</if>
             <if test="channelNum != null">#{channelNum},</if>
             <if test="videoAddress != null">#{videoAddress},</if>
+            <if test="photoAddress != null">#{photoAddress},</if>
             <if test="account != null">#{account},</if>
             <if test="port != null">#{port},</if>
             <if test="password != null">#{password},</if>
@@ -101,6 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="equipmentName != null">equipment_name = #{equipmentName},</if>
             <if test="channelNum != null">channel_num = #{channelNum},</if>
             <if test="videoAddress != null">video_address = #{videoAddress},</if>
+            <if test="photoAddress != null">photo_address = #{photoAddress},</if>
             <if test="account != null">account = #{account},</if>
             <if test="port != null">port = #{port},</if>
             <if test="password != null">password = #{password},</if>
@@ -115,6 +119,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </trim>
         where channel_id = #{channelId}
     </update>
+    <update id="updateChannelNumberByChannelId" parameterType="channelNumberVo">
+        update channel_number
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="photoAddress != null">photo_address = #{photoAddress},</if>
+        </trim>
+        where channel_id = #{channelId}
+    </update>
 
     <delete id="deleteChannelNumberByChannelId" parameterType="Long">
         delete from channel_number where channel_id = #{channelId}