调整
This commit is contained in:
parent
c3597decea
commit
46753e4f02
@ -114,7 +114,7 @@ public class WebSocketSdcpServiceImpl extends WebSocketService {
|
||||
reqDTO.setData(data);
|
||||
String message = JSON.toJSONString(reqDTO);
|
||||
try {
|
||||
log.info("发送【获取初始化】指令:channel={},message={}", channel, message);
|
||||
log.info("发送【初始化】指令:channel={},message={}", channel, message);
|
||||
socket.session.getBasicRemote().sendText(message);
|
||||
} catch (IOException e) { throw new RuntimeException(e); }
|
||||
}
|
||||
@ -131,7 +131,7 @@ public class WebSocketSdcpServiceImpl extends WebSocketService {
|
||||
String img64 = dataMap.get("Data").toString();
|
||||
WebSocketService uSocket = clients.get(userId);
|
||||
if (null == uSocket || null == uSocket.session || !uSocket.session.isOpen()) {
|
||||
log.info("<<< 用户【{}】已退出连接无需发送,忽略", userId);
|
||||
log.info("<<< 用户【{}】已退出连接,忽略", userId);
|
||||
return;
|
||||
}
|
||||
ImageDataVo imageDataVo = imageUser.get(uSocket.session.getId());
|
||||
@ -139,7 +139,7 @@ public class WebSocketSdcpServiceImpl extends WebSocketService {
|
||||
imageUser.put(uSocket.session.getId(), imageDataVo);
|
||||
Map<String, Object> commandResult = new HashMap<>();
|
||||
commandResult.put("deviceSn", deviceSn);
|
||||
commandResult.put("chunkIndex", dataMap.get("ChunkIndex")); // 图片当前分片数
|
||||
commandResult.put("chunkIndex", (Integer.parseInt(dataMap.get("ChunkIndex")) + 1) + ""); // 图片当前分片数
|
||||
commandResult.put("totalChunks", dataMap.get("TotalChunks")); // 图片总的分片数
|
||||
sendVueMessage(JSON.toJSONString(new SocketMsg(commandResult, "图片传输中", MsgEnum.WRITEIMG)), uSocket.channel, uSocket.session);
|
||||
}
|
||||
@ -189,9 +189,13 @@ public class WebSocketSdcpServiceImpl extends WebSocketService {
|
||||
if (method == MethodEnum.response) {
|
||||
// 指令响应消息
|
||||
WebSocketResData data = param.getData();
|
||||
if (null == data.getData() || "".equals(data.getData().toString())) {
|
||||
log.info("<<< 该消息不是用户指令反馈,忽略");
|
||||
return;
|
||||
}
|
||||
JSONObject cData = JSON.parseObject(data.getData().toString());
|
||||
if (!cData.containsKey("UserId")) {
|
||||
log.info("<<< 该消息不是用户指令请求反馈,忽略");
|
||||
log.info("<<< 该消息不是用户指令反馈,忽略");
|
||||
return;
|
||||
}
|
||||
WebSocketService uSocket = clients.get(cData.get("UserId").toString());
|
||||
|
@ -44,8 +44,8 @@ public class WebSocketVueServiceImpl extends WebSocketService {
|
||||
}
|
||||
}
|
||||
|
||||
// 每1分钟检测用户是否断开,断开则需要将视频断开
|
||||
@Scheduled(fixedRate = 60000)
|
||||
// 每3分钟检测用户是否断开,断开则需要将视频断开
|
||||
@Scheduled(fixedRate = 180000)
|
||||
public void checkCloseVideo() {
|
||||
List<String> uClients = clients.keySet().stream().filter(i -> !i.equals(WebSocketConfig.TOPIC_PREFIX)).collect(Collectors.toList());
|
||||
if (uClients.isEmpty() && !videoUser.isEmpty()) {
|
||||
@ -55,6 +55,7 @@ public class WebSocketVueServiceImpl extends WebSocketService {
|
||||
Map<String, Object> dataParam = new HashMap<>();
|
||||
dataParam.put("Enable", 0);
|
||||
dataParam.put("UserId", "-1");
|
||||
dataParam.put("StreamID", "");
|
||||
WebSocketReqData data = new WebSocketReqData();
|
||||
data.setCmd(386);
|
||||
data.setData(dataParam);
|
||||
@ -181,7 +182,7 @@ public class WebSocketVueServiceImpl extends WebSocketService {
|
||||
// {"Topic":"sdcp/request/12345678","command":"PAUSE"}
|
||||
else if (command.equals(CapabilitieEnum.PAUSE.name())) {
|
||||
BusDevice device = myDeviceService.getByDeviceCode(deviceSn);
|
||||
if (!device.getStatus().equals(CurrentStatusEnum.SDCP_MACHINE_STATUS_PRINTING.getCode())) {
|
||||
if (!device.getStatus().equals(CurrentStatusEnum.SDCP_MACHINE_STATUS_PREPARE.getCode())) {
|
||||
Map<String, Object> commandResult = new HashMap<>();
|
||||
commandResult.put("deviceSn", deviceSn);
|
||||
sendVueMessage(session, JSON.toJSONString(new SocketMsg(commandResult, "当前状态无法操作暂停", MsgEnum.ERROR)));
|
||||
@ -197,7 +198,7 @@ public class WebSocketVueServiceImpl extends WebSocketService {
|
||||
// {"Topic":"sdcp/request/12345678","command":"EXIT"}
|
||||
else if (command.equals(CapabilitieEnum.EXIT.name())) {
|
||||
BusDevice device = myDeviceService.getByDeviceCode(deviceSn);
|
||||
if (device.getStatus().equals(CurrentStatusEnum.SDCP_MACHINE_STATUS_IDLE.getCode()) && device.getPrintStatus().equals(PrintInfoStatusEnum.SDCP_PRINT_STATUS_IDLE.getCode())) {
|
||||
if (device.getStatus().equals(CurrentStatusEnum.SDCP_MACHINE_STATUS_IDLE.getCode())) {
|
||||
Map<String, Object> commandResult = new HashMap<>();
|
||||
commandResult.put("deviceSn", deviceSn);
|
||||
sendVueMessage(session, JSON.toJSONString(new SocketMsg(commandResult, "当前状态无法操作退出", MsgEnum.ERROR)));
|
||||
@ -228,6 +229,12 @@ public class WebSocketVueServiceImpl extends WebSocketService {
|
||||
// 图片异物报警继续
|
||||
// {"Topic":"sdcp/request/12345678","command":"ALARM_CONTINUE"}
|
||||
else if (command.equals(CapabilitieEnum.ALARM_CONTINUE.name())) {
|
||||
BusDevice device = myDeviceService.getByDeviceCode(deviceSn);
|
||||
if (!device.getErrorStatus().equals(ErrorStatusEnum.SDCP_PRINT_ERROR_PIC.getCode())) {
|
||||
Map<String, Object> commandResult = new HashMap<>();
|
||||
commandResult.put("deviceSn", deviceSn);
|
||||
sendVueMessage(session, JSON.toJSONString(new SocketMsg(commandResult, "当前无异物,无需操作", MsgEnum.ERROR)));
|
||||
}
|
||||
data.setCmd(132);
|
||||
Map<String, Object> dataParam = new HashMap<>();
|
||||
dataParam.put("UserId", session.getId());
|
||||
@ -237,6 +244,12 @@ public class WebSocketVueServiceImpl extends WebSocketService {
|
||||
// 图片异物报警暂停
|
||||
// {"Topic":"sdcp/request/12345678","command":"ALARM_EXIT"}
|
||||
else if (command.equals(CapabilitieEnum.ALARM_EXIT.name())) {
|
||||
BusDevice device = myDeviceService.getByDeviceCode(deviceSn);
|
||||
if (!device.getErrorStatus().equals(ErrorStatusEnum.SDCP_PRINT_ERROR_PIC.getCode())) {
|
||||
Map<String, Object> commandResult = new HashMap<>();
|
||||
commandResult.put("deviceSn", deviceSn);
|
||||
sendVueMessage(session, JSON.toJSONString(new SocketMsg(commandResult, "当前无异物,无需操作", MsgEnum.ERROR)));
|
||||
}
|
||||
data.setCmd(133);
|
||||
Map<String, Object> dataParam = new HashMap<>();
|
||||
dataParam.put("UserId", session.getId());
|
||||
@ -262,6 +275,7 @@ public class WebSocketVueServiceImpl extends WebSocketService {
|
||||
Map<String, Object> dataParam = new HashMap<>();
|
||||
dataParam.put("Enable", command.equals(CapabilitieEnum.OPEN_VIDEO.name()) ? 1 : 0);
|
||||
dataParam.put("UserId", session.getId());
|
||||
dataParam.put("StreamID", "");
|
||||
data.setData(dataParam);
|
||||
LinkedList<String> userIds = videoUser.get(deviceSn);
|
||||
// 打开视频
|
||||
|
Loading…
Reference in New Issue
Block a user