自动化立体仓库 - WMS系统
#1
dubin
2025-12-20 db11805d2209fd37b24037fce159c7d5a39d8177
#1
10个文件已修改
406 ■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/BarcodeMatnrController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/MatController.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/mapper/WaitPakinMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/MobileService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/WaitPakinService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/WaitPakinServiceImpl.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/CommonService.java 353 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/web/WcsController.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/common.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/BarcodeMatnrController.java
@@ -173,7 +173,7 @@
        combMats.add(combMat);
        combParam.setBarcode(waitPakin.getBarcode());
        combParam.setCombMats(combMats);
        mobileService.adjustNew(combParam, Boolean.TRUE, getUserId());
//        mobileService.adjustNew(combParam, Boolean.TRUE, getUserId());
        return R.ok("并板成功");
    }
@@ -204,7 +204,7 @@
            combMats.add(combMat);
            combParam.setBarcode(matBarcode.getZpallet());
            combParam.setCombMats(combMats);
            mobileService.adjustNew(combParam, Boolean.TRUE, getUserId());
            mobileService.adjustNew(combParam, Boolean.TRUE, getUserId(),matBarcode);
        }
        return R.ok("并板成功");
    }
src/main/java/com/zy/asrs/controller/MatController.java
@@ -157,6 +157,9 @@
        if (Cools.isEmpty(mat) || null==mat.getId()){
            return R.error();
        }
        if (null != matService.selectByMatnr(mat.getMatnr())) {
            return R.error("商品模具名称已存在");
        }
        if (mat.getColor().equals("正常")){
            mat.setColor("报废");
        }else if (mat.getColor().equals("报废")){
src/main/java/com/zy/asrs/mapper/WaitPakinMapper.java
@@ -12,4 +12,7 @@
    @Select("select count(*) from cust_wait_pakin where matnr = #{matnr};")
    Integer selectCountByMatNr(String matnr);
    @Select("select count(*) from cust_wait_pakin where matnr = #{matnr} and zpallet = #{zpallet};")
    Integer selectByBarcodeAndMatnr(String matnr, String zpallet);
}
src/main/java/com/zy/asrs/service/MobileService.java
@@ -38,7 +38,7 @@
                  Double curOutQty, Integer ioType, Long userId, Date now);
    void adjustNew(MobileAdjustParam param, Boolean re, Long userId);
    void adjustNew(MobileAdjustParam param, Boolean re, Long userId,MatBarcode matBarcode);
    void combToWms(WaitPakin waitPakin);
}
src/main/java/com/zy/asrs/service/WaitPakinService.java
@@ -11,4 +11,6 @@
    void comb(List<MatBarcode> list);
    Integer selectCountByMatNr(String matnr);
    Integer selectByBarcodeAndMatnr(String matnr, String zpallet);
}
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -678,7 +678,7 @@
    @Override
    @Transactional
    public void adjustNew(MobileAdjustParam param, Boolean re, Long userId) {
    public void adjustNew(MobileAdjustParam param, Boolean re, Long userId,MatBarcode matBarcode) {
        WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", param.getBarcode()));
        if (Cools.isEmpty(wrkMast)) {
            throw new CoolException("托盘码:" + param.getBarcode() + " 无有效工作档");
@@ -711,6 +711,8 @@
                detl.sync(wrkDetl);
                detl.setWrkNo(wrkMast.getWrkNo());
                detl.setZpallet(wrkMast.getBarcode());
                detl.setModel(matBarcode.getModel() == null?"":matBarcode.getModel());
                detl.setSpecs(matBarcode.getSpecs() == null?"":matBarcode.getSpecs());
                wrkDetlService.insert(detl);
                recordRecordLog = recordRecordLog + "\n" + "新增一条明细:" + "\t商品编号:" + wrkDetl.getMatnr() + "\t批号:" + wrkDetl.getBatch() + "\t数量:" + wrkDetl.getAnfme();
                adjDetl.setOriQty(0.0);
src/main/java/com/zy/asrs/service/impl/WaitPakinServiceImpl.java
@@ -10,6 +10,7 @@
import com.zy.common.model.DetlDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
@@ -28,6 +29,7 @@
    @Autowired
    private WaitPakinService waitPakinService;
    @Transactional
    @Override
    public void comb(List<MatBarcode> list) {
        String zpallet = list.get(0).getZpallet();
@@ -45,6 +47,12 @@
            Mat mat = matService.selectByMatnr(matBarcode.getMatnr());
            if (Cools.isEmpty(mat)) {
                throw new CoolException(matBarcode.getMatnr() + "商品档案不存在");
            }
            //对于已经组托过的 模具+托盘 不允许再次组托
            Integer waitPakinCount = waitPakinService.selectByBarcodeAndMatnr(matBarcode.getMatnr(), matBarcode.getZpallet());
            if (waitPakinCount >= 1){
                throw new CoolException("该模具已经组托,商品模具名称:" + matBarcode.getMatnr() + "托盘码:" + matBarcode.getZpallet());
            }
            WaitPakin waitPakin1 = new WaitPakin();
            waitPakin1.sync(mat);
@@ -72,4 +80,9 @@
    public Integer selectCountByMatNr(String matnr) {
        return this.baseMapper.selectCountByMatNr(matnr);
    }
    @Override
    public Integer selectByBarcodeAndMatnr(String matnr, String zpallet) {
        return this.baseMapper.selectByBarcodeAndMatnr(matnr, zpallet);
    }
}
src/main/java/com/zy/common/service/CommonService.java
@@ -417,11 +417,11 @@
        return getLocNoEmpty(whsType, staDescId, sourceStaNo, matnr, batch, grade, 0, locTypeDto, 0);
    }
//    @Transactional
//    public StartupDto getLocNoEmptyNew(Integer whsType, Integer staDescId, Integer sourceStaNo,LocTypeDto locTypeDto,String barcode) {
//        whsType = Utils.GetWhsType(sourceStaNo);
//        return getLocNoEmptyNew(whsType, staDescId, sourceStaNo,locTypeDto,barcode,0,0);
//    }
    @Transactional
    public StartupDto getLocNoEmptyNew(Integer whsType, Integer staDescId, Integer sourceStaNo,LocTypeDto locTypeDto,String barcode) {
        whsType = Utils.GetWhsType(sourceStaNo);
        return getLocNoEmptyNew(whsType, staDescId, sourceStaNo,locTypeDto,barcode,0,0);
    }
    @Transactional
    public StartupDto getLocNoEmpty(Integer whsType, Integer staDescId, Integer sourceStaNo, String matnr, String batch, String grade, Integer moveCrnNo, LocTypeDto locTypeDto, int times) {
@@ -729,176 +729,175 @@
        return startupDto;
    }
//    @Transactional
//    public StartupDto getLocNoEmptyNew(Integer whsType, Integer staDescId, Integer sourceStaNo,LocTypeDto locTypeDto,String barcode,int  times, Integer moveCrnNo) {
//        // 初始化参数
//        int crnNo = 0;      //堆垛机号
//        int nearRow = 0;    //最浅库位排
//        int curRow = 0;     //最深库位排
//        int rowCount = 0;   //轮询轮次
//        LocMast locMast = null;     // 目标库位
//
//        StartupDto startupDto = new StartupDto();
//        RowLastno rowLastno = rowLastnoService.selectById(whsType);
//        int sRow = rowLastno.getsRow();
//        int eRow = rowLastno.geteRow();
//        int crnNumber = rowLastno.getCrnQty();
//
//        if (Cools.isEmpty(rowLastno)) {
//            throw new CoolException("数据异常,请联系管理员");
//        }
//        // ===============>>>> 开始执行
//        curRow = rowLastno.getCurrentRow();
//
//        if (!Cools.isEmpty(moveCrnNo) && moveCrnNo != 0) {
//            crnNumber = moveCrnNo;
//            if (times == 0) {
//                curRow = moveCrnNo * 4 - 1;
//            } else {
//                curRow = moveCrnNo * 4 - 2;
//            }
//        }
//
//        //此程序用于优化堆垛机异常时的运行时间
//        for (int i = times; i < crnNumber; i++) {
//            int[] locNecessaryParameters = Utils.LocNecessaryParameters(whsType, curRow, crnNumber);
//            curRow = locNecessaryParameters[1];
//            crnNo = locNecessaryParameters[2];
//            if (basCrnpService.checkSiteError(crnNo, true)) {
//                rowCount = locNecessaryParameters[0];
//                nearRow = locNecessaryParameters[3];
//                break;
//            } else {
//                times++;
//            }
//        }
//        if (nearRow == 0) {
//            throw new CoolException("无可用堆垛机");
//        }
//
//        Wrapper<StaDesc> wrapper = null;
//        StaDesc staDesc = null;
//        BasDevp staNo = null;
//
//        if (Utils.BooleanWhsTypeSta(whsType, staDescId)) {
//            // 获取目标站
//            wrapper = new EntityWrapper<StaDesc>()
//                    .eq("type_no", staDescId)
//                    .eq("stn_no", sourceStaNo)
//                    .eq("crn_no", crnNo);
//            staDesc = staDescService.selectOne(wrapper);
//            if (Cools.isEmpty(staDesc)) {
//                log.error("type_no={},stn_no={},crn_no={}", staDescId, sourceStaNo, crnNo);
//                crnNo = 0;
//            }
//            staNo = basDevpService.selectById(staDesc.getCrnStn());
//            if (!staNo.getAutoing().equals("Y")) {
//                crnNo = 0;
//            }
//            startupDto.setStaNo(staNo.getDevNo());
//        }
//
//        // 更新库位排号
//        if (Utils.BooleanWhsTypeSta(whsType, staDescId)) {
//            rowLastno.setCurrentRow(curRow);
//            rowLastnoService.updateById(rowLastno);
//        }
//
//        // 1.按规则查找库位
//        if (Cools.isEmpty(locMast) && crnNo != 0) {
//            List<LocMast> locMasts = new ArrayList<>();
//            if (barcode.startsWith("6")){
//                locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
//                        .eq("loc_sts","O")
//                        .in("row1",2,3)
//                        .in("lev1",1,2,3,4,5,6,7)
//                        .orderBy("row1",true)
//                        .orderBy("lev1",true)
//                );
//            }else if (barcode.startsWith("7")){
//                locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
//                        .eq("loc_sts","O")
//                        .in("row1",2,3)
//                        .in("lev1",8,9,10,11,12)
//                        .orderBy("row1",true)
//                        .orderBy("lev1",true)
//                );
//            }else if (barcode.startsWith("8")){
//                locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
//                        .eq("loc_sts","O")
//                        .eq("lev1",13)
//                        .in("row1",2,3)
//                        .orderBy("row1",true)
//                        .orderBy("lev1",true)
//                );
//            }
//
//            if (locMasts.size() <= 7){
//                throw new CoolException("无空库位可用");
//            }
//
//            locMasts.sort(new Comparator<LocMast>() {
//                @Override
//                public int compare(LocMast o1, LocMast o2) {
//                    int b1 = o1.getBay1();
//                    int b2 = o2.getBay1();
//                    if (o1.getBay1() >= 15) {
//                        b1 = Math.abs(15 - o1.getBay1());
//                    }
//                    if (o2.getBay1() >= 15) {
//                        b2 = Math.abs(15 - o2.getBay1());
//                    }
//                    return b2 - b1;
//                }
//            });
//
//            for (LocMast locMast1 : locMasts) {
//                if (Utils.isDeepLoc(slaveProperties,locMast1.getLocNo())){
//                    continue;
//                }
//                String deepLoc = Utils.getDeepLoc(slaveProperties, locMast1.getLocNo());
//                LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", deepLoc));
//                if (Cools.isEmpty(locMast2)){
//                    continue;
//                }
//                if (locMast2.getLocSts().equals("P")||locMast2.getLocSts().equals("Q")||locMast2.getLocSts().equals("R")||locMast2.getLocSts().equals("S")){
//                    continue;
//                }
//                if (!Cools.isEmpty(locMast2)&&locMast2.getLocSts().equals("O")){
//                    locMast = locMast2;
//                    break;
//                }
//                if (!Cools.isEmpty(locMast2)&&(locMast2.getLocSts().equals("F")||locMast2.getLocSts().equals("D"))){
//                    locMast = locMast1;
//                    break;
//                }
//            }
//        }
//
//        if (!Cools.isEmpty(locMast) && !basCrnpService.checkSiteError(crnNo, true)) {
//            locMast = null;
//        }
//
//        // 递归查询
//        if (Cools.isEmpty(locMast) || !locMast.getLocSts().equals("O")) {
//            // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归
//            if (times < rowCount) {
//                times = times + 1;
//                return getLocNoEmptyNew(1, staDescId, sourceStaNo,locTypeDto,barcode);
//            }
//            log.error("系统没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times);
//            throw new CoolException("没有空库位");
//        }
//        String locNo = locMast.getLocNo();
//
//        // 生成工作号
//        int workNo = getWorkNo(0);
//        // 返回dto
//        startupDto.setWorkNo(workNo);
//        startupDto.setCrnNo(crnNo);
//        startupDto.setSourceStaNo(sourceStaNo);
//        startupDto.setLocNo(locNo);
//        return startupDto;
//
//    }
    @Transactional
    public StartupDto getLocNoEmptyNew(Integer whsType, Integer staDescId, Integer sourceStaNo,LocTypeDto locTypeDto,String barcode,int  times, Integer moveCrnNo) {
        // 初始化参数
        int crnNo = 0;      //堆垛机号
        int nearRow = 0;    //最浅库位排
        int curRow = 0;     //最深库位排
        int rowCount = 0;   //轮询轮次
        LocMast locMast = null;     // 目标库位
        StartupDto startupDto = new StartupDto();
        RowLastno rowLastno = rowLastnoService.selectById(whsType);
        int sRow = rowLastno.getsRow();
        int eRow = rowLastno.geteRow();
        int crnNumber = rowLastno.getCrnQty();
        if (Cools.isEmpty(rowLastno)) {
            throw new CoolException("数据异常,请联系管理员");
        }
        // ===============>>>> 开始执行
        curRow = rowLastno.getCurrentRow();
        if (!Cools.isEmpty(moveCrnNo) && moveCrnNo != 0) {
            crnNumber = moveCrnNo;
            if (times == 0) {
                curRow = moveCrnNo * 4 - 1;
            } else {
                curRow = moveCrnNo * 4 - 2;
            }
        }
        //此程序用于优化堆垛机异常时的运行时间
        for (int i = times; i < crnNumber; i++) {
            int[] locNecessaryParameters = Utils.LocNecessaryParameters(whsType, curRow, crnNumber);
            curRow = locNecessaryParameters[1];
            crnNo = locNecessaryParameters[2];
            if (basCrnpService.checkSiteError(crnNo, true)) {
                rowCount = locNecessaryParameters[0];
                nearRow = locNecessaryParameters[3];
                break;
            } else {
                times++;
            }
        }
        if (nearRow == 0) {
            throw new CoolException("无可用堆垛机");
        }
        Wrapper<StaDesc> wrapper = null;
        StaDesc staDesc = null;
        BasDevp staNo = null;
        if (Utils.BooleanWhsTypeSta(whsType, staDescId)) {
            // 获取目标站
            wrapper = new EntityWrapper<StaDesc>()
                    .eq("type_no", staDescId)
                    .eq("stn_no", sourceStaNo)
                    .eq("crn_no", crnNo);
            staDesc = staDescService.selectOne(wrapper);
            if (Cools.isEmpty(staDesc)) {
                log.error("type_no={},stn_no={},crn_no={}", staDescId, sourceStaNo, crnNo);
                crnNo = 0;
            }
            staNo = basDevpService.selectById(staDesc.getCrnStn());
            if (!staNo.getAutoing().equals("Y")) {
                crnNo = 0;
            }
            startupDto.setStaNo(staNo.getDevNo());
        }
        // 更新库位排号
        if (Utils.BooleanWhsTypeSta(whsType, staDescId)) {
            rowLastno.setCurrentRow(curRow);
            rowLastnoService.updateById(rowLastno);
        }
        // 1.按规则查找库位
        if (Cools.isEmpty(locMast) && crnNo != 0) {
            List<LocMast> locMasts = new ArrayList<>();
            if (barcode.startsWith("6")){
                locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                        .eq("loc_sts","O")
                        .in("row1",2,3)
                        .in("lev1",1,2,3,4,5,6,7)
                        .orderBy("row1",true)
                        .orderBy("lev1",true)
                );
            }else if (barcode.startsWith("7")){
                locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                        .eq("loc_sts","O")
                        .in("row1",2,3)
                        .in("lev1",8,9,10,11,12)
                        .orderBy("row1",true)
                        .orderBy("lev1",true)
                );
            }else if (barcode.startsWith("8")){
                locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                        .eq("loc_sts","O")
                        .eq("lev1",13)
                        .in("row1",2,3)
                        .orderBy("row1",true)
                        .orderBy("lev1",true)
                );
            }
            if (locMasts.size() <= 7){
                throw new CoolException("无空库位可用");
            }
            locMasts.sort(new Comparator<LocMast>() {
                @Override
                public int compare(LocMast o1, LocMast o2) {
                    int b1 = o1.getBay1();
                    int b2 = o2.getBay1();
                    if (o1.getBay1() >= 15) {
                        b1 = Math.abs(15 - o1.getBay1());
                    }
                    if (o2.getBay1() >= 15) {
                        b2 = Math.abs(15 - o2.getBay1());
                    }
                    return b2 - b1;
                }
            });
            for (LocMast locMast1 : locMasts) {
                if (Utils.isDeepLoc(slaveProperties,locMast1.getLocNo())){
                    continue;
                }
                String deepLoc = Utils.getDeepLoc(slaveProperties, locMast1.getLocNo());
                LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", deepLoc));
                if (Cools.isEmpty(locMast2)){
                    continue;
                }
                if (locMast2.getLocSts().equals("P")||locMast2.getLocSts().equals("Q")||locMast2.getLocSts().equals("R")||locMast2.getLocSts().equals("S")){
                    continue;
                }
                if (!Cools.isEmpty(locMast2)&&locMast2.getLocSts().equals("O")){
                    locMast = locMast2;
                    break;
                }
                if (!Cools.isEmpty(locMast2)&&(locMast2.getLocSts().equals("F")||locMast2.getLocSts().equals("D"))){
                    locMast = locMast1;
                    break;
                }
            }
        }
        if (!Cools.isEmpty(locMast) && !basCrnpService.checkSiteError(crnNo, true)) {
            locMast = null;
        }
        // 递归查询
        if (Cools.isEmpty(locMast) || !locMast.getLocSts().equals("O")) {
            // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归
            if (times < rowCount) {
                times = times + 1;
                return getLocNoEmptyNew(1, staDescId, sourceStaNo,locTypeDto,barcode);
            }
            log.error("系统没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times);
            throw new CoolException("没有空库位");
        }
        String locNo = locMast.getLocNo();
        // 生成工作号
        int workNo = getWorkNo(0);
        // 返回dto
        startupDto.setWorkNo(workNo);
        startupDto.setCrnNo(crnNo);
        startupDto.setSourceStaNo(sourceStaNo);
        startupDto.setLocNo(locNo);
        return startupDto;
    }
}
src/main/java/com/zy/common/web/WcsController.java
@@ -95,14 +95,14 @@
        }
        // 空托盘按照托盘码分配库位
