| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.entity.WrkLastno; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.WrkLastnoService; |
| | |
| | | |
| | | @Override |
| | | public void run() { |
| | | //检测入库站是否有任务生成,并启动入库 |
| | | checkInStationHasTask(); |
| | | //检测入库站是否有任务生成,并按站点 lane 异步启动入库 |
| | | stationOperateProcessUtils.submitStationEnableInTasks(DISPATCH_INTERVAL_MS); |
| | | //请求生成入库任务,保留按站点 lane 串行提交 |
| | | generateStoreWrkFile(); |
| | | |
| | |
| | | stationOperateProcessUtils.submitCheckTaskToCompleteTasks(DISPATCH_INTERVAL_MS); |
| | | // 检测并处理出库排序 |
| | | stationOperateProcessUtils.submitCheckStationOutOrderTasks(MAINTENANCE_INTERVAL_MS); |
| | | // // 监控输送线绕圈站点 |
| | | // stationOperateProcessUtils.submitWatchCircleStationTasks(MAINTENANCE_INTERVAL_MS); |
| | | // 检测输送线运行堵塞 |
| | | stationOperateProcessUtils.submitCheckStationRunBlockTasks(MAINTENANCE_INTERVAL_MS); |
| | | // // 检测站台空闲超时后的恢复处理 |
| | | // stationOperateProcessUtils.submitCheckStationIdleRecoverTasks(MAINTENANCE_INTERVAL_MS); |
| | | } |
| | | |
| | | @Override |
| | |
| | | InTaskApplyRequest request = StoreInTaskPolicy.super.buildApplyRequest(context); |
| | | request.getExtraParams().put("weight", context.getStationProtocol().getWeight()); |
| | | return request; |
| | | } |
| | | |
| | | //检测入库站是否有任务生成,并启动入库 |
| | | private synchronized void checkInStationHasTask() { |
| | | List<BasDevp> basDevps = basDevpService.list(new QueryWrapper<>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo()); |
| | | if(stationThread == null){ |
| | | continue; |
| | | } |
| | | |
| | | Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap(); |
| | | |
| | | List<StationObjModel> list = basDevp.getInStationList$(); |
| | | for (StationObjModel entity : list) { |
| | | Integer stationId = entity.getStationId(); |
| | | if(!stationMap.containsKey(stationId)){ |
| | | continue; |
| | | } |
| | | |
| | | StationProtocol stationProtocol = stationMap.get(stationId); |
| | | if (stationProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | Object lock = redisUtil.get(RedisKeyType.GENERATE_ENABLE_IN_STATION_DATA_LIMIT.key + stationId); |
| | | if(lock != null){ |
| | | continue; |
| | | } |
| | | |
| | | //满足自动、无物、工作号0,生成入库数据 |
| | | if (stationProtocol.isAutoing() |
| | | && stationProtocol.isLoading() |
| | | && stationProtocol.getTaskNo() == 0 |
| | | && stationProtocol.isEnableIn() |
| | | ) { |
| | | if (stationProtocol.getIoMode() != 1) { |
| | | continue;//不属于入库模式 |
| | | } |
| | | |
| | | //启动入库,删除条码站退回限制 |
| | | Integer backStationId = entity.getBarcodeStation().getStationId(); |
| | | String lockKey = RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + backStationId; |
| | | if (redisUtil.hasKey(lockKey)) { |
| | | StationProtocol backStationProtocol = stationMap.get(backStationId); |
| | | if (backStationProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (backStationProtocol.isAutoing() |
| | | && !backStationProtocol.isLoading() |
| | | && stationProtocol.getTaskNo() == 0 |
| | | ) { |
| | | //条码站自动、无物、工作号0。删除条码站退回限制 |
| | | redisUtil.del(lockKey); |
| | | } |
| | | } |
| | | |
| | | StationCommand command = stationThread.getCommand(StationCommandType.MOVE, commonService.getWorkNo(WrkIoType.ENABLE_IN.id), stationId, backStationId, 0); |
| | | stationCommandDispatcher.dispatch(basDevp.getDevpNo(), command, "gsl-process", "enable-in"); |
| | | if (entity.getBarcodeStation() != null && entity.getBarcodeStation().getStationId() != null) { |
| | | Utils.precomputeInTaskEnableRow(entity.getBarcodeStation().getStationId()); |
| | | } |
| | | redisUtil.set(RedisKeyType.GENERATE_ENABLE_IN_STATION_DATA_LIMIT.key + stationId, "lock", 15); |
| | | News.info("{}站点启动入库成功,数据包:{}", stationId, JSON.toJSONString(command)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void generateStoreWrkFile() { |
| | |
| | | return false; |
| | | } |
| | | |
| | | String lockKey = RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getStationId(); |
| | | Object lock = redisUtil.get(lockKey); |
| | | Object lock = redisUtil.get(RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getStationId()); |
| | | if (lock != null) { |
| | | return false; |
| | | } |
| | |
| | | } |
| | | stationCommandDispatcher.dispatch(basDevp.getDevpNo(), command, "gsl-process", "station-back"); |
| | | News.info("{}扫码站异常,已退回至{},条码站状态:{}", stationProtocol.getTaskNo(), backStation.getStationId(), JSON.toJSONString(stationProtocol)); |
| | | redisUtil.set(lockKey, "lock", 60 * 60); |
| | | redisUtil.set(RedisKeyType.GENERATE_STATION_BACK_LIMIT.key + stationProtocol.getStationId(), "lock", 60 * 60); |
| | | return false; |
| | | } |
| | | |