润德安全帽添加:server_push_ca_sip_sos类型
This commit is contained in:
parent
f9613c9d39
commit
e7f62ce397
@ -38,6 +38,13 @@ public class SafetyHatWSClient {
|
|||||||
private Session session;
|
private Session session;
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
public SafetyHatWSClient(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SafetyHatWSClient() {
|
||||||
|
}
|
||||||
|
|
||||||
@OnOpen
|
@OnOpen
|
||||||
public void open(Session session) {
|
public void open(Session session) {
|
||||||
log.info("SafetyHatWSClient连接客户端:" + id + ",连接服务端...");
|
log.info("SafetyHatWSClient连接客户端:" + id + ",连接服务端...");
|
||||||
@ -184,10 +191,41 @@ public class SafetyHatWSClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (Objects.equals(cmd, "server_push_ca_sip_sos")) {
|
||||||
|
log.info("SafetyHatWSClient接收报警数据:server_push_ca_sip_sos");
|
||||||
|
addSafetyHatAlarm(jo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addSafetyHatAlarm(JSONObject jo) {
|
||||||
|
JSONObject caInfo = jo.getJSONObject("ca_info");
|
||||||
|
if (caInfo == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String deviceId = caInfo.getString("device_id");
|
||||||
|
SafetyHatDev dev = SpringContextUtils.getBean(SafetyHatDevMapper.class).selectOne(new LambdaQueryWrapper<SafetyHatDev>().eq(SafetyHatDev::getDevSn, deviceId));
|
||||||
|
if (dev == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//纬度(坐标系:高德地图 GCJ-02)
|
||||||
|
SafetyHatAlarm alarm = new SafetyHatAlarm();
|
||||||
|
alarm.setWorkerInfoId(dev.getWorkerInfoId());
|
||||||
|
alarm.setDevSn(dev.getDevSn());
|
||||||
|
alarm.setAlarmTime(new Date(jo.getLong("time") * 1000L));
|
||||||
|
alarm.setProjectSn(dev.getProjectSn());
|
||||||
|
alarm.setAlarmType(7);
|
||||||
|
alarm.setLatitude(jo.getDouble("x_point"));
|
||||||
|
alarm.setLongitude(jo.getDouble("y_point"));
|
||||||
|
alarm.setFenceId(dev.getFenceId());
|
||||||
|
alarm.setType(dev.getType());
|
||||||
|
alarm.setWorkerInfoName(dev.getWorkerInfoName());
|
||||||
|
try {
|
||||||
|
SpringContextUtils.getBean(ISafetyHatAlarmService.class).add(alarm);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("error:", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@OnClose
|
@OnClose
|
||||||
public void onClose() {
|
public void onClose() {
|
||||||
@ -213,11 +251,4 @@ public class SafetyHatWSClient {
|
|||||||
this.session.getAsyncRemote().sendText(message);
|
this.session.getAsyncRemote().sendText(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SafetyHatWSClient(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SafetyHatWSClient() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user