自动化立体仓库 - WMS系统
#
whycq
2024-09-19 2d6cdc6d4a4feac22724b516ffbaec629896255c
src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java
@@ -151,6 +151,7 @@
            } else {
                Double anfme = agvWrkDetl.getAnfme() + pick.getCount();
                agvWrkDetl.setAnfme(anfme);
                agvWrkDetl.setModiTime(new Date());
                agvWrkDetlService.update(agvWrkDetl,new EntityWrapper<AgvWrkDetl>().eq("matnr",agvWrkDetl.getMatnr()).eq("three_code",agvWrkDetl.getThreeCode()).eq("supp_code",pick.getSuppCode()));
            }
@@ -178,6 +179,7 @@
        }
        if (agvLocDetls.size() == sameNumber) {
            agvWrkMast.setIoType(101);
            agvWrkMast.setModiTime(new Date());
            agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no", pickParams.getWrkNo()));
        }
@@ -237,7 +239,7 @@
                checkOrderQty(order,combMat);
            }
            DetlDto detlDto = new DetlDto(combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), combMat.getCsocode(), combMat.getIsoseq(),combMat.getContainerCode(),param.getLocType());
            DetlDto detlDto = new DetlDto(combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), combMat.getCsocode(), combMat.getIsoseq(),combMat.getContainerCode(),param.getLocType(),combMat.getProcessSts());
            //同一货架下相同物料信息和批号转为一个入库通知档
            if (DetlDto.has(detlDtos, detlDto)) {
                DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(), detlDto.getCsocode(), detlDto.getIsoseq(),detlDto.getContainerCode());
@@ -293,6 +295,8 @@
        waitPakin.setDeadTime(detlDto.getIsoseq());
        waitPakin.setLocType(detlDto.getLocType());
        waitPakin.setProcessSts(detlDto.getProcessSts());
        waitPakin.setAppeUser(userId);
@@ -386,6 +390,20 @@
    public String handControlLocMove(LocMoveParam param, Long userId) {
        String fl = String.valueOf(param.getFloor());
        short floor =(short)Integer.parseInt(fl.substring(0, 1));
        switch (param.getFloor()) {
            case "1F01":
                floor = 1;
                break;
            case "1F02":
                floor = 4;
                break;
            case "2F":
                floor = 2;
                break;
            case "3F":
                floor = 3;
                break;
        }
        Integer ioType = 0;
        AgvLocMast agvLocMast = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no", param.getLocNo()));
        if (Cools.isEmpty(agvLocMast)) {
@@ -403,17 +421,21 @@
            }
        } else {
            if (agvLocMast.getFloor() != floor) {
//                if (floor==1 && agvLocMast.getFloor()!=1){
//                    ioType = 121;
//                }else {
                    if (agvLocMast.getFloor() == 1) {
                        throw new CoolException("当前库位请选择调拨单调拨!");
                if (agvLocMast.getFloor() == 1 && (floor == 2 || floor == 3)) {
                    throw new CoolException("当前库位请选择调拨单调拨!");
                } else {
                    ioType = 12;
                }
            } else {
                if (agvLocMast.getFloor() == 1) {
                    if (agvLocMast.getLev1() == 1 && floor == 1) {
                        ioType = 11;
                    } else {
                        ioType = 12;
                    }
//                }
            } else {
                ioType = 11;
                } else {
                    ioType = 11;
                }
            }
        }
        Date now = new Date();
@@ -423,7 +445,21 @@
            throw new CoolException("当前"+agvLocMast.getBarcode()+"货架码已在工作档中");
        }
        //检索库位,选择合适的库位
        AgvLocMast locMast = agvCommonService.getLocNo(agvLocMast.getLocType1(),floor,false,true);
        AgvLocMast locMast = null;
        if (floor == 1) {
            locMast = agvCommonService.getLocNo(agvLocMast.getLocType1(),floor,true,false);
        } else {
            locMast = agvCommonService.getLocNo(agvLocMast.getLocType1(),floor,false,false);
        }
        // 目标楼层去 吸塑2楼
        if (floor == 4) {
            if (locMast.getLev1() == 1) {
                throw new CoolException("吸塑一楼没有空库位可以移库!");
            }
        }
        if (Cools.isEmpty(locMast)) {
            throw new CoolException("当前楼层没有空库位");
        }
