| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.framework.common.SnowflakeIdWorker; |
| | | import com.vincent.rsf.server.manager.entity.Loc; |
| | | import com.vincent.rsf.server.manager.entity.Task; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.LocStsType; |
| | | import com.vincent.rsf.server.manager.enums.TaskStsType; |
| | | import com.vincent.rsf.server.manager.enums.TaskType; |
| | | import com.vincent.rsf.server.manager.service.LocService; |
| | | import com.vincent.rsf.server.manager.service.TaskService; |
| | | import com.vincent.rsf.server.manager.service.impl.BasStationAreaServiceImpl; |
| | | import com.vincent.rsf.server.manager.service.impl.BasStationServiceImpl; |
| | | import com.vincent.rsf.server.manager.service.impl.DeviceSiteServiceImpl; |
| | | import com.vincent.rsf.server.system.constant.GlobalConfigCode; |
| | | import com.vincent.rsf.server.system.entity.*; |
| | | import com.vincent.rsf.server.system.service.ConfigService; |
| | |
| | | private FlowInstanceServiceImpl flowInstanceService; |
| | | @Autowired |
| | | private FlowStepInstanceServiceImpl flowStepInstanceService; |
| | | @Autowired |
| | | private BasStationAreaServiceImpl basStationAreaService; |
| | | @Autowired |
| | | private DeviceSiteServiceImpl deviceSiteService; |
| | | @Autowired |
| | | private BasStationServiceImpl basStationService; |
| | | |
| | | /** |
| | | * @author Munch D. Luffy |
| | |
| | | return; |
| | | } |
| | | taskList.forEach(task -> { |
| | | boolean endSign = true; |
| | | boolean endSignUp = false; |
| | | String sou = null; |
| | | String end = null; |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) |
| | |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_OUT.type)) { |
| | | endSignUp = true; |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getOrgLoc())); |
| | | sou = loc.getAreaId().toString(); |
| | | end = task.getTargSite(); |
| | | |
| | | BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>() |
| | | .eq(BasStation::getStationName, end) |
| | | .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) |
| | | ); |
| | | if (Cools.isEmpty(basStation)) { |
| | | endSign = false; |
| | | } |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CROSS_DOCKING_OUT.type)){ |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getOrgLoc())); |
| | | sou = loc.getAreaId().toString(); |
| | |
| | | sou = loc2.getAreaId().toString(); |
| | | } |
| | | List<TaskPathTemplateMerge> taskPathTemplateMergeList = taskPathTemplateMergeService.list(new LambdaQueryWrapper<TaskPathTemplateMerge>().eq(TaskPathTemplateMerge::getSourceType, sou).eq(TaskPathTemplateMerge::getTargetType, end)); |
| | | if (Objects.isNull(taskPathTemplateMergeList) || taskPathTemplateMergeList.isEmpty()) { |
| | | if (Objects.isNull(taskPathTemplateMergeList) || taskPathTemplateMergeList.isEmpty() || !endSign) { |
| | | List<TaskPathTemplateMerge> list = taskPathTemplateMergeService.list(new LambdaQueryWrapper<TaskPathTemplateMerge>().eq(TaskPathTemplateMerge::getStepSize,1)); |
| | | if (!Cools.isEmpty(list)) { |
| | | List<String[]> stationList = new ArrayList<>(); |
| | |
| | | stationList.add(taskPathTemplate.route()); |
| | | }); |
| | | List<Long> longs = RouteWmsStepFlow.routeGet(stationList, sou, end); |
| | | if (longs != null && !longs.isEmpty()) { |
| | | if (endSign && longs != null && !longs.isEmpty()) { |
| | | TaskPathTemplateMerge taskPathTemplateMerge = new TaskPathTemplateMerge(); |
| | | taskPathTemplateMerge.setTemplateCode(sou+"===>"+end); |
| | | taskPathTemplateMerge.setTemplateName(sou+"===>"+end); |
| | |
| | | taskPathTemplateMerge.setConditionExpression(longList); |
| | | taskPathTemplateMerge.setStepSize(longList.size()); |
| | | taskPathTemplateMergeService.save(taskPathTemplateMerge); |
| | | } else { |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_OUT.type)) {//出库 |
| | | //没有路径 进入库区筛选站点 |
| | | List<String> targSiteArea = task.getTargSiteArea(); |
| | | //提取出所有站点 |
| | | List<String> siteList = new ArrayList<>(); |
| | | //筛选出存在路径的站点 |
| | | List<String> siteListRoute = new ArrayList<>(); |
| | | //筛选可替换选项 |
| | | List<String> siteListUp = new ArrayList<>(); |
| | | if (targSiteArea != null && !targSiteArea.isEmpty()) { |
| | | for (String areaId : targSiteArea) { |
| | | BasStationArea basStationArea = basStationAreaService.getById(Long.parseLong(areaId)); |
| | | if (basStationArea == null || basStationArea.getStationAlias() == null || basStationArea.getStationAlias().isEmpty()) { |
| | | continue; |
| | | } |
| | | siteList.addAll(basStationArea.getStationAlias()); |
| | | } |
| | | if (!siteList.isEmpty()) { |
| | | //查询站点路径 |
| | | for (String site : siteList) { |
| | | List<Long> routeGet = RouteWmsStepFlow.routeGet(stationList, sou, site); |
| | | if (routeGet!=null && !routeGet.isEmpty()){ |
| | | siteListRoute.add(site); |
| | | } |
| | | } |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getOrgLoc())); |
| | | //查询站点配置 |
| | | if (!siteListRoute.isEmpty()) { |
| | | for (String site : siteListRoute) { |
| | | //拣料出库 -- 盘点出库 |
| | | DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() |
| | | .eq(DeviceSite::getSite, site) |
| | | .eq(!Objects.isNull(loc.getChannel()),DeviceSite::getChannel, loc.getChannel()) |
| | | .eq(DeviceSite::getType, task.getTaskType()).last("limit 1"),false); |
| | | if (!Objects.isNull(deviceSite)) { |
| | | BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>() |
| | | .eq(BasStation::getStationName, site) |
| | | .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) |
| | | ); |
| | | if (Cools.isEmpty(basStation) || !basStation.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) { |
| | | continue; |
| | | } |
| | | task.setTargSite(site); |
| | | taskService.updateById(task); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | // System.out.println("任务:"+task.getTaskCode()+"查询步序为:"+longs); |
| | | } |
| | | } else { |
| | | //生成实际路径 |
| | | boolean actualPath = generateActualPath(task, taskPathTemplateMergeList.get(0)); |
| | | boolean actualPath = generateActualPath(task, taskPathTemplateMergeList.get(0),endSignUp); |
| | | if (!actualPath) { |
| | | log.error("生成实际路径失败"); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | public boolean generateActualPath(Task task,TaskPathTemplateMerge taskPathTemplateMerge) { |
| | | public boolean generateActualPath(Task task,TaskPathTemplateMerge taskPathTemplateMerge,boolean endSignUp) { |
| | | boolean actualPath = false; |
| | | List<Integer> conditionExpression = taskPathTemplateMerge.getConditionExpression(); |
| | | Integer i = 0;//it顺序 |
| | |
| | | } |
| | | } |
| | | task.setDeviceSiteId(taskInstance.getId()); |
| | | |
| | | if (endSignUp){ |
| | | BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getTargSite())); |
| | | if (basStation == null){ |
| | | return false; |
| | | } |
| | | if (!basStation.getType().equals(0)){ |
| | | basStation.setUseStatus(LocStsType.LOC_STS_TYPE_S.type); |
| | | basStationService.updateById(basStation); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | taskService.updateById(task); |
| | | return actualPath; |
| | | } |