#
luxiaotao1123
2021-03-20 b650e00a5e5ecdad78014452c8bfa60b3ffbfca7
src/main/java/zy/cloud/wms/common/service/MainService.java
@@ -39,13 +39,13 @@
    private SnowflakeIdWorker snowflakeIdWorker;
    @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());
@@ -55,27 +55,29 @@
            // 查询存有当前物料的货位
            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;
    }
@@ -117,15 +119,15 @@
                        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();