| | |
| | | import com.vincent.rsf.server.manager.enums.*; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.vincent.rsf.server.manager.service.impl.BasStationServiceImpl; |
| | | import com.vincent.rsf.server.system.constant.GlobalConfigCode; |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | | import com.vincent.rsf.server.system.entity.Config; |
| | | import com.vincent.rsf.server.system.service.ConfigService; |
| | | import com.vincent.rsf.server.system.utils.SerialRuleUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | * 自动生成库位明细 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | // @Scheduled(cron = "0/25 * * * * ?") |
| | | @Scheduled(cron = "0/25 * * * * ?") |
| | | public void insertRandomMats() { |
| | | List<Loc> list = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type)); |
| | | for (Loc loc : list) { |
| | |
| | | * @description: 自动完成盘点功能 |
| | | * @version 1.0 |
| | | */ |
| | | @Scheduled(cron = "0/35 * * * * ?") |
| | | @Scheduled(cron = "0/25 * * * * ?") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void autoCheckComplete() { |
| | | Boolean autoRunArea = configService.getVal("AUTO_RUN_CHECK_ORDERS", Boolean.class); |
| | | if (!autoRunArea) { |
| | | return; |
| | | } |
| | | //获取任务列表中,为盘点出库的任务 |
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>() |
| | | .in(Task::getTaskType, Arrays.asList(TaskType.TASK_TYPE_CHECK_OUT.type, TaskType.TASK_TYPE_CHECK_IN.type))); |
| | | .in(Task::getTaskType, Arrays.asList(TaskType.TASK_TYPE_CHECK_OUT.type, |
| | | TaskType.TASK_TYPE_PICK_IN.type, |
| | | TaskType.TASK_TYPE_PICK_AGAIN_OUT.type, |
| | | TaskType.TASK_TYPE_CHECK_IN.type))); |
| | | |
| | | if (!tasks.isEmpty()) { |
| | | tasks.forEach(task -> { |
| | |
| | | if (task.getTaskStatus().equals(TaskStsType.WAVE_SEED.id)) { |
| | | if (!stationService.update(new LambdaUpdateWrapper<BasStation>() |
| | | .eq(BasStation::getStationName, task.getTargSite()) |
| | | .set(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_F.type))) { |
| | | throw new CoolException("站点状态修改失败!!"); |
| | | .set(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_R.type))) { |
| | | log.error("站点状态修改完成失败,当前任务状态:", task.getTaskStatus()); |
| | | // throw new CoolException("站点状态修改失败!!"); |
| | | } |
| | | try { |
| | | taskService.pickOrCheckTask(task.getId(), Constants.TASK_TYPE_OUT_CHECK); |
| | | taskService.pickOrCheckTask(task.getId(), task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type) ? Constants.TASK_TYPE_OUT_CHECK : ""); |
| | | |
| | | if (!stationService.update(new LambdaUpdateWrapper<BasStation>() |
| | | .eq(BasStation::getStationName, task.getTargSite()) |
| | | .set(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_R.type))) { |
| | | throw new CoolException("站点状态修改失败!!"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("error====>", e); |
| | | } |
| | |
| | | * @description: 自动生成任务 |
| | | * @version 1.0 |
| | | */ |
| | | @Scheduled(cron = "0/25 * * * * ?") |
| | | @Scheduled(cron = "0/5 * * * * ?") |
| | | public void genRun() { |
| | | Boolean flagAuto = configService.getVal("AUTO_RUN_CHECK_ORDERS", Boolean.class); |
| | | if (!flagAuto) { |
| | | Config config = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.AUTO_RUN_CHECK_ORDERS)); |
| | | if (!Boolean.parseBoolean(config.getVal())) { |
| | | return; |
| | | } |
| | | //获取任务列表中,为盘点出库的任务 |
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>() |
| | | .in(Task::getTaskType, Arrays.asList(TaskType.TASK_TYPE_CHECK_OUT.type, TaskType.TASK_TYPE_CHECK_IN.type))); |
| | | if (tasks.size() >= 6) { |
| | | if (tasks.size() >= 30) { |
| | | return; |
| | | } |
| | | String autoRunArea = configService.getVal("AUTO_RUN_AREA", String.class); |
| | |
| | | continue; |
| | | } |
| | | try { |
| | | //生成盘点出库任务,站点预约 |
| | | if (!stationService.update(new LambdaUpdateWrapper<BasStation>() |
| | | .eq(BasStation::getStationName, deviceSite.getSite()) |
| | | .set(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_S.type))) { |
| | | throw new CoolException("站点状态更新失败!!"); |
| | | } |
| | | locItemService.generateTask(TaskResouceType.TASK_RESOUCE_CHECK_TYPE.val, locToTaskParams, getLoginUserId()); |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | |
| | | |
| | | // // 出库,需要校验工作档是否存在,存在就说明站点处于忙碌状态 |
| | | // this.runLocToSta(locGroupList, staGroupList, staTaskMemo); |
| | | // // 移库 |
| | | // // 移库locGroupList |
| | | // this.runLocToLoc(locGroupList, staTaskMemo); |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 生成移库任务 |
| | | * @param |
| | | * @param |
| | | */ |
| | | // 移库 |
| | | private void runLocToLoc(List<Integer> locGroupList, String staTaskMemo) { |
| | | @Scheduled(cron = "0/7 * * * * ?") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void runLocToLoc() { |
| | | Config config = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.AUTO_RUN_CHECK_ORDERS)); |
| | | if (!Boolean.parseBoolean(config.getVal())) { |
| | | return; |
| | | } |
| | | List<Integer> locGroupList = new ArrayList<>(); |
| | | //获取任务列表中,为盘点出库的任务 |
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>() |
| | | .eq(Task::getTaskType, TaskType.TASK_TYPE_LOC_MOVE.type)); |
| | | if (!tasks.isEmpty() && tasks.size() >= 10) { |
| | | return; |
| | | } |
| | | String autoRunArea = configService.getVal("AUTO_RUN_AREA", String.class); |
| | | if (Cools.isEmpty(autoRunArea)) { |
| | | return; |
| | | } |
| | | for (char c : autoRunArea.toCharArray()) { |
| | | switch (c) { |
| | | case '1': |
| | | locGroupList = LocGroupConstant.FAR_RIGHT_LOC_ROW_LIST; |
| | | break; |
| | | case '2': |
| | | locGroupList = LocGroupConstant.RIGHT_LOC_ROW_LIST; |
| | | break; |
| | | case '3': |
| | | locGroupList = LocGroupConstant.MIDDLE_LOC_ROW_LIST; |
| | | break; |
| | | case '4': |
| | | locGroupList = LocGroupConstant.LEFT_LOC_ROW_LIST; |
| | | break; |
| | | case '5': |
| | | locGroupList = LocGroupConstant.FAR_LEFT_LOC_ROW_LIST; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | Integer startRow = Collections.min(locGroupList); |
| | | Integer endRow = Collections.max(locGroupList); |
| | | |
| | | String memo = "DEMO_LOC_" + startRow + "-" + endRow; |
| | | |
| | | |
| | | // STOCK |
| | | LambdaQueryWrapper<Loc> stockWrapper = new LambdaQueryWrapper<Loc>().eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type); |
| | | if (null != startRow) { |