自动化立体仓库 - WMS系统
#
whycq
2024-01-12 ef106c9a6002872892de9db355ef7cd37512dba5
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -79,9 +79,10 @@
    private ManLocDetlService manLocDetlService;
    @Autowired
    private ManLocDetlMapper manLocDetlMapper;
    @Autowired
    private  DocTypeService docTypeService;
    @Autowired
    private MatV2Service matV2Service;
    @Override
    @Transactional
    public void comb(CombParam param, Long userId) {
@@ -136,11 +137,16 @@
            for (DetlDto detlDto : detlDtos) {
                Mat mat = matService.selectByMatnr(detlDto.getMatnr());
                if (Cools.isEmpty(mat)) {
                    throw new CoolException(detlDto.getMatnr() + "商品档案不存在");
                }
                WaitPakin waitPakin = new WaitPakin();
                waitPakin.sync(mat);
                if (Cools.isEmpty(mat)) {
                    MatV2 matV2 = matV2Service.selectOne(new EntityWrapper<MatV2>().eq("matnr", detlDto.getMatnr()));
                    if(Cools.isEmpty(matV2)){
                        throw new CoolException(detlDto.getMatnr() + "商品档案不存在");
                    }
                    waitPakin.sync(matV2);
                } else {
                    waitPakin.sync(mat);
                }
                waitPakin.setBatch(detlDto.getBatch());
                waitPakin.setZpallet(param.getBarcode());   // 托盘码
                waitPakin.setIoStatus("N");     // 入出状态
@@ -669,20 +675,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 +695,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 +749,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 +799,5 @@
        return R.ok("下架完成");
    }
}