| | |
| | | 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); |
| | |
| | | //同步 1: 是 0: 否 |
| | | private Integer sync; |
| | | |
| | | //执行完成后是否释放提升机,默认不释放 1: 释放 0: 不释放 |
| | | private Integer releaseLift; |
| | | |
| | | public static MotionDto build(BuildSupport<MotionDto> support) { |
| | | MotionDto dto = new MotionDto(); |
| | | |
| | |
| | | private Integer sync; |
| | | |
| | | /** |
| | | * 执行完成后是否释放提升机,默认不释放 1: 释放 0: 不释放 |
| | | */ |
| | | @ApiModelProperty(value= "执行完成后是否释放提升机,默认不释放 1: 释放 0: 不释放") |
| | | private Integer releaseLift; |
| | | |
| | | /** |
| | | * 任务类型 |
| | | */ |
| | | @ApiModelProperty(value= "任务类型") |
| | |
| | | private Integer sync; |
| | | |
| | | /** |
| | | * 执行完成后是否释放提升机,默认不释放 1: 释放 0: 不释放 |
| | | */ |
| | | @ApiModelProperty(value= "执行完成后是否释放提升机,默认不释放 1: 释放 0: 不释放") |
| | | private Integer releaseLift; |
| | | |
| | | /** |
| | | * 任务类型 |
| | | */ |
| | | @ApiModelProperty(value= "任务类型") |
| | |
| | | return motionList; |
| | | } |
| | | |
| | | //检测提升机是否有任务绑定 |
| | | boolean liftResult = Utils.checkLiftHasBinding(Integer.parseInt(transferLiftDevice.getDeviceNo())); |
| | | if (liftResult) { |
| | | //存在任务,禁止解析 |
| | | return motionList; |
| | | } |
| | | |
| | | //获取小车待机库位 ==> 进提升机 |
| | | ShuttleStandby shuttleStandbyTo = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>() |
| | | .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId()) |
| | |
| | | })), |
| | | MotionDto.build((dto -> { |
| | | dto.setShuttleNo(shuttleDevice.getId().intValue()); |
| | | dto.setLiftNo(transferLiftDevice.getId().intValue()); |
| | | dto.setLocNo(standbyLocNoTo); |
| | | })), |
| | | MotionCtgType.SHUTTLE_MOVE |
| | |
| | | null |
| | | , MotionDto.build((dto -> { |
| | | dto.setLiftNo(transferLiftDevice.getId().intValue()); |
| | | dto.setReleaseLift(1);//执行完成后释放提升机 |
| | | })) |
| | | )); |
| | | |
| | |
| | | null |
| | | , MotionDto.build((dto -> { |
| | | dto.setLiftNo(transferLiftDevice.getId().intValue()); |
| | | dto.setReleaseLift(1);//执行完成后释放提升机 |
| | | })) |
| | | )); |
| | | |
| | |
| | | //检测穿梭车是否有任务绑定 |
| | | boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo()); |
| | | if (shuttleResult) { |
| | | //存在任务,禁止解析 |
| | | return motionList; |
| | | } |
| | | |
| | | //检测提升机是否有任务绑定 |
| | | boolean liftResult = Utils.checkLiftHasBinding(Integer.parseInt(transferLiftDevice.getDeviceNo())); |
| | | if (liftResult) { |
| | | //存在任务,禁止解析 |
| | | return motionList; |
| | | } |
| | |
| | | dto.setLev(5);//索牌项目5层是输送线层 |
| | | dto.setStaNo(1);//提升机左侧 |
| | | dto.setSync(0);//异步执行 |
| | | dto.setReleaseLift(1);//执行完成后释放提升机 |
| | | })) |
| | | )); |
| | | |
| | |
| | | null |
| | | , MotionDto.build((dto -> { |
| | | dto.setLiftNo(transferLiftDevice.getId().intValue()); |
| | | dto.setReleaseLift(1);//执行完成后释放提升机 |
| | | })) |
| | | )); |
| | | |
| | |
| | | //检测穿梭车是否有任务绑定 |
| | | boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo()); |
| | | if (shuttleResult) { |
| | | //存在任务,禁止解析 |
| | | return motionList; |
| | | } |
| | | |
| | | //检测提升机是否有任务绑定 |
| | | boolean liftResult = Utils.checkLiftHasBinding(Integer.parseInt(transferLiftDevice.getDeviceNo())); |
| | | if (liftResult) { |
| | | //存在任务,禁止解析 |
| | | return motionList; |
| | | } |
| | |
| | | motion.setOrigin(String.valueOf(liftDispatcher.getLiftLevOffset(target.getLiftNo(), origin.getLev()))); |
| | | } |
| | | motion.setTarget(String.valueOf(liftDispatcher.getLiftLevOffset(target.getLiftNo(), target.getLev()))); |
| | | })); |
| | | |
| | | // if (target.getUpdateLiftNo() != null && target.getWrkNo() != null) { |
| | | // if (target.getUpdateLiftNo()) { |
| | | // |
| | | // } |
| | | // } |
| | | if (target.getSync() != null) { |
| | | motion.setSync(target.getSync()); |
| | | } |
| | | |
| | | if (target.getReleaseLift() != null) { |
| | | motion.setReleaseLift(target.getReleaseLift()); |
| | | } |
| | | })); |
| | | |
| | | return motionList; |
| | | } |
| | |
| | | |
| | | if (target.getSync() != null) { |
| | | motion.setSync(target.getSync()); |
| | | } |
| | | |
| | | if (target.getReleaseLift() != null) { |
| | | motion.setReleaseLift(target.getReleaseLift()); |
| | | } |
| | | })); |
| | | |
| | |
| | | motion.setDeviceCtg(DeviceCtgType.LIFT.val()); |
| | | motion.setDevice(String.valueOf(target.getLiftNo())); |
| | | motion.setMotionCtg(MotionCtgType.LIFT_LOCK.val()); |
| | | |
| | | if (target.getSync() != null) { |
| | | motion.setSync(target.getSync()); |
| | | } |
| | | |
| | | if (target.getReleaseLift() != null) { |
| | | motion.setReleaseLift(target.getReleaseLift()); |
| | | } |
| | | })); |
| | | |
| | | return motionList; |
| | |
| | | motion.setDeviceCtg(DeviceCtgType.LIFT.val()); |
| | | motion.setDevice(String.valueOf(target.getLiftNo())); |
| | | motion.setMotionCtg(MotionCtgType.LIFT_UNLOCK.val()); |
| | | |
| | | if (target.getSync() != null) { |
| | | motion.setSync(target.getSync()); |
| | | } |
| | | |
| | | if (target.getReleaseLift() != null) { |
| | | motion.setReleaseLift(target.getReleaseLift()); |
| | | } |
| | | })); |
| | | |
| | | return motionList; |
| | |
| | | import com.zy.asrs.wcs.core.utils.ConveyorDispatcher; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.StaProtocol; |
| | | import com.zy.asrs.wcs.rcs.thread.DevpThread; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | case CONVEYOR_INBOUND_TO_LIFT://输送线入库至提升机 |
| | | break; |
| | | case CONVEYOR_OUTBOUND://输送线出库 |
| | | StaProtocol staProtocol = devpThread.getStation().get(Integer.parseInt(motion.getOrigin())); |
| | | if (!(staProtocol.isAutoing() && staProtocol.isLoading())) { |
| | | return false; |
| | | } |
| | | |
| | | boolean result = devpThread.writeWorkSta(Integer.parseInt(motion.getOrigin()), motion.getTaskNo().shortValue(), Short.parseShort(motion.getTarget())); |
| | | if (!result) { |
| | | return false; |
| | |
| | | import com.zy.asrs.wcs.core.model.enums.MotionStsType; |
| | | import com.zy.asrs.wcs.core.service.MotionService; |
| | | import com.zy.asrs.wcs.core.service.TaskService; |
| | | import com.zy.asrs.wcs.core.utils.Utils; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | |
| | | return false; |
| | | } |
| | | |
| | | //检测提升机是否有任务绑定 |
| | | boolean liftResult = Utils.checkLiftHasBinding(deviceNo, String.valueOf(motion.getTaskNo())); |
| | | if (liftResult) { |
| | | //存在任务,禁止执行 |
| | | return false; |
| | | } |
| | | |
| | | //每次执行提升机指令都绑定提升机 |
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, motion.getTaskNo())); |
| | | if (task == null) { |
| | | return false; |
| | |
| | | return false; |
| | | } |
| | | |
| | | if (motion.getReleaseLift() == 1) {//释放提升机 |
| | | task.setLiftNo(null); |
| | | task.setUpdateTime(new Date()); |
| | | if (!taskService.updateById(task)) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | break; |
| | | case LIFT_WITH_GOODS: |
| | | // 判断提升机是否空闲 |
| | |
| | | } |
| | | } |
| | | |
| | | if (motion.getReleaseLift() == 1) {//释放提升机 |
| | | task.setLiftNo(null); |
| | | task.setUpdateTime(new Date()); |
| | | if (!taskService.updateById(task)) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | break; |
| | | case LIFT_WITH_SHUTTLE: |
| | |
| | | if (liftThread.isLock(null)) { |
| | | return false; |
| | | } |
| | | |
| | | if (motion.getReleaseLift() == 1) {//释放提升机 |
| | | task.setLiftNo(null); |
| | | task.setUpdateTime(new Date()); |
| | | if (!taskService.updateById(task)) { |
| | | return false; |
| | | } |
| | | } |
| | | break; |
| | | case LIFT_SHUTTLE_ARRIVAL: |
| | | |
| | |
| | | |
| | | List<Task> selectWorkingByShuttle(Integer shuttleNo, String taskNo); |
| | | |
| | | List<Task> selectWorkingByLift(Integer liftNo); |
| | | List<Task> selectWorkingByLift(Integer liftNo, String taskNo); |
| | | |
| | | Task selectChargeWorking(Integer shuttleNo); |
| | | |
| | |
| | | |
| | | List<Task> selectWorkingByShuttle(Integer shuttleNo, String taskNo); |
| | | |
| | | List<Task> selectWorkingByLift(Integer liftNo); |
| | | List<Task> selectWorkingByLift(Integer liftNo, String taskNo); |
| | | |
| | | Task selectChargeWorking(Integer shuttleNo); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Task> selectWorkingByLift(Integer liftNo) { |
| | | return this.baseMapper.selectWorkingByLift(liftNo); |
| | | public List<Task> selectWorkingByLift(Integer liftNo, String taskNo) { |
| | | return this.baseMapper.selectWorkingByLift(liftNo, taskNo); |
| | | } |
| | | |
| | | @Override |
| | |
| | | * 检测提升机是否有任务绑定 |
| | | */ |
| | | public static boolean checkLiftHasBinding(Integer liftNo) { |
| | | return checkLiftHasBinding(liftNo, null); |
| | | } |
| | | |
| | | /** |
| | | * 检测提升机是否有任务绑定 |
| | | */ |
| | | public static boolean checkLiftHasBinding(Integer liftNo, String taskNo) { |
| | | TaskService taskService = SpringUtils.getBean(TaskService.class); |
| | | List<Task> tasks = taskService.selectWorkingByLift(liftNo); |
| | | List<Task> tasks = taskService.selectWorkingByLift(liftNo, taskNo); |
| | | if (tasks.isEmpty()) { |
| | | return false;//无任务绑定 |
| | | } |
| | |
| | | select * from wcs_task |
| | | where task_sts in (1,2,3,101,102,103,301,302,303,401,402,403) |
| | | and lift_no = #{liftNo} |
| | | <if test="taskNo!=null"> |
| | | and task_no != #{taskNo} |
| | | </if> |
| | | order by priority desc,start_time,task_no asc |
| | | </select> |
| | | |