update:
出库液压台在线且高位则选为出库台
This commit is contained in:
		@@ -63,6 +63,7 @@ public class RunTaskUtils {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 进炉加工
 | 
			
		||||
     *
 | 
			
		||||
     * @param currTaskId 任务id
 | 
			
		||||
     * @return R
 | 
			
		||||
     * @throws InterruptedException
 | 
			
		||||
@@ -74,25 +75,25 @@ public class RunTaskUtils {
 | 
			
		||||
        PointInfo startPoint = pointInfoServiceBiz.getOne(new QueryWrapper<PointInfo>().eq(PointInfo.NOTE, startPosition));
 | 
			
		||||
        // 可以根据点位类型判断起点是否为液压台(2是液压台)
 | 
			
		||||
        Integer startPointType = startPoint.getType();
 | 
			
		||||
        if (startPointType==2){
 | 
			
		||||
        if (startPointType == 2) {
 | 
			
		||||
            Map<String, Object> yeya = new HashMap();
 | 
			
		||||
            //type=1为 入
 | 
			
		||||
            yeya.put("type", 1);
 | 
			
		||||
            if ("YYT003".equals(currTask.getStartPosition())){
 | 
			
		||||
            if ("YYT003".equals(currTask.getStartPosition())) {
 | 
			
		||||
                yeya.put("number", 3);
 | 
			
		||||
            }
 | 
			
		||||
            if ("YYT004".equals(currTask.getStartPosition())){
 | 
			
		||||
            if ("YYT004".equals(currTask.getStartPosition())) {
 | 
			
		||||
                yeya.put("number", 4);
 | 
			
		||||
            }
 | 
			
		||||
            if ("YYT002".equals(currTask.getStartPosition())){
 | 
			
		||||
            if ("YYT002".equals(currTask.getStartPosition())) {
 | 
			
		||||
                yeya.put("number", 2);
 | 
			
		||||
            }
 | 
			
		||||
            if ("YYT001".equals(currTask.getStartPosition())){
 | 
			
		||||
            if ("YYT001".equals(currTask.getStartPosition())) {
 | 
			
		||||
                yeya.put("number", 1);
 | 
			
		||||
            }
 | 
			
		||||
            String yeyaJudgeStatus = JSON.toJSONString(yeya);
 | 
			
		||||
            //判断起点液压台是否已放货且提升到位
 | 
			
		||||
            String yeyaStatus=null;
 | 
			
		||||
            String yeyaStatus = null;
 | 
			
		||||
            try {
 | 
			
		||||
                yeyaStatus = HttpClient.httpPost("http://192.168.6.51:8009/yeya/isReadyForYeyaStatus", yeyaJudgeStatus);
 | 
			
		||||
            } catch (IOException e) {
 | 
			
		||||
@@ -100,13 +101,13 @@ public class RunTaskUtils {
 | 
			
		||||
                logger.error(new Date() + "WCS接口超时未响应!");
 | 
			
		||||
            }
 | 
			
		||||
            //taskStatus==3满足条件,其他状态值说明液压台不满足开始任务的条件(无货物或者有货物但是没提升到位)
 | 
			
		||||
            if (Integer.parseInt(JSONObject.parseObject(yeyaStatus).get("taskStatus").toString()) != 1){
 | 
			
		||||
                return R.failed(startPoint.getName()+"号液压台不满足任务执行所必须的条件,请检查液压台是否有货物且提升到位!");
 | 
			
		||||
            if (Integer.parseInt(JSONObject.parseObject(yeyaStatus).get("taskStatus").toString()) != 1) {
 | 
			
		||||
                return R.failed(startPoint.getName() + "号液压台不满足任务执行所必须的条件,请检查液压台是否有货物且提升到位!");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //是否有小车在运行
 | 
			
		||||
        List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS, 1));
 | 
			
		||||
        if (vehicleInfoList.size()>0){
 | 
			
		||||
        if (vehicleInfoList.size() > 0) {
 | 
			
		||||
            //有小车在运行,提示当前有车辆在运行,请稍后
 | 
			
		||||
            return R.failed("当前轨道有RGV车辆在运动,请等待当前RGV车辆执行完毕再执行任务!");
 | 
			
		||||
        }
 | 
			
		||||
@@ -122,10 +123,10 @@ public class RunTaskUtils {
 | 
			
		||||
            return R.failed("目标工业炉不可用!");
 | 
			
		||||
        }
 | 
			
		||||
        //工业炉可用未满
 | 
			
		||||
        if (resultBoolean){
 | 
			
		||||
        if (resultBoolean) {
 | 
			
		||||
            //计算出路径最短的车辆id
 | 
			
		||||
            Long vehicleId = taskDistanceUtils.chooseVehicle(currTask.getStartPosition(), currTask.getTargetPosition());
 | 
			
		||||
            if (vehicleId==0){
 | 
			
		||||
            if (vehicleId == 0) {
 | 
			
		||||
                logger.info("两辆车都不在线,请检查后重试!");
 | 
			
		||||
                return R.failed("两辆车都不在线,请检查后重试!");
 | 
			
		||||
            }
 | 
			
		||||
@@ -139,7 +140,7 @@ public class RunTaskUtils {
 | 
			
		||||
            currTask.setUpdateTime(LocalDateTime.now());
 | 
			
		||||
            currTaskServiceBiz.updateById(currTask);
 | 
			
		||||
            //异步调用车辆
 | 
			
		||||
            asynRunTaskService.asynRunTask(currTask.getId(),vehicleId);
 | 
			
		||||
            asynRunTaskService.asynRunTask(currTask.getId(), vehicleId);
 | 
			
		||||
            return R.ok("操作成功,任务已开始执行。");
 | 
			
		||||
        } else {
 | 
			
		||||
            //工业炉已满
 | 
			
		||||
@@ -148,14 +149,14 @@ public class RunTaskUtils {
 | 
			
		||||
                    .eq(Location.STATUS, 0)
 | 
			
		||||
                    .eq(Location.VALID, 1));
 | 
			
		||||
            //缓存区未满
 | 
			
		||||
            if (count >0) {
 | 
			
		||||
            if (count > 0) {
 | 
			
		||||
                //分配一个缓存区库位
 | 
			
		||||
                Location location = locationServiceBiz.list(new QueryWrapper<Location>()
 | 
			
		||||
                        .eq(Location.STATUS, 0)
 | 
			
		||||
                        .eq(Location.VALID, 1)).get(0);
 | 
			
		||||
                //计算出路径最短的车辆id,起点液压台,终点缓存区库位点
 | 
			
		||||
                Long vehicleId = taskDistanceUtils.chooseVehicle(currTask.getStartPosition(), location.getCode());
 | 
			
		||||
                if (vehicleId==0){
 | 
			
		||||
                if (vehicleId == 0) {
 | 
			
		||||
                    logger.info("两辆车都不在线,请检查后重试!");
 | 
			
		||||
                    return R.failed("两辆车都不在线,请检查后重试!");
 | 
			
		||||
                }
 | 
			
		||||
@@ -180,7 +181,7 @@ public class RunTaskUtils {
 | 
			
		||||
                currTask.setLocationName(location.getLocationName());
 | 
			
		||||
                currTaskServiceBiz.updateById(currTask);
 | 
			
		||||
                //异步调用车辆
 | 
			
		||||
                asynRunTaskService.asynRunTaskToWarehouse(currTask.getId(),vehicleId,location);
 | 
			
		||||
                asynRunTaskService.asynRunTaskToWarehouse(currTask.getId(), vehicleId, location);
 | 
			
		||||
                return R.ok("操作成功!当前目标工业炉已满,托盘准备加入缓存区待加工队列。");
 | 
			
		||||
            }
 | 
			
		||||
            return R.failed("当前目标工业炉已满!缓存区已满!请稍后重试!");
 | 
			
		||||
@@ -191,6 +192,7 @@ public class RunTaskUtils {
 | 
			
		||||
     * 加工完成、出炉。传入工业炉id,查询正在该工业炉加工的currTask,查询是否有空闲车辆,有,
 | 
			
		||||
     * (查询是否为自动任务,是,查询下一步的工业炉是否空闲,是,调车去下一工业炉加工,否,暂存缓存区)
 | 
			
		||||
     * 呼叫车辆暂存缓存区,车辆调度任务结束后,(结束后再查询缓R存区队列避免车辆路线冲突)查询该工业炉的缓存区队列,开始下一托盘货物调度进工业炉
 | 
			
		||||
     *
 | 
			
		||||
     * @return R
 | 
			
		||||
     */
 | 
			
		||||
    public R runTaskForOutKiln(Long kilnId) throws IOException {
 | 
			
		||||
@@ -199,7 +201,7 @@ public class RunTaskUtils {
 | 
			
		||||
                .eq("is_in", 1)
 | 
			
		||||
                .eq("status", 1)
 | 
			
		||||
                .eq("kiln_id", kilnId).orderByAsc(CurrTask.BEGIN_TIME));
 | 
			
		||||
        if (currTaskList.size()==0){
 | 
			
		||||
        if (currTaskList.size() == 0) {
 | 
			
		||||
            return R.failed();
 | 
			
		||||
        }
 | 
			
		||||
        CurrTask currTask = currTaskList.get(0);
 | 
			
		||||
@@ -267,8 +269,17 @@ public class RunTaskUtils {
 | 
			
		||||
            vehicleInfo.setStatus(1);
 | 
			
		||||
            vehicleInfo.setUpdateTime(LocalDateTime.now());
 | 
			
		||||
            vehicleInfoServiceBiz.updateById(vehicleInfo);
 | 
			
		||||
            asynRunTaskService.asynRunOutStockForKilnToYYT(currTask.getId(),"YYT001",vehicleId);
 | 
			
		||||
            return R.ok("操作成功!托盘即将出库到一号液压台。");
 | 
			
		||||
            String yytCode = "YYT001";
 | 
			
		||||
            //选择出库液压台
 | 
			
		||||
            if (platFormPosition("YYT001")) {
 | 
			
		||||
                yytCode = "YYT001";
 | 
			
		||||
            } else if (platFormPosition("YYT002")) {
 | 
			
		||||
                yytCode = "YYT002";
 | 
			
		||||
            } else {
 | 
			
		||||
                yytCode = "YYT001";
 | 
			
		||||
            }
 | 
			
		||||
            asynRunTaskService.asynRunOutStockForKilnToYYT(currTask.getId(), yytCode, vehicleId);
 | 
			
		||||
            return R.ok("操作成功!托盘即将出库到" + yytCode + "液压台。");
 | 
			
		||||
        } else {
 | 
			
		||||
            //查询缓存区库位是否已满
 | 
			
		||||
            int count = locationServiceBiz.count(new QueryWrapper<Location>()
 | 
			
		||||
@@ -318,49 +329,50 @@ public class RunTaskUtils {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 从缓存区出库
 | 
			
		||||
     * @param locationId 库位id
 | 
			
		||||
     *
 | 
			
		||||
     * @param locationId  库位id
 | 
			
		||||
     * @param yeyaTaiCode 液压台code
 | 
			
		||||
     * @return R
 | 
			
		||||
     */
 | 
			
		||||
    public R runTaskForOut(Long locationId,String yeyaTaiCode) throws IOException {
 | 
			
		||||
    public R runTaskForOut(Long locationId, String yeyaTaiCode) throws IOException {
 | 
			
		||||
        Location location = locationServiceBiz.getById(locationId);
 | 
			
		||||
        //是否有小车在运行
 | 
			
		||||
        List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS, 1));
 | 
			
		||||
        if (vehicleInfoList.size()>0){
 | 
			
		||||
        if (vehicleInfoList.size() > 0) {
 | 
			
		||||
            //有小车在运行,提示当前有车辆在运行,请稍后
 | 
			
		||||
            return R.failed("当前轨道有RGV车辆在运动,请等待当前RGV车辆执行完毕再执行任务!");
 | 
			
		||||
        }
 | 
			
		||||
            Map<String, Object> yeya = new HashMap();
 | 
			
		||||
            //type=1随意赋值,不用type了
 | 
			
		||||
            yeya.put("type", 1);
 | 
			
		||||
            if ("YYT003".equals(yeyaTaiCode)){
 | 
			
		||||
                yeya.put("number", 3);
 | 
			
		||||
            }
 | 
			
		||||
            if ("YYT004".equals(yeyaTaiCode)){
 | 
			
		||||
                yeya.put("number", 4);
 | 
			
		||||
            }
 | 
			
		||||
            if ("YYT002".equals(yeyaTaiCode)){
 | 
			
		||||
                yeya.put("number", 2);
 | 
			
		||||
            }
 | 
			
		||||
            if ("YYT001".equals(yeyaTaiCode)){
 | 
			
		||||
                yeya.put("number", 1);
 | 
			
		||||
            }
 | 
			
		||||
            String yeyaJudgeStatus = JSON.toJSONString(yeya);
 | 
			
		||||
            //判断起点液压台是否在线且提升到位
 | 
			
		||||
            String yeyaStatus=null;
 | 
			
		||||
            try {
 | 
			
		||||
                yeyaStatus = HttpClient.httpPost("http://192.168.6.51:8009/yeya/isReadyForYeyaStatus", yeyaJudgeStatus);
 | 
			
		||||
            } catch (IOException e) {
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
                logger.error(new Date() + "WCS接口超时未响应!");
 | 
			
		||||
            }
 | 
			
		||||
            //taskStatus==3满足条件,其他状态值说明液压台不满足开始任务的条件(无货物或者有货物但是没提升到位)
 | 
			
		||||
            if (Integer.parseInt(JSONObject.parseObject(yeyaStatus).get("taskStatus").toString()) != 1){
 | 
			
		||||
                return R.failed("液压台"+yeyaTaiCode+"不满足任务执行所必须的条件,请检查液压台是否有货物且提升到位!");
 | 
			
		||||
            }
 | 
			
		||||
        Map<String, Object> yeya = new HashMap();
 | 
			
		||||
        //type=1随意赋值,不用type了
 | 
			
		||||
        yeya.put("type", 1);
 | 
			
		||||
        if ("YYT003".equals(yeyaTaiCode)) {
 | 
			
		||||
            yeya.put("number", 3);
 | 
			
		||||
        }
 | 
			
		||||
        if ("YYT004".equals(yeyaTaiCode)) {
 | 
			
		||||
            yeya.put("number", 4);
 | 
			
		||||
        }
 | 
			
		||||
        if ("YYT002".equals(yeyaTaiCode)) {
 | 
			
		||||
            yeya.put("number", 2);
 | 
			
		||||
        }
 | 
			
		||||
        if ("YYT001".equals(yeyaTaiCode)) {
 | 
			
		||||
            yeya.put("number", 1);
 | 
			
		||||
        }
 | 
			
		||||
        String yeyaJudgeStatus = JSON.toJSONString(yeya);
 | 
			
		||||
        //判断起点液压台是否在线且提升到位
 | 
			
		||||
        String yeyaStatus = null;
 | 
			
		||||
        try {
 | 
			
		||||
            yeyaStatus = HttpClient.httpPost("http://192.168.6.51:8009/yeya/isReadyForYeyaStatus", yeyaJudgeStatus);
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            logger.error(new Date() + "WCS接口超时未响应!");
 | 
			
		||||
        }
 | 
			
		||||
        //taskStatus==3满足条件,其他状态值说明液压台不满足开始任务的条件(无货物或者有货物但是没提升到位)
 | 
			
		||||
        if (Integer.parseInt(JSONObject.parseObject(yeyaStatus).get("taskStatus").toString()) != 1) {
 | 
			
		||||
            return R.failed("液压台" + yeyaTaiCode + "不满足任务执行所必须的条件,请检查液压台是否有货物且提升到位!");
 | 
			
		||||
        }
 | 
			
		||||
        //计算出路径最短的车辆id
 | 
			
		||||
        Long vehicleId = taskDistanceUtils.chooseVehicle(location.getCode(), yeyaTaiCode);
 | 
			
		||||
        if (vehicleId==0){
 | 
			
		||||
        if (vehicleId == 0) {
 | 
			
		||||
            return R.failed("两辆车都不在线,请检查后重试!");
 | 
			
		||||
        }
 | 
			
		||||
        //占用车辆
 | 
			
		||||
@@ -369,7 +381,7 @@ public class RunTaskUtils {
 | 
			
		||||
        vehicleInfo.setUpdateTime(LocalDateTime.now());
 | 
			
		||||
        vehicleInfoServiceBiz.updateById(vehicleInfo);
 | 
			
		||||
        //异步调用车辆
 | 
			
		||||
        asynRunTaskService.asynRunOutStock(locationId,yeyaTaiCode,vehicleInfo.getId());
 | 
			
		||||
        asynRunTaskService.asynRunOutStock(locationId, yeyaTaiCode, vehicleInfo.getId());
 | 
			
		||||
        // TODO: 2022/3/19
 | 
			
		||||
        System.out.println("操作成功,任务已开始执行。");
 | 
			
		||||
        return R.ok("操作成功,任务已开始执行。");
 | 
			
		||||
@@ -377,39 +389,41 @@ public class RunTaskUtils {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取变量值
 | 
			
		||||
     * @param nameSpace nameSpace前缀
 | 
			
		||||
     *
 | 
			
		||||
     * @param nameSpace    nameSpace前缀
 | 
			
		||||
     * @param variableName 变量名称
 | 
			
		||||
     * @return result字符串
 | 
			
		||||
     */
 | 
			
		||||
    private String readPlcToString(String nameSpace, String variableName){
 | 
			
		||||
        String identifier=nameSpace.concat(variableName);
 | 
			
		||||
    private String readPlcToString(String nameSpace, String variableName) {
 | 
			
		||||
        String identifier = nameSpace.concat(variableName);
 | 
			
		||||
        Map<String, Object> json = new HashMap();
 | 
			
		||||
        json.put("nameSpace", 6);
 | 
			
		||||
        json.put("plcName", "plc1");
 | 
			
		||||
        json.put("identifier",identifier);
 | 
			
		||||
        json.put("identifier", identifier);
 | 
			
		||||
        String result = null;
 | 
			
		||||
        try {
 | 
			
		||||
            result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            logger.info("readPLC: "+identifier+" 的值失败");
 | 
			
		||||
            logger.info("readPLC: " + identifier + " 的值失败");
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 判断液压台是否准备好放货
 | 
			
		||||
     *
 | 
			
		||||
     * @param platFormCode 液压台编码
 | 
			
		||||
     * @return 是/否
 | 
			
		||||
     */
 | 
			
		||||
    private Boolean platFormStatus(String platFormCode){
 | 
			
		||||
        String identifier=null;
 | 
			
		||||
        if ("YYT001".equals(platFormCode)){
 | 
			
		||||
            identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform4ToWCS.";
 | 
			
		||||
    private Boolean platFormStatus(String platFormCode) {
 | 
			
		||||
        String identifier = null;
 | 
			
		||||
        if ("YYT001".equals(platFormCode)) {
 | 
			
		||||
            identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform4ToWCS.";
 | 
			
		||||
            Map<String, Object> json = new HashMap();
 | 
			
		||||
            json.put("nameSpace", 6);
 | 
			
		||||
            json.put("plcName", "plc1");
 | 
			
		||||
            json.put("identifier",identifier+"Online");
 | 
			
		||||
            json.put("identifier", identifier + "Online");
 | 
			
		||||
            String result = null;
 | 
			
		||||
            try {
 | 
			
		||||
                result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
 | 
			
		||||
@@ -418,11 +432,11 @@ public class RunTaskUtils {
 | 
			
		||||
                logger.info("获取液压台1当前是否在线失败");
 | 
			
		||||
            }
 | 
			
		||||
            Boolean aBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
 | 
			
		||||
            if (aBoolean){
 | 
			
		||||
            if (aBoolean) {
 | 
			
		||||
                Map<String, Object> statusJson = new HashMap();
 | 
			
		||||
                statusJson.put("nameSpace", 6);
 | 
			
		||||
                statusJson.put("plcName", "plc1");
 | 
			
		||||
                statusJson.put("identifier",identifier+"TaskState");
 | 
			
		||||
                statusJson.put("identifier", identifier + "TaskState");
 | 
			
		||||
                String statusResult = null;
 | 
			
		||||
                try {
 | 
			
		||||
                    statusResult = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(statusJson));
 | 
			
		||||
@@ -431,21 +445,21 @@ public class RunTaskUtils {
 | 
			
		||||
                    logger.info("获取液压台1当前状态失败");
 | 
			
		||||
                }
 | 
			
		||||
                Integer status = Integer.valueOf(JSONObject.parseObject(statusResult).get("result").toString());
 | 
			
		||||
                if (status==1){
 | 
			
		||||
                if (status == 1) {
 | 
			
		||||
                    return true;
 | 
			
		||||
                }else {
 | 
			
		||||
                } else {
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
            }else {
 | 
			
		||||
            } else {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if ("YYT002".equals(platFormCode)){
 | 
			
		||||
            identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform3ToWCS.";
 | 
			
		||||
        if ("YYT002".equals(platFormCode)) {
 | 
			
		||||
            identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform3ToWCS.";
 | 
			
		||||
            Map<String, Object> json = new HashMap();
 | 
			
		||||
            json.put("nameSpace", 6);
 | 
			
		||||
            json.put("plcName", "plc1");
 | 
			
		||||
            json.put("identifier",identifier+"Online");
 | 
			
		||||
            json.put("identifier", identifier + "Online");
 | 
			
		||||
            String result = null;
 | 
			
		||||
            try {
 | 
			
		||||
                result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
 | 
			
		||||
@@ -454,11 +468,11 @@ public class RunTaskUtils {
 | 
			
		||||
                logger.info("获取液压台2当前是否在线失败");
 | 
			
		||||
            }
 | 
			
		||||
            Boolean aBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
 | 
			
		||||
            if (aBoolean){
 | 
			
		||||
            if (aBoolean) {
 | 
			
		||||
                Map<String, Object> statusJson = new HashMap();
 | 
			
		||||
                statusJson.put("nameSpace", 6);
 | 
			
		||||
                statusJson.put("plcName", "plc1");
 | 
			
		||||
                statusJson.put("identifier",identifier+"TaskState");
 | 
			
		||||
                statusJson.put("identifier", identifier + "TaskState");
 | 
			
		||||
                String statusResult = null;
 | 
			
		||||
                try {
 | 
			
		||||
                    statusResult = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(statusJson));
 | 
			
		||||
@@ -467,41 +481,124 @@ public class RunTaskUtils {
 | 
			
		||||
                    logger.info("获取液压台2当前状态失败");
 | 
			
		||||
                }
 | 
			
		||||
                Integer status = Integer.valueOf(JSONObject.parseObject(statusResult).get("result").toString());
 | 
			
		||||
                if (status==1){
 | 
			
		||||
                if (status == 1) {
 | 
			
		||||
                    return true;
 | 
			
		||||
                }else {
 | 
			
		||||
                } else {
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
            }else {
 | 
			
		||||
            } else {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 选择出库液压台;
 | 
			
		||||
     * 查询液压台1和液压台2是否为高位,都不为高位则选择液压台1
 | 
			
		||||
     */
 | 
			
		||||
    private Boolean platFormPosition(String platFormCode) {
 | 
			
		||||
        String identifier = null;
 | 
			
		||||
        if ("YYT001".equals(platFormCode)) {
 | 
			
		||||
            identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform4ToWCS.";
 | 
			
		||||
            Map<String, Object> json = new HashMap();
 | 
			
		||||
            json.put("nameSpace", 6);
 | 
			
		||||
            json.put("plcName", "plc1");
 | 
			
		||||
            json.put("identifier", identifier + "Online");
 | 
			
		||||
            String result = null;
 | 
			
		||||
            try {
 | 
			
		||||
                result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
 | 
			
		||||
            } catch (IOException e) {
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
                logger.info("获取液压台1当前是否在线失败");
 | 
			
		||||
            }
 | 
			
		||||
            Boolean aBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
 | 
			
		||||
            if (aBoolean) {
 | 
			
		||||
                Map<String, Object> statusJson = new HashMap();
 | 
			
		||||
                statusJson.put("nameSpace", 6);
 | 
			
		||||
                statusJson.put("plcName", "plc1");
 | 
			
		||||
                statusJson.put("identifier", identifier + "LifterPosition");
 | 
			
		||||
                String statusResult = null;
 | 
			
		||||
                try {
 | 
			
		||||
                    statusResult = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(statusJson));
 | 
			
		||||
                } catch (IOException e) {
 | 
			
		||||
                    e.printStackTrace();
 | 
			
		||||
                    logger.info("获取液压台1当前是否高位");
 | 
			
		||||
                }
 | 
			
		||||
                Integer status = Integer.valueOf(JSONObject.parseObject(statusResult).get("result").toString());
 | 
			
		||||
                if (status == 2) {
 | 
			
		||||
                    return true;
 | 
			
		||||
                } else {
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if ("YYT002".equals(platFormCode)) {
 | 
			
		||||
            identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform3ToWCS.";
 | 
			
		||||
            Map<String, Object> json = new HashMap();
 | 
			
		||||
            json.put("nameSpace", 6);
 | 
			
		||||
            json.put("plcName", "plc1");
 | 
			
		||||
            json.put("identifier", identifier + "Online");
 | 
			
		||||
            String result = null;
 | 
			
		||||
            try {
 | 
			
		||||
                result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
 | 
			
		||||
            } catch (IOException e) {
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
                logger.info("获取液压台2当前是否在线失败");
 | 
			
		||||
            }
 | 
			
		||||
            Boolean aBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
 | 
			
		||||
            if (aBoolean) {
 | 
			
		||||
                Map<String, Object> statusJson = new HashMap();
 | 
			
		||||
                statusJson.put("nameSpace", 6);
 | 
			
		||||
                statusJson.put("plcName", "plc1");
 | 
			
		||||
                statusJson.put("identifier", identifier + "LifterPosition");
 | 
			
		||||
                String statusResult = null;
 | 
			
		||||
                try {
 | 
			
		||||
                    statusResult = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(statusJson));
 | 
			
		||||
                } catch (IOException e) {
 | 
			
		||||
                    e.printStackTrace();
 | 
			
		||||
                    logger.info("获取液压台2当前是否高位失败");
 | 
			
		||||
                }
 | 
			
		||||
                Integer status = Integer.valueOf(JSONObject.parseObject(statusResult).get("result").toString());
 | 
			
		||||
                if (status == 2) {
 | 
			
		||||
                    return true;
 | 
			
		||||
                } else {
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 车辆是否在线
 | 
			
		||||
     *
 | 
			
		||||
     * @param vehicleId 车辆id
 | 
			
		||||
     * @return true/false
 | 
			
		||||
     * @throws IOException  plc访问失败
 | 
			
		||||
     * @throws IOException plc访问失败
 | 
			
		||||
     */
 | 
			
		||||
    private Boolean rgvOnline(Long vehicleId) throws IOException {
 | 
			
		||||
        String identifier=null;
 | 
			
		||||
        if (vehicleId==1){
 | 
			
		||||
            identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Online";
 | 
			
		||||
        String identifier = null;
 | 
			
		||||
        if (vehicleId == 1) {
 | 
			
		||||
            identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Online";
 | 
			
		||||
        }
 | 
			
		||||
        if (vehicleId==2){
 | 
			
		||||
            identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Online";
 | 
			
		||||
        if (vehicleId == 2) {
 | 
			
		||||
            identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Online";
 | 
			
		||||
        }
 | 
			
		||||
        Map<String, Object> json = new HashMap();
 | 
			
		||||
        json.put("nameSpace", 6);
 | 
			
		||||
        json.put("plcName", "plc1");
 | 
			
		||||
        json.put("identifier",identifier);
 | 
			
		||||
        json.put("identifier", identifier);
 | 
			
		||||
        String result = null;
 | 
			
		||||
        try {
 | 
			
		||||
            result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            logger.info("获取车辆"+vehicleId+"当前是否在线失败");
 | 
			
		||||
            logger.info("获取车辆" + vehicleId + "当前是否在线失败");
 | 
			
		||||
        }
 | 
			
		||||
        Boolean online = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
 | 
			
		||||
        return online;
 | 
			
		||||
@@ -509,28 +606,29 @@ public class RunTaskUtils {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 车辆是否空闲
 | 
			
		||||
     *
 | 
			
		||||
     * @param vehicleId 车辆id
 | 
			
		||||
     * @return true/false
 | 
			
		||||
     * @throws IOException  plc访问失败
 | 
			
		||||
     * @throws IOException plc访问失败
 | 
			
		||||
     */
 | 
			
		||||
    private Boolean rgvFree(Long vehicleId) throws IOException {
 | 
			
		||||
        String identifier=null;
 | 
			
		||||
        if (vehicleId==1){
 | 
			
		||||
            identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Free";
 | 
			
		||||
        String identifier = null;
 | 
			
		||||
        if (vehicleId == 1) {
 | 
			
		||||
            identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV1ToWCS.Free";
 | 
			
		||||
        }
 | 
			
		||||
        if (vehicleId==2){
 | 
			
		||||
            identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Free";
 | 
			
		||||
        if (vehicleId == 2) {
 | 
			
		||||
            identifier = "S7-1200 station_2.Boutique.DB500_PLCToWCS.RGV2ToWCS.Free";
 | 
			
		||||
        }
 | 
			
		||||
        Map<String, Object> json = new HashMap();
 | 
			
		||||
        json.put("nameSpace", 6);
 | 
			
		||||
        json.put("plcName", "plc1");
 | 
			
		||||
        json.put("identifier",identifier);
 | 
			
		||||
        json.put("identifier", identifier);
 | 
			
		||||
        String result = null;
 | 
			
		||||
        try {
 | 
			
		||||
            result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            logger.info("获取车辆"+vehicleId+"当前是否空闲失败");
 | 
			
		||||
            logger.info("获取车辆" + vehicleId + "当前是否空闲失败");
 | 
			
		||||
        }
 | 
			
		||||
        Boolean free = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
 | 
			
		||||
        return free;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user