自动化立体仓库 - WMS系统
skyouc
1 天以前 029ffbf20db7196d4f460bc741fd5f36a80689ae
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -453,43 +453,50 @@
            throw new CoolException("机台信息不存在或已禁用!!");
        }
        List<LocAroundBind> binds = locAroundBindService.selectList(new EntityWrapper<LocAroundBind>()
                .eq("dev_no", basDevice.getDevNo())
                .eq("is_default", 1));
        LocAroundBind binds = locAroundBindService.selectOne(new EntityWrapper<LocAroundBind>()
                .eq("dev_no", basDevice.getDevNo()).orderBy("is_default", false));
        if (Objects.isNull(binds) || binds.isEmpty()) {
        if (Objects.isNull(binds)) {
            throw new CoolException("机台未设置默认工作位!!");
        }
//
//        Set<String> locs = binds.stream().map(LocAroundBind::getBlocNo).collect(Collectors.toSet());
        Set<String> locs = binds.stream().map(LocAroundBind::getBlocNo).collect(Collectors.toSet());
//        LocMast locMasts = locMastService.selectOne(new EntityWrapper<LocMast>()
//                .in("loc_no", locs)
//                .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
//                .orderAsc(Arrays.asList("loc_no")));
//        if (Objects.isNull(locMasts)) {
//            binds = locAroundBindService.selectList(new EntityWrapper<LocAroundBind>()
//                    .eq("dev_no", basDevice.getDevNo()));
//
//            Set<String> nlocs = binds.stream().map(LocAroundBind::getBlocNo).collect(Collectors.toSet());
//
//            locMasts = locMastService.selectOne(new EntityWrapper<LocMast>()
//                    .in("loc_no", nlocs)
//                    .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
//                    .orderAsc(Arrays.asList("loc_no")));
//            if (Objects.isNull(locMasts)) {
//                throw new CoolException("暂无可用工作位!!");
//            }
//        }
        LocAroundBind bLocNo = locAroundBindService.selectOne(new EntityWrapper<LocAroundBind>().eq("b_loc_no", binds.getBlocNo()));
        bLocNo.setLocType(LocStsType.LOC_STS_TYPE_S.type);
        if (!locAroundBindService.updateById(bLocNo)) {
            throw new CoolException("工位预约失败!!");
        }
        LocMast locMasts = locMastService.selectOne(new EntityWrapper<LocMast>()
                .in("loc_no", locs)
                .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
                .orderAsc(Arrays.asList("loc_no"))
                .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
                .eq("loc_no", bLocNo.getBlocNo()));
        if (Objects.isNull(locMasts)) {
            binds = locAroundBindService.selectList(new EntityWrapper<LocAroundBind>()
                    .eq("dev_no", basDevice.getDevNo()));
            Set<String> nlocs = binds.stream().map(LocAroundBind::getBlocNo).collect(Collectors.toSet());
            locMasts = locMastService.selectOne(new EntityWrapper<LocMast>()
                    .in("loc_no", nlocs)
                    .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
                    .orderAsc(Arrays.asList("loc_no"))
                    .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
            if (Objects.isNull(locMasts)) {
                throw new CoolException("暂无可用工作位!!");
            }
            LocAroundBind bLocNo = locAroundBindService.selectOne(new EntityWrapper<LocAroundBind>().eq("b_loc_no", locMasts.getLocNo()));
            bLocNo.setLocType(LocStsType.LOC_STS_TYPE_S.type);
            if (!locAroundBindService.updateById(bLocNo)) {
                throw new CoolException("工位预约失败!!");
            }
        locMasts.setLocSts(LocStsType.LOC_STS_TYPE_S.type);
        locMasts.setModiUser(userId);
        locMasts.setModiTime(now);
        if (!locMastService.updateById(locMasts)) {
            throw new CoolException("预约库位状态失败,库位号:" + locMasts.getLocNo());
        }
        List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locMasts.getLocNo(), 1);
@@ -542,7 +549,7 @@
            wrkDetl.setIoTime(now);
            wrkDetl.setWrkNo(workNo);
            wrkDetl.setOrderNo(locDto.getOrderNo());
            wrkDetl.setAnfme(locDto.getAnfme()); // 数量
//            wrkDetl.setAnfme(locDto.getAnfme()); // 数量
            wrkDetl.setStandby1(locDto.getStandby1());
            LocDetl locDel = locDetlService.selectOne(new EntityWrapper<LocDetl>()
                    .eq("loc_no", locDto.getLocNo())
@@ -557,7 +564,7 @@
            wrkDetl.setUnit(locDel.getUnit());
            wrkDetl.setSpecs(locDel.getSpecs());
            wrkDetl.setBatch(locDel.getBatch());
//            wrkDetl.setAnfme(locDel.getAnfme());
            wrkDetl.setAnfme(locDel.getAnfme());
            wrkDetl.setAppeTime(now);
            wrkDetl.setAppeUser(userId);
            wrkDetl.setModiTime(now);
@@ -1206,9 +1213,18 @@
            if (!Objects.isNull(wrkMast.getWrkCode())) {
                LocAroundBind aroundBind = locAroundBindService.selectOne(new EntityWrapper<LocAroundBind>().eq("b_loc_no", wrkMast.getSourceLocNo()));
                if (!Objects.isNull(aroundBind)) {
                    aroundBind.setLocType(LocStsType.LOC_STS_TYPE_O.type);
                    aroundBind.setLocType(LocStsType.LOC_STS_TYPE_F.type);
                    if (!locAroundBindService.updateById(aroundBind)) {
                        throw new CoolException("工位状态修改失败!!");
                    }
                }
                LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", wrkMast.getSourceLocNo()));
                if (!Objects.isNull(locMast)) {
                    locMast.setLocSts(LocStsType.LOC_STS_TYPE_F.type);
                    if (!locMastService.updateById(locMast)) {
                        throw new CoolException("库位状态修改失败!!");
                    }
                }
            }
@@ -1519,11 +1535,12 @@
        if (!locMastService.updateById(locMast)) {
            throw new CoolException("修改库位状态失败");
        }
//        wrkMast.setWrkCode(null);
//
//        if (!wrkMastService.updateById(wrkMast)) {
//            throw new CoolException("任务档更新失败!!");
//        }
        wrkMast.setWrkCode(null);
        if (!wrkMastService.updateById(wrkMast)) {
            throw new CoolException("任务档更新失败!!");
        }
    }