| | |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.api.enums.LocAreaType; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.service.impl.BasAreasServiceImpl; |
| | | import com.zy.asrs.service.impl.BasStationServiceImpl; |
| | | import com.zy.asrs.service.impl.LocCacheServiceImpl; |
| | | import com.zy.common.model.LocDto; |
| | | import com.zy.common.model.TaskDto; |
| | | import com.zy.common.web.BaseController; |
| | |
| | | private OrderPakoutService orderPakOutService; |
| | | @Autowired |
| | | private CheckOrderService checkOrderService; |
| | | |
| | | @Autowired |
| | | private BasAreasService basAreasService; |
| | | @Autowired |
| | | private LocCacheServiceImpl locCacheService; |
| | | @Autowired |
| | | private BasStationServiceImpl basStationService; |
| | | |
| | | |
| | | @PostMapping("/out/pakout/orderDetlIds/auth") |
| | |
| | | |
| | | List<LocDto> locDtos = new ArrayList<>(); |
| | | |
| | | Set<String> exist = new HashSet<>(); |
| | | Set<String> exist = new HashSet<>(); |
| | | |
| | | |
| | | |
| | | // 获取订单主表 |
| | | OrderPakout orderPakOut = orderPakOutService.selectByNo(orderDetlPakouts.get(0).getOrderNo()); |
| | | // 盘点单出库 |
| | | if (orderPakOut.getDocType() == 8) { |
| | | // 备货单 |
| | | if (orderPakOut.getDocType() == 5) { |
| | | List<BasAreas> basAreas = basAreasService.selectList(new EntityWrapper<BasAreas>().in("whs_type_id", LocAreaType.SO_HOLDING.type, LocAreaType.EO_HOLDING.type)); |
| | | List<Long> areaIds = basAreas.stream() |
| | | .map(BasAreas::getId) |
| | | .collect(Collectors.toList()); |
| | | for (OrderDetlPakout orderDetl : orderDetlPakouts) { |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getWorkQty()).orElse(0.0D); |
| | | if (issued <= 0.0D) { |
| | | continue; |
| | | } |
| | | List<LocDetl> locDetls = locDetlService.queryStockAll(null, exist,orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | orderDetl.getBrand(),orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(),orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3()); |
| | | List<LocDetl> locDetls = locDetlService.queryStockAllCache(null, exist,orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | orderDetl.getBrand(),orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(),orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3(),areaIds); |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | | issued >= locDetl.getAnfme() ? locDetl.getAnfme() : issued); |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo())); |
| | | // LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo())); |
| | | LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("loc_no", locDetl.getLocNo())); |
| | | locDto.setFrozen(locDetl.getFrozen()); |
| | | locDto.setFrozenLoc(locMast.getFrozen()); |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), 107); |
| | | locDto.setFrozenLoc(locCache.getFrozen()); |
| | | List<BasStation> basStations = basStationService.selectList(new EntityWrapper<BasStation>().in("area_id", areaIds)); |
| | | List<String> collect = basStations.stream().map(BasStation::getDevNo).collect(Collectors.toList()); |
| | | locDto.setAgvStaNos(collect); |
| | | locDto.setBrand(orderDetl.getBrand()); |
| | | |
| | | locDto.setStandby1(orderDetl.getStandby1()); |
| | | locDto.setStandby2(orderDetl.getStandby2()); |
| | | locDto.setStandby3(orderDetl.getStandby3()); |
| | | locDto.setBoxType1(orderDetl.getBoxType1()); |
| | | locDto.setBoxType2(orderDetl.getBoxType2()); |
| | | locDto.setBoxType3(orderDetl.getBoxType3()); |
| | | |
| | | locDto.setStaNos(staNos); |
| | | locDtos.add(locDto); |
| | | exist.add(locDetl.getLocNo()); |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |
| | | } else { |
| | |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(null, orderDetl.getMatnr(), orderDetl.getMaktx(), orderDetl.getBatch(), orderDetl.getOrderNo(), issued); |
| | | locDto.setBrand(orderDetl.getBrand()); |
| | | |
| | | locDto.setStandby1(orderDetl.getStandby1()); |
| | | locDto.setStandby2(orderDetl.getStandby2()); |
| | | locDto.setStandby3(orderDetl.getStandby3()); |
| | |
| | | } |
| | | } |
| | | } else { |
| | | List<BasAreas> basAreas = basAreasService.selectList(new EntityWrapper<BasAreas>().in("whs_type_id", LocAreaType.AUTOMATED.type)); |
| | | List<Long> areaIds = basAreas.stream() |
| | | .map(BasAreas::getId) |
| | | .collect(Collectors.toList()); |
| | | for (OrderDetlPakout orderDetl : orderDetlPakouts) { |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getWorkQty()).orElse(0.0D); |
| | | if (issued <= 0.0D) { |
| | | continue; |
| | | } |
| | | List<LocDetl> locDetls = locDetlService.queryStockAll(null, exist,orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | orderDetl.getBrand(),orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(),orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3()); |
| | | orderDetl.getBrand(),orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(),orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3(),areaIds); |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/out/agvPakOut/auth") |
| | | @ManagerAuth(memo = "订单出库") |
| | | public synchronized R agvPakOut(@RequestBody List<LocDto> locDtos) throws InterruptedException { |
| | | if (Cools.isEmpty(locDtos)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | List<LocDto> locDtoArrayList = new ArrayList<>(); |
| | | for (LocDto locDto : locDtos){ |
| | | if (locDto.getFrozen()!=1 && locDto.getFrozenLoc()!=1){ |
| | | locDtoArrayList.add(locDto); |
| | | } |
| | | } |
| | | locDtos = locDtoArrayList; |
| | | if (Cools.isEmpty(locDtos)) { |
| | | return R.parse("库存/库位被冻结,请处理后出库!!!"); |
| | | } |
| | | boolean lack = true; |
| | | for (LocDto locDto : locDtos) { |
| | | if (!locDto.isLack()) { |
| | | lack = false; |
| | | break; |
| | | } |
| | | } |
| | | if (lack) { |
| | | return R.error("库存不足"); |
| | | } |
| | | |
| | | Thread.sleep(1000L); |
| | | |
| | | List<TaskDto> taskDtos = new ArrayList<>(); |
| | | // 根据 (库位 & 出库站) 分组; 理想状态:一组为一次出库任务 |
| | | for (LocDto locDto : locDtos) { |
| | | if (locDto.isLack()) { continue; } |
| | | TaskDto taskDto = new TaskDto(locDto.getLocNo(), locDto.getAgvStaNo(), locDto); |
| | | if (TaskDto.has(taskDtos, taskDto)) { |
| | | TaskDto dto = TaskDto.find(taskDtos, taskDto); |
| | | assert dto != null; |
| | | dto.getLocDtos().addAll(taskDto.getLocDtos()); |
| | | } else { |
| | | taskDtos.add(taskDto); |
| | | } |
| | | } |
| | | // ----------------------------------------------------------------------------------------------- |
| | | for (TaskDto taskDto : taskDtos) { |
| | | // BasDevp staNo = basDevpService.checkSiteStatus(taskDto.getStaNo()); |
| | | BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", taskDto.getAgvStaNo())); |
| | | workService.agvStockOut(station, taskDto, getUserId()); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |