|  |  |  | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.vincent.rsf.server.manager.enums.WaveRuleType; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @param | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public R getOrderOutTaskItem(OrderOutTaskParam param) { | 
|---|
|  |  |  | if (Cools.isEmpty(param.getWaveId())) { | 
|---|
|  |  |  | if (Cools.isEmpty(param.getWaveId())){ | 
|---|
|  |  |  | throw new CoolException("策略参数为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(param.getOrderId())) { | 
|---|
|  |  |  | if (Cools.isEmpty(param.getOrderId())){ | 
|---|
|  |  |  | throw new CoolException("单据id为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | WaveRule waveRule = waveRuleService.getOne(new LambdaQueryWrapper<WaveRule>().eq(WaveRule::getId, param.getWaveId())); | 
|---|
|  |  |  | if (Cools.isEmpty(waveRule)) { | 
|---|
|  |  |  | if (Cools.isEmpty(waveRule)){ | 
|---|
|  |  |  | throw new CoolException("未找到当前策略"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<OrderOutItemDto> locItems = null; | 
|---|
|  |  |  | if (WaveRuleType.Efficiency_First.type.equals(waveRule.getType())) { | 
|---|
|  |  |  | locItems = efficiencyFirst(param.getOrderId()); | 
|---|
|  |  |  | locItems =  efficiencyFirst(param.getOrderId()); | 
|---|
|  |  |  | } else if (WaveRuleType.First_In_First_Out.type.equals(waveRule.getType())) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(locItems); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private List<LocItem> getEfficiencyFirstItemList(AsnOrderItem asnOrderItem) { | 
|---|
|  |  |  | private List<LocItem> getEfficiencyFirstItemList(AsnOrderItem asnOrderItem){ | 
|---|
|  |  |  | QueryWrapper<LocItem> locItemQueryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | locItemQueryWrapper.eq("matnr_code", asnOrderItem.getMatnrCode()); | 
|---|
|  |  |  | locItemQueryWrapper.eq("batch", asnOrderItem.getSplrBatch()); | 
|---|
|  |  |  | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | locItemQueryWrapper.apply(applySql); | 
|---|
|  |  |  | List<LocItem> locItems = locItemService.list(locItemQueryWrapper); | 
|---|
|  |  |  | locItems.sort((s1, s2) -> LocUtils.isShallowLoc(s1.getLocCode()) ? -1 : 0); | 
|---|
|  |  |  | locItems.sort((s1,s2)-> LocUtils.isShallowLoc(s1.getLocCode())?-1:0); | 
|---|
|  |  |  | return locItems; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private List<OrderOutItemDto> efficiencyFirst(Long orderId) { | 
|---|
|  |  |  | private List<OrderOutItemDto> efficiencyFirst(Long orderId){ | 
|---|
|  |  |  | List<AsnOrderItem> asnOrderItems = asnOrderItemService.list(new LambdaQueryWrapper<AsnOrderItem>() | 
|---|
|  |  |  | .eq(AsnOrderItem::getAsnId, orderId) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | 
|---|
|  |  |  | for (LocItem locItem : locItems) { | 
|---|
|  |  |  | Loc loc = locService.getById(locItem.getLocId()); | 
|---|
|  |  |  | List<LocItem> itemList = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocCode, locItem.getLocCode())); | 
|---|
|  |  |  | if (issued.doubleValue() > 0) { | 
|---|
|  |  |  | if (issued.doubleValue() > 0){ | 
|---|
|  |  |  | ExistDto existDto = new ExistDto().setBatch(locItem.getBatch()).setMatnr(locItem.getMatnrCode()).setLocNo(locItem.getLocCode()); | 
|---|
|  |  |  | if (existDtos.add(existDto)) { | 
|---|
|  |  |  | if (existDtos.add(existDto)){ | 
|---|
|  |  |  | locItem.setWorkQty(issued.doubleValue() >= locItem.getAnfme() ? locItem.getAnfme() : issued.doubleValue()); | 
|---|
|  |  |  | OrderOutItemDto orderOutItemDto = new OrderOutItemDto(); | 
|---|
|  |  |  | orderOutItemDto.setLocItem(locItem); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<DeviceSite> deviceSites = deviceSiteService.list(new LambdaQueryWrapper<DeviceSite>() | 
|---|
|  |  |  | .eq(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()) { | 
|---|
|  |  |  | DeviceSite deviceSite = deviceSites.stream().findFirst().get(); | 
|---|
|  |  |  | orderOutItemDto.setSiteNo(deviceSite.getSite()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<OrderOutItemDto.staListDto> maps = new ArrayList<>(); | 
|---|
|  |  |  | for (DeviceSite sta : deviceSites) { | 
|---|
|  |  |  | OrderOutItemDto.staListDto staListDto = new OrderOutItemDto.staListDto(); | 
|---|