| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.wcs.common.ExecuteSupport; |
| | | import com.zy.asrs.wcs.core.entity.BasShuttle; |
| | | import com.zy.asrs.wcs.core.entity.Loc; |
| | | import com.zy.asrs.wcs.core.entity.Task; |
| | |
| | | import com.zy.asrs.wcs.core.model.command.ShuttleCommand; |
| | | import com.zy.asrs.wcs.core.model.command.ShuttleRedisCommand; |
| | | import com.zy.asrs.wcs.core.model.enums.ShuttleCommandModeType; |
| | | import com.zy.asrs.wcs.core.model.enums.ShuttleTaskModeType; |
| | | import com.zy.asrs.wcs.core.service.BasShuttleService; |
| | | import com.zy.asrs.wcs.core.service.LocService; |
| | | import com.zy.asrs.wcs.core.utils.NavigateMapUtils; |
| | |
| | | redisCommand.setAssignCommand(assignCommand);//命令 |
| | | //任务数据保存到redis |
| | | if (redisUtil.set(DeviceRedisConstant.SHUTTLE_WORK_FLAG + assignCommand.getTaskNo(), JSON.toJSONString(redisCommand))) { |
| | | //下发行驶路径 |
| | | boolean result = shuttleThread.movePath(assignCommand.getNodes(), assignCommand.getTaskNo().intValue()); |
| | | if (!result) { |
| | | return false; |
| | | if (assignCommand.getTaskMode() == ShuttleTaskModeType.PAK_IN.id |
| | | || assignCommand.getTaskMode() == ShuttleTaskModeType.PAK_OUT.id |
| | | || assignCommand.getTaskMode() == ShuttleTaskModeType.MOVE_LOC_NO.id |
| | | || assignCommand.getTaskMode() == ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO.id) { |
| | | //下发行驶路径 |
| | | boolean result = shuttleThread.movePath(assignCommand.getNodes(), assignCommand.getTaskNo()); |
| | | if (!result) { |
| | | return false; |
| | | } |
| | | } |
| | | shuttleProtocol.setTaskNo(assignCommand.getTaskNo().intValue()); |
| | | shuttleProtocol.setTaskNo(assignCommand.getTaskNo()); |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | if (obj == null) { |
| | | return false; |
| | | } |
| | | ShuttleRedisCommand redisCommand = JSON.parseObject(obj.toString(), ShuttleRedisCommand.class); |
| | | |
| | | JSONObject jsonObject = JSON.parseObject(String.valueOf(obj)); |
| | | System.out.println(JSON.parseObject(String.valueOf(obj))); |
| | | ShuttleRedisCommand redisCommand = JSON.parseObject(String.valueOf(obj), ShuttleRedisCommand.class); |
| | | System.out.println(JSON.toJSONString(redisCommand)); |
| | | if (redisCommand == null) { |
| | | return false; |
| | | } |
| | |
| | | } |
| | | |
| | | //判断设备是否空闲 |
| | | if (!shuttleThread.isIdle()) { |
| | | if (!shuttleThread.isIdle(() -> { |
| | | return shuttleProtocol.getTaskNo().equals(taskNo); |
| | | })) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | |
| | | // 系统任务 |
| | | if (assignCommand.getAuto()) { |
| | | if (!assignCommand.getCharge()) { |
| | | //对主线程抛出等待确认状态waiting |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.WAITING); |
| | | }else { |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.CHARGING_WAITING); |
| | | } |
| | | // if (!assignCommand.getCharge()) { |
| | | // //对主线程抛出等待确认状态waiting |
| | | // shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.WAITING); |
| | | // }else { |
| | | // shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.CHARGING_WAITING); |
| | | // } |
| | | News.info("四向穿梭车任务执行下发完成等待执行结束,穿梭车号={},任务数据={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); |
| | | |
| | | // 手动任务 |
| | |
| | | return false; |
| | | } |
| | | |
| | | commandStep++; |
| | | //更新redis数据 |
| | | redisCommand.setCommandStep(commandStep); |
| | | //任务数据保存到redis |
| | | redisUtil.set(DeviceRedisConstant.SHUTTLE_WORK_FLAG + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); |
| | | return true; |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | //小车空闲且有跑库程序 |
| | | if (!(shuttleThread.isIdle() && shuttleProtocol.getMoveLoc())) { |
| | | //小车开启跑库模式 |
| | | if (!shuttleProtocol.getMoveLoc()) { |
| | | return; |
| | | } |
| | | |
| | | //小车空闲 |
| | | if (!shuttleThread.isIdle()) { |
| | | return; |
| | | } |
| | | |
| | |
| | | return result; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String s = "{\"commandStep\":0,\"liftSecurityMk\":false,\"shuttleNo\":6,\"wrkNo\":30095,\"assignCommand\":{\"sourceLocNo\":\"3-1-1\",\"auto\":true,\"shuttleNo\":6,\"taskMode\":19,\"charge\":false,\"nodes\":[{\"isInflectionPoint\":false,\"f\":0,\"g\":0,\"h\":0,\"x\":3,\"y\":1,\"nodeZ\":1,\"z\":1,\"direction\":\"top\"},{\"isInflectionPoint\":false,\"f\":1,\"g\":0,\"h\":1,\"x\":2,\"y\":1,\"nodeZ\":1,\"z\":1},{\"isInflectionPoint\":false,\"f\":1,\"g\":1,\"h\":0,\"x\":1,\"y\":1,\"nodeZ\":1,\"z\":1}],\"locNo\":\"1-1-1\",\"taskNo\":30095,\"deviceId\":6,\"commands\":[{\"mode\":1,\"targetLocNo\":\"1-1-1\",\"shuttleNo\":78,\"nodes\":[{\"isInflectionPoint\":false,\"moveDistance\":1000,\"f\":0,\"g\":0,\"h\":0,\"x\":3,\"y\":1,\"nodeZ\":1,\"z\":1,\"direction\":\"top\"},{\"isInflectionPoint\":false,\"moveDistance\":1000,\"f\":1,\"g\":0,\"h\":1,\"x\":2,\"y\":1,\"nodeZ\":1,\"z\":1,\"direction\":\"top\"},{\"isInflectionPoint\":false,\"moveDistance\":1000,\"f\":1,\"g\":1,\"h\":0,\"x\":1,\"y\":1,\"nodeZ\":1,\"z\":1,\"direction\":\"top\"}],\"taskNo\":0,\"body\":\"{\\\"messageName\\\":\\\"runOrder\\\",\\\"nodeX\\\":1,\\\"nodeY\\\":1,\\\"msgTime\\\":\\\"2024-04-12 17:39:16\\\",\\\"nodeZ\\\":1,\\\"deviceNo\\\":78,\\\"taskId\\\":5}\",\"complete\":false}]}}"; |
| | | ShuttleRedisCommand shuttleRedisCommand = JSON.parseObject(s, ShuttleRedisCommand.class); |
| | | System.out.println(shuttleRedisCommand); |
| | | } |
| | | |
| | | } |