| | |
| | | package com.vincent.rsf.server.manager.schedules; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.*; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.vincent.rsf.server.manager.service.impl.DeviceSiteServiceImpl; |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | | import com.vincent.rsf.server.system.service.ConfigService; |
| | | import com.vincent.rsf.server.system.utils.SerialRuleUtils; |
| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.*; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private LocService locService; |
| | | |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | @Autowired |
| | | private BasStationService stationService; |
| | | |
| | | @Autowired |
| | | private TaskService taskService; |
| | | |
| | | |
| | | @Autowired |
| | | private TaskItemService taskItemService; |
| | | |
| | | @Autowired |
| | | private MatnrService matnrService; |
| | | |
| | | @Autowired |
| | | private LocItemService locItemService; |
| | | @Autowired |
| | | private DeviceSiteService deviceSiteService; |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/9/1 |
| | | * @description: 自动生成盘点跑库单 |
| | | * @version 1.0 |
| | | */ |
| | | public void autoCheckOrders() { |
| | | List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type).last("limit 1")); |
| | | locs.forEach(loc -> { |
| | | List<LocItem> locItems = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId())); |
| | | if (!locItems.isEmpty()) { |
| | | DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>().eq(DeviceSite::getType, TaskType.TASK_TYPE_CHECK_OUT.type), false); |
| | | //生成盘点任务参数 |
| | | LocToTaskParams locToTaskParams = new LocToTaskParams(); |
| | | locToTaskParams.setType(Constants.TASK_TYPE_OUT_CHECK) |
| | | .setItems(locItems) |
| | | .setSiteNo(deviceSite.getSite()) |
| | | .setOrgLoc(loc.getCode()); |
| | | try { |
| | | locItemService.generateTask(TaskResouceType.TASK_RESOUCE_CHECK_TYPE.val, locToTaskParams, getLoginUserId()); |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/9/1 |
| | | * @description: 自动完成盘点功能 |
| | | * @version 1.0 |
| | | */ |
| | | public void autoCheckComplete() { |
| | | //获取任务列表中,为盘点出库的任务 |
| | | 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.isEmpty()) { |
| | | tasks.forEach(task -> { |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) { |
| | | if (task.getTaskStatus().equals(TaskStsType.GENERATE_IN.id)) { |
| | | task.setTaskStatus(TaskStsType.COMPLETE_IN.id); |
| | | if (!taskService.updateById(task)) { |
| | | throw new CoolException("盘点再入库任务完成失败!!"); |
| | | } |
| | | } |
| | | } else { |
| | | //创建出库任务状态 |
| | | if (task.getTaskStatus().equals(TaskStsType.GENERATE_OUT.id)) { |
| | | task.setTaskStatus(TaskStsType.COMPLETE_OUT.id); |
| | | if (!taskService.updateById(task)) { |
| | | throw new CoolException("盘点出库任务完成失败!!"); |
| | | } |
| | | //出库已完成,等待盘点中 |
| | | } else if (task.getTaskStatus().equals(TaskStsType.WAVE_SEED.id)) { |
| | | try { |
| | | taskService.pickOrCheckTask(task.getId(), Constants.TASK_TYPE_OUT_CHECK); |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | | |
| | | public void genRun() { |
| | | String autoRunArea = configService.getVal("AUTO_RUN_AREA", String.class); |
| | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | private void autoRun(List<Integer> locGroupList, List<String> staGroupList) { |
| | | |
| | | List<String> staPreNos = getStaPrefixes(staGroupList); |
| | | String staTaskMemo = "DEMO_STA_" + String.join("-", staPreNos); |
| | | log.error("=========>"); |
| | | log.info(staTaskMemo); |
| | | System.out.println(staTaskMemo); |
| | | |
| | | List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getMemo, staTaskMemo)); |
| | | if (!Cools.isEmpty(list) && list.size() > 30) { |
| | |
| | | } |
| | | // 入库 应该根据工作档回去 |
| | | this.runStaToLoc(locGroupList, staGroupList, staTaskMemo); |
| | | |
| | | // 出库,需要校验工作档是否存在,存在就说明站点处于忙碌状态 |
| | | this.runLocToSta(locGroupList, staGroupList, staTaskMemo); |
| | | |
| | | // 移库 |
| | | this.runLocToLoc(locGroupList, staTaskMemo); |
| | | } |
| | | |
| | | |
| | | // 入库 |
| | | private void runStaToLoc(List<Integer> locGroupList, List<String> staGroupList, String memo) { |
| | | Integer startRow = Collections.min(locGroupList); |
| | | Integer endRow = Collections.max(locGroupList); |
| | | |
| | | |
| | | // STA IDLE |
| | | LambdaQueryWrapper<BasStation> idleWrapper = new LambdaQueryWrapper<BasStation>().eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_F.type).in(BasStation::getStationName, staGroupList); |