自动化立体仓库 - WMS系统
#
野心家
2023-06-08 5a0592f51e21bebc2155fb94e5058deb0604299c
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -669,20 +669,15 @@
                return R.error("该订单是出库订单,无法入库");
            }
            OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>()
                    .eq("order_no", jsonOrderDetl.getOrderNo())
                    .and()
                    .eq("maktx",jsonOrderDetl.getMaktx()));
            OrderDetl orderDetl = orderDetlService.selectItem(jsonOrderDetl.getOrderNo(),jsonOrderDetl.getMatnr(),jsonOrderDetl.getBatch());
            if (Cools.isEmpty(orderDetl)) {
                return R.error("单据明细有误,请检查");
            }
            if (orderDetl.getAnfme() - (jsonOrderDetl.getAnfme() + orderDetl.getWorkQty()) < 0) {
                return R.error("入库数量大于可入数量");
            }
            ManLocDetl checkManLocDetl = manLocDetlService.selectOne(new EntityWrapper<ManLocDetl>()
                    .eq("loc_no", jsonLocNo)
                    .eq("matnr", orderDetl.getMatnr())
                    .eq("batch",orderDetl.getBatch()));
            //查询平库中是否有一样的物料号,有的话直接增加数量
            ManLocDetl checkManLocDetl = manLocDetlService.selectInventory(jsonLocNo,orderDetl.getMatnr(),jsonOrderDetl.getBatch());
            if (checkManLocDetl == null) {
                ManLocDetl manLocDetl = new ManLocDetl();
                Synchro.Copy(orderDetl, manLocDetl);
@@ -694,13 +689,13 @@
                manLocDetl.setModiTime(date);
                manLocDetl.setCreateTime(date);
                manLocDetl.setBatch(jsonOrderDetl.getBatch());
                manLocDetlService.insert(manLocDetl);
                if(!manLocDetlService.insert(manLocDetl)){
                    return R.error("修改平库物料失败!");
                }
            } else {
                checkManLocDetl.setAnfme(checkManLocDetl.getAnfme() + jsonOrderDetl.getAnfme());
                checkManLocDetl.setModiTime(date);
                manLocDetlService.update(checkManLocDetl, new EntityWrapper<ManLocDetl>()
                        .eq("loc_no", jsonLocNo)
                        .eq("matnr", orderDetl.getMatnr()));
                if(manLocDetlService.increase(checkManLocDetl.getAnfme() + jsonOrderDetl.getAnfme(), jsonOrderDetl.getOrderNo(), jsonOrderDetl.getMaktx(), jsonOrderDetl.getBatch())<=0){
                    return R.error("修改平库物料失败!");
                }
            }
            orderDetl.setQty(orderDetl.getQty() + jsonOrderDetl.getAnfme());
            orderDetl.setWorkQty(orderDetl.getWorkQty() + jsonOrderDetl.getAnfme());
@@ -748,46 +743,30 @@
            if (Cools.isEmpty(node, order)) {
                return R.error("参数为空");
            }
            OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>()
                    .eq("order_no", jsonOrderDetl.getOrderNo())
                    .and()
                    .eq("maktx",jsonOrderDetl.getMaktx())
                    .and()
                    .eq("batch",jsonOrderDetl.getBatch()));
            OrderDetl orderDetl = orderDetlService.selectItem(jsonOrderDetl.getOrderNo(),jsonOrderDetl.getMatnr(),jsonOrderDetl.getBatch());
            if (Cools.isEmpty(orderDetl)) {
                return R.error("单据明细有误,请检查");
            }
            if (jsonOrderDetl.getAnfme() > (orderDetl.getAnfme() - orderDetl.getWorkQty())) {
                return R.error("出库数量大于单据可出数量");
            }
            ManLocDetl manLocDetl = manLocDetlService.selectOne(new EntityWrapper<ManLocDetl>()
                    .eq("loc_no", jsonLocNo)
                    .and()
                    .eq("maktx", jsonOrderDetl.getMaktx())
                    .and()
                    .eq("batch",jsonOrderDetl.getBatch()));
            if (manLocDetl == null) {
            //查询平库中是否有一样的物料号
            ManLocDetl checkManLocDetl = manLocDetlService.selectInventory(jsonLocNo,orderDetl.getMatnr(),orderDetl.getBatch());
            if (checkManLocDetl == null) {
                return R.error("该库位没有出库的物料信息");
            }
            if (jsonOrderDetl.getAnfme() > manLocDetl.getAnfme()) {
            if (jsonOrderDetl.getAnfme() > checkManLocDetl.getAnfme()) {
                return R.error("出库数量大于可出数量");
            }
            Double finalQty = manLocDetl.getAnfme() - jsonOrderDetl.getAnfme();
            Double finalQty = checkManLocDetl.getAnfme() - jsonOrderDetl.getAnfme();
            if (finalQty <= 0){
                manLocDetlService.delete(new EntityWrapper<ManLocDetl>()
                        .eq("loc_no", jsonLocNo)
                        .and()
                        .eq("matnr", orderDetl.getMatnr())
                        .and()
                        .eq("batch",jsonOrderDetl.getBatch()));
                if(manLocDetlService.deleteDatailed(jsonLocNo, jsonOrderDetl.getMatnr(), jsonOrderDetl.getBatch())<=0){
                    return R.error("修改平库物料失败!");
                }
            }else {
                manLocDetl.setAnfme(finalQty);
                manLocDetl.setModiTime(date);
                manLocDetlService.update(manLocDetl,new EntityWrapper<ManLocDetl>()
                        .eq("loc_no", jsonLocNo)
                        .eq("matnr", orderDetl.getMatnr())
                        .and()
                        .eq("batch",jsonOrderDetl.getBatch()));
                if(manLocDetlService.increase(finalQty, jsonLocNo, jsonOrderDetl.getMatnr(), jsonOrderDetl.getBatch())<=0){
                    return R.error("修改平库物料失败!");
                }
            }
            orderDetl.setQty(orderDetl.getQty() + jsonOrderDetl.getAnfme());
            orderDetl.setWorkQty(orderDetl.getWorkQty() + jsonOrderDetl.getAnfme());
@@ -814,4 +793,5 @@
        return R.ok("下架完成");
    }
}