自动化立体仓库 - WMS系统
zyx
2024-03-29 16a3dbbf28606a90dd6dadeffe843f53f72d3955
src/main/java/com/zy/asrs/service/impl/AgvWorkServiceImpl.java
@@ -91,7 +91,7 @@
            //检索库位,选择合适的库位
            AgvLocMast agvLocMast = agvCommonService.getLocNo(agvBasDevp.getLocType1());
            //生成工作档
            AgvWrkMast wrkMast = createWrkMast(1,201L,agvBasDevp.getDevNo(),agvLocMast.getLocNo(),agvBasDevp.getBarcode(),now,userId, isConveyor);
            AgvWrkMast wrkMast = createWrkMast(1,201L,agvBasDevp.getDevNo(),agvLocMast.getLocNo(),agvBasDevp.getBarcode(),now,userId, agvBasDevp.getLocType2());
            //标记是否为输送线入库
            wrkMast.setMk(isConveyor ? "Y" : "N");
            //生成工作档明细
@@ -134,7 +134,7 @@
            //判断是否全板出库
            int ioType = isPakOut(sourceLocNo,taskDto) ?  101 : 103;
            //生成工作档
            AgvWrkMast wrkMast = createWrkMast(ioType,wrkSts,sourceLocNo,targetLocNo,containerCode,now,userId,false);
            AgvWrkMast wrkMast = createWrkMast(ioType,wrkSts,sourceLocNo,targetLocNo,containerCode,now,userId,0);
            //生成工作档明细
            taskDto.getLocDtos().forEach(locDto -> {
                if (!BaseController.isJSON(locDto.getOrderNo())) {
@@ -258,8 +258,10 @@
                return;
            }
            int containerType = getContainerTypeByloc(taskDto.getLocNo());
            //生成工作档
            AgvWrkMast wrkMast = createWrkMast(107, 21L,taskDto.getLocNo(),taskDto.getAgvStaNo(),taskDto.getLocDtos().get(0).getContainerCode(),now,userId,false);
            AgvWrkMast wrkMast = createWrkMast(107, 21L,taskDto.getLocNo(),taskDto.getAgvStaNo(),taskDto.getLocDtos().get(0).getContainerCode(),now,userId,containerType);
            //生成工作档明细
            taskDto.getLocDtos().forEach(locDto -> {
                //明细档所需参数
@@ -299,8 +301,9 @@
        }
        Date now = new Date();
        //生成移库工作档
        AgvWrkMast wrkMast = createWrkMast(11, 21L, sourceLocNo, targetLocNo, sourceLocDetl.getSuppCode(), now, userId,false);
        AgvWrkMast wrkMast = createWrkMast(11, 21L, sourceLocNo, targetLocNo, sourceLocDetl.getSuppCode(), now, userId,getContainerTypeByloc(sourceLocNo));
        //生成工作党明细
        createWrkDetlReWrite(sourceLocDetl.getMatnr(),wrkMast.getWrkNo(),null,sourceLocDetl.getBatch(),sourceLocDetl.getAnfme(),sourceLocDetl.getZpallet(),now,userId,sourceLocDetl.getThreeCode(),sourceLocDetl.getDeadTime());
        //修改目标库位状态
@@ -313,7 +316,7 @@
    入库
     */
    @Transactional
    public String emptyPlateIn(String station,String containerCode,int containerType, Long userId) {
    public String emptyPlateIn(String station,String containerCode,Short containerType, Long userId) {
        Date now = new Date();
        // 源站点状态检测
@@ -338,28 +341,35 @@
        }
        //检索库位,选择合适的库位
        AgvLocMast agvLocMast = agvLocMast = agvCommonService.getLocNo(agvBasDevp.getLocType1());
        AgvLocMast agvLocMast = agvCommonService.getLocNo(agvBasDevp.getLocType1());
        //查询入库通知档
        List<AgvWaitPakin> agvWaitPakinList = agvWaitPakinService.selectByContainerCode(containerCode);
        if(!Cools.isEmpty(agvWaitPakinList)){
            String devNo = agvBasDevp.getDevNo();
            String locNo = agvLocMast.getLocNo();
            //生成工作档
            AgvWrkMast wrkMast = createWrkMast(1,201L,agvBasDevp.getDevNo(),agvLocMast.getLocNo(),containerCode,now,userId, false);
            AgvWrkMast wrkMast = createWrkMast(1,201L,devNo,locNo,containerCode,now,userId, containerType);
            //生成工作档明细
            agvWaitPakinList.forEach(wp -> {
                createWrkDetlReWrite(wp.getMatnr(),wrkMast.getWrkNo(),wp.getOrderNo(),wp.getBatch(),wp.getAnfme(),wp.getSuppCode(),now,userId,wp.getThreeCode(),wp.getDeadTime());
            });
            //修改入库通知档状态
            agvWaitPakinService.updateIoStatus(containerCode,"Y");
            //更新源站点状态
            updateAgvBasDevp(agvBasDevp,"R");
        }else {
            // 生成工作档 10.空板入库
            createWrkMast(10,201L,agvBasDevp.getDevNo(),agvLocMast.getLocNo(),containerCode,now,userId,false);
            createWrkMast(10,201L,agvBasDevp.getDevNo(),agvLocMast.getLocNo(),containerCode,now,userId,containerType);
            //更新源站点状态
            updateAgvBasDevp(agvBasDevp,"R",containerType);
        }
        //更新源站点状态
        updateAgvBasDevp(agvBasDevp,"R");
        //更新目标库位状态和信息
        updateAgvLocMast(agvLocMast,"S", (short) containerType);
        updateAgvLocMast(agvLocMast,"S");
        return agvLocMast.getLocNo();
    }
@@ -378,9 +388,11 @@
        //寻找相应类型的空托盘
        AgvLocMast agvLocMast = agvLocMastService.selectEmptyZpallet(containerType);
        if (Cools.isEmpty(agvLocMast)) {
            throw new CoolException("暂无当前出库站点类型的空托盘!");
        }
        //生成工作档
        createWrkMast(110,21L,agvLocMast.getLocNo(),agvBasDevp.getDevNo(),agvLocMast.getBarcode(),now,userId,false);
        createWrkMast(110,21L,agvLocMast.getLocNo(),agvBasDevp.getDevNo(),agvLocMast.getBarcode(),now,userId,containerType);
        //修改源库位状态
        updateAgvLocMast(agvLocMast,"R");
@@ -541,11 +553,11 @@
        //出库任务 101.出库 || 103.拣料出库 || 107.盘点出库
        if(wrkMast.getIoType() == 101 || wrkMast.getIoType() == 103 || wrkMast.getIoType() == 107){
            //修改出库站点状态
            agvBasDevpService.updateLocStsAndBarcodeByDevNo(wrkMast.getLocNo(),"F",wrkMast.getBarcode());
            agvBasDevpService.updateLocStsAndBarcodeByDevNo(wrkMast.getLocNo(),"F",wrkMast.getBarcode(),wrkMast.getWhsType().shortValue());
        }
        //出库任务 110.空板出库
        if(wrkMast.getIoType() == 110){
            agvBasDevpService.updateLocStsAndBarcodeByDevNo(wrkMast.getLocNo(),"F",wrkMast.getBarcode());
            agvBasDevpService.updateLocStsAndBarcodeByDevNo(wrkMast.getLocNo(),"F",wrkMast.getBarcode(),wrkMast.getWhsType().shortValue());
        }
    }
@@ -567,8 +579,8 @@
            String devNo = wrkMast.getSourceLocNo();
            //目标库位
            String locNo = wrkMast.getLocNo();
            agvLocMastService.updateLocStsByLocNo(locNo,"O","");
            agvBasDevpService.updateLocStsAndBarcodeByDevNo(devNo,"F",wrkMast.getBarcode());
            agvLocMastService.updateLocStsByLocNo(locNo,"O","",null);
            agvBasDevpService.updateLocStsAndBarcodeByDevNo(devNo,"F",wrkMast.getBarcode(),wrkMast.getWhsType().shortValue());
            //出库取消
        }else {
@@ -576,9 +588,9 @@
            String locNo = wrkMast.getSourceLocNo();
            //目标站点
            String devNo = wrkMast.getLocNo();
            agvLocMastService.updateLocStsByLocNo(locNo,"F",wrkMast.getBarcode());
            agvLocMastService.updateLocStsByLocNo(locNo,"F",wrkMast.getBarcode(),(short)getContainerTypeByloc(locNo));
            if(devNo.contains("@")){
                agvBasDevpService.updateLocStsAndBarcodeByDevNo(devNo,"O","");
                agvBasDevpService.updateLocStsAndBarcodeByDevNo(devNo,"O","",null);
            }
        }
@@ -647,6 +659,17 @@
    }
    /*
    更新源站点信息和库位托盘类型
     */
    private void updateAgvBasDevp(AgvBasDevp agvBasDevp, String locSts, Short continerType){
        if(!Cools.isEmpty(agvBasDevp)){
            agvBasDevp.setLocSts(locSts);
            agvBasDevp.setLocType2(continerType);
            agvBasDevpService.updateById(agvBasDevp);
        }
    }
    /*
    生成工作档明细
     */
    private void createWrkDetlReWrite(String matnr, int wrkNo, String orderNo,String batch, double anfme, String zpallet, Date now, Long userId, String csocode, String isoseq){
@@ -706,7 +729,7 @@
    /*
    生成工作档
     */
    private AgvWrkMast createWrkMast(int ioType, long wrkSts, String sourceLocNo, String locNo, String barcode,  Date now, Long userId, boolean isConveyor){
    private AgvWrkMast createWrkMast(int ioType, long wrkSts, String sourceLocNo, String locNo, String barcode,  Date now, Long userId, int containerType){
        AgvWrkMast wrkMast = new AgvWrkMast();
        //工作状态
        wrkMast.setWrkSts(wrkSts);
@@ -721,8 +744,9 @@
        wrkMast.setLocNo(locNo);
        //容器编码
        wrkMast.setBarcode(barcode);
        //标记是否为输送线入库
        wrkMast.setMk(isConveyor ? "Y" : "N");
        //容器类型
        wrkMast.setWhsType(containerType);
        wrkMast.setAppeUser(userId);
        wrkMast.setAppeTime(now);
        wrkMast.setModiUser(userId);
@@ -811,4 +835,10 @@
        }
    }
    private int getContainerTypeByloc(String locNo){
        return agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no",locNo)).getLocType2();
    }
}