#
Junjie
2024-01-11 901b2ab3e0e7c592602848cfa256f34c5b0c7bb8
zy-asrs-common/src/main/java/com/zy/asrs/common/wms/service/CommonService.java
@@ -3,6 +3,8 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.common.domain.dto.LocTypeDto;
import com.zy.asrs.common.domain.dto.StartupDto;
import com.zy.asrs.common.domain.entity.StaDesc;
import com.zy.asrs.common.sys.service.StaDescService;
import com.zy.asrs.common.wms.entity.*;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.exception.CoolException;
@@ -43,7 +45,7 @@
     * @return workNo(工作号)
     */
    public int getWorkNo(Integer wrkMk) {
        WrkLastno wrkLastno = wrkLastnoService.getById(wrkMk);
        WrkLastno wrkLastno = wrkLastnoService.getOne(new LambdaQueryWrapper<WrkLastno>().eq(WrkLastno::getWrkMk, wrkMk));
        if (Cools.isEmpty(wrkLastno)) {
            throw new CoolException("数据异常,请联系管理员");
        }
@@ -78,15 +80,9 @@
    /**
     * 检索库位号
     *
     * @param whsType     类型 1:双深式货架
     * @param staDescId   路径ID
     * @param sourceStaNo 源站
     * @param matnr       物料号集合
     * @return locNo 检索到的库位号
     */
    @Transactional
    public StartupDto getLocNo(Integer whsType, Integer staDescId, Integer sourceStaNo, Integer moveCrnNo, LocTypeDto locTypeDto, int times) {
    public StartupDto getLocNo(Integer staDescId, Integer sourceStaNo, Long hostId, LocTypeDto locTypeDto, int times) {
        // 目标库位
        LocMast locMast = null;
@@ -112,7 +108,7 @@
//        }
        //搜索整个空库位组
        locMast = getLocNoStepSingle(locTypeDto, staDescId, sourceStaNo);
        locMast = getLocNoStepSingle(locTypeDto, staDescId, sourceStaNo, hostId);
        if (locMast != null) {
            //找到库位,返回dto
            return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto
@@ -226,7 +222,7 @@
            List<LocMast> locMasts = locMastService.list(new LambdaQueryWrapper<LocMast>()
                    .eq(LocMast::getLocSts, "O")
                    .eq(LocMast::getLocType1, 1)
                    .eq(LocMast::getCrnNo, staDesc.getCrnNo())
                    .eq(LocMast::getCrnNo, staDesc.getDeviceNo())
                    .orderByAsc(LocMast::getLev1, LocMast::getBay1, LocMast::getRow1));
            if (!locMasts.isEmpty()) {
                for (LocMast loc : locMasts) {
@@ -248,18 +244,19 @@
    }
    // 搜索单品(整个库位组)
    private LocMast getLocNoStepSingle(LocTypeDto locTypeDto, Integer staDescId, Integer sourceStaNo) {
    private LocMast getLocNoStepSingle(LocTypeDto locTypeDto, Integer staDescId, Integer sourceStaNo, Long hostId) {
        LocMast locMast = null;
        // 获取目标站
        LambdaQueryWrapper<StaDesc> wrapper = new LambdaQueryWrapper<StaDesc>()
                .eq(StaDesc::getTypeNo, staDescId)
                .eq(StaDesc::getStnNo, sourceStaNo);
                .eq(StaDesc::getStnNo, sourceStaNo)
                .eq(StaDesc::getHostId, hostId);
        StaDesc staDesc = staDescService.getOne(wrapper);
        if (staDesc == null) {
            throw new CoolException("入库路径不存在");
        }
        List<LocMast> locMasts = locMastService.list(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocSts, "O"));//搜索货物
        List<LocMast> locMasts = locMastService.list(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocSts, "O").eq(LocMast::getHostId, hostId));//搜索货物
        if (locMasts == null) {
            return null;
@@ -279,8 +276,7 @@
        // 获取目标站
        LambdaQueryWrapper<StaDesc> wrapper = new LambdaQueryWrapper<StaDesc>()
                .eq(StaDesc::getTypeNo, staDescId)
                .eq(StaDesc::getStnNo, sourceStaNo)
                .eq(StaDesc::getCrnNo,locMast.getCrnNo());
                .eq(StaDesc::getStnNo, sourceStaNo);
        StaDesc staDesc = staDescService.getOne(wrapper);
        if (Cools.isEmpty(staDesc)) {
            log.error("入库路径不存在, staDescId={}, sourceStaNo={}", staDescId, sourceStaNo);
@@ -288,9 +284,9 @@
        }
        // 检测目标站
        BasDevp staNo = basDevpService.getById(staDesc.getCrnStn());
        BasDevp staNo = basDevpService.getById(staDesc.getDeviceStn());
        if (!staNo.getAutoing().equals("Y")) {
            throw new CoolException("目标站" + staDesc.getCrnStn() + "不可用");
            throw new CoolException("目标站" + staDesc.getDeviceStn() + "不可用");
        }
        // 生成工作号
@@ -300,7 +296,6 @@
        startupDto.setSourceStaNo(sourceStaNo);
        startupDto.setStaNo(staNo.getDevNo());
        startupDto.setLocNo(locMast.getLocNo());
        startupDto.setCrnNo(staDesc.getCrnNo());
        return startupDto;
    }
}