[*] 日常优化
This commit is contained in:
@@ -788,6 +788,9 @@ class Taoyao extends RemoteClient {
|
|||||||
const { header, body } = message;
|
const { header, body } = message;
|
||||||
const { signal } = header;
|
const { signal } = header;
|
||||||
switch (signal) {
|
switch (signal) {
|
||||||
|
case "client::broadcast":
|
||||||
|
me.defaultClientBroadcast(message);
|
||||||
|
break;
|
||||||
case "client::reboot":
|
case "client::reboot":
|
||||||
me.defaultClientReboot(message);
|
me.defaultClientReboot(message);
|
||||||
break;
|
break;
|
||||||
@@ -1002,6 +1005,52 @@ class Taoyao extends RemoteClient {
|
|||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 终端告警信令
|
||||||
|
*
|
||||||
|
* @param {*} message
|
||||||
|
*/
|
||||||
|
clientAlarm(message) {
|
||||||
|
const me = this;
|
||||||
|
const date = new Date();
|
||||||
|
const datetime = "" +
|
||||||
|
date.getFullYear() +
|
||||||
|
((date.getMonth() < 9 ? "0" : "") + (date.getMonth() + 1)) +
|
||||||
|
((date.getDate() < 10 ? "0" : "") + date.getDate()) +
|
||||||
|
((date.getHours() < 10 ? "0" : "") + date.getHours()) +
|
||||||
|
((date.getMinutes() < 10 ? "0" : "") + date.getMinutes()) +
|
||||||
|
((date.getSeconds() < 10 ? "0" : "") + date.getSeconds());
|
||||||
|
me.push(protocol.buildMessage("client::alarm", {
|
||||||
|
message,
|
||||||
|
datetime,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 终端广播信令
|
||||||
|
*
|
||||||
|
* @param {*} message 广播信息
|
||||||
|
* @param {*} clientType 终端类型(可选)
|
||||||
|
*/
|
||||||
|
clientBroadcast(message, clientType) {
|
||||||
|
const me = this;
|
||||||
|
me.push(protocol.buildMessage("client::broadcast", {
|
||||||
|
...message,
|
||||||
|
clientType,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 终端广播信令
|
||||||
|
*
|
||||||
|
* @param {*} message 信令消息
|
||||||
|
*/
|
||||||
|
defaultClientBroadcast(message) {
|
||||||
|
const me = this;
|
||||||
|
const { header, body } = message;
|
||||||
|
console.debug("终端广播", header, body);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 终端配置信令
|
* 终端配置信令
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -62,17 +62,18 @@ public class ClientStatus {
|
|||||||
* @param body 消息主体
|
* @param body 消息主体
|
||||||
*/
|
*/
|
||||||
public void copy(Map<String, Object> body) {
|
public void copy(Map<String, Object> body) {
|
||||||
this.setLatitude(MapUtils.getDouble(body, Constant.LATITUDE));
|
this.setLatitude(MapUtils.get(body, Constant.LATITUDE, this.latitude));
|
||||||
this.setLongitude(MapUtils.getDouble(body, Constant.LONGITUDE));
|
this.setLongitude(MapUtils.get(body, Constant.LONGITUDE, this.longitude));
|
||||||
this.setHumidity(MapUtils.getDouble(body, Constant.HUMIDITY));
|
this.setHumidity(MapUtils.get(body, Constant.HUMIDITY, this.humidity));
|
||||||
this.setTemperature(MapUtils.getDouble(body, Constant.TEMPERATURE));
|
this.setTemperature(MapUtils.get(body, Constant.TEMPERATURE, this.temperature));
|
||||||
this.setSignal(MapUtils.getInteger(body, Constant.SIGNAL));
|
this.setSignal(MapUtils.get(body, Constant.SIGNAL, this.signal));
|
||||||
this.setBattery(MapUtils.getInteger(body, Constant.BATTERY));
|
this.setBattery(MapUtils.get(body, Constant.BATTERY, this.battery));
|
||||||
this.setAlarming(MapUtils.getBoolean(body, Constant.ALARMING));
|
this.setAlarming(MapUtils.get(body, Constant.ALARMING, this.alarming));
|
||||||
this.setCharging(MapUtils.getBoolean(body, Constant.CHARGING));
|
this.setCharging(MapUtils.get(body, Constant.CHARGING, this.charging));
|
||||||
this.setClientRecording(MapUtils.getBoolean(body, Constant.CLIENT_RECORDING));
|
this.setClientRecording(MapUtils.get(body, Constant.CLIENT_RECORDING, this.clientRecording));
|
||||||
this.status(MapUtils.get(body, Constant.STATUS));
|
// this.setServerRecording(MapUtils.get(body, Constant.SERVER_RECORDING, this.serverRecording));
|
||||||
this.config(MapUtils.get(body, Constant.CONFIG));
|
this.status(MapUtils.get(body, Constant.STATUS, this.status));
|
||||||
|
this.config(MapUtils.get(body, Constant.CONFIG, this.config));
|
||||||
this.setLastHeartbeat(LocalDateTime.now());
|
this.setLastHeartbeat(LocalDateTime.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
@Description(
|
@Description(
|
||||||
body = """
|
body = """
|
||||||
{
|
{
|
||||||
"message": "告警描述",
|
"message" : "告警描述",
|
||||||
"datetime": "告警时间(yyyyMMddHHmmss)"
|
"datetime": "告警时间(yyyyMMddHHmmss)"
|
||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
@@ -42,7 +42,7 @@ public class ClientAlarmProtocol extends ProtocolClientAdapter {
|
|||||||
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
||||||
final String alarmMessage = MapUtils.get(body, Constant.MESSAGE);
|
final String alarmMessage = MapUtils.get(body, Constant.MESSAGE);
|
||||||
final String alarmDatetime = MapUtils.get(body, Constant.DATETIME);
|
final String alarmDatetime = MapUtils.get(body, Constant.DATETIME);
|
||||||
log.warn(
|
log.info(
|
||||||
"""
|
"""
|
||||||
终端告警:{}
|
终端告警:{}
|
||||||
终端类型:{}
|
终端类型:{}
|
||||||
|
|||||||
Reference in New Issue
Block a user