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;
|
}
|
}
|