From 0f69561e397093b5165c4aac58530721d5c62178 Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期一, 25 十一月 2024 11:03:16 +0800 Subject: [PATCH] #led --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/SurayLiftThread.java | 88 ++++++++++++++++++++++++++++--------------- 1 files changed, 57 insertions(+), 31 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 ae8097c..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; @@ -92,8 +93,13 @@ //----------璇诲彇鎻愬崌鏈虹姸鎬�----------- //妯″紡 liftProtocol.setModel(true); + + boolean runningState = data.getInteger("runningState") == 1; + if (!data.getInteger("completeTaskNo").equals(data.getInteger("taskNo"))) { + runningState = true;//宸ヤ綔鍙蜂笉涓�鑷达紝璁や负澶勪簬杩愯涓� + } //杩愯鐘舵�� - liftProtocol.setRun(data.getInteger("runningState") == 1); + liftProtocol.setRun(runningState); //灏辩华鐘舵�� liftProtocol.setReady(data.getInteger("readyState") == 1); //鏈夋墭鐩� @@ -212,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 @@ -478,6 +499,11 @@ return extend.getLock(); } + @Override + public int generateDeviceTaskNo(int taskNo, MotionCtgType motionCtgType) { + return taskNo; + } + //***************璁惧灞傞�氳-涓嶅悓鍘傚晢璁惧閫氳鏂规涓嶄竴鑷�*************** //璇锋眰鐧诲綍 -- Gitblit v1.9.1