| | |
| | | @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<StoPreVo> stockOutPreview(OrderStoDto dto) { |
| | | public List<StoPreTab> stockOutPreview(OrderStoDto dto) { |
| | | if (Cools.isEmpty(dto) || Cools.isEmpty(dto.getCustOrders())) { |
| | | throw new CoolException("数据异常,请联系管理员"); |
| | | } |
| | | // 检查库存是否足够 |
| | | locDetlService.checkLocDetlCount(dto.getNumber()); |
| | | List<StoPreVo> result = new ArrayList<>(); |
| | | List<StoPreTab> result = new ArrayList<>(); |
| | | for (CustOrder custOrder : dto.getCustOrders()) { |
| | | // 判断物料是否存在 |
| | | Mat mat = matService.selectByMatnr(custOrder.getUserCode()); |
| | |
| | | // 查询存有当前物料的货位 |
| | | 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); |
| | | double anfme = issued; |
| | | 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); |
| | | // 视图对象 |
| | | StoPreTab tab = new StoPreTab(); |
| | | tab.setTitle(mat.getMatnr() + "(" + mat.getMaktx() + ")"); |
| | | tab.setMatnr(mat.getMatnr()); |
| | | tab.setMaktx(mat.getMaktx()); |
| | | tab.setAnfme(anfme); |
| | | |
| | | tab.setLocNo(locDetl.getLocNo()); |
| | | tab.setNodeId(locDetl.getNodeId()); |
| | | tab.setTotal(locDetl.getAnfme()); |
| | | tab.setReduce(issued>=locDetl.getAnfme()?locDetl.getAnfme():issued); |
| | | tab.setRemQty(tab.getTotal() - tab.getReduce()); |
| | | tab.setPrior(locDetlService.isPrior(locDetl.getNodeId(), mat.getMatnr())); |
| | | tab.setPrior$(tab.getPrior()?"✔":"×"); |
| | | result.add(tab); |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |
| | | } |
| | | } |
| | | result.add(vo); |
| | | |
| | | } |
| | | return result; |
| | | } |