| | |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | |
| | | // @Transactional |
| | | // public List<StoPreVo> stockOutPreview0(OrderStoDto dto) { |
| | | // if (Cools.isEmpty(dto) || Cools.isEmpty(dto.getCustOrders())) { |
| | | // throw new CoolException("数据异常,请联系管理员"); |
| | | // } |
| | | // // 检查库存是否足够 |
| | | // locDetlService.checkLocDetlCount(dto.getNumber()); |
| | | // List<StoPreVo> result = new ArrayList<>(); |
| | | // for (CustOrder custOrder : dto.getCustOrders()) { |
| | | // // 判断物料是否存在 |
| | | // Mat mat = matService.selectByMatnr(custOrder.getUserCode()); |
| | | // if (null == mat) { |
| | | // throw new CoolException(custOrder.getUserCode() + "物料尚未更新。" + custOrder.getNumber() +"单据因此中断!"); |
| | | // } |
| | | // // 查询存有当前物料的货位 |
| | | // List<LocDetl> locDetls = locDetlService.findOfSort(mat.getMatnr()); |
| | | // double issued = Optional.ofNullable(custOrder.getQty()).orElse(0.0D) ; |
| | | // // 视图对象 |
| | | // StoPreVo vo = new StoPreVo(); |
| | | // vo.setMatnr(mat.getMatnr()); |
| | | // vo.setMaktx(mat.getMaktx()); |
| | | // vo.setAnfme(issued); |
| | | // List<StoPreVo.StoPreLoc> locVos = new ArrayList<>(); |
| | | // vo.setLocs(locVos); |
| | | // for (LocDetl locDetl : locDetls) { |
| | | // if (issued > 0) { |
| | | // StoPreVo.StoPreLoc locVo = new StoPreVo.StoPreLoc(); |
| | | // locVo.setLocNo(locDetl.getLocNo()); |
| | | // locVo.setNodeId(locDetl.getNodeId()); |
| | | // locVo.setTotal(locDetl.getAnfme()); |
| | | // locVo.setReduce(issued>=locDetl.getAnfme()?locDetl.getAnfme():issued); |
| | | // locVo.setPrior(locDetlService.isPrior(locDetl.getNodeId(), mat.getMatnr())); |
| | | // locVos.add(locVo); |
| | | // // 剩余待出数量递减 |
| | | // issued = issued - locDetl.getAnfme(); |
| | | // } |
| | | // } |
| | | // result.add(vo); |
| | | // } |
| | | // return result; |
| | | // } |
| | | |
| | | @Transactional |
| | | public List<StoPreTab> stockOutPreview(OrderStoDto dto) { |
| | | if (Cools.isEmpty(dto) || Cools.isEmpty(dto.getCustOrders())) { |
| | |
| | | throw new CoolException("保存出库通知单失败"); |
| | | } |
| | | if (issued>=locDetl.getAnfme()) { |
| | | // 删除库存明细 |
| | | if (!locDetlService.removeStock(locDetl.getNodeId(), mat.getMatnr())) { |
| | | throw new CoolException("删除库存明细失败"); |
| | | } |
| | | // // 删除库存明细 |
| | | // if (!locDetlService.removeStock(locDetl.getNodeId(), mat.getMatnr())) { |
| | | // throw new CoolException("删除库存明细失败"); |
| | | // } |
| | | } else { |
| | | // 修改库存明细数量 |
| | | if (!locDetlService.reduceStock(locDetl.getNodeId(), mat.getMatnr(), issued)) { |
| | | throw new CoolException("修改库存明细数量失败"); |
| | | } |
| | | // // 修改库存明细数量 |
| | | // if (!locDetlService.reduceStock(locDetl.getNodeId(), mat.getMatnr(), issued)) { |
| | | // throw new CoolException("修改库存明细数量失败"); |
| | | // } |
| | | } |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |