自动化立体仓库 - WMS系统
skyouc
6 天以前 51ee242a62364a98af86b9bd3b9d191cd75c2f18
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -443,6 +443,54 @@
     * @date 2026/1/9 20:16
     */
    private void generateOutStock(TaskDto taskDto, Long userId, int workNo, String wrkCode, Date now, int ioType, LocMast locMast, StaDesc staDesc, String deviceNo) {
        if (Objects.isNull(deviceNo)) {
            throw new CoolException("机台号不能为空!!");
        }
        BasDevice basDevice = basDeviceService.selectOne(new EntityWrapper<BasDevice>()
                .eq("status", 1)
                .eq("dev_no", deviceNo));
        if (Objects.isNull(basDevice)) {
            throw new CoolException("机台信息不存在或已禁用!!");
        }
        List<LocAroundBind> binds = locAroundBindService.selectList( new EntityWrapper<LocAroundBind>()
                .eq("dev_no", basDevice.getDevNo())
                .eq("is_default", 1));
        if (Objects.isNull(binds) || binds.isEmpty()) {
            throw new CoolException("机台未设置默认工作位!!");
        }
        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"))
                .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
        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("暂无可用工作位!!");
            }
        }
        List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locMasts.getLocNo(), 1);
        //TODO 1. 获取入库站点, 目标库位  3. 将出库明细添加至入库明细
        Integer staNo = staNos.stream().findFirst().get();
        // 生成工作档
        WrkMast wrkMast = new WrkMast();
        wrkMast.setWrkNo(workNo);
@@ -454,7 +502,9 @@
        wrkMast.setIoPri(13D); // 优先级:13
        wrkMast.setCrnNo(locMast.getCrnNo());
        wrkMast.setSourceStaNo(staDesc.getCrnStn() + ""); // 源站
        wrkMast.setStaNo(staDesc.getStnNo() + ""); // 目标站
//        wrkMast.setStaNo(staDesc.getStnNo() + ""); // 目标站
        wrkMast.setStaNo(staNo + ""); // 目标站
        wrkMast.setLocNo(locMasts.getLocNo());
        wrkMast.setSourceLocNo(taskDto.getLocNo()); // 源库位
        wrkMast.setFullPlt("Y"); // 满板:Y
        wrkMast.setPicking("N"); // 拣料