| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.common.service.CommonService; |
| | |
| | | public class GslProcess implements MainProcessPluginApi, StoreInTaskPolicy { |
| | | private static final String CRN_TASK_LANE = "crn"; |
| | | private static final String STATION_TASK_LANE = "station"; |
| | | private static final String GENERATE_STORE_TASK_LANE_PREFIX = "generate-store-"; |
| | | private static final long DISPATCH_INTERVAL_MS = 200L; |
| | | private static final long MAINTENANCE_INTERVAL_MS = 500L; |
| | | private static final long TASK_SLOW_LOG_THRESHOLD_MS = 1000L; |
| | |
| | | public void run() { |
| | | //检测入库站是否有任务生成,并启动入库 |
| | | checkInStationHasTask(); |
| | | //请求生成入库任务 |
| | | generateStoreWrkFile(); |
| | | //按站点拆分生成入库任务,避免单个站点阻塞整轮扫描 |
| | | submitGenerateStoreTasks(); |
| | | |
| | | //堆垛机与输送站点都按单个任务提交到各自串行通道,逐个执行 |
| | | submitCrnTask("crnIoExecute", DISPATCH_INTERVAL_MS, crnOperateUtils::crnIoExecute); |
| | |
| | | submitStationTask("watchCircleStation", MAINTENANCE_INTERVAL_MS, stationOperateProcessUtils::watchCircleStation); |
| | | submitStationTask("checkStationRunBlock", MAINTENANCE_INTERVAL_MS, stationOperateProcessUtils::checkStationRunBlock); |
| | | submitStationTask("checkStationIdleRecover", MAINTENANCE_INTERVAL_MS, stationOperateProcessUtils::checkStationIdleRecover); |
| | | } |
| | | |
| | | /** |
| | | * 请求生成入库任务 |
| | | * 入库站,根据条码扫描生成入库工作档 |
| | | */ |
| | | public synchronized void generateStoreWrkFile() { |
| | | storeInTaskGenerationService.generate(this); |
| | | } |
| | | |
| | | @Override |
| | |
| | | ) { |
| | | StationCommand command = stationThread.getCommand(StationCommandType.MOVE, commonService.getWorkNo(WrkIoType.ENABLE_IN.id), stationId, entity.getBarcodeStation().getStationId(), 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)); |
| | | } |
| | |
| | | submitProcessTask(STATION_TASK_LANE, taskName, minIntervalMs, task); |
| | | } |
| | | |
| | | private void submitGenerateStoreTasks() { |
| | | List<BasDevp> basDevps = basDevpService.list(new QueryWrapper<>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | List<StationObjModel> barcodeStations = getBarcodeStations(basDevp); |
| | | for (StationObjModel stationObjModel : barcodeStations) { |
| | | Integer stationId = stationObjModel == null ? null : stationObjModel.getStationId(); |
| | | if (stationId == null) { |
| | | continue; |
| | | } |
| | | submitGenerateStoreTask(stationId, DISPATCH_INTERVAL_MS, |
| | | () -> storeInTaskGenerationService.generate(this, basDevp, stationObjModel)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void submitGenerateStoreTask(Integer stationId, long minIntervalMs, Runnable task) { |
| | | submitProcessTask(GENERATE_STORE_TASK_LANE_PREFIX + stationId, "generateStoreWrkFile", minIntervalMs, task); |
| | | } |
| | | |
| | | private void submitCrnTask(String taskName, long minIntervalMs, Runnable task) { |
| | | submitProcessTask(CRN_TASK_LANE, taskName, minIntervalMs, task); |
| | | } |