//        else if (param.getIoType() == 10) {
//            if (Cools.isEmpty(param.getBarcode())) {
//                return R.error("条码不能为空");
//            }
//            if (!param.getBarcode().startsWith("6") && !param.getBarcode().startsWith("7") && !param.getBarcode().startsWith("8")){
//                return R.error("不存在的托盘类型");
//            }
//        }
        else if (param.getIoType() == 10) {
            if (Cools.isEmpty(param.getBarcode())) {
                return R.error("条码不能为空");
            }
            if (!param.getBarcode().startsWith("6") && !param.getBarcode().startsWith("7") && !param.getBarcode().startsWith("8")){
                return R.error("不存在的托盘类型");
            }
        }
        if (Cools.isEmpty(param.getLocType1())) {
@@ -445,8 +445,8 @@
        // 源站点状态检测
        BasDevp sourceStaNo = basDevpService.checkSiteStatus(devpNo, true);
        // 检索库位
        StartupDto dto = commonService.getLocNoEmpty(1, 10, devpNo, null, null, null, locTypeDto);
//        StartupDto dto = commonService.getLocNoEmptyNew(1, 10, devpNo,locTypeDto,barcode);
//        StartupDto dto = commonService.getLocNoEmpty(1, 10, devpNo, null, null, null, locTypeDto);
        StartupDto dto = commonService.getLocNoEmptyNew(1, 10, devpNo,locTypeDto,barcode);
        int workNo = dto.getWorkNo();
        // 生成工作档
        WrkMast wrkMast = new WrkMast();
src/main/webapp/static/js/common.js
@@ -236,7 +236,7 @@
    ,{field: 'batch', align: 'center',title: '批次', hide:true,sort:true}
    ,{field: 'outOrderNo', align: 'center',title: '合同号', sort:true, hide: true}
    ,{field: 'unit', align: 'center',title: '单位', hide: true}
    ,{field: 'anfme', align: 'center',title: '数量', hide: true}
    ,{field: 'anfme', align: 'center',title: '数量', hide: false}
    ,{field: 'zpallet', align: 'center',title: '托盘条码', hide: false}
    ,{field: 'specs', align: 'center',title: '规格', hide: false}
    ,{field: 'color', align: 'center',title: '颜色', hide: true}