@@ -453,6 +489,7 @@
        mast.setAppeTime(now);
        mast.setModiUser(userId);
        mast.setModiTime(now);
        mast.setLogErrMemo("handControlLocMove");
        if (!agvWrkMastService.insertByIncrease(mast)) {
            throw new CoolException("保存工作档失败");
        }
@@ -477,10 +514,13 @@
        }
        // 如果当前任务是箱壳二三楼回退一楼的 回滚调拨单
        if (ioType == 12 && locMast.getFloor() == 1) {
        if (ioType == 12 && locMast.getFloor() == 1 && floor != 4 && agvLocMast.getFloor() != 1) {
            List<AgvLocDetl> agvLocDetls = agvLocDetlService.selectList(new EntityWrapper<AgvLocDetl>().eq("loc_no", agvLocMast.getLocNo()));
            for (AgvLocDetl agvLocDetl : agvLocDetls) {
                OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("three_code", agvLocDetl.getThreeCode()).eq("matnr", agvLocDetl.getMatnr()).eq("order_no", "DB" + agvLocDetl.getOrderNo()));
                OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("three_code", agvLocDetl.getThreeCode()).eq("matnr", agvLocDetl.getMatnr()).eq("source", 33));
                if (Cools.isEmpty(orderDetl)) {
                    throw new CoolException("当前物料的调拨单不存在!");
                }
                orderDetl.setQty(orderDetl.getQty() - agvLocDetl.getAnfme());
                if (!orderDetlService.updateById(orderDetl)) {
                    throw new CoolException("保存工作明细失败");
@@ -512,8 +552,28 @@
        if (!agvWrkMast.getBarcode().equals(param.getBarcode())) {
            throw new CoolException("当前货架码与任务不匹配");
        }
        if (!agvWrkMast.getWrkSts().equals(207L)) {
            throw new CoolException("工作状态不符合离场条件");
        if (!agvWrkMast.getWrkSts().equals(207L) && !agvWrkMast.getWrkSts().equals(205L)) {
            throw new CoolException("当前工作状态:" + agvWrkMast.getWrkSts$() +"不符合离场条件");
        }
        if (agvWrkMast.getWrkSts().equals(205L)) {
            // 库位 -- 接驳位 / 库位
            if (agvWrkMast.getLocNo().substring(0,2).equals("DB")) {
                agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getLocNo(),"F",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
                // 接驳位 -- 库位
            } else {
                agvLocMastService.updateLocStsByLocNo(agvWrkMast.getLocNo(),"D",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
            }
            // 接驳位 -- 库位
            if (agvWrkMast.getSourceLocNo().substring(0,2).equals("DB")) {
                agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getSourceLocNo(),"O","",(short)0);
                // 库位 -- 接驳位 / 库位
            } else {
                //修改源库位状态为O
                agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O","",agvWrkMast.getWhsType().shortValue(),"",(short)0);
                //更新目标库位明细 101.出库 删除源库位库存明细
                agvLocDetlService.delete(new EntityWrapper<AgvLocDetl>().eq("loc_no",agvWrkMast.getSourceLocNo()));
            }
        }
        //生成AGV工作历史档 + 生成AGV工作明细历史档
@@ -536,7 +596,7 @@
            }
        }
        // 更新站点状态
        agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O","",null);
//        agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O","",null);
        // 更新源库位状态
        agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getLocNo(),"O","",agvWrkMast.getWhsType().shortValue());
