| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wcs.common.ExecuteSupport; |
| | | import com.zy.asrs.wcs.core.action.LiftAction; |
| | |
| | | import com.zy.asrs.wcs.core.utils.*; |
| | | import com.zy.asrs.wcs.rcs.News; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | |
| | | import com.zy.asrs.wcs.rcs.thread.DevpThread; |
| | | import com.zy.asrs.wcs.rcs.thread.LiftThread; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | import com.zy.asrs.wcs.system.entity.Dict; |
| | | import com.zy.asrs.wcs.system.service.DictService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private ShuttleDispatcher shuttleDispatcher; |
| | | @Autowired |
| | | private NavigateUtils navigateUtils; |
| | | @Autowired |
| | | private DictService dictService; |
| | | |
| | | // 计算 |
| | | public Boolean accept(Motion motion) { |
| | |
| | | } |
| | | shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); |
| | | shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE; |
| | | |
| | | if (!checkSimilarityPath(motion, assignCommand)) { |
| | | return false; |
| | | } |
| | | |
| | | break; |
| | | case SHUTTLE_TRANSPORT://穿梭车载货行走 |
| | | // 如果已经在当前条码则过滤 |
| | |
| | | } |
| | | shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); |
| | | shuttleTaskModeType = ShuttleTaskModeType.TRANSPORT; |
| | | |
| | | if (!checkSimilarityPath(motion, assignCommand)) { |
| | | return false; |
| | | } |
| | | |
| | | if (motion.getReleaseLift() == 2) {//执行中释放提升机 |
| | | task.setLiftNo(0); |
| | |
| | | } |
| | | shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); |
| | | shuttleTaskModeType = ShuttleTaskModeType.TRANSPORT_TO_CONVEYOR; |
| | | |
| | | if (!checkSimilarityPath(motion, assignCommand)) { |
| | | return false; |
| | | } |
| | | |
| | | break; |
| | | case SHUTTLE_MOVE_LIFT_PALLET://穿梭车顶升并移动 |
| | | shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); |
| | | shuttleTaskModeType = ShuttleTaskModeType.MOVE_PALLET_LIFT; |
| | | |
| | | if (!checkSimilarityPath(motion, assignCommand)) { |
| | | return false; |
| | | } |
| | | |
| | | shuttleCommands.add(0, shuttleThread.getLiftCommand(motion.getTaskNo(), true)); |
| | | break; |
| | | case SHUTTLE_MOVE_DOWN_PALLET://穿梭车移动并托盘下降 |
| | | shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); |
| | | shuttleTaskModeType = ShuttleTaskModeType.MOVE_PALLET_DOWN; |
| | | |
| | | if (!checkSimilarityPath(motion, assignCommand)) { |
| | | return false; |
| | | } |
| | | |
| | | shuttleCommands.add(shuttleCommands.size(), shuttleThread.getLiftCommand(motion.getTaskNo(), false)); |
| | | break; |
| | | case SHUTTLE_MOVE_FROM_LIFT://出提升机 |
| | |
| | | return commands; |
| | | } |
| | | |
| | | private boolean checkSimilarityPath(Motion motion, ShuttleAssignCommand assignCommand) { |
| | | String movePath = motion.getMovePath(); |
| | | if (Cools.isEmpty(movePath)) { |
| | | return false; |
| | | } |
| | | |
| | | Double similarityRef = 0.9D; |
| | | Dict similarityRefDict = dictService.getOne(new LambdaQueryWrapper<Dict>() |
| | | .eq(Dict::getFlag, "similarityRef") |
| | | .eq(Dict::getStatus, 1)); |
| | | if (similarityRefDict != null) { |
| | | similarityRef = Double.parseDouble(similarityRefDict.getValue()); |
| | | } |
| | | |
| | | List<NavigateNode> originPath = JSON.parseArray(movePath, NavigateNode.class); |
| | | List<NavigateNode> finalPath = assignCommand.getNodes(); |
| | | |
| | | if (finalPath == null) { |
| | | return false; |
| | | } |
| | | |
| | | Double similarity = navigateUtils.similarityPath(originPath, finalPath); |
| | | if (similarity <= similarityRef) { |
| | | Object object = redisUtil.get(DeviceRedisConstant.SIMILARITY_TIMES + motion.getTaskNo()); |
| | | if (object == null) { |
| | | redisUtil.set(DeviceRedisConstant.SIMILARITY_TIMES + motion.getTaskNo(), System.currentTimeMillis(), 60 * 60 * 24); |
| | | }else { |
| | | long similarityTimeoutRef = 20L;//默认超时20s |
| | | Dict similarityTimeoutDict = dictService.getOne(new LambdaQueryWrapper<Dict>() |
| | | .eq(Dict::getFlag, "similarityTimeout") |
| | | .eq(Dict::getStatus, 1)); |
| | | if (similarityTimeoutDict != null) { |
| | | similarityTimeoutRef = Long.parseLong(similarityTimeoutDict.getValue()); |
| | | } |
| | | |
| | | long recordTime = Long.parseLong(object.toString()); |
| | | if (System.currentTimeMillis() - recordTime > (60 * similarityTimeoutRef)) { |
| | | //超时,直接放行 |
| | | return true; |
| | | } |
| | | } |
| | | News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget()); |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | } |