Pu Zhibing
2025-04-25 f8a708d9d960db750c9dd029efbe4a9f63d53fe8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.ruoyi.dataInterchange.server;
 
import com.alibaba.fastjson.JSON;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.dataInterchange.dao.UPExgMsgRegisterDao;
import com.ruoyi.dataInterchange.model.DOWNPlaybackMsgControl;
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/24 11:51
 */
@Slf4j
@Service
public class DOWNPlaybackMsgControlService {
    
    @Resource
    private UPExgMsgRegisterDao upExgMsgRegisterDao;
    
    
    /**
     * 远程录像回放控制
     *
     * @param inferiorPlatformId
     * @param vehicleNo
     * @param controlType
     * @param fastTime
     * @return
     */
    public R playbackMsgControl(Integer inferiorPlatformId, String vehicleNo, Integer controlType, Integer fastTime) {
        Channel channel = ChannelMap.getClientChannel(inferiorPlatformId);
        if (!channel.isActive()) {
            return R.fail("失败");
        }
        //查询车辆信息
        UPExgMsgRegister exgMsgRegister = upExgMsgRegisterDao.findByVehicleNo(vehicleNo);
        DOWNPlaybackMsgControl downPlaybackMsgControl = new DOWNPlaybackMsgControl();
        downPlaybackMsgControl.setVehicleNo(exgMsgRegister.getVehicleNo());
        downPlaybackMsgControl.setVehicleColor(exgMsgRegister.getVehicleColor());
        downPlaybackMsgControl.setDataType(DataType.DOWN_PLAYBACK_MSG_CONTROL.getCode());
        downPlaybackMsgControl.setDataLength(10);
        downPlaybackMsgControl.setControlType(controlType);
        downPlaybackMsgControl.setFastTime(fastTime);
        downPlaybackMsgControl.setDateTime(null);
        byte[] body = downPlaybackMsgControl.encode();
        OuterPacket out = new OuterPacket(DataType.DOWN_PLAYBACK_MSG.getCode(), inferiorPlatformId, body);
        channel.writeAndFlush(out);
        log.info("远程录像回放控制请求({}):{}", DataType.DOWN_PLAYBACK_MSG_CONTROL.getCode(), JSON.toJSONString(downPlaybackMsgControl));
        return R.ok();
    }
}