123
ZY
2025-05-14 ce641926a957d238b202aa0d9dac3b8f15aff153
src/main/java/com/zy/common/service/CommonService.java
@@ -1,8 +1,8 @@
package com.zy.common.service;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.core.common.Arith;
import com.core.common.Cools;
import com.core.exception.CoolException;
@@ -13,6 +13,7 @@
import com.zy.common.model.LocTypeDto;
import com.zy.common.model.Shelves;
import com.zy.common.model.StartupDto;
import com.zy.common.utils.News;
import com.zy.core.properties.SlaveProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -53,7 +54,7 @@
     * @return workNo(工作号)
     */
    public int getWorkNo(Integer wrkMk) {
        WrkLastno wrkLastno = wrkLastnoService.selectById(wrkMk);
        WrkLastno wrkLastno = wrkLastnoService.getById(wrkMk);
        if (Cools.isEmpty(wrkLastno)) {
            throw new CoolException("数据异常,请联系管理员");
        }
@@ -63,7 +64,7 @@
        int eNo = wrkLastno.getENo();
        workNo = workNo>=eNo ? sNo : workNo+1;
        while (true) {
            WrkMast wrkMast = wrkMastService.selectById(workNo);
            WrkMast wrkMast = wrkMastService.getById(workNo);
            if (null != wrkMast) {
                workNo = workNo>=eNo ? sNo : workNo+1;
            } else {
@@ -79,7 +80,7 @@
        if (workNo == 0) {
            throw new CoolException("生成工作号失败,请联系管理员");
        } else {
            if (wrkMastService.selectById(workNo)!=null) {
            if (wrkMastService.getById(workNo)!=null) {
                throw new CoolException("生成工作号" + workNo + "在工作档中已存在");
            }
        }
@@ -120,7 +121,7 @@
            default:
                throw new CoolException("库位排号分配错误, 源站号:" + sourceStaNo);
        }
        RowLastno rowLastno = rowLastnoService.selectById(whsType);
        RowLastno rowLastno = rowLastnoService.getById(whsType);
        if (Cools.isEmpty(rowLastno)) {
            throw new CoolException("数据异常,请联系管理员");
        }
@@ -145,7 +146,7 @@
                }
                String shallowLocNo = Utils.getShallowLoc(slaveProperties, locNo);
                // 检测目标库位是否为空库位
                LocMast shallowLoc = locMastService.selectById(shallowLocNo);
                LocMast shallowLoc = locMastService.getById(shallowLocNo);
                if (shallowLoc != null && shallowLoc.getLocSts().equals("O")) {
                    if (basCrnpService.checkSiteError(shallowLoc.getCrnNo(), true)) {
                        if (VersionUtils.locMoveCheckLocType(shallowLoc, locTypeDto)) {
@@ -160,7 +161,7 @@
        // 靠近摆放规则 --- 空托
        if (staDescId == 10) {
            List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow));
            List<LocMast> locMasts = locMastService.list(new QueryWrapper<LocMast>().eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow));
            if (locMasts.size() > 0) {
                for (LocMast loc : locMasts) {
                    if (Utils.isShallowLoc(slaveProperties, loc.getLocNo())) {
@@ -168,7 +169,7 @@
                    }
                    String shallowLocNo = Utils.getShallowLoc(slaveProperties,  loc.getLocNo());
                    // 检测目标库位是否为空库位
                    LocMast shallowLoc = locMastService.selectById(shallowLocNo);
                    LocMast shallowLoc = locMastService.getById(shallowLocNo);
                    if (shallowLoc != null && shallowLoc.getLocSts().equals("O")) {
                        if (basCrnpService.checkSiteError(shallowLoc.getCrnNo(), true)) {
                            locMast = shallowLoc;
@@ -234,16 +235,16 @@
            throw new CoolException("没有可用的堆垛机");
        }
        // 获取目标站
        Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
        Wrapper<StaDesc> wrapper = new QueryWrapper<StaDesc>()
                .eq("type_no", staDescId)
                .eq("stn_no", sourceStaNo)
                .eq("crn_no", crnNo);
        StaDesc staDesc = staDescService.selectOne(wrapper);
        StaDesc staDesc = staDescService.getOne(wrapper);
        if (Cools.isEmpty(staDesc)) {
            log.error("type_no={},stn_no={},crn_no={}", staDescId, sourceStaNo, crnNo);
            News.error("type_no={},stn_no={},crn_no={}", staDescId, sourceStaNo, crnNo);
            throw new CoolException("入库路径不存在");
        }
        BasDevp staNo = basDevpService.selectById(staDesc.getCrnStn());
        BasDevp staNo = basDevpService.getById(staDesc.getCrnStn());
        if (!staNo.getAutoing().equals("Y")) {
            throw new CoolException("目标站"+staDesc.getCrnStn()+"不可用");
        }
@@ -257,17 +258,31 @@
        if (locMast == null) {
            if (Utils.isShallowLoc(slaveProperties, curRow)) {
                Integer deepRow = Utils.getDeepRow(slaveProperties, curRow);
                locMast = locMastService.queryFreeLocMast(deepRow, locTypeDto.getLocType1());
                locMast = locMastService.queryFreeLocMast(deepRow, locTypeDto.getLocType1(), locTypeDto.getLocType2());
                // 因库位移转、需预留空库位
                if (!locMastService.checkEmptyCount(locMast)) {
                    locMast = null;
                }
            }
            if (Cools.isEmpty(locMast)) {
                locMast = locMastService.queryFreeLocMast(curRow, locTypeDto.getLocType1());
                locMast = locMastService.queryFreeLocMast(curRow, locTypeDto.getLocType1(), locTypeDto.getLocType2());
                // 因库位移转、需预留空库位
                if (!locMastService.checkEmptyCount(locMast)) {
                    locMast = null;
                }
                // 目标库位 ===>> 浅库位, 则校验其深库位是否为 F D X
                if (null != locMast && Utils.isShallowLoc(slaveProperties, locMast.getLocNo())) {
                    LocMast deepLoc = locMastService.getById(Utils.getDeepLoc(slaveProperties, locMast.getLocNo()));
                    if (!deepLoc.getLocSts().equals("F") && !deepLoc.getLocSts().equals("D") && !deepLoc.getLocSts().equals("X")) {
                        locMast = null;
                    }
                }
                // 目标库位 ===>> 深库位, 则校验其浅库位是否为 O
                if (null != locMast && Utils.isDeepLoc(slaveProperties, locMast.getLocNo())) {
                    LocMast shallowLoc = locMastService.getById(Utils.getShallowLoc(slaveProperties, locMast.getLocNo()));
                    if (!shallowLoc.getLocSts().equals("O")) {
                        locMast = null;
                    }
                }
            }
        }
@@ -287,7 +302,7 @@
                locTypeDto.setLocType1((short) 2);
                return getLocNo(null, staDescId, sourceStaNo, matNos, locTypeDto, times);
            }
            log.error("系统没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times);
            News.error("系统没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times);
            throw new CoolException("没有空库位");
        }
        String locNo = locMast.getLocNo();