自动化立体仓库 - WMS系统
1
ZY
2025-04-02 de3b3cc4f19e7188915265162626d386ccce7863
1
1个文件已修改
245 ■■■■ 已修改文件
src/main/java/com/zy/common/service/CommonService.java 245 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/CommonService.java
@@ -3,16 +3,13 @@
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.core.common.Arith;
import com.core.common.Cools;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.result.KeyValueVo;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.Utils;
import com.zy.asrs.utils.VersionUtils;
import com.zy.common.model.LocTypeDto;
import com.zy.common.model.Shelves;
import com.zy.common.model.StartupDto;
import com.zy.common.properties.SlaveProperties;
import lombok.extern.slf4j.Slf4j;
@@ -20,9 +17,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
@@ -59,6 +53,7 @@
    /**
     * 生成工作号
     *
     * @param wrkMk
     * @return workNo(工作号)
     */
@@ -71,17 +66,17 @@
        int workNo = wrkLastno.getWrkNo();
        int sNo = wrkLastno.getSNo();
        int eNo = wrkLastno.getENo();
        workNo = workNo>=eNo ? sNo : workNo+1;
        workNo = workNo >= eNo ? sNo : workNo + 1;
        while (true) {
            WrkMast wrkMast = wrkMastService.selectById(workNo);
            if (null != wrkMast) {
                workNo = workNo>=eNo ? sNo : workNo+1;
                workNo = workNo >= eNo ? sNo : workNo + 1;
            } else {
                break;
            }
        }
        // 修改序号记录
        if (workNo > 0){
        if (workNo > 0) {
            wrkLastno.setWrkNo(workNo);
            wrkLastnoService.updateById(wrkLastno);
        }
@@ -89,7 +84,7 @@
        if (workNo == 0) {
            throw new CoolException("生成工作号失败,请联系管理员");
        } else {
            if (wrkMastService.selectById(workNo)!=null) {
            if (wrkMastService.selectById(workNo) != null) {
                throw new CoolException("生成工作号" + workNo + "在工作档中已存在");
            }
        }
@@ -98,14 +93,14 @@
    //拆盘机处空板扫码,驱动托盘向码垛位,不入库
    @Transactional
    public StartupDto getScanBarcodeEmptyBoard(){
    public StartupDto getScanBarcodeEmptyBoard() {
        StartupDto startupDto = new StartupDto();
        Integer staNo = 0;
        if (wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 201).eq("staNo", 216))<2){
            staNo=216;
        if (wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 201).eq("staNo", 216)) < 2) {
            staNo = 216;
        }
        if (wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 201).eq("staNo", 220))<2){
            staNo=220;
        if (wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 201).eq("staNo", 220)) < 2) {
            staNo = 220;
        }
        startupDto.setStaNo(staNo);
