Pu Zhibing
2025-03-21 cab404b1a79927964a546a118cf4c171fa0bbfdf
新增加管理后台接口和对接音视频协议
4个文件已修改
15个文件已添加
824 ■■■■■ 已修改文件
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CarServiceImpl.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DriverServiceImpl.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/controller/DOWNRealvideoMsgStartupController.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/dao/UPAuthorizeMsgStartupDao.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/DOWNPlaybackMsgControl.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/DOWNPlaybackMsgStartup.java 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/DOWNRealvideoMsgEnd.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/DOWNRealvideoMsgStartup.java 92 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/RealVideoMsg.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/UPAuthorizeMsgStartup.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/UPPlaybackMsgControlAck.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/UPPlaybackMsgStartupAck.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/UPRealvideoMsgEndAck.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/UPRealvideoMsgStartupAck.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/enu/DataType.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/netty/server/NettyHandle.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/AuthorizeMsgService.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/DOWNRealvideoMsgStartupService.java 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/RealvideoMsg.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CarServiceImpl.java
@@ -47,6 +47,9 @@
            startTime = car.getCreateTime().toEpochSecond(ZoneOffset.ofHours(8));
        }
        List<UPExgMsgRegisterVo> list = upExgMsgRegisterClient.getUPExgMsgRegisterListIsAfterCreateTime(startTime).getData();
        if (null == list || list.isEmpty()) {
            return;
        }
        List<Enterprise> list1 = enterpriseService.list();
        List<Car> carList = new ArrayList<>();
        for (UPExgMsgRegisterVo vo : list) {
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DriverServiceImpl.java
@@ -45,6 +45,9 @@
            createTime = driver.getUpdateTime().toEpochSecond(ZoneOffset.ofHours(8));
        }
        List<UPExgMsgReportDriverInfoVo> list = upExgMsgReportDriverInfoClient.getUPExgMsgReportDriverInfoListIsAfterCreateTime(createTime).getData();
        if (null == list || list.isEmpty()) {
            return;
        }
        List<Enterprise> list1 = enterpriseService.list();
        List<Driver> driverList = new ArrayList<>();
        for (UPExgMsgReportDriverInfoVo vo : list) {
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/controller/DOWNRealvideoMsgStartupController.java
New file
@@ -0,0 +1,42 @@
package com.ruoyi.dataInterchange.controller;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.dataInterchange.server.DOWNRealvideoMsgStartupService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
 * 实时音视频控制器
 *
 * @author zhibing.pu
 * @Date 2025/3/21 11:11
 */
@RestController
@RequestMapping("/downRealVideoMsgStartupController")
public class DownRealVideoMsgStartupController {
    @Resource
    private DOWNRealvideoMsgStartupService downRealvideoMsgStartupService;
    /**
     * 发起实时音视频请求
     *
     * @param vehicleNo 车牌号
     * @return
     */
    public R<?> startupRealVideo(@RequestParam("inferiorPlatformId") Integer inferiorPlatformId, @RequestParam("vehicleNo") String vehicleNo) {
        R realVideo = downRealvideoMsgStartupService.startupRealVideo(inferiorPlatformId, vehicleNo);
        if (realVideo.getCode() != 200) {
            return realVideo;
        }
        //发送成功,定时任务还是获取响应结果
        int num = 0;
        while (true) {
        }
    }
}
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/dao/UPAuthorizeMsgStartupDao.java
New file
@@ -0,0 +1,22 @@
package com.ruoyi.dataInterchange.dao;
import com.ruoyi.dataInterchange.model.UPAuthorizeMsgStartup;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;
/**
 * @author zhibing.pu
 * @Date 2025/3/21 11:01
 */
@Repository
public interface UPAuthorizeMsgStartupDao extends ElasticsearchRepository<UPAuthorizeMsgStartup, String> {
    /**
     * 根据下级平台唯一编号查询音视频时效口令
     *
     * @param inferiorPlatformId
     * @return
     */
    UPAuthorizeMsgStartup findByInferiorPlatformIdOrderByCreateTimeDesc(Integer inferiorPlatformId);
}
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/DOWNPlaybackMsgControl.java
New file
@@ -0,0 +1,55 @@
package com.ruoyi.dataInterchange.model;
import lombok.Data;
/**
 * 远程录像回放控制请求
 *
 * @author zhibing.pu
 * @Date 2025/3/21 10:30
 */
@Data
public class DOWNPlaybackMsgControl {
    /**
     * 车牌号
     */
    private String vehicleNo;
    /**
     * 车牌颜色
     */
    private Integer vehicleColor;
    /**
     * 子业务类型标识
     */
    private Integer dataType;
    /**
     * 后续数据长度
     */
    private Integer dataLength;
    /**
     * 控制指令
     * 0x00: 正常回放
     * 0x01: 暂停回放
     * 0x02: 结束回放
     * 0x03: 快进回放
     * 0x04: 关键帧快退回放
     * 0x05: 拖动回放
     * 0x06: 关键帧播放
     */
    private Integer controlType;
    /**
     * 快进或快退倍数,回放控制位0x03和0x04时,此字段内容有效,否则置0
     * 0x00: 无效
     * 0x01: 1倍
     * 0x02: 2倍
     * 0x03: 4倍
     * 0x04: 8倍
     * 0x05: 16倍
     */
    private Integer fastTime;
    /**
     * 拖动位置,回放控制为0x05时,此字段内容有效
     */
    private Long dateTime;
}
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/DOWNPlaybackMsgStartup.java
New file
@@ -0,0 +1,70 @@
package com.ruoyi.dataInterchange.model;
import lombok.Data;
/**
 * 远程录像回放请求
 *
 * @author zhibing.pu
 * @Date 2025/3/21 9:57
 */
@Data
public class DOWNPlaybackMsgStartup {
    /**
     * 车牌号
     */
    private String vehicleNo;
    /**
     * 车牌颜色
     */
    private Integer vehicleColor;
    /**
     * 子业务类型标识
     */
    private Integer dataType;
    /**
     * 后续数据长度
     */
    private Integer dataLength;
    /**
     * 逻辑通道号
     */
    private Integer channelId;
    /**
     * 视频类型
     * 0x00: 音视频
     * 0x01: 音频
     * 0x02: 视频
     */
    private Integer avttemType;
    /**
     * 码流类型
     * 0:所有码流
     * 1:主码流
     * 2:子码流
     */
    private Integer streamType;
    /**
     * 存储器类型
     * 0:所有存储器
     * 1:主存储器
     * 2:灾备存储器
     */
    private Integer memType;
    /**
     * 回放起始时间
     */
    private Long playbackStartTime;
    /**
     * 回放结束时间
     */
    private Long playbackEndTime;
    /**
     * 时效口令
     */
    private String authorizeCode;
    /**
     * 车辆进入跨域地区后5min之内的任一位置
     */
    private String gnssData;
}
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/DOWNRealvideoMsgEnd.java
New file
@@ -0,0 +1,40 @@
package com.ruoyi.dataInterchange.model;
import lombok.Data;
/**
 * 主动请求停止实时音视频传输
 *
 * @author zhibing.pu
 * @Date 2025/3/21 9:51
 */
@Data
public class DOWNRealvideoMsgEnd {
    /**
     * 车牌号
     */
    private String vehicleNo;
    /**
     * 车牌颜色
     */
    private Integer vehicleColor;
    /**
     * 子业务类型标识
     */
    private Integer dataType;
    /**
     * 后续数据长度
     */
    private Integer dataLength;
    /**
     * 逻辑通道号
     */
    private Integer channelId;
    /**
     * 视频类型
     * 0x00: 音视频
     * 0x01: 音频
     * 0x02: 视频
     */
    private Integer avttemType;
}
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/DOWNRealvideoMsgStartup.java
New file
@@ -0,0 +1,92 @@
package com.ruoyi.dataInterchange.model;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import lombok.Data;
/**
 * 实时音视频请求
 *
 * @author zhibing.pu
 * @Date 2025/3/21 9:33
 */
@Data
public class DOWNRealvideoMsgStartup {
    /**
     * 车牌号
     */
    private String vehicleNo;
    /**
     * 车牌颜色
     */
    private Integer vehicleColor;
    /**
     * 子业务类型标识
     */
    private Integer dataType;
    /**
     * 后续数据长度
     */
    private Integer dataLength;
    /**
     * 逻辑通道号
     */
    private Integer channelId;
    /**
     * 视频类型
     * 0x00: 音视频
     * 0x01: 音频
     * 0x02: 视频
     */
    private Integer avttemType;
    /**
     * 时效口令
     */
    private String authorizeCode;
    /**
     * 车辆进入跨域地区后5min之内的任一位置
     */
    private String gnssData;
    /**
     * 编码登录回复报文
     */
    public byte[] encode() {
        ByteBuf byteBuf = Unpooled.buffer(130);
        byte[] bytes1 = this.getVehicleNo().getBytes();
        for (int i = 0; i < 21; i++) {
            if (i < bytes1.length) {
                byteBuf.writeByte(bytes1[i]);
            } else {
                byteBuf.writeByte(0x00);
            }
        }
        byteBuf.writeByte(this.getVehicleColor());
        byteBuf.writeShort(this.getDataType());
        byteBuf.writeInt(this.getDataLength());
        byteBuf.writeChar(this.getChannelId());
        byteBuf.writeChar(this.getAvttemType());
        byte[] bytes2 = this.getAuthorizeCode().getBytes();
        for (int i = 0; i < 64; i++) {
            if (i < bytes2.length) {
                byteBuf.writeByte(bytes2[i]);
            } else {
                byteBuf.writeByte(0x00);
            }
        }
        byte[] bytes3 = this.getGnssData().getBytes();
        for (int i = 0; i < 36; i++) {
            if (i < bytes3.length) {
                byteBuf.writeByte(bytes3[i]);
            } else {
                byteBuf.writeByte(0x00);
            }
        }
        byte[] bytes = ByteBufUtil.getBytes(byteBuf);
        byteBuf.release();
        return bytes;
    }
}
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/RealVideoMsg.java
New file
@@ -0,0 +1,31 @@
package com.ruoyi.dataInterchange.model;
import lombok.Data;
/**
 * @author zhibing.pu
 * @Date 2025/3/21 13:59
 */
@Data
public class RealVideoMsg {
    /**
     * 车牌号
     */
    private String vehicleNo;
    /**
     * 车牌颜色
     */
    private int vehicleColor;
    /**
     * 子业务类型标识
     */
    private int dataType;
    /**
     * 后续数据长度
     */
    private int dataLength;
    /**
     * 数据部分
     */
    private byte[] data;
}
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/UPAuthorizeMsgStartup.java
New file
@@ -0,0 +1,52 @@
package com.ruoyi.dataInterchange.model;
import com.ruoyi.dataInterchange.pojo.BaseModel;
import com.ruoyi.dataInterchange.util.jtt809.common.Jtt809Util;
import io.netty.buffer.ByteBuf;
import lombok.Data;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
/**
 * 时效口令上报
 *
 * @author zhibing.pu
 * @Date 2025/3/21 9:27
 */
@Data
@Document(indexName = "up_authorize_msg")
public class UPAuthorizeMsgStartup extends BaseModel {
    /**
     * 子业务类型标识
     */
    @Field(type = FieldType.Integer)
    private int dataType;
    /**
     * 企业视频监控平台唯一编码
     */
    @Field(type = FieldType.Text)
    private String plateformId;
    /**
     * 附属地政府平台使用的时效口令
     */
    @Field(type = FieldType.Text)
    private String authorizeCode1;
    /**
     * 跨域地区政府平台使用的时效口令
     */
    @Field(type = FieldType.Text)
    private String authorizeCode2;
    /**
     * 解析登录报文
     */
    public UPAuthorizeMsgStartup decode(ByteBuf byteBuf) {
        this.dataType = byteBuf.readShort();
        this.plateformId = Jtt809Util.readGBKString(byteBuf, 11);
        this.authorizeCode1 = Jtt809Util.readGBKString(byteBuf, 64);
        this.authorizeCode2 = Jtt809Util.readGBKString(byteBuf, 64);
        return this;
    }
}
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/UPPlaybackMsgControlAck.java
New file
@@ -0,0 +1,37 @@
package com.ruoyi.dataInterchange.model;
import lombok.Data;
/**
 * 远程录像回放控制请求应答
 *
 * @author zhibing.pu
 * @Date 2025/3/21 10:37
 */
@Data
public class UPPlaybackMsgControlAck {
    /**
     * 车牌号
     */
    private String vehicleNo;
    /**
     * 车牌颜色
     */
    private Integer vehicleColor;
    /**
     * 子业务类型标识
     */
    private Integer dataType;
    /**
     * 后续数据长度
     */
    private Integer dataLength;
    /**
     * 应答结果
     * 0x00: 成功
     * 0x01: 失败
     * 0x02: 不支持
     * 0x03: 会话结束
     */
    private Integer result;
}
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/UPPlaybackMsgStartupAck.java
New file
@@ -0,0 +1,47 @@
package com.ruoyi.dataInterchange.model;
import lombok.Data;
/**
 * 远程录像回放请求应答
 *
 * @author zhibing.pu
 * @Date 2025/3/21 10:04
 */
@Data
public class UPPlaybackMsgStartupAck {
    /**
     * 车牌号
     */
    private String vehicleNo;
    /**
     * 车牌颜色
     */
    private Integer vehicleColor;
    /**
     * 子业务类型标识
     */
    private Integer dataType;
    /**
     * 后续数据长度
     */
    private Integer dataLength;
    /**
     * 企业视频服务器IP地址
     */
    private String serverIP;
    /**
     * 企业视频服务端口号
     */
    private Integer serverPort;
    /**
     * 应答结果
     * 0x00: 成功
     * 0x01: 失败
     * 0x02: 不支持
     * 0x03: 会话结束
     * 0x04: 失效口令错误
     * 0x05: 不满足跨域条件
     */
    private Integer result;
}
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/UPRealvideoMsgEndAck.java
New file
@@ -0,0 +1,37 @@
package com.ruoyi.dataInterchange.model;
import lombok.Data;
/**
 * 主动请求停止实时音视频传输应答
 *
 * @author zhibing.pu
 * @Date 2025/3/21 9:54
 */
@Data
public class UPRealvideoMsgEndAck {
    /**
     * 车牌号
     */
    private String vehicleNo;
    /**
     * 车牌颜色
     */
    private Integer vehicleColor;
    /**
     * 子业务类型标识
     */
    private Integer dataType;
    /**
     * 后续数据长度
     */
    private Integer dataLength;
    /**
     * 应答结果
     * 0x00: 成功
     * 0x01: 失败
     * 0x02: 不支持
     * 0x03: 会话结束
     */
    private Integer result;
}
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/UPRealvideoMsgStartupAck.java
New file
@@ -0,0 +1,47 @@
package com.ruoyi.dataInterchange.model;
import lombok.Data;
/**
 * 实时音视频请求应答
 *
 * @author zhibing.pu
 * @Date 2025/3/21 9:45
 */
@Data
public class UPRealvideoMsgStartupAck {
    /**
     * 车牌号
     */
    private String vehicleNo;
    /**
     * 车牌颜色
     */
    private Integer vehicleColor;
    /**
     * 子业务类型标识
     */
    private Integer dataType;
    /**
     * 后续数据长度
     */
    private Integer dataLength;
    /**
     * 应答结果
     * 0x00: 成功
     * 0x01: 失败
     * 0x02: 不支持
     * 0x03: 会话结束
     * 0x04: 失效口令错误
     * 0x05: 不满足跨域条件
     */
    private Integer result;
    /**
     * 企业视频服务器IP地址
     */
    private String serverIP;
    /**
     * 企业视频服务端口号
     */
    private Integer serverPort;
}
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/model/enu/DataType.java
@@ -4,6 +4,7 @@
/**
 * 数据类型标识
 *
 * @author zhibing.pu
 * @Date 2025/2/24 10:39
 */
@@ -95,8 +96,25 @@
    UP_BASE_MSG_VEHICLE_ADDED_ACK(0x1601, "补报车辆静态信息应答消息"),
    DOWN_BASE_MSG(0x9600, "从链路车辆静态信息交换业务"),
    DOWN_BASE_MSG_VEHICLE_ADDED(0x9601, "补报车辆静态信息请求"),
    UP_AUTHORIZE_MSG(0x1700, "主链路视频时效口令交互"),
    UP_AUTHORIZE_MSG_STARTUP(0x1701, "主链路视频时效口令上报"),
    DOWN_AUTHORIZE_MSG(0x9700, "从链路视频时效口令交互"),
    UP_REALVIDEO_MSG(0x1800, "主链路实时音视频交互"),
    UP_REALVIDEO_MSG_STARTUP_ACK(0x1801, "实时音视频请求应答"),
    UP_REALVIDEO_MSG_END_ACK(0x1802, "主动请求停止实时音视频传输应答"),
    DOWN_REALVIDEO_MSG(0x9800, "从链路实时音视频交互"),
    DOWN_REALVIDEO_MSG_STARTUP(0x9801, "实时音视频请求"),
    DOWN_REALVIDEO_MSG_END(0x9802, "主动请求停止实时音视频传输"),
    UP_SEARCH_MSG(0x1900, "主链路远程录像检索交互"),
    DOWN_SEARCH_MSG(0x9900, "从链路远程录像检索交互"),
    UP_PLAYBACK_MSG(0x1A00, "主链路远程录像回放交互"),
    UP_PLAYBACK_MSG_STARTUP_ACK(0x1A01, "远程录像回放请求应答"),
    UP_PLAYBACK_MSG_CONTROL_ACK(0x1A02, "远程录像回放控制请求应答"),
    DOWN_PLAYBACK_MSG(0x9A00, "从链路远程录像回放交互"),
    DOWN_PLAYBACK_MSG_STARTUP(0x9A01, "远程录像回放请求"),
    DOWN_PLAYBACK_MSG_CONTROL(0x9A02, "远程录像回放控制请求"),
    UP_DOWNLOAD_MSG(0x1B00, "主链路远程录像下载交互"),
    DOWN_DOWNLOAD_MSG(0x9B00, "从链路远程录像下载交互"),
    
    
    ;
@@ -111,10 +129,9 @@
    }
    
    
    public static DataType getDataType(int code){
    public static DataType getDataType(int code) {
        for (DataType value : DataType.values()) {
            if(code == value.getCode()){
            if (code == value.getCode()) {
                return value;
            }
        }
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/netty/server/NettyHandle.java
@@ -54,6 +54,12 @@
    @Resource
    private BaseMsgService baseMsgService = SpringUtils.getBean(BaseMsgService.class);
    
    @Resource
    private AuthorizeMsgService authorizeMsgService = SpringUtils.getBean(AuthorizeMsgService.class);
    @Resource
    private RealvideoMsg realvideoMsg = SpringUtils.getBean(RealvideoMsg.class);
    
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object object) throws Exception {
@@ -153,6 +159,14 @@
                log.info("车辆静态信息交换业务({}):{}", DataType.UP_BASE_MSG.getCode(), out);
                baseMsgService.up_base_msg(ctx, out);
                break;
            case UP_AUTHORIZE_MSG:
                log.info("主链路视频时效口令交互({}):{}", DataType.UP_AUTHORIZE_MSG.getCode(), out);
                authorizeMsgService.up_authorize_msg(ctx, out);
                break;
            case UP_REALVIDEO_MSG:
                log.info("主链路实时音视频交互({}):{}", DataType.UP_REALVIDEO_MSG.getCode(), out);
                realvideoMsg.up_realvideo_msg(ctx, out);
                break;
            default:
                break;
        }
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/AuthorizeMsgService.java
New file
@@ -0,0 +1,48 @@
package com.ruoyi.dataInterchange.server;
import com.alibaba.fastjson.JSON;
import com.ruoyi.dataInterchange.dao.UPAuthorizeMsgStartupDao;
import com.ruoyi.dataInterchange.model.UPAuthorizeMsgStartup;
import com.ruoyi.dataInterchange.util.jtt809.packet.common.OuterPacket;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
/**
 * 主链路视频时效口令交互
 *
 * @author zhibing.pu
 * @Date 2025/3/21 10:45
 */
@Slf4j
@Service
public class AuthorizeMsgService {
    @Resource
    private RedisTemplate redisTemplate;
    @Resource
    private UPAuthorizeMsgStartupDao upAuthorizeMsgStartupDao;
    public void up_authorize_msg(ChannelHandlerContext ctx, OuterPacket out) {
        if (!redisTemplate.hasKey("login:" + out.getGnsscenterId())) {
            log.error("链路还未登录校验,拒绝连接");
            ctx.close();
            return;
        }
        byte[] body = out.getBody();
        ByteBuf byteBuf = Unpooled.wrappedBuffer(body);
        UPAuthorizeMsgStartup startup = new UPAuthorizeMsgStartup().decode(byteBuf);
        log.info("主链路视频时效口令上报:" + JSON.toJSONString(startup));
        startup.setInferiorPlatformId(out.getGnsscenterId());
        startup.setCreateTime(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)));
        upAuthorizeMsgStartupDao.save(startup);
    }
}
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/DOWNRealvideoMsgStartupService.java
New file
@@ -0,0 +1,68 @@
package com.ruoyi.dataInterchange.server;
import com.alibaba.fastjson.JSON;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.dataInterchange.dao.UPAuthorizeMsgStartupDao;
import com.ruoyi.dataInterchange.dao.UPExgMsgRegisterDao;
import com.ruoyi.dataInterchange.model.DOWNRealvideoMsgStartup;
import com.ruoyi.dataInterchange.model.UPAuthorizeMsgStartup;
import com.ruoyi.dataInterchange.model.UPExgMsgRegister;
import com.ruoyi.dataInterchange.model.enu.DataType;
import com.ruoyi.dataInterchange.netty.client.ChannelMap;
import com.ruoyi.dataInterchange.util.jtt809.packet.common.OuterPacket;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
 * 实时音视频服务类
 *
 * @author zhibing.pu
 * @Date 2025/3/21 11:16
 */
