| | |
| | | import com.zy.common.model.LocDto; |
| | | import com.zy.common.model.TaskDto; |
| | | import com.zy.common.web.BaseController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | |
| | | * Created by vincent on 2022/3/26 |
| | | */ |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | public class OutController extends BaseController { |
| | | |
| | |
| | | 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.queryStockAll(null, exist, orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | orderDetl.getBrand(), orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3()); |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | |
| | | 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.queryStockAll(null, exist, orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | orderDetl.getBrand(), orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3()); |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | |
| | | |
| | | @PostMapping("/out/pakout/auth") |
| | | @ManagerAuth(memo = "订单出库") |
| | | @Transactional |
| | | public synchronized R pakout(@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){ |
| | | for (LocDto locDto : locDtos) { |
| | | if (locDto.getFrozen() != 1 && locDto.getFrozenLoc() != 1) { |
| | | locDtoArrayList.add(locDto); |
| | | } |
| | | } |
| | |
| | | List<TaskDto> taskDtos = new ArrayList<>(); |
| | | // 根据 (库位 & 出库站) 分组; 理想状态:一组为一次出库任务 |
| | | for (LocDto locDto : locDtos) { |
| | | if (locDto.isLack()) { continue; } |
| | | if (locDto.isLack()) { |
| | | continue; |
| | | } |
| | | TaskDto taskDto = new TaskDto(locDto.getLocNo(), locDto.getStaNo(), locDto, locDto.getStandby1()); |
| | | if (TaskDto.has(taskDtos, taskDto)) { |
| | | TaskDto dto = TaskDto.find(taskDtos, taskDto); |
| | |
| | | } |
| | | } |
| | | // ----------------------------------------------------------------------------------------------- |
| | | int failCount = 0; |
| | | for (TaskDto taskDto : taskDtos) { |
| | | BasDevp staNo = basDevpService.checkSiteStatus(taskDto.getStaNo()); |
| | | if (!Objects.isNull(taskDto.getDeviceNo())) { |
| | | //生成出库任务 |
| | | workService.stockOut(staNo, taskDto, taskDto.getDeviceNo(), getUserId()); |
| | | } else { |
| | | workService.stockOut(staNo, taskDto, null, getUserId()); |
| | | if (!stockOutSafely(taskDto, getUserId(), "手动订单出库")) { |
| | | failCount++; |
| | | } |
| | | } |
| | | if (failCount > 0) { |
| | | return R.ok("部分出库任务已生成,成功" + (taskDtos.size() - failCount) + "条,失败" + failCount + "条,请查看日志"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | private boolean stockOutSafely(TaskDto taskDto, Long userId, String scene) { |
| | | try { |
| | | BasDevp staNo = basDevpService.checkSiteStatus(taskDto.getStaNo()); |
| | | workService.stockOut(staNo, taskDto, taskDto.getDeviceNo(), userId); |
| | | return true; |
| | | } catch (Exception e) { |
| | | log.error("{}失败[locNo={}, staNo={}, deviceNo={}, orderNos={}],原因: {}", |
| | | scene, |
| | | taskDto.getLocNo(), |
| | | taskDto.getStaNo(), |
| | | taskDto.getDeviceNo(), |
| | | collectOrderNos(taskDto), |
| | | getErrorMessage(e)); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | private String collectOrderNos(TaskDto taskDto) { |
| | | Set<String> orderNos = new LinkedHashSet<>(); |
| | | for (LocDto locDto : taskDto.getLocDtos()) { |
| | | if (!Cools.isEmpty(locDto.getOrderNo())) { |
| | | orderNos.add(locDto.getOrderNo()); |
| | | } |
| | | } |
| | | return orderNos.toString(); |
| | | } |
| | | |
| | | private String getErrorMessage(Exception e) { |
| | | return Cools.isEmpty(e.getMessage()) ? e.getClass().getSimpleName() : e.getMessage(); |
| | | } |
| | | } |