| | |
| | | import com.vincent.rsf.server.manager.enums.WaveRuleType; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.vincent.rsf.server.manager.enums.LocStsType; |
| | | import io.swagger.models.auth.In; |
| | | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | |
| | | import javax.swing.*; |
| | |
| | | DeviceSiteService deviceSiteService = SpringUtils.getBean(DeviceSiteService.class); |
| | | |
| | | List<OrderOutItemDto> list = new ArrayList<>(); |
| | | Set<ExistDto> existDtos = new HashSet<>(); |
| | | //不让站点重复使用问题 |
| | | List<BasStation> stations = new ArrayList<>(); |
| | | List<ExistDto> existDtos = new ArrayList<>(); |
| | | Set<Loc> locs = new HashSet<>(); |
| | | for (WaveToLocParams item : params) { |
| | | BigDecimal issued = new BigDecimal(item.getAnfme().toString()) |
| | | .subtract(new BigDecimal(item.getWorkQty().toString())); |
| | |
| | | locItems = LocManageUtil.getFirstInFirstOutItemList(item.getMatnrCode(), item.getBatch(), item.getAnfme()); |
| | | } |
| | | } |
| | | |
| | | for (LocItem locItem : locItems) { |
| | | Loc loc = locService.getById(locItem.getLocId()); |
| | | List<LocItem> itemList = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocCode, locItem.getLocCode())); |
| | |
| | | .setSource(item.getItemId());//波次明细ID |
| | | OrderOutItemDto orderOutItemDto = new OrderOutItemDto(); |
| | | orderOutItemDto.setLocItem(locItem); |
| | | |
| | | orderOutItemDto.setSource(item.getItemId()) |
| | | .setSourceId(item.getWaveId()); |
| | | List<DeviceSite> deviceSites = deviceSiteService.list(new LambdaQueryWrapper<DeviceSite>() |
| | | .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel()) |
| | | .eq(DeviceSite::getType, issued.doubleValue() >= locItem.getAnfme() && itemList.size() == 1 ? TaskType.TASK_TYPE_OUT.type : TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) |
| | | ); |
| | | |
| | | if (!deviceSites.isEmpty()) { |
| | | List<OrderOutItemDto.staListDto> maps = new ArrayList<>(); |
| | | for (DeviceSite sta : deviceSites) { |
| | | OrderOutItemDto.staListDto staListDto = new OrderOutItemDto.staListDto(); |
| | | staListDto.setStaNo(sta.getSite()); |
| | | staListDto.setStaName(sta.getSite()); |
| | | maps.add(staListDto); |
| | | if (locs.add(loc)) { |
| | | if (!deviceSites.isEmpty()) { |
| | | List<OrderOutItemDto.staListDto> maps = new ArrayList<>(); |
| | | for (DeviceSite sta : deviceSites) { |
| | | OrderOutItemDto.staListDto staListDto = new OrderOutItemDto.staListDto(); |
| | | staListDto.setStaNo(sta.getSite()); |
| | | staListDto.setStaName(sta.getSite()); |
| | | maps.add(staListDto); |
| | | } |
| | | orderOutItemDto.setStaNos(maps); |
| | | //获取满足条件站点 |
| | | Set<String> stationSet = deviceSites.stream().map(DeviceSite::getSite).collect(Collectors.toSet()); |
| | | //已使用站点 |
| | | 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) |
| | | .in(BasStation::getStationName, stationSet) |
| | | .notIn(!stas.isEmpty(), BasStation::getStationName, stas) |
| | | .last("LIMIT 1")); |
| | | stations.add(basStation); |
| | | |
| | | if (Objects.isNull(basStation)) { |
| | | throw new CoolException("站點不存在!!"); |
| | | } |
| | | orderOutItemDto.setSitesNo(basStation.getStationName()); |
| | | } |
| | | orderOutItemDto.setStaNos(maps); |
| | | //默认获取第一站点 |
| | | DeviceSite deviceSite = deviceSites.stream().findFirst().get(); |
| | | BasStationService basStationService = SpringUtils.getBean(BasStationService.class); |
| | | BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>() |
| | | .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) |
| | | .last("LIMIT 1")); |
| | | if (Objects.isNull(basStation)) { |
| | | throw new CoolException("站點不存在!!"); |
| | | } |
| | | orderOutItemDto.setSitesNo(basStation.getStationName()); |
| | | } |
| | | |
| | | orderOutItemDto.setSource(item.getItemId()) |
| | | .setSourceId(item.getWaveId()); |
| | | |
| | | list.add(orderOutItemDto); |
| | | |