@@ -605,6 +665,7 @@
        if (!agvWrkMast.getBarcode().equals(param.getBarcode())) {
            throw new CoolException("当前货架码与任务不匹配");
        }
        agvWrkMast.setModiTime(new Date());
        agvWrkMast.setWrkSts(213L);
        agvWrkMast.setSourceLocNo("");
        if (!agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no",agvWrkMast.getWrkNo()))) {
@@ -633,6 +694,7 @@
            throw new CoolException("当前工作类型不能空架进场");
        }
        agvWrkMast.setWrkSts(214L);
        agvWrkMast.setModiTime(new Date());
        agvWrkMast.setSourceLocNo(param.getDevNo());
        if (!agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no",agvWrkMast.getWrkNo()))) {
            throw new CoolException("更新工作档失败");
@@ -642,7 +704,7 @@
        return "ok";
    }
    /*
     * 站点回退
     * 转手动回流
    */
    @Override
    @Transactional
@@ -657,6 +719,68 @@
        }
        return "ok";
    }
    /*
     * 确认加工完成
     */
    @Override
    @Transactional
    public String processed(AgvMobileStartPakin param, Long userId) {
        Date now = new Date();
        AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("barcode", param.getBarcode()).eq("loc_no", param.getDevNo()));
        if (Cools.isEmpty(agvWrkMast)) {
            throw new CoolException("暂无当前货架的工作档");
        }
        if (agvWrkMast.getWrkSts() != 205) {
            throw new CoolException("当前任务未完成,请确认");
        }
        //生成AGV工作历史档 + 生成AGV工作明细历史档
        agvWrkMastLogService.save(agvWrkMast);
        agvWrkDetlLogService.save(agvWrkMast.getWrkNo());
        String sourceLocNo = agvWrkMast.getSourceLocNo();
        AgvLocMast newLocMast = agvCommonService.getLocNo(3, 1,false,false);
        agvWrkMast.setSourceLocNo(agvWrkMast.getLocNo());
        agvWrkMast.setLocNo(newLocMast.getLocNo());
        agvWrkMast.setIoType(57);
        agvWrkMast.setWrkSts(201L);
        agvWrkMast.setModiUser(userId);
        agvWrkMast.setModiTime(now);
        if (!agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no",agvWrkMast.getWrkNo()))) {
            throw new CoolException("更新工作档失败");
        }
        // 更新源站点 + 目标库位状态 + 历史源库位
        agvBasDevpService.updateLocStsAndBarcodeByDevNo(param.getDevNo(),"R",param.getBarcode(),agvWrkMast.getWhsType().shortValue());
        agvLocMastService.updateLocStsByLocNo(newLocMast.getLocNo(),"S",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
        agvLocMastService.updateLocStsByLocNo(sourceLocNo,"O","",(short)30);
        agvLocDetlService.delete(new EntityWrapper<AgvLocDetl>().eq("loc_no",sourceLocNo));
        List<AgvWrkDetl> agvWrkDetls = agvWrkDetlService.selectList(new EntityWrapper<AgvWrkDetl>().eq("supp_code",param.getBarcode()));
        agvWrkDetls.forEach(agvWrkDetl -> {
            for (AgvWrkDetl wrkDetl : param.getWrkDetls()) {
                if (wrkDetl.getMatnr().equals(agvWrkDetl.getMatnr()) && wrkDetl.getThreeCode().equals(agvWrkDetl.getThreeCode())) {
                    agvWrkDetl.setAnfme(wrkDetl.getAnfme());
                    break;
                }
            }
            agvWrkDetl.setProcessSts(2);
            agvWrkDetl.setOrderNo(agvWrkDetl.getOrderNo().substring(2));
            agvWrkDetl.setModiUser(userId);
            agvWrkDetl.setModiTime(now);
            if (!agvWrkDetlService.update(agvWrkDetl,new EntityWrapper<AgvWrkDetl>()
                    .eq("matnr",agvWrkDetl.getMatnr())
                    .eq("three_code",agvWrkDetl.getThreeCode())
                    .eq("supp_code",param.getBarcode()))) {
                throw new CoolException("更新工作明细失败");
            }
        });
        return "ok";
    }
    /*
     * 站点回退
@@ -751,7 +875,7 @@
        wrkMast.setAppeTime(now);
        wrkMast.setModiUser(userId);
        wrkMast.setModiTime(now);
        wrkMast.setLogErrMemo("doBack");
        if (!agvWrkMastService.insertByIncrease(wrkMast)) {
            throw new CoolException("保存工作档失败");
        }