| | |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.model.MesCombParam; |
| | | import com.zy.common.model.enums.WorkNoType; |
| | | import com.zy.common.properties.AgvProperties; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @Resource |
| | | private BasDevpMapper basDevpMapper; |
| | | |
| | | @Resource |
| | | private AgvProperties agvProperties; |
| | | |
| | | @Override |
| | | public R inLocCallAgv(CallAgvParam param,Long userId) { |
| | | int type = param.getType(); |
| | |
| | | locCacheService.updateById(locCache); |
| | | break; |
| | | case 3: |
| | | // 判断条码在wms不存在,是空托盘 |
| | | // 已组托 |
| | | // 判断是否为空托入库:检查条码在wms中不存在,确认为空托盘 |
| | | log.info("开始判断是否为空托入库,条码:{}", barcode); |
| | | |
| | | // 检查是否已组托 |
| | | int waitPakInCount = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", barcode)); |
| | | if (waitPakInCount != 0) { |
| | | log.warn("条码组托档已存在,不是空托盘:{}", barcode); |
| | | throw new CoolException("条码组托档已存在:" + barcode); |
| | | } |
| | | // 有任务 |
| | | |
| | | // 检查是否有任务 |
| | | int wrkMastCount = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("barcode", barcode)); |
| | | if (wrkMastCount != 0) { |
| | | log.warn("条码任务档已存在,不是空托盘:{}", barcode); |
| | | throw new CoolException("条码任务档已存在:" + barcode); |
| | | } |
| | | // 有库存 |
| | | |
| | | // 检查是否有库存 |
| | | int locDetlCount = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", barcode)); |
| | | if (locDetlCount != 0) { |
| | | log.warn("条码库存已存在,不是空托盘:{}", barcode); |
| | | throw new CoolException("条码库存已存在:" + barcode); |
| | | } |
| | | |
| | | // 通过所有检查,确认为空托盘,设置为空托入库 |
| | | ioType = 10; |
| | | log.info("确认为空托盘,设置为空托入库,条码:{},ioType:{}", barcode, ioType); |
| | | break; |
| | | default: |
| | | throw new CoolException("入库类型错误,type:" + type); |
| | |
| | | throw new CoolException(barcode+ ":条码存在agv搬运任务!"); |
| | | } |
| | | |
| | | // 根据whs_type选择站点和机器人组 |
| | | Long whsType = locCache.getWhsType(); |
| | | List<String> targetStations; |
| | | String robotGroup; |
| | | |
| | | if (whsType != null && whsType.equals(agvProperties.getWhsTypeMapping().getInboundArea())) { |
| | | // whs_type = 1: 入库区,使用东侧站点和Group-001 |
| | | targetStations = agvProperties.getEastStations(); |
| | | robotGroup = agvProperties.getRobotGroupEast(); |
| | | log.info("库位whs_type={},使用入库区配置(东侧站点和Group-001)", whsType); |
| | | } else if (whsType != null && whsType.equals(agvProperties.getWhsTypeMapping().getCacheArea())) { |
| | | // whs_type = 2: 缓存区,使用西侧站点和Group-002 |
| | | targetStations = agvProperties.getWestStations(); |
| | | robotGroup = agvProperties.getRobotGroupWest(); |
| | | log.info("库位whs_type={},使用缓存区配置(西侧站点和Group-002)", whsType); |
| | | } else { |
| | | // whs_type为空或其他值,根据type判断(兼容旧逻辑) |
| | | if (type == 1) { |
| | | targetStations = agvProperties.getEastStations(); |
| | | robotGroup = agvProperties.getRobotGroupEast(); |
| | | } else { |
| | | targetStations = agvProperties.getWestStations(); |
| | | robotGroup = agvProperties.getRobotGroupWest(); |
| | | } |
| | | log.warn("库位whs_type={}未配置或不在映射范围内,使用type={}的默认逻辑", whsType, type); |
| | | } |
| | | |
| | | // 将站点字符串列表转换为整数列表 |
| | | List<Integer> siteIntList = targetStations.stream() |
| | | .map(Integer::parseInt) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 判断能入站点 |
| | | List<Integer> sites = basDevpMapper.selectList( |
| | | new EntityWrapper<BasDevp>() |
| | | .eq("canining", "Y") |
| | | .in("dev_no", type == 1 ? Arrays.asList(1003, 1005, 1007) : Arrays.asList(1044, 1046, 1048)) |
| | | .in("dev_no", siteIntList) |
| | | ).stream().map(BasDevp::getDevNo).collect(Collectors.toList()); |
| | | |
| | | if (sites.isEmpty()) { |
| | | throw new CoolException("没有能入站点,type:" + type); |
| | | throw new CoolException("没有能入站点,whs_type:" + whsType + ",type:" + type); |
| | | } |
| | | |
| | | // 获取没有出库任务的站点 |
| | |
| | | .setTaskType("agv") |
| | | .setIoPri(10D) |
| | | .setStaNo(String.valueOf(endSite)) |
| | | .setSourceStaNo(sourceSite) // 设置源站点 |
| | | .setInvWh(robotGroup) // 根据whs_type设置机器人组 |
| | | .setFullPlt(ioType != 10 ? "N" : "Y")// 满板:Y |
| | | .setPicking("N") // 拣料 |
| | | .setExitMk("N")// 退出 |
| | | .setSourceLocNo(sourceSite) |
| | | .setSourceLocNo(locCache.getLocNo()) // 设置源库位编号,用于AGV fromBin |
| | | .setEmptyMk(ioType == 10 ? "Y" : "N")// 空板 |
| | | .setBarcode(barcode)// 托盘码 |
| | | .setLinkMis("N") |