@Slf4j
@Service
public class DOWNRealvideoMsgStartupService {
    @Resource
    private UPExgMsgRegisterDao upExgMsgRegisterDao;
    @Resource
    private UPAuthorizeMsgStartupDao upAuthorizeMsgStartupDao;
    /**
     * 发起实时音视频请求
     *
     * @param vehicleNo
     */
    public R startupRealVideo(Integer inferiorPlatformId, String vehicleNo) {
        Channel channel = ChannelMap.getClientChannel(inferiorPlatformId);
        if (!channel.isActive()) {
            return R.fail("失败");
        }
        //查询车辆信息
        UPExgMsgRegister exgMsgRegister = upExgMsgRegisterDao.findByVehicleNo(vehicleNo);
        UPAuthorizeMsgStartup authorizeMsgStartup = upAuthorizeMsgStartupDao.findByInferiorPlatformIdOrderByCreateTimeDesc(inferiorPlatformId);
        if (null == authorizeMsgStartup) {
            return R.fail("获取失效口令失败");
        }
        DOWNRealvideoMsgStartup downRealvideoMsgStartup = new DOWNRealvideoMsgStartup();
        downRealvideoMsgStartup.setVehicleNo(exgMsgRegister.getVehicleNo());
        downRealvideoMsgStartup.setVehicleColor(exgMsgRegister.getVehicleColor());
        downRealvideoMsgStartup.setDataType(DataType.DOWN_REALVIDEO_MSG_STARTUP.getCode());
        downRealvideoMsgStartup.setDataLength(102);
        downRealvideoMsgStartup.setChannelId(1);
        downRealvideoMsgStartup.setAvttemType(0X00);
        downRealvideoMsgStartup.setAuthorizeCode(authorizeMsgStartup.getAuthorizeCode1());
        downRealvideoMsgStartup.setGnssData("");
        byte[] body = downRealvideoMsgStartup.encode();
        OuterPacket out = new OuterPacket(DataType.DOWN_REALVIDEO_MSG.getCode(), body);
        channel.writeAndFlush(out);
        log.info("发起实时音视频请求({}):{}", DataType.DOWN_REALVIDEO_MSG_STARTUP.getCode(), JSON.toJSONString(downRealvideoMsgStartup));
        return R.ok();
    }
}
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/RealvideoMsg.java
New file
@@ -0,0 +1,89 @@
package com.ruoyi.dataInterchange.server;
import com.ruoyi.dataInterchange.model.RealVideoMsg;
import com.ruoyi.dataInterchange.model.enu.DataType;
import com.ruoyi.dataInterchange.util.jtt809.common.Jtt809Util;
import com.ruoyi.dataInterchange.util.jtt809.packet.common.OuterPacket;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
 * 主链路实时音视频交互
 *
 * @author zhibing.pu
 * @Date 2025/3/21 11:58
 */
