zjj
2024-11-25 0f69561e397093b5165c4aac58530721d5c62178
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
@@ -483,6 +499,11 @@
        return extend.getLock();
    }
    @Override
    public int generateDeviceTaskNo(int taskNo, MotionCtgType motionCtgType) {
        return taskNo;
    }
    //***************设备层通讯-不同厂商设备通讯方案不一致***************
    //请求登录