nishiwei
5 days ago 3f43e40ed1a1e9f66b3ad2862da9dbc4b710c712
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
package com.ard.sample.manage.service.impl;
 
import com.ard.sample.manage.model.dto.DeviceDTO;
import com.ard.sample.manage.model.enums.DeviceDomainEnum;
import com.ard.sample.manage.model.enums.DockModelEnum;
 
/**
 * 【机场1】机型解析器(Dock1 适配共享层新增)。
 *
 * <p>从 DeviceDTO 的 domain/type(即 device_model_key 三段 domain-type-sub_type 的落库结果)
 * 解析设备所属的机场代际:机场设备按 type 判 1/2,飞行器按 type 判 67/91。
 * 无法识别(遥控器、未绑定设备、type 为空等)返回 null——调用方应兜底走 dock2 原链,
 * 保证 dock2 与改造前行为完全一致。
 *
 * @author ard
 * @date 2026/10/16
 */
public final class DockModelResolver {
 
    private DockModelResolver() {
    }
 
    /**
     * 解析设备所属机型。
     *
     * @param device 在线设备(DeviceDTO 的 domain/type/subType 由绑定/上线时 device_model_key 三段解析落库)
     * @return {@link DockModelEnum#DOCK1} / {@link DockModelEnum#DOCK2};无法识别返回 null
     */
    public static DockModelEnum resolve(DeviceDTO device) {
        if (device == null || device.getDomain() == null || device.getType() == null) {
            return null;
        }
        if (DeviceDomainEnum.DOCK.getVal() == device.getDomain()) {
            return DockModelEnum.fromDockType(device.getType());
        }
        if (DeviceDomainEnum.SUB_DEVICE.getVal() == device.getDomain()) {
            return DockModelEnum.fromDroneType(device.getType());
        }
        return null;
    }
}