From eb4ea056ddd2502fdb6f49a2ad0a01836b7e71fa Mon Sep 17 00:00:00 2001 From: Junjie <xjj@123> Date: 星期四, 17 十月 2024 14:40:14 +0800 Subject: [PATCH] # --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java | 76 +++++++++++++++++++++++--------------- 1 files changed, 46 insertions(+), 30 deletions(-) diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java index f1c4e9e..a08d18d 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java @@ -17,6 +17,7 @@ import com.zy.asrs.wcs.rcs.News; import com.zy.asrs.wcs.rcs.cache.OutputQueue; import com.zy.asrs.wcs.rcs.entity.DeviceDataLog; +import com.zy.asrs.wcs.rcs.model.CommandResponse; import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType; import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; import com.zy.asrs.wcs.rcs.service.DeviceDataLogService; @@ -217,148 +218,163 @@ } @Override - public synchronized boolean move(LiftCommand command) { + public synchronized CommandResponse move(LiftCommand command) { + CommandResponse response = new CommandResponse(false); try { String loginToken = requestLoginToken(); if (loginToken == null) { - return false; + return response; } HashMap<String, Object> headers = new HashMap<>(); headers.put("Authorization", "Bearer " + loginToken); - String response = new HttpHandler.Builder() + String responseStr = new HttpHandler.Builder() .setUri(API_URL) .setPath("/RDS/lifterTask") .setHeaders(headers) .setJson(command.getBody()) .build() .doPost(); - JSONObject jsonObject = JSON.parseObject(response); + JSONObject jsonObject = JSON.parseObject(responseStr); Integer code = jsonObject.getInteger("code"); + response.setMessage(JSON.toJSONString(jsonObject)); if (code.equals(200)) { - return true; + response.setResult(true); + return response; } } catch (Exception e) { e.printStackTrace(); } - return false; + return response; } @Override - public synchronized boolean palletInOut(LiftCommand command) { + public synchronized CommandResponse palletInOut(LiftCommand command) { + CommandResponse response = new CommandResponse(false); try { String loginToken = requestLoginToken(); if (loginToken == null) { - return false; + return response; } HashMap<String, Object> headers = new HashMap<>(); headers.put("Authorization", "Bearer " + loginToken); - String response = new HttpHandler.Builder() + String responseStr = new HttpHandler.Builder() .setUri(API_URL) .setPath("/RDS/lifterTask") .setHeaders(headers) .setJson(command.getBody()) .build() .doPost(); - JSONObject jsonObject = JSON.parseObject(response); + JSONObject jsonObject = JSON.parseObject(responseStr); Integer code = jsonObject.getInteger("code"); + response.setMessage(JSON.toJSONString(jsonObject)); if (code.equals(200)) { - return true; + response.setResult(true); + return response; } } catch (Exception e) { e.printStackTrace(); } - return false; + return response; } @Override - public synchronized boolean lock(LiftCommand command) { + public synchronized CommandResponse lock(LiftCommand command) { + CommandResponse response = new CommandResponse(false); try { String loginToken = requestLoginToken(); if (loginToken == null) { - return false; + return response; } HashMap<String, Object> headers = new HashMap<>(); headers.put("Authorization", "Bearer " + loginToken); - String response = new HttpHandler.Builder() + String responseStr = new HttpHandler.Builder() .setUri(API_URL) .setPath("/RDS/lifterOperation") .setHeaders(headers) .setJson(command.getBody()) .build() .doPost(); - JSONObject jsonObject = JSON.parseObject(response); + JSONObject jsonObject = JSON.parseObject(responseStr); Integer code = jsonObject.getInteger("code"); + response.setMessage(JSON.toJSONString(jsonObject)); if (code.equals(200)) { - return true; + response.setResult(true); + return response; } } catch (Exception e) { e.printStackTrace(); } - return false; + return response; } @Override - public synchronized boolean unlock(LiftCommand command) { + public synchronized CommandResponse unlock(LiftCommand command) { + CommandResponse response = new CommandResponse(false); try { String loginToken = requestLoginToken(); if (loginToken == null) { - return false; + return response; } HashMap<String, Object> headers = new HashMap<>(); headers.put("Authorization", "Bearer " + loginToken); - String response = new HttpHandler.Builder() + String responseStr = new HttpHandler.Builder() .setUri(API_URL) .setPath("/RDS/lifterOperation") .setHeaders(headers) .setJson(command.getBody()) .build() .doPost(); - JSONObject jsonObject = JSON.parseObject(response); + JSONObject jsonObject = JSON.parseObject(responseStr); Integer code = jsonObject.getInteger("code"); + response.setMessage(JSON.toJSONString(jsonObject)); if (code.equals(200)) { - return true; + response.setResult(true); + return response; } } catch (Exception e) { e.printStackTrace(); } - return false; + return response; } @Override - public synchronized boolean reset(LiftCommand command) { + public synchronized CommandResponse reset(LiftCommand command) { + CommandResponse response = new CommandResponse(false); try { String loginToken = requestLoginToken(); if (loginToken == null) { - return false; + return response; } HashMap<String, Object> headers = new HashMap<>(); headers.put("Authorization", "Bearer " + loginToken); - String response = new HttpHandler.Builder() + String responseStr = new HttpHandler.Builder() .setUri(API_URL) .setPath("/RDS/lifterOperation") .setHeaders(headers) .setJson(command.getBody()) .build() .doPost(); - JSONObject jsonObject = JSON.parseObject(response); + JSONObject jsonObject = JSON.parseObject(responseStr); Integer code = jsonObject.getInteger("code"); + response.setMessage(JSON.toJSONString(jsonObject)); if (code.equals(200)) { - return true; + response.setResult(true); + return response; } } catch (Exception e) { e.printStackTrace(); } - return false; + return response; } @Override -- Gitblit v1.9.1