[*] 日常优化
This commit is contained in:
@@ -62,17 +62,18 @@ public class ClientStatus {
|
||||
* @param body 消息主体
|
||||
*/
|
||||
public void copy(Map<String, Object> body) {
|
||||
this.setLatitude(MapUtils.getDouble(body, Constant.LATITUDE));
|
||||
this.setLongitude(MapUtils.getDouble(body, Constant.LONGITUDE));
|
||||
this.setHumidity(MapUtils.getDouble(body, Constant.HUMIDITY));
|
||||
this.setTemperature(MapUtils.getDouble(body, Constant.TEMPERATURE));
|
||||
this.setSignal(MapUtils.getInteger(body, Constant.SIGNAL));
|
||||
this.setBattery(MapUtils.getInteger(body, Constant.BATTERY));
|
||||
this.setAlarming(MapUtils.getBoolean(body, Constant.ALARMING));
|
||||
this.setCharging(MapUtils.getBoolean(body, Constant.CHARGING));
|
||||
this.setClientRecording(MapUtils.getBoolean(body, Constant.CLIENT_RECORDING));
|
||||
this.status(MapUtils.get(body, Constant.STATUS));
|
||||
this.config(MapUtils.get(body, Constant.CONFIG));
|
||||
this.setLatitude(MapUtils.get(body, Constant.LATITUDE, this.latitude));
|
||||
this.setLongitude(MapUtils.get(body, Constant.LONGITUDE, this.longitude));
|
||||
this.setHumidity(MapUtils.get(body, Constant.HUMIDITY, this.humidity));
|
||||
this.setTemperature(MapUtils.get(body, Constant.TEMPERATURE, this.temperature));
|
||||
this.setSignal(MapUtils.get(body, Constant.SIGNAL, this.signal));
|
||||
this.setBattery(MapUtils.get(body, Constant.BATTERY, this.battery));
|
||||
this.setAlarming(MapUtils.get(body, Constant.ALARMING, this.alarming));
|
||||
this.setCharging(MapUtils.get(body, Constant.CHARGING, this.charging));
|
||||
this.setClientRecording(MapUtils.get(body, Constant.CLIENT_RECORDING, this.clientRecording));
|
||||
// this.setServerRecording(MapUtils.get(body, Constant.SERVER_RECORDING, this.serverRecording));
|
||||
this.status(MapUtils.get(body, Constant.STATUS, this.status));
|
||||
this.config(MapUtils.get(body, Constant.CONFIG, this.config));
|
||||
this.setLastHeartbeat(LocalDateTime.now());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Description(
|
||||
body = """
|
||||
{
|
||||
"message": "告警描述",
|
||||
"message" : "告警描述",
|
||||
"datetime": "告警时间(yyyyMMddHHmmss)"
|
||||
}
|
||||
""",
|
||||
@@ -40,9 +40,9 @@ public class ClientAlarmProtocol extends ProtocolClientAdapter {
|
||||
|
||||
@Override
|
||||
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);
|
||||
log.warn(
|
||||
log.info(
|
||||
"""
|
||||
终端告警:{}
|
||||
终端类型:{}
|
||||
|
||||
@@ -33,20 +33,20 @@ import com.acgist.taoyao.signal.protocol.ProtocolClientAdapter;
|
||||
)
|
||||
public class ClientBroadcastProtocol extends ProtocolClientAdapter {
|
||||
|
||||
public static final String SIGNAL = "client::broadcast";
|
||||
|
||||
public ClientBroadcastProtocol() {
|
||||
super("终端广播信令", SIGNAL);
|
||||
}
|
||||
public static final String SIGNAL = "client::broadcast";
|
||||
|
||||
public ClientBroadcastProtocol() {
|
||||
super("终端广播信令", SIGNAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
||||
final String queryClientType = MapUtils.get(body, Constant.CLIENT_TYPE);
|
||||
if(StringUtils.isEmpty(queryClientType)) {
|
||||
this.clientManager.broadcast(client, message);
|
||||
} else {
|
||||
this.clientManager.broadcast(client, message, ClientType.of(queryClientType));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
||||
final String queryClientType = MapUtils.get(body, Constant.CLIENT_TYPE);
|
||||
if(StringUtils.isEmpty(queryClientType)) {
|
||||
this.clientManager.broadcast(client, message);
|
||||
} else {
|
||||
this.clientManager.broadcast(client, message, ClientType.of(queryClientType));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user