| | |
| | | package com.zy.asrs.wms.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.common.domain.dto.LocDto; |
| | | import com.zy.asrs.common.domain.dto.OrderDto; |
| | | import com.zy.asrs.common.domain.dto.TaskDto; |
| | | import com.zy.asrs.common.sys.service.StaDescService; |
| | | import com.zy.asrs.common.web.BaseController; |
| | | import com.zy.asrs.common.wms.entity.LocDetl; |
| | | import com.zy.asrs.common.wms.entity.OrderDetl; |
| | | import com.zy.asrs.common.wms.entity.*; |
| | | import com.zy.asrs.common.wms.service.*; |
| | | import com.zy.asrs.framework.annotations.ManagerAuth; |
| | | import com.zy.asrs.framework.common.BaseRes; |
| | |
| | | if (Cools.isEmpty(ids)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | Long hostId = getHostId(); |
| | | List<OrderDetl> orderDetls = orderDetlService.listByIds(ids); |
| | | List<LocDto> locDtos = new ArrayList<>(); |
| | | |
| | |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getQty()).orElse(0.0D); |
| | | if (issued <= 0.0D) { continue; } |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getOrigin(), exist); |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), hostId); |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (!Cools.isEmpty(locDetl.getMemo())){ |
| | | continue; |
| | |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | | issued >= locDetl.getAnfme() ? locDetl.getAnfme() : issued); |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), issued >= locDetl.getAnfme() ? 101 : 103); |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), issued >= locDetl.getAnfme() ? 101 : 103, hostId); |
| | | locDto.setStaNos(staNos); |
| | | locDtos.add(locDto); |
| | | exist.add(locDetl.getLocNo()); |
| | |
| | | return R.ok().add(locDtos); |
| | | } |
| | | |
| | | @PostMapping("/out/pakout/auth") |
| | | @ManagerAuth(memo = "订单出库") |
| | | public synchronized R pakout(@RequestBody List<LocDto> locDtos) throws InterruptedException { |
| | | if (Cools.isEmpty(locDtos)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | Long hostId = getHostId(); |
| | | boolean lack = true; |
| | | for (LocDto locDto : locDtos) { |
| | | if (!locDto.isLack()) { |
| | | lack = false; |
| | | break; |
| | | } |
| | | } |
| | | if (lack) { |
| | | return R.error("库存不足"); |
| | | } |
| | | |
| | | Thread.sleep(500L); |
| | | |
| | | // 订单预校验 ===>> 1.订单状态; 2.订单带出数量 |
| | | List<OrderDto> orderDtos = new ArrayList<>(); |
| | | for (LocDto locDto : locDtos) { |
| | | if (Cools.isEmpty(locDto.getOrderNo())) { continue; } |
| | | OrderDto orderDto = new OrderDto(locDto.getOrderNo(), locDto.getMatnr(), locDto.getAnfme()); |
| | | if (OrderDto.has(orderDtos, orderDto)) { |
| | | OrderDto dto = OrderDto.find(orderDtos, orderDto); |
| | | assert dto != null; |
| | | dto.setAnfme(dto.getAnfme() + orderDto.getAnfme()); |
| | | } else { |
| | | orderDtos.add(orderDto); |
| | | } |
| | | } |
| | | for (OrderDto orderDto : orderDtos) { |
| | | Order order = orderService.selectByNo(orderDto.getOrderNo(), hostId); |
| | | if (order.getSettle() > 2) { |
| | | return R.error(orderDto.getOrderNo() + "订单已失效,请及时刷新页面"); |
| | | } |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), orderDto.getMatnr(), null); |
| | | if (orderDetl.getAnfme() - orderDetl.getQty() < orderDto.getAnfme()) { |
| | | return R.ok(orderDto.getOrderNo() + "订单已作业,请及时刷新页面"); |
| | | } |
| | | } |
| | | |
| | | List<TaskDto> taskDtos = new ArrayList<>(); |
| | | // 根据 (库位 & 出库站) 分组; 理想状态:一组为一次出库任务 |
| | | for (LocDto locDto : locDtos) { |
| | | if (locDto.isLack()) { continue; } |
| | | //2022-08-04 Add,防止前端页面提取库位信息后,在其他地方对该库位生成了出库任务(库位状态非F状态) |
| | | LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>() |
| | | .eq(LocMast::getLocNo, locDto.getLocNo()) |
| | | .eq(LocMast::getHostId, hostId)); |
| | | if(!Cools.isEmpty(locMast) && !locMast.getLocSts().equals("F")){ |
| | | return R.error("库位号非在库状态,请重新选择出库库位===>>" + locDto.getLocNo()); |
| | | } |
| | | |
| | | TaskDto taskDto = new TaskDto(locDto.getLocNo(), locDto.getStaNo(), locDto, hostId); |
| | | 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(), false, hostId); |
| | | workService.stockOut(staNo.getDevNo(), taskDto, getUserId(), hostId); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |