| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean matchCandidate(StoreInTaskContext context) { |
| | | return canRequestStoreIn(context.getStationProtocol()); |
| | | } |
| | | |
| | | @Override |
| | | public boolean beforeApply(StoreInTaskContext context) { |
| | | StationProtocol stationProtocol = context.getStationProtocol(); |
| | | if (stationProtocol.getError() <= 0) { |
| | | return true; |
| | | } |
| | | |
| | | Object lock = redisUtil.get(RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getStationId()); |
| | | if (lock != null) { |
| | | return false; |
| | | } |
| | | |
| | | StationObjModel backStation = context.getStationObjModel().getBackStation(); |
| | | StationCommand command = context.getStationThread().getCommand(StationCommandType.MOVE, |
| | | commonService.getWorkNo(WrkIoType.STATION_BACK.id), |
| | | context.getStationObjModel().getStationId(), |
| | | backStation.getStationId(), 0); |
| | | if (command == null) { |
| | | News.taskInfo(stationProtocol.getTaskNo(), "{}工作,获取输送线命令失败", stationProtocol.getTaskNo()); |
| | | return false; |
| | | } |
| | | stationCommandDispatcher.dispatch(context.getBasDevp().getDevpNo(), command, "gsl-process", "station-back"); |
| | | News.taskInfo(stationProtocol.getTaskNo(), "{}扫码异常,已退回至{}", backStation.getStationId()); |
| | | redisUtil.set(RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getStationId(), "lock", 10); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public InTaskApplyRequest buildApplyRequest(StoreInTaskContext context) { |
| | | InTaskApplyRequest request = StoreInTaskPolicy.super.buildApplyRequest(context); |
| | | request.getExtraParams().put("weight", context.getStationProtocol().getWeight()); |
| | |
| | | if (!stationMap.containsKey(stationId)) { |
| | | continue; |
| | | } |
| | | if (!handleErrorStationBack(basDevp, stationThread, stationObjModel, stationMap.get(stationId))) { |
| | | continue; |
| | | } |
| | | if (!canRequestStoreIn(stationMap.get(stationId))) { |
| | | continue; |
| | | } |
| | |
| | | |
| | | private boolean canRequestStoreIn(StationProtocol stationProtocol) { |
| | | return stationProtocol != null |
| | | && stationProtocol.getError() <= 0 |
| | | && stationProtocol.isAutoing() |
| | | && stationProtocol.isLoading() |
| | | && stationProtocol.isInEnable() |
| | |
| | | && !Cools.isEmpty(stationProtocol.getBarcode()); |
| | | } |
| | | |
| | | private boolean handleErrorStationBack(BasDevp basDevp, |
| | | StationThread stationThread, |
| | | StationObjModel stationObjModel, |
| | | StationProtocol stationProtocol) { |
| | | if (!stationProtocol.isAutoing()) { |
| | | return false; |
| | | } |
| | | |
| | | if (!stationProtocol.isLoading()) { |
| | | return false; |
| | | } |
| | | |
| | | if (stationProtocol.getError() <= 0) { |
| | | return true; |
| | | } |
| | | |
| | | Object lock = redisUtil.get(RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getStationId()); |
| | | if (lock != null) { |
| | | return false; |
| | | } |
| | | |
| | | StationObjModel backStation = stationObjModel.getBackStation(); |
| | | StationCommand command = stationThread.getCommand(StationCommandType.MOVE, |
| | | commonService.getWorkNo(WrkIoType.STATION_BACK.id), |
| | | stationObjModel.getStationId(), |
| | | backStation.getStationId(), 0); |
| | | if (command == null) { |
| | | News.taskInfo(stationProtocol.getTaskNo(), "{}工作,获取输送线命令失败", stationProtocol.getTaskNo()); |
| | | return false; |
| | | } |
| | | stationCommandDispatcher.dispatch(basDevp.getDevpNo(), command, "gsl-process", "station-back"); |
| | | News.taskInfo(stationProtocol.getTaskNo(), "{}扫码异常,已退回至{}", backStation.getStationId()); |
| | | redisUtil.set(RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getStationId(), "lock", 10); |
| | | return false; |
| | | } |
| | | |
| | | } |