@Slf4j
@Service
public class RealvideoMsg {
    @Resource
    private RedisTemplate redisTemplate;
    public void up_realvideo_msg(ChannelHandlerContext ctx, OuterPacket out) {
        if (!redisTemplate.hasKey("login:" + out.getGnsscenterId())) {
            log.error("链路还未登录校验,拒绝连接");
            ctx.close();
            return;
        }
        RealVideoMsg realVideoMsg = getRealVideoMsg(out);
        DataType dataType = DataType.getDataType(realVideoMsg.getDataType());
        switch (dataType) {
            case UP_REALVIDEO_MSG_STARTUP_ACK:
                log.info("实时音视频请求应答({}):{}", DataType.UP_REALVIDEO_MSG_STARTUP_ACK.getCode(), out);
                up_realvideo_msg_startup_ack(ctx, out.getGnsscenterId(), realVideoMsg);
                break;
            case UP_WARN_MSG_ADPT_INFO:
                log.info("上报报警信息({}):{}", DataType.UP_WARN_MSG_ADPT_INFO.getCode(), out);
                up_warn_msg_adpt_info(ctx, out.getGnsscenterId(), warnMsg);
                break;
            default:
                break;
        }
    }
    public RealVideoMsg getRealVideoMsg(OuterPacket out) {
        byte[] body = out.getBody();
        ByteBuf byteBuf = Unpooled.wrappedBuffer(body);
        //车牌号
        String vehicleNo = Jtt809Util.readGBKString(byteBuf, 21);
        //车牌颜色
        byte vehicleColor = byteBuf.readByte();
        //子业务类型标识
        int dataType = byteBuf.readUnsignedShort();
        //后续数据长度
        int dataLength = byteBuf.readInt();
        //子业务数据包
        byte[] data = new byte[byteBuf.readableBytes()];
        byteBuf.readBytes(data);
        RealVideoMsg realVideoMsg = new RealVideoMsg();
        realVideoMsg.setVehicleNo(vehicleNo);
        realVideoMsg.setVehicleColor(vehicleColor);
        realVideoMsg.setDataType(dataType);
        realVideoMsg.setDataLength(dataLength);
        realVideoMsg.setData(data);
        return realVideoMsg;
    }
    /**
     * 实时音视频请求应答
     *
     * @param ctx
     * @param gnsscenterId
     * @param realVideoMsg
     */
    public void up_realvideo_msg_startup_ack(ChannelHandlerContext ctx, Integer gnsscenterId, RealVideoMsg realVideoMsg) {
    }
}