| | |
| | | DeviceSiteService deviceSiteService = SpringUtils.getBean(DeviceSiteService.class); |
| | | |
| | | List<OrderOutItemDto> list = new ArrayList<>(); |
| | | //不让站点重复使用问题 |
| | | List<BasStation> stations = new ArrayList<>(); |
| | | List<ExistDto> existDtos = new ArrayList<>(); |
| | | Set<Loc> locs = new HashSet<>(); |
| | | for (WaveToLocParams item : params) { |
| | |
| | | maps.add(staListDto); |
| | | } |
| | | orderOutItemDto.setStaNos(maps); |
| | | //获取满足条件站点 |
| | | // 按可出规则选择站点 |
| | | Set<String> stationSet = deviceSites.stream().map(DeviceSite::getSite).collect(Collectors.toSet()); |
| | | String sType = "H"; |
| | | //获取高低站点类型 |
| | | if (startsWithTwoChars(loc.getBarcode(), "31")) { |
| | | sType = "L"; |
| | | } |
| | | //已使用站点 |
| | | Set<String> stas = stations.stream().map(BasStation::getStationName).collect(Collectors.toSet()); |
| | | BasStationService basStationService = SpringUtils.getBean(BasStationService.class); |
| | | BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>() |
| | | .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) |
| | | List<BasStation> candidateStations = basStationService.list(new LambdaQueryWrapper<BasStation>() |
| | | .in(BasStation::getStationName, stationSet) |
| | | // .eq(BasStation::getSType, sType) |
| | | .notIn(!stas.isEmpty(), BasStation::getStationName, stas) |
| | | .last("LIMIT 1")); |
| | | stations.add(basStation); |
| | | |
| | | if (Objects.isNull(basStation)) { |
| | | throw new CoolException("站點不存在!!"); |
| | | .eq(BasStation::getStatus, 1) |
| | | .eq(BasStation::getOutAble, 1)); |
| | | if (candidateStations.isEmpty()) { |
| | | throw new CoolException("无可出站点,请检查站点状态或能出配置!!"); |
| | | } |
| | | candidateStations.sort((a, b) -> { |
| | | boolean a1001 = "1001".equals(a.getStationName()); |
| | | boolean b1001 = "1001".equals(b.getStationName()); |
| | | if (a1001 && !b1001) return -1; |
| | | if (!a1001 && b1001) return 1; |
| | | return 0; |
| | | }); |
| | | BasStation basStation = candidateStations.get(0); |
| | | orderOutItemDto.setSitesNo(basStation.getStationName()); |
| | | } |
| | | } |