| | |
| | | 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; |
| | |
| | | liftProtocol.setModel(true); |
| | | |
| | | boolean runningState = data.getInteger("runningState") == 1; |
| | | if (data.getInteger("completeTaskNo") != data.getInteger("taskNo")) { |
| | | if (!data.getInteger("completeTaskNo").equals(data.getInteger("taskNo"))) { |
| | | runningState = true;//工作号不一致,认为处于运行中 |
| | | } |
| | | //运行状态 |
| | |
| | | } |
| | | |
| | | @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 |
| | |
| | | return extend.getLock(); |
| | | } |
| | | |
| | | @Override |
| | | public int generateDeviceTaskNo(int taskNo, MotionCtgType motionCtgType) { |
| | | return taskNo; |
| | | } |
| | | |
| | | //***************设备层通讯-不同厂商设备通讯方案不一致*************** |
| | | |
| | | //请求登录 |