自动化立体仓库 - WMS系统
skyouc
昨天 8ae2f2dcfe7e263d42c21ed7644641c780445b95
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -453,43 +453,51 @@
            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("loc_type", LocStsType.LOC_STS_TYPE_O.type)
                .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_R.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 +550,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 +565,12 @@
            wrkDetl.setUnit(locDel.getUnit());
            wrkDetl.setSpecs(locDel.getSpecs());
            wrkDetl.setBatch(locDel.getBatch());
//            wrkDetl.setAnfme(locDel.getAnfme());
            //库存数量
            wrkDetl.setStockQty(locDel.getAnfme());
            //单据数量
            wrkDetl.setRealQty(locDto.getAnfme());
            //单据数量
            wrkDetl.setAnfme(locDto.getAnfme());
            wrkDetl.setAppeTime(now);
            wrkDetl.setAppeUser(userId);
            wrkDetl.setModiTime(now);
@@ -1206,9 +1219,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("库位状态修改失败!!");
                    }
                }
            }
@@ -1504,6 +1526,7 @@
            wrkDetls.forEach(wrkDetl -> {
                WrkDetl wrkDetl1 = new WrkDetl();
                BeanUtils.copyProperties(wrkDetl, wrkDetl1);
                wrkDetl1.setAnfme(wrkDetl.getStockQty() - wrkDetl.getAnfme());
                wrkDetl1.setWrkNo(wokNo);
                if (!wrkDetlService.insert(wrkDetl1)) {
                    throw new CoolException("任务档明细保存失败!!");
@@ -1519,6 +1542,7 @@
        if (!locMastService.updateById(locMast)) {
            throw new CoolException("修改库位状态失败");
        }
//        wrkMast.setWrkCode(null);
//
//        if (!wrkMastService.updateById(wrkMast)) {
@@ -1714,7 +1738,7 @@
        if (Objects.isNull(binds) || binds.isEmpty()) {
            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)