forked from dyf/fys-Multi-tenant
feat(mqtt): 新增星汉设备数据处理规则和解析逻辑- 添加 MqttXinghanCommandType 枚举类,用于识别和处理星汉设备的命令类型
- 新增 MqttXinghanJson 类,用于解析星汉设备的 JSON 数据 - 在 ReceiverMessageHandler 中集成星汉设备数据的处理逻辑 - 添加 XingHanCommandTypeConstants 常量类,定义星汉设备的命令类型常量 - 实现 XinghanDeviceDataRule 类,处理星汉设备主动上报的数据命令
This commit is contained in:
@ -0,0 +1,56 @@
|
||||
package com.fuyuanshen.global.mqtt.base;
|
||||
|
||||
import cn.hutool.core.lang.Dict;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Collections;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component
|
||||
public final class MqttXinghanCommandType {
|
||||
private MqttXinghanCommandType() {}
|
||||
|
||||
public enum XinghanCommandTypeEnum {
|
||||
GRADE_INFO(101),
|
||||
PIC_TRANS(102),
|
||||
TEX_TRANS(103),
|
||||
BREAK_NEWS(104),
|
||||
UNKNOWN(0);
|
||||
|
||||
private final int value;
|
||||
XinghanCommandTypeEnum(int value) { this.value = value; }
|
||||
public int getValue() { return value; }
|
||||
}
|
||||
|
||||
private static final Map<String, XinghanCommandTypeEnum> KEY_TO_TYPE;
|
||||
static {
|
||||
LinkedHashMap<String, XinghanCommandTypeEnum> map = new LinkedHashMap<>();
|
||||
map.put("sta_DetectGrade", XinghanCommandTypeEnum.GRADE_INFO);
|
||||
map.put("sta_PowerTime", XinghanCommandTypeEnum.GRADE_INFO);
|
||||
map.put("sta_longitude", XinghanCommandTypeEnum.GRADE_INFO);
|
||||
map.put("sta_latitude", XinghanCommandTypeEnum.GRADE_INFO);
|
||||
map.put("sta_PicTrans", XinghanCommandTypeEnum.PIC_TRANS);
|
||||
map.put("sta_TexTrans", XinghanCommandTypeEnum.TEX_TRANS);
|
||||
map.put("sta_BreakNews", XinghanCommandTypeEnum.BREAK_NEWS);
|
||||
KEY_TO_TYPE = Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
public static int computeVirtualCommandType(Dict payloadDict) {
|
||||
if (payloadDict == null) {
|
||||
return XinghanCommandTypeEnum.UNKNOWN.getValue();
|
||||
}
|
||||
try {
|
||||
for (String key : KEY_TO_TYPE.keySet()) {
|
||||
if (payloadDict.containsKey(key)) {
|
||||
return KEY_TO_TYPE.get(key).getValue();
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
return XinghanCommandTypeEnum.UNKNOWN.getValue();
|
||||
}
|
||||
|
||||
return XinghanCommandTypeEnum.UNKNOWN.getValue();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package com.fuyuanshen.global.mqtt.base;
|
||||
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Data
|
||||
public class MqttXinghanJson {
|
||||
|
||||
/**
|
||||
* 第一键值对,静电预警档位:3,2,1,0,分别表示高档/中档/低挡/关闭.
|
||||
*/
|
||||
@JsonProperty("sta_DetectGrade")
|
||||
private Integer staDetectGrade;
|
||||
/**
|
||||
* 第二键值对,照明档位,2,1,0,分别表示弱光/强光/关闭
|
||||
*/
|
||||
@JsonProperty("sta_LightGrade")
|
||||
private Integer staLightGrade;
|
||||
/**
|
||||
* 第三键值对,SOS档位,2,1,0, 分别表示红蓝模式/爆闪模式/关闭
|
||||
*/
|
||||
@JsonProperty("sta_SOSGrade")
|
||||
public int staSOSGrade;
|
||||
/**
|
||||
* 第四键值对,剩余照明时间,0-5999,单位分钟。
|
||||
*/
|
||||
@JsonProperty("sta_PowerTime")
|
||||
public int staPowerTime;
|
||||
/**
|
||||
* 第五键值对,剩余电量百分比,0-100
|
||||
*/
|
||||
@JsonProperty("sta_PowerPercent")
|
||||
public int staPowerPercent;
|
||||
/**
|
||||
* 第六键值对, 近电预警级别, 0-无预警,1-弱预警,2-中预警,3-强预警,4-非常强预警。
|
||||
*/
|
||||
@JsonProperty("sta_DetectResult")
|
||||
public int staDetectResult;
|
||||
/**
|
||||
* 第七键值对, 静止报警状态,0-未静止报警,1-正在静止报警。
|
||||
*/
|
||||
@JsonProperty("staShakeBit")
|
||||
public int sta_ShakeBit;
|
||||
/**
|
||||
* 第八键值对, 4G信号强度,0-32,数值越大,信号越强。
|
||||
*/
|
||||
@JsonProperty("sta_4gSinal")
|
||||
public int sta4gSinal;
|
||||
/**
|
||||
* 第九键值对,IMIE卡号
|
||||
*/
|
||||
@JsonProperty("sta_imei")
|
||||
public int staimei;
|
||||
/**
|
||||
* 第十键值对,经度
|
||||
*/
|
||||
@JsonProperty("sta_longitude")
|
||||
public String stalongitude;
|
||||
/**
|
||||
* 第十一键值对,纬度
|
||||
*/
|
||||
@JsonProperty("sta_latitude")
|
||||
public String stalatitude;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user