| | |
| | | String sourceSite = param.getSourceSite(); |
| | | String barcode = param.getBarcode(); |
| | | int ioType; |
| | | // 查询源站点(库位)信息,但不检查是否存在,允许下单成功 |
| | | // 站点不存在的检查将在定时任务(AgvHandler.callAgv)中进行 |
| | | LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("loc_no", sourceSite)); |
| | | if (null == locCache) { |
| | | throw new CoolException("站点不存在:" + sourceSite); |
| | | } |
| | | switch (type) { |
| | | case 1: |
| | | // 判断有没有组托 |
| | |
| | | if (count == 0) { |
| | | throw new CoolException("条码未组托:" + barcode); |
| | | } |
| | | ioType = 101; |
| | | ioType = 1; // AGV容器入库(实托入库) |
| | | |
| | | locCache.setLocSts(LocStsType.LOC_STS_TYPE_R.type); |
| | | locCacheService.updateById(locCache); |
| | | // 如果库位存在,更新状态为入库预约;不存在则跳过,由定时任务处理 |
| | | if (locCache != null) { |
| | | locCache.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.入库预约 |
| | | locCacheService.updateById(locCache); |
| | | } |
| | | break; |
| | | case 2: |
| | | // 判断是拣选回库托盘 |
| | |
| | | if (wrkMast.getIoType() != 103 && wrkMast.getIoType() != 107) { |
| | | throw new CoolException("条码不需要回库:" + barcode); |
| | | } |
| | | ioType = wrkMast.getIoType() - 50; |
| | | ioType = wrkMast.getIoType() - 50; // 103->53(拣料入库), 107->57(盘点入库) |
| | | |
| | | locCache.setLocSts(LocStsType.LOC_STS_TYPE_R.type); |
| | | locCacheService.updateById(locCache); |
| | | // 如果库位存在,更新状态为入库预约;不存在则跳过,由定时任务处理 |
| | | if (locCache != null) { |
| | | locCache.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.入库预约(容器回库是入库操作) |
| | | locCacheService.updateById(locCache); |
| | | } |
| | | break; |
| | | case 3: |
| | | // 判断是否为空托入库:检查条码在wms中不存在,确认为空托盘 |
| | |
| | | } |
| | | |
| | | // 根据whs_type和库位编号前缀选择站点和机器人组 |
| | | Long whsType = locCache.getWhsType(); |
| | | String locNo = locCache.getLocNo(); |
| | | // 如果库位不存在,使用默认逻辑(根据type判断),站点不存在的检查将在定时任务中进行 |
| | | Long whsType = locCache != null ? locCache.getWhsType() : null; |
| | | String locNo = locCache != null ? locCache.getLocNo() : sourceSite; |
| | | List<String> targetStations; |
| | | String robotGroup; |
| | | |
| | |
| | | agvProperties.getWestDisplayName(), robotGroup); |
| | | } else { |
| | | // whs_type为空或其他值,根据type判断(兼容旧逻辑) |
| | | // 如果库位不存在,也使用此逻辑 |
| | | if (type == 1) { |
| | | targetStations = agvProperties.getEastStations(); |
| | | robotGroup = agvProperties.getRobotGroupEast(); |
| | |
| | | targetStations = agvProperties.getWestStations(); |
| | | robotGroup = agvProperties.getRobotGroupWest(); |
| | | } |
| | | log.warn("库位whs_type={}未配置或不在映射范围内,使用type={}的默认逻辑", whsType, type); |
| | | if (locCache == null) { |
| | | log.warn("源站点(库位){}不存在,使用type={}的默认逻辑,站点检查将在定时任务中进行", sourceSite, type); |
| | | } else { |
| | | log.warn("库位whs_type={}未配置或不在映射范围内,使用type={}的默认逻辑", whsType, type); |
| | | } |
| | | } |
| | | |
| | | // 将站点字符串列表转换为整数列表 |
| | |
| | | .map(Integer::parseInt) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 判断能入站点(in_enable="Y"表示能入) |
| | | // 判断能入站点(in_enable="Y"表示能入),排除dev_no=0的无效站点 |
| | | // 注意:不在此处检查站点是否存在或可用,允许下单成功 |
| | | // 站点检查和分配将在定时任务(AgvHandler.callAgv)中进行 |
| | | List<Integer> sites = basDevpMapper.selectList( |
| | | new EntityWrapper<BasDevp>() |
| | | .eq("in_enable", "Y") // in_enable是能入 |
| | | .in("dev_no", siteIntList) |
| | | ).stream().map(BasDevp::getDevNo).collect(Collectors.toList()); |
| | | |
| | | if (sites.isEmpty()) { |
| | | throw new CoolException("没有能入站点,whs_type:" + whsType + ",type:" + type); |
| | | } |
| | | .ne("dev_no", 0) // 排除dev_no=0的无效站点 |
| | | ).stream() |
| | | .map(BasDevp::getDevNo) |
| | | .filter(devNo -> devNo != null && devNo != 0) // 再次过滤,确保不为null或0 |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 获取没有出库任务的站点 |
| | | List<Integer> canInSites = basDevpMapper.getCanInSites(sites); |
| | | if (canInSites.isEmpty()) { |
| | | throw new CoolException("请等待出库完成,type:" + type); |
| | | } |
| | | List<Integer> canInSites = sites.isEmpty() ? new ArrayList<>() : basDevpMapper.getCanInSites(sites); |
| | | |
| | | // 寻找入库任务最少的站点(且必须in_enable="Y"能入 和 canining="Y"可入) |
| | | // 寻找入库任务最少的站点(且必须in_enable="Y"能入 和 canining="Y"可入),排除dev_no=0的无效站点 |
| | | // 注意:不在此处检查未完成的AGV任务,允许PDA持续申请下单 |
| | | // 未完成任务的检查将在发送AGV请求时进行(AgvHandler.callAgv) |
| | | List<BasDevp> devList = basDevpMapper.selectList(new EntityWrapper<BasDevp>() |
| | | List<BasDevp> devList = canInSites.isEmpty() ? new ArrayList<>() : basDevpMapper.selectList(new EntityWrapper<BasDevp>() |
| | | .in("dev_no", canInSites) |
| | | .eq("in_enable", "Y") // in_enable是能入 |
| | | .eq("canining", "Y") // canining是可入 |
| | | ); |
| | | .ne("dev_no", 0) // 排除dev_no=0的无效站点 |
| | | ).stream() |
| | | .filter(dev -> dev.getDevNo() != null && dev.getDevNo() != 0) // 再次过滤,确保不为null或0 |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 选择站点(如果可入站点为空,则不在创建任务时分配站点,由定时任务分配) |
| | | Integer endSite = null; |
| | |
| | | } |
| | | |
| | | endSite = basDevp.getDevNo(); |
| | | |
| | | // 入库暂存+1 |
| | | basDevpMapper.incrementInQty(endSite); |
| | | |
| | | // 检查站点是否有效(不能为0或null) |
| | | if (endSite == null || endSite == 0) { |
| | | log.error("分配的站点无效(dev_no={}),不分配站点,将在定时任务中分配", endSite); |
| | | endSite = null; // 设置为null,由定时任务分配 |
| | | } else { |
| | | // 入库暂存+1 |
| | | basDevpMapper.incrementInQty(endSite); |
| | | } |
| | | } else { |
| | | // 没有可入站点,记录日志但不阻止下单,站点分配将在定时任务中处理 |
| | | String groupName = (whsType != null && whsType.equals(agvProperties.getWhsTypeMapping().getInboundArea())) |
| | | ? agvProperties.getEastDisplayName() : agvProperties.getWestDisplayName(); |
| | | log.warn("{}可用站点({})中没有可入站点(in_enable='Y'且canining='Y'),暂不分配站点,将在定时任务中分配", groupName, canInSites); |
| | | // log.warn("{}可用站点({})中没有可入站点(in_enable='Y'且canining='Y'),暂不分配站点,将在定时任务中分配", groupName, canInSites); |
| | | } |
| | | |
| | | |
| | |
| | | .setStaNo(endSite != null ? String.valueOf(endSite) : null) // 如果分配了站点则设置,否则为null,由定时任务分配 |
| | | .setSourceStaNo(sourceSite) // 设置源站点 |
| | | .setInvWh(robotGroup) // 根据whs_type设置机器人组 |
| | | .setFullPlt(ioType != 10 ? "N" : "Y")// 满板:Y |
| | | .setFullPlt(ioType == 10 ? "N" : "Y")// 空托入库(ioType=10)设置为N,其他入库设置为Y(满板) |
| | | .setPicking("N") // 拣料 |
| | | .setExitMk("N")// 退出 |
| | | .setSourceLocNo(locCache.getLocNo()) // 设置源库位编号,用于AGV fromBin |
| | | .setEmptyMk(ioType == 10 ? "Y" : "N")// 空板 |
| | | .setSourceLocNo(locCache != null ? locCache.getLocNo() : sourceSite) // 设置源库位编号,用于AGV fromBin,如果库位不存在则使用sourceSite |
| | | .setEmptyMk(ioType == 10 ? "Y" : "N")// 空托入库(ioType=10)设置为Y,其他设置为N |
| | | .setBarcode(barcode)// 托盘码 |
| | | .setLinkMis("N") |
| | | .setAppeTime(now) |
| | |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | |
| | | // 更新暂存位状态为 R.出库预约 |
| | | basStationMapper.updateLocStsBatch( Collections.singletonList(String.valueOf(sourceSite)), "R"); |
| | | // 如果库位存在,根据ioType更新暂存位状态:入库任务设置为S(入库预约),出库任务设置为R(出库预约) |
| | | if (locCache != null) { |
| | | String locSts = (ioType < 100) ? "S" : "R"; // 入库任务(ioType < 100)设置为S,出库任务设置为R |
| | | basStationMapper.updateLocStsBatch( Collections.singletonList(String.valueOf(sourceSite)), locSts); |
| | | } |
| | | return R.ok("agv任务生成成功!"); |
| | | |
| | | } |