| | |
| | | package com.zy.asrs.wcs.core.action; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.wcs.core.entity.Task; |
| | | import com.zy.asrs.wcs.core.model.command.*; |
| | | import com.zy.asrs.wcs.core.model.enums.LiftCommandModeType; |
| | | import com.zy.asrs.wcs.core.service.TaskService; |
| | | import com.zy.asrs.wcs.core.utils.RedisUtil; |
| | | import com.zy.asrs.wcs.rcs.News; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | |
| | | public synchronized boolean assignWork(Device device, LiftAssignCommand assignCommand) { |
| | | LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue()); |
| | |
| | | public synchronized boolean executeWork(Device device, Integer taskNo) { |
| | | Object obj = redisUtil.get(DeviceRedisConstant.LIFT_WORK_FLAG + taskNo); |
| | | if (obj == null) { |
| | | return false; |
| | | } |
| | | |
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, taskNo)); |
| | | if (task == null) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | if (liftProtocol.getLev() == command.getTargetLev()) { |
| | | command.setComplete(true); |
| | | } |
| | | |
| | | if (task.getTaskSts() < 100) {//入库判断托盘是否进入提升机 |
| | | if (!liftProtocol.getHasTray()) { |
| | | return false; |
| | | } |
| | | } else if (task.getTaskSts() >= 100 && task.getTaskSts() < 200) {//出库判断托盘是否离开提升机 |
| | | if (liftProtocol.getHasTray()) { |
| | | return false; |
| | | } |
| | | } |
| | | } else if (command.getMode() == LiftCommandModeType.RESET.id) { |
| | | //复位 |
| | | command.setComplete(true); |
| | | } else if (command.getMode() == LiftCommandModeType.LOCK.id) { |
| | | //复位 |
| | | command.setComplete(true); |
| | | } else if (command.getMode() == LiftCommandModeType.UNLOCK.id) { |
| | | //复位 |
| | | command.setComplete(true); |
| | | } |
| | | |
| | | // 更新redis数据 |
| | |
| | | |
| | | //对主线程抛出等待确认状态waiting |
| | | liftThread.setProtocolStatus(LiftProtocolStatusType.WAITING); |
| | | liftThread.commandFinished(taskNo);//调用完成后续指令(部分提升机有后续指令,实际情况看是否有真正实现方法) |
| | | redisUtil.del(DeviceRedisConstant.LIFT_WORK_FLAG + taskNo); |
| | | return false;//禁止再下发命令 |
| | | } |