@@ -121,34 +116,41 @@
     * @return locNo 检索到的库位号
     */
    @Transactional
    public StartupDto getLocNo( Integer staDescId, Integer sourceStaNo, String matnr, String batch, String grade, LocTypeDto locTypeDto,boolean mixture) {
        try{
    public StartupDto getLocNo(Integer staDescId, Integer sourceStaNo, String matnr, String batch, String grade, LocTypeDto locTypeDto, boolean mixture) {
        try {
            Integer whsType = Utils.GetWhsType(sourceStaNo);
            RowLastno rowLastno = rowLastnoService.selectById(whsType);
            RowLastnoType rowLastnoType = rowLastnoTypeService.selectById(rowLastno.getTypeId());
            /**
             * 库型 1: 标准堆垛机库  2: 平库  3: 穿梭板  4: 四向车  5: AGV  0: 未知
             */
            switch (rowLastnoType.getType()){
            switch (rowLastnoType.getType()) {
                case 1:
                    return getLocNoRun(whsType,staDescId,sourceStaNo,matnr,batch,grade,0,locTypeDto,0);
                    StartupDto locNoRun = getLocNoRun(whsType, staDescId, sourceStaNo, matnr, batch, grade, 0, locTypeDto, 0);
                    List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                            .eq("loc_sts", "O").eq("loc_type1", locTypeDto.getLocType1()).eq("whs_type", rowLastnoType.getType().longValue()));
                    if (locMasts != null && locMasts.size() < 8) {
                        throw new CoolException("没有空库位");
                    }
                    return locNoRun;
                case 2:
                    log.error("站点={} 未查询到对应的规则",sourceStaNo);
                    log.error("站点={} 未查询到对应的规则", sourceStaNo);
                    break;
                case 3:
                    log.error("站点={} 未查询到对应的规则",sourceStaNo);
                    log.error("站点={} 未查询到对应的规则", sourceStaNo);
                    break;
                case 4:
                    return getLocNoRun4(whsType,staDescId,sourceStaNo,matnr,batch,grade,4,locTypeDto,0,mixture);
                    return getLocNoRun4(whsType, staDescId, sourceStaNo, matnr, batch, grade, 4, locTypeDto, 0, mixture);
                case 5:
                    return getLocNoRun5(whsType,staDescId,sourceStaNo,matnr,batch,grade,0,locTypeDto,0);
                    return getLocNoRun5(whsType, staDescId, sourceStaNo, matnr, batch, grade, 0, locTypeDto, 0);
                default:
                    log.error("站点={} 未查询到对应的规则",sourceStaNo);
                    log.error("站点={} 未查询到对应的规则", sourceStaNo);
                    break;
            }
        }catch (Exception e){
            log.error("站点={} 未查询到对应的规则",sourceStaNo);
        } catch (Exception e) {
            log.error("站点={} 未查询到对应的规则", sourceStaNo);
        }
        return null;
    }
@@ -198,27 +200,27 @@
        // ===============>>>> 开始执行
        curRow = rowLastno.getCurrentRow();
        if (!Cools.isEmpty(moveCrnNo) && moveCrnNo!=0){
        if (!Cools.isEmpty(moveCrnNo) && moveCrnNo != 0) {
            crnNumber = moveCrnNo;
            if (times==0){
                curRow = moveCrnNo*4-1;
            }else {
                curRow = moveCrnNo*4-2;
            if (times == 0) {
                curRow = moveCrnNo * 4 - 1;
            } else {
                curRow = moveCrnNo * 4 - 2;
            }
        }
        //此程序用于优化堆垛机异常时的运行时间
        for (int i = times; i <= crnNumber*2; i++) {
            int[] locNecessaryParameters = Utils.LocNecessaryParameters(rowLastno, curRow, crnNumber,whsType);
        for (int i = times; i <= crnNumber * 2; i++) {
            int[] locNecessaryParameters = Utils.LocNecessaryParameters(rowLastno, curRow, crnNumber, whsType);
            curRow = locNecessaryParameters[1];
            crnNo = locNecessaryParameters[2];
            if (basCrnpService.checkSiteError(crnNo, true)) {
                rowCount =  locNecessaryParameters[0];
                rowCount = locNecessaryParameters[0];
                nearRow = locNecessaryParameters[3];
                List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                        .eq("row1", nearRow).eq("loc_sts", "O").eq("whs_type",rowLastnoType.getType().longValue()));
                int crnCountO = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).le("io_type",100));
                if (locMasts.size()-crnCountO<=2){
                        .eq("row1", nearRow).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()));
                int crnCountO = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).le("io_type", 100));
                if (locMasts.size() - crnCountO <= 2) {
                    times++;
                    continue;
                }
@@ -235,9 +237,9 @@
        boolean signRule2 = false;
        if (Utils.BooleanWhsTypeStaIoType(rowLastno)){
        if (Utils.BooleanWhsTypeStaIoType(rowLastno)) {
            // 靠近摆放规则 --- 同天同规格物料 //分离版
            if (!Cools.isEmpty(matnr) &&  staDescId == 1){
            if (!Cools.isEmpty(matnr) && staDescId == 1) {
                signRule1 = true;
            }
            // 靠近摆放规则 --- 同天同规格物料 //互通版
@@ -245,34 +247,34 @@
                signRule2 = true;
            }
            if (!Cools.isEmpty(matnr) &&  (staDescId == 11 || staDescId == 111)) {
            if (!Cools.isEmpty(matnr) && (staDescId == 11 || staDescId == 111)) {
                signRule1 = true;
            }
        }
        if (signRule1){
            if (nearRow!=curRow){
        if (signRule1) {
            if (nearRow != curRow) {
                List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                        .eq("row1", nearRow).eq("loc_sts", "O").eq("whs_type",rowLastnoType.getType().longValue()));
                for (LocMast locMast1:locMasts){
                        .eq("row1", nearRow).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()));
                for (LocMast locMast1 : locMasts) {
                    //获取巷道
//                    List<String> groupOutsideLocCrn = Utils.getGroupOutLocCrn(curRow,nearRow,locMast1.getLocNo(), curRow>nearRow);
//                    LocMast locMastGro = locMastService.selectById(wrkMast.getLocNo());
                    //获取目标库位所在巷道最浅非空库位
                    LocMast locMastF = locMastService.selectLocByLocStsPakInF(curRow,nearRow,locMast1,rowLastnoType.getType().longValue());
                    if (!Cools.isEmpty(locMastF) && locMastF.getLocSts().equals("F")){
                    LocMast locMastF = locMastService.selectLocByLocStsPakInF(curRow, nearRow, locMast1, rowLastnoType.getType().longValue());
                    if (!Cools.isEmpty(locMastF) && locMastF.getLocSts().equals("F")) {
                        LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("loc_no", locMastF.getLocNo()));
                        if (!Cools.isEmpty(locDetl) && matnr.equals(locDetl.getMatnr())
                                && batch.equals(batch.isEmpty() ? "" : locDetl.getBatch())
                                && grade.equals(grade.isEmpty() ? "" : locDetl.getBrand())) {
                            //获取目标库位所在巷道最深空库位
                            locMast = locMastService.selectLocByLocStsPakInO(curRow,nearRow,locMast1,rowLastnoType.getType().longValue());
                            locMast = locMastService.selectLocByLocStsPakInO(curRow, nearRow, locMast1, rowLastnoType.getType().longValue());
                            break;
                        }
                    }
                }
            }
        }else if (signRule2){
        } else if (signRule2) {
            List<String> locNos = locDetlService.getSameDetlToday(matnr, sRow, eRow);
            for (String locNo : locNos) {
                if (Utils.isShallowLoc(slaveProperties, locNo)) {
@@ -310,9 +312,9 @@
//        }
        // 靠近摆放规则 --- 空托 //互通版
        if (staDescId == 10  && Utils.BooleanWhsTypeStaIoType(rowLastno)) {
        if (staDescId == 10 && Utils.BooleanWhsTypeStaIoType(rowLastno)) {
            List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                    .eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow).eq("whs_type",rowLastnoType.getType().longValue()));
                    .eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow).eq("whs_type", rowLastnoType.getType().longValue()));
            if (!locMasts.isEmpty()) {
                for (LocMast loc : locMasts) {
                    if (Utils.isShallowLoc(slaveProperties, loc.getLocNo())) {
@@ -349,17 +351,17 @@
                log.error("type_no={},stn_no={},crn_no={}", staDescId, sourceStaNo, crnNo);
//                throw new CoolException("入库路径不存在");
                crnNo = 0;
            }else {
            } else {
                staNo = basDevpService.selectById(staDesc.getCrnStn());
                if (!staNo.getAutoing().equals("Y")) {
                    log.error("目标站"+staDesc.getCrnStn()+"不可用");
                    log.error("目标站" + staDesc.getCrnStn() + "不可用");
//                throw new CoolException("目标站"+staDesc.getCrnStn()+"不可用");
                    crnNo = 0;
                }
                startupDto.setStaNo(staNo.getDevNo());
            }
            // 更新库位排号
            if (Cools.isEmpty(locMast)){
            if (Cools.isEmpty(locMast)) {
                rowLastno.setCurrentRow(curRow);
                rowLastnoService.updateById(rowLastno);
            }
@@ -370,26 +372,26 @@
        // 1.按规则查找库位
        if (Cools.isEmpty(locMast) && crnNo != 0) {
            List<LocMast> locMasts = null;
            if (Utils.isNorth(sourceStaNo)){
            if (Utils.isNorth(sourceStaNo)) {
                locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                        .eq("row1", nearRow)
                        .eq("loc_sts", "O").eq("whs_type",rowLastnoType.getType().longValue())
                        .orderBy("lev1",true).orderBy("bay1",false));
            }else {
                        .eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())
                        .orderBy("lev1", true).orderBy("bay1", false));
            } else {
                locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                        .eq("row1", nearRow)
                        .eq("loc_sts", "O").eq("whs_type",rowLastnoType.getType().longValue())
                        .orderBy("lev1",true).orderBy("bay1",true));
                        .eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())
                        .orderBy("lev1", true).orderBy("bay1", true));
            }
            for (LocMast locMast1 : locMasts) {
                if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) {
                    continue;
                }
                if (Utils.BooleanWhsTypeStaIoType(rowLastno)){
                if (Utils.BooleanWhsTypeStaIoType(rowLastno)) {
                    String shallowLoc = Utils.getDeepLoc(slaveProperties, locMast1.getLocNo());
                    LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>()
                            .eq("loc_no", shallowLoc).eq("loc_sts", "O").eq("whs_type",rowLastnoType.getType().longValue()));
                            .eq("loc_no", shallowLoc).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()));
                    if (!Cools.isEmpty(locMast2)) {
                        locMast = locMast2;
                        break;
@@ -402,27 +404,27 @@
                }
            }
            if (Cools.isEmpty(locMast) && Utils.BooleanWhsTypeStaIoType(rowLastno)){
            if (Cools.isEmpty(locMast) && Utils.BooleanWhsTypeStaIoType(rowLastno)) {
                for (LocMast locMast1 : locMasts) {
                    if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) {
                        continue;
                    }
                    if (Utils.BooleanWhsTypeStaIoType(rowLastno)){
                    if (Utils.BooleanWhsTypeStaIoType(rowLastno)) {
                        String shallowLoc = Utils.getDeepLoc(slaveProperties, locMast1.getLocNo());
                        LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>()
                                .eq("loc_no", shallowLoc).eq("loc_sts", "O").eq("whs_type",rowLastnoType.getType().longValue()));
                                .eq("loc_no", shallowLoc).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()));
                        if (!Cools.isEmpty(locMast2)) {
                            locMast = locMast2;
                            break;
                        } else {
                            locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>()
                                    .eq("loc_no", shallowLoc).eq("loc_sts", "F").eq("whs_type",rowLastnoType.getType().longValue()));
                                    .eq("loc_no", shallowLoc).eq("loc_sts", "F").eq("whs_type", rowLastnoType.getType().longValue()));
                            if (!Cools.isEmpty(locMast2)) {
                                locMast = locMast1;
                                break;
                            } else {
                                locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>()
                                        .eq("loc_no", shallowLoc).eq("loc_sts", "D").eq("whs_type",rowLastnoType.getType().longValue()));
                                        .eq("loc_no", shallowLoc).eq("loc_sts", "D").eq("whs_type", rowLastnoType.getType().longValue()));
                                if (!Cools.isEmpty(locMast2)) {
                                    locMast = locMast1;
                                    break;
@@ -446,15 +448,15 @@
        // 递归查询
        if (Cools.isEmpty(locMast) || !locMast.getLocSts().equals("O")) {
            // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归
            if (times < rowCount*2) {
            if (times < rowCount * 2) {
                times = times + 1;
                return getLocNoRun(whsType, staDescId, sourceStaNo, matnr, batch, grade,moveCrnNo, locTypeDto, times);
                return getLocNoRun(whsType, staDescId, sourceStaNo, matnr, batch, grade, moveCrnNo, locTypeDto, times);
            }
            // 2.库位当前所属尺寸无空库位时,调整尺寸参数,向上兼容检索库位
            if (locTypeDto.getLocType1() < 3) {
                int i = locTypeDto.getLocType1() + 1;
                locTypeDto.setLocType1((short)i);
                return getLocNoRun(whsType,staDescId,sourceStaNo,matnr,batch,grade,0,locTypeDto,0);
                locTypeDto.setLocType1((short) i);
                return getLocNoRun(whsType, staDescId, sourceStaNo, matnr, batch, grade, 0, locTypeDto, 0);
            }
            log.error("系统没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times);
            throw new CoolException("没有空库位");
@@ -471,7 +473,7 @@
        return startupDto;
    }
    public StartupDto getLocNoRun4(Integer whsType, Integer staDescId, Integer sourceStaNo, String matnr, String batch, String grade, Integer moveCrnNo, LocTypeDto locTypeDto, int times,boolean mixture) {
    public StartupDto getLocNoRun4(Integer whsType, Integer staDescId, Integer sourceStaNo, String matnr, String batch, String grade, Integer moveCrnNo, LocTypeDto locTypeDto, int times, boolean mixture) {
        if (Cools.isEmpty(matnr)) {  //物料号
            matnr = "";
        }
@@ -505,7 +507,7 @@
        // ===============>>>> 开始执行
        curRow = rowLastno.getCurrentRow();
        if (!Cools.isEmpty(moveCrnNo) && moveCrnNo!=0){
        if (!Cools.isEmpty(moveCrnNo) && moveCrnNo != 0) {
            crnNumber = moveCrnNo;
//            if (times==0){
//                curRow = moveCrnNo*4-1;
@@ -515,15 +517,15 @@
        }
        //此程序用于优化堆垛机异常时的运行时间
        for (int i = times; i < crnNumber*2; i++) {
            int[] locNecessaryParameters = Utils.LocNecessaryParameters(rowLastno, curRow, crnNumber,whsType);
            rowCount =  locNecessaryParameters[0];
        for (int i = times; i < crnNumber * 2; i++) {
            int[] locNecessaryParameters = Utils.LocNecessaryParameters(rowLastno, curRow, crnNumber, whsType);
            rowCount = locNecessaryParameters[0];
            curRow = locNecessaryParameters[1];
            crnNo = locNecessaryParameters[2];
            nearRow = locNecessaryParameters[3];
            List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                    .eq("crn_no", crnNo).eq("loc_sts", "O").eq("whs_type",rowLastnoType.getType().longValue()));
            if (locMasts.size()<=5){
                    .eq("crn_no", crnNo).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()));
            if (locMasts.size() <= 5) {
                times++;
                continue;
            }
@@ -548,10 +550,10 @@
            if (Cools.isEmpty(staDesc)) {
                log.error("入库路径不存在:type_no={},stn_no={},crn_no={}", staDescId, sourceStaNo, crnNo);
                crnNo = 0;
            }else {
            } else {
                staNo = basDevpService.selectById(staDesc.getCrnStn());
                if (!staNo.getAutoing().equals("Y")) {
                    log.error("目标站"+staDesc.getCrnStn()+"不可用");
                    log.error("目标站" + staDesc.getCrnStn() + "不可用");
                    crnNo = 0;
                }
                startupDto.setStaNo(staNo.getDevNo());
@@ -570,8 +572,8 @@
        if (Cools.isEmpty(locMast) && crnNo != 0) {
            List<LocMast> locMasts = new ArrayList<>();
            int floor = 0;
            if (locTypeDto.getLev1() == null){
                if (locTypeDto.getLocType1() == 1){
            if (locTypeDto.getLev1() == null) {
                if (locTypeDto.getLocType1() == 1) {
                    int F1count = locMastService.selectCount(new EntityWrapper<LocMast>()
                            .in("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())
                            .eq("crn_no", 7)
@@ -585,14 +587,14 @@
                                .eq("lev1", 2));
                        if (F2count <= 10) {
                            throw new CoolException("库位不足");
                        }else {
                        } else {
                            floor = 2;
                        }
                    }else {
                    } else {
                        floor = 1;
                    }
                }else if (locTypeDto.getLocType1() == 2){
                } else if (locTypeDto.getLocType1() == 2) {
                    int F3count = locMastService.selectCount(new EntityWrapper<LocMast>()
                            .in("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())
                            .eq("crn_no", 7)
@@ -602,51 +604,51 @@
                        throw new CoolException("库位不足");
                    }
                    floor = 3;
                }else {
                } else {
                    throw new CoolException("库位高度数据异常");
                }
            }
            if (locTypeDto.getLev1() != null){
            if (locTypeDto.getLev1() != null) {
                locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                        .eq("bay1", nearRow)
                        .in("loc_sts", "O").eq("whs_type",rowLastnoType.getType().longValue())
                        .eq("crn_no",7)
                        .eq("loc_type1",locTypeDto.getLocType1())
                        .eq("lev1",locTypeDto.getLev1()).orderBy("row1",false));//最浅库位
            }else {
                if (floor == 0){
                        .in("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())
                        .eq("crn_no", 7)
                        .eq("loc_type1", locTypeDto.getLocType1())
                        .eq("lev1", locTypeDto.getLev1()).orderBy("row1", false));//最浅库位
            } else {
                if (floor == 0) {
                    throw new CoolException("库位已满");
                }
                locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                        .eq("bay1", nearRow)
                        .in("loc_sts", "O").eq("whs_type",rowLastnoType.getType().longValue())
                        .eq("crn_no",7)
                        .eq("loc_type1",locTypeDto.getLocType1())
                        .eq("lev1",floor).orderBy("row1",false));//最浅库位
                        .in("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())
                        .eq("crn_no", 7)
                        .eq("loc_type1", locTypeDto.getLocType1())
                        .eq("lev1", floor).orderBy("row1", false));//最浅库位
            }
            for (LocMast locMast1 : locMasts) {
                if (locMast != null){
                if (locMast != null) {
                    break;
                }
                if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) {
                    continue;
                }
                List<LocMast> locMasts1 = null;
                if (nearRow == 2 || nearRow ==7 || nearRow == 12){
                if (nearRow == 2 || nearRow == 7 || nearRow == 12) {
                    locMasts1 = locMastService.selectList(new EntityWrapper<LocMast>()
                            .eq("gro1", locMast1.getGro1())
                            .eq("crn_no",7)
                            .eq("loc_type1",locTypeDto.getLocType1())
                            .orderBy("bay1",true));
                }else {
                            .eq("crn_no", 7)
                            .eq("loc_type1", locTypeDto.getLocType1())
                            .orderBy("bay1", true));
                } else {
                    locMasts1 = locMastService.selectList(new EntityWrapper<LocMast>()
                            .eq("gro1", locMast1.getGro1())
                            .eq("crn_no",7)
                            .eq("loc_type1",locTypeDto.getLocType1())
                            .orderBy("bay1",false));
                            .eq("crn_no", 7)
                            .eq("loc_type1", locTypeDto.getLocType1())
                            .orderBy("bay1", false));
                }
                if (Cools.isEmpty(locMasts1)) {
                    continue;
@@ -655,7 +657,7 @@
                    if (locMastGro1.getLocSts().equals("P") || locMastGro1.getLocSts().equals("Q") || locMastGro1.getLocSts().equals("R") || locMastGro1.getLocSts().equals("X")) {
                        break;
                    }
                    if (locMastGro1.getLocSts().equals("O")){
                    if (locMastGro1.getLocSts().equals("O")) {
                        locMast = locMastGro1;
                        break;
                    }
@@ -667,9 +669,9 @@
        // 递归查询
        if (Cools.isEmpty(locMast) || !locMast.getLocSts().equals("O")) {
            // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归
            if (times < rowCount*2) {
            if (times < rowCount * 2) {
                times = times + 1;
                return getLocNoRun4(whsType, staDescId, sourceStaNo, matnr, batch, grade,moveCrnNo, locTypeDto, times,mixture);
                return getLocNoRun4(whsType, staDescId, sourceStaNo, matnr, batch, grade, moveCrnNo, locTypeDto, times, mixture);
            }
            log.error("系统没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times);
            throw new CoolException("没有空库位");
@@ -685,6 +687,7 @@
        startupDto.setLocNo(locNo);
        return startupDto;
    }
    public StartupDto getLocNoRun5(Integer whsType, Integer staDescId, Integer sourceStaNo, String matnr, String batch, String grade, Integer moveCrnNo, LocTypeDto locTypeDto, int times) {
        if (Cools.isEmpty(matnr)) {  //物料号
            matnr = "";
@@ -714,20 +717,20 @@
        }
        int sRow = rowLastno.getsRow();
        int eRow = rowLastno.geteRow();
        int crnNumber = eRow-sRow+1;
        int crnNumber = eRow - sRow + 1;
        // ===============>>>> 开始执行
        curRow = rowLastno.getCurrentRow();
        if (!Cools.isEmpty(moveCrnNo) && moveCrnNo!=0){
        if (!Cools.isEmpty(moveCrnNo) && moveCrnNo != 0) {
            crnNumber = moveCrnNo;
        }
        //此程序用于优化堆垛机异常时的运行时间
        int[] locNecessaryParameters = Utils.LocNecessaryParameters(rowLastno, curRow, crnNumber,whsType);
        int[] locNecessaryParameters = Utils.LocNecessaryParameters(rowLastno, curRow, crnNumber, whsType);
        curRow = locNecessaryParameters[1];
        crnNo = locNecessaryParameters[2];
        rowCount =  locNecessaryParameters[0];
        rowCount = locNecessaryParameters[0];
        nearRow = locNecessaryParameters[3];
        Wrapper<StaDesc> wrapper = null;
@@ -748,10 +751,10 @@
                log.error("type_no={},stn_no={},crn_no={}", staDescId, sourceStaNo, crnNo);
//                throw new CoolException("入库路径不存在");
                crnNo = 0;
            }else {
            } else {
                staNo = basDevpService.selectById(staDesc.getCrnStn());
                if (!staNo.getAutoing().equals("Y")) {
                    log.error("目标站"+staDesc.getCrnStn()+"不可用");
                    log.error("目标站" + staDesc.getCrnStn() + "不可用");
//                throw new CoolException("目标站"+staDesc.getCrnStn()+"不可用");
                    crnNo = 0;
                }
@@ -771,8 +774,8 @@
        if (Cools.isEmpty(locMast) && crnNo != 0) {
            List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                    .eq("row1", nearRow)
                    .eq("loc_sts", "O").eq("whs_type",rowLastnoType.getType().longValue())
                    .orderBy("lev1",true).orderBy("bay1",true));//最浅库位
                    .eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())
                    .orderBy("lev1", true).orderBy("bay1", true));//最浅库位
            for (LocMast locMast1 : locMasts) {
                if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) {
                    continue;
@@ -781,8 +784,8 @@
//                    //获取目标库位所在巷道最深空库位
//                    LocMast locMast2 = locMastService.selectLocByLocStsPakInO(curRow,nearRow,locMast1,rowLastnoType.getType().longValue());
//                    if (!Cools.isEmpty(locMast2) && locMast2.getBay1()==curRow) {
                        locMast = locMast1;
                        break;
                locMast = locMast1;
                break;
//                    }
//                }
            }
@@ -791,10 +794,10 @@
        // 递归查询
        if (Cools.isEmpty(locMast) || !locMast.getLocSts().equals("O")) {
            // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归
            if (times < rowCount*2) {
            if (times < rowCount * 2) {
                times = times + 1;
                return getLocNoRun5(whsType, staDescId, sourceStaNo, matnr, batch, grade,moveCrnNo, locTypeDto, times);
                return getLocNoRun5(whsType, staDescId, sourceStaNo, matnr, batch, grade, moveCrnNo, locTypeDto, times);
            }
            log.error("系统没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times);
            throw new CoolException("没有空库位");
@@ -818,7 +821,7 @@
            return msg.substring(0, 16);
        } else {
            StringBuilder msgBuilder = new StringBuilder(msg);
            for(int i = 0; i < count - msg.length(); ++i) {
            for (int i = 0; i < count - msg.length(); ++i) {
                msgBuilder.insert(0, "0");
            }
            return msgBuilder.toString();