| | |
| | | package com.zy.asrs.wcs.core.action; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.wcs.core.entity.BasShuttle; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.zy.asrs.wcs.core.entity.Loc; |
| | | import com.zy.asrs.wcs.core.entity.Task; |
| | | import com.zy.asrs.wcs.core.model.NavigateNode; |
| | |
| | | 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; |
| | |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | import org.aspectj.apache.bcel.generic.RET; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | private LocService locService; |
| | | @Autowired |
| | | private ShuttleDispatcher shuttleDispatcher; |
| | | @Autowired |
| | | private ObjectMapper objectMapper; |
| | | |
| | | public synchronized boolean assignWork(Device device, ShuttleAssignCommand assignCommand) { |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); |
| | |
| | | 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.setSyncTaskNo(assignCommand.getTaskNo()); |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | if (obj == null) { |
| | | return false; |
| | | } |
| | | ShuttleRedisCommand redisCommand = JSON.parseObject(obj.toString(), ShuttleRedisCommand.class); |
| | | |
| | | ShuttleRedisCommand redisCommand = null; |
| | | try { |
| | | redisCommand = objectMapper.readValue(String.valueOf(obj), ShuttleRedisCommand.class); |
| | | } catch (JsonProcessingException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | if (redisCommand == null) { |
| | | return false; |
| | | } |
| | |
| | | } |
| | | |
| | | //判断设备是否空闲 |
| | | if (!shuttleThread.isIdle()) { |
| | | if (!shuttleThread.isDeviceIdle()) { |
| | | return false; |
| | | } |
| | | // if (!shuttleThread.isIdle(() -> { |
| | | // return shuttleProtocol.getTaskNo().equals(taskNo); |
| | | // })) { |
| | | // return false; |
| | | // } |
| | | |
| | | //判断工作号是否相同 |
| | | if (!shuttleProtocol.getTaskNo().equals(taskNo)) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | // 托盘顶升 |
| | | //判断是否顶升到位 |
| | | if (shuttleProtocol.getHasLift()) { |
| | | //判断是否有物 |
| | | if (shuttleProtocol.getHasPallet()) { |
| | | command.setComplete(true); |
| | | } |
| | | command.setComplete(true); |
| | | // //判断是否有物 |
| | | // if (shuttleProtocol.getHasPallet()) { |
| | | // command.setComplete(true); |
| | | // } |
| | | } |
| | | } else if (command.getMode() == ShuttleCommandModeType.PALLET_DOWN.id) { |
| | | // 托盘下降命令 |
| | |
| | | //手动模式不抛出等待状态,直接复位空闲状态 |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); |
| | | //任务号清零 |
| | | shuttleProtocol.setTaskNo(0); |
| | | shuttleProtocol.setSyncTaskNo(0); |
| | | //标记复位 |
| | | shuttleProtocol.setPakMk(true); |
| | | News.info("四向穿梭车手动任务执行完成,穿梭车号={},任务数据={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); |
| | |
| | | return false; |
| | | } |
| | | |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.WORKING); |
| | | commandStep++; |
| | | //更新redis数据 |
| | | redisCommand.setCommandStep(commandStep); |
| | | //任务数据保存到redis |
| | | redisUtil.set(DeviceRedisConstant.SHUTTLE_WORK_FLAG + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); |
| | | return true; |
| | | } |
| | | |