自动化立体仓库 - WMS系统
skyouc
6 小时以前 bfa307fb0fe82ce6f5a2ea354fcee43d9d1f0fa1
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -1454,7 +1454,13 @@
                    .eq("ctn_type", mat.getTagId())
                    .eq("dev_no", params.getTarSite()));
            if (Objects.isNull(station)) {
//                throw new CoolException("!!");
                continue;
            }
            Task task = taskService.selectOne(new EntityWrapper<Task>().eq("source_sta_no", station.getDevNo()).or().eq("sta_no", station.getDevNo()));
            if (!Objects.isNull(task)) {
                throw new CoolException("当前站点上一个任务未完成!!");
            }
            /**生成缓存区出库任务*/
@@ -1485,7 +1491,8 @@
        List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>()
                .eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type)
                .eq("area_id", basAreas.getId()));
                .eq("area_id", basAreas.getId())
                .orderAsc(Arrays.asList("modi_time")));
        if (locCaches.isEmpty()) {
            throw new CoolException("暂无空板库位");
        }
@@ -1508,12 +1515,10 @@
        if (Objects.isNull(params.getOrgSite())) {
            throw new CoolException("源站点不能为空!!");
        }
        BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("name", params.getTarSite()));
        if (Objects.isNull(basAreas)) {
            return R.error("站点不存在,请检查站点是否输入正确!!");
        }
        List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>()
                .in("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
                .eq("area_id", basAreas.getId()));
@@ -1591,15 +1596,11 @@
        });
        // 修改目标库位状态
        if (loc.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
            loc.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.入库预约
            loc.setModiTime(new Date());
            loc.setModiUser(userId);
            if (!locCacheService.update(loc, new EntityWrapper<LocCache>().eq("loc_no", loc.getLocNo()))) {
                throw new CoolException("更新目标库位状态失败");
            }
        } else {
            throw new CoolException("移转失败,目标库位状态:" + loc.getLocSts$());
        loc.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.入库预约
        loc.setModiTime(new Date());
        loc.setModiUser(userId);
        if (!locCacheService.update(loc, new EntityWrapper<LocCache>().eq("loc_no", loc.getLocNo()))) {
            throw new CoolException("更新目标库位状态失败");
        }
        // 修改原站点信息
@@ -1883,36 +1884,41 @@
        if (Cools.isEmpty(basStation)) {
            throw new CoolException("请输入正确的站点号");
        }
        WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", params.getOrgBarcode()));
        if (Objects.isNull(wrkMast)) {
            throw new CoolException("出库任务档信息不存在!!");
        }
        for (CollectionPakinParams.CombMat combMat : params.getCombMats()) {
            if (combMat.getWorkQty().compareTo(BigDecimal.ZERO) == 0) {
                continue;
        if (basStation.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type) || basStation.getLocSts().equals(LocStsType.LOC_STS_TYPE_F.type)) {
            WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", params.getOrgBarcode()));
            if (Objects.isNull(wrkMast)) {
                throw new CoolException("出库任务档信息不存在!!");
            }
            OrderPakin orderPakin = orderPakinService.selectByNo(combMat.getOrderNo());
            if (Cools.isEmpty(orderPakin)) {
                throw new CoolException("未找到备货入库单");
            }
            for (CollectionPakinParams.CombMat combMat : params.getCombMats()) {
                if (combMat.getWorkQty().compareTo(BigDecimal.ZERO) == 0) {
                    continue;
                }
            UpdateDetailsOfPakin(orderPakin, combMat);
                OrderPakin orderPakin = orderPakinService.selectByNo(combMat.getOrderNo());
                if (Cools.isEmpty(orderPakin)) {
                    throw new CoolException("未找到备货入库单");
                }
            BasStationDetl basStationDetl = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>()
                    .eq("dev_no", basStation.getDevNo())
                    .eq("matnr", combMat.getMatnr())
                    .eq("order_no", combMat.getOrderNo())
                    .eq(!Cools.isEmpty(combMat.getBatch()), "batch", combMat.getBatch())
                    .eq(!Cools.isEmpty(combMat.getStandby1()), "standby1", combMat.getStandby1()));
                try {
                    UpdateDetailsOfPakin(orderPakin, combMat);
                } catch (Exception e) {
                    log.error(e.getMessage());
                    throw new CoolException(e.getMessage());
                }
                BasStationDetl basStationDetl = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>()
                        .eq("dev_no", basStation.getDevNo())
                        .eq("matnr", combMat.getMatnr())
                        .eq("order_no", combMat.getOrderNo())
                        .eq(!Cools.isEmpty(combMat.getBatch()), "batch", combMat.getBatch())
                        .eq(!Cools.isEmpty(combMat.getStandby1()), "standby1", combMat.getStandby1()));
            Wrapper<WrkDetl> wrapper = new EntityWrapper<WrkDetl>()
                    .eq("wrk_no", wrkMast.getWrkNo())
                    .eq("matnr", combMat.getMatnr())
                    .eq("supp_coode", combMat.getStandby1());
                Wrapper<WrkDetl> wrapper = new EntityWrapper<WrkDetl>()
                        .eq("wrk_no", wrkMast.getWrkNo())
                        .eq("matnr", combMat.getMatnr())
                        .eq("supp_coode", combMat.getStandby1());
////                    .eq(!Objects.isNull(params.getBoxType1()), "boxType1", params.getBoxType1())
//
//            if (!Objects.isNull(params.getBoxType1())) {
@@ -1921,42 +1927,45 @@
//            WrkDetl wrkDetl = wrkDetlService.selectOne(wrapper);
            if (Cools.isEmpty(basStationDetl)) {
                basStationDetl = new BasStationDetl();
                Mat mat = matService.selectByMatnr(combMat.getMatnr());
                BeanUtils.copyProperties(mat, basStationDetl);
                basStationDetl
                        .setId(null)
                        .setOrderNo(orderPakin.getOrderNo())
                        .setDevNo(basStation.getDevNo())
                        .setBarcode(params.getTarBarcode())
                        .setZpallet(params.getTarBarcode())
                        .setBatch(combMat.getBatch())
                        .setBoxType1(params.getBoxType1())
                        .setSuppCode(combMat.getStandby1())
                        .setStandby1(combMat.getStandby1())
                        .setAnfme(combMat.getWorkQty().doubleValue());
                if (Cools.isEmpty(basStationDetl)) {
                    basStationDetl = new BasStationDetl();
                    Mat mat = matService.selectByMatnr(combMat.getMatnr());
                    BeanUtils.copyProperties(mat, basStationDetl);
                    basStationDetl
                            .setId(null)
                            .setOrderNo(orderPakin.getOrderNo())
                            .setDevNo(basStation.getDevNo())
                            .setBarcode(params.getTarBarcode())
                            .setZpallet(params.getTarBarcode())
                            .setBatch(combMat.getBatch())
                            .setBoxType1(params.getBoxType1())
                            .setSuppCode(combMat.getStandby1())
                            .setStandby1(combMat.getStandby1())
                            .setAnfme(combMat.getWorkQty().doubleValue());
//                if (!Objects.isNull(wrkDetl) && !wrkDetl.getMatnr().equals(combMat.getMatnr())) {
//                    throw new CoolException("请检查隔层是否绑定正确!!");
//                }
                if (!basStationDetlService.insert(basStationDetl)) {
                    throw new CoolException("插入明细失败");
                }
                    if (!basStationDetlService.insert(basStationDetl)) {
                        throw new CoolException("插入明细失败");
                    }
            } else {
                BigDecimal anfme = new BigDecimal(basStationDetl.getAnfme().toString()).add(combMat.getWorkQty());
                basStationDetl.setAnfme(anfme.doubleValue());
                if (!basStationDetlService.updateById(basStationDetl)) {
                    throw new CoolException("更新明细数据失败");
                } else {
                    BigDecimal anfme = new BigDecimal(basStationDetl.getAnfme().toString()).add(combMat.getWorkQty());
                    basStationDetl.setAnfme(anfme.doubleValue());
                    if (!basStationDetlService.updateById(basStationDetl)) {
                        throw new CoolException("更新明细数据失败");
                    }
                }
            }
        }
        if (basStation.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type)
                || basStation.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
            basStation.setBarcode(params.getTarBarcode());
            basStation.setLocSts(LocStsType.LOC_STS_TYPE_F.type);
            basStationService.updateById(basStation);
            if (basStation.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type)
                    || basStation.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
                basStation.setBarcode(params.getTarBarcode());
                basStation.setLocSts(LocStsType.LOC_STS_TYPE_F.type);
                basStationService.updateById(basStation);
            }
        } else {
            throw new CoolException("当前站点不是在库状态,无法绑定台车!!");
        }
        return R.ok();
@@ -2296,7 +2305,12 @@
                    });
                } else {
                    // 获取当前供应商+ 物料在库
                    LocMast notFullList = locMastService.selectNotFull(mats.getLocType(), one.getId());
                    List<String> locs = new ArrayList<>();
                    if (!locMasts.isEmpty()) {
                        locs = locMasts.stream().map(CrnTaskDetlDTO::getLocNo).collect(Collectors.toList());
                    }
                    LocMast notFullList = locMastService.selectNotFull(mats.getLocType(), one.getId(), locs);
                    if (Objects.isNull(notFullList)) {
                        continue;
                    }
@@ -2305,6 +2319,11 @@
                    if (Objects.isNull(container)) {
                        throw new CoolException("数据错误,容器不存在!!");
                    }
//                    notFullList.setLocSts(LocStsType.LOC_STS_TYPE_R.type);
//                    if (!locMastService.update(notFullList, new EntityWrapper<LocMast>().eq("loc_no", notFullList.getLocNo()))) {
//                        throw new CoolException("预约出库失败!!");
//                    }
                    List<LocDetl> adetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", notFullList.getLocNo()));
                    Set<String> sets = adetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet());
                    List<LocDetl> locDtls = new ArrayList<>();
@@ -2335,13 +2354,17 @@
                }
            }
        });
        Integer whyType = 2;
        if (station.getId().equals(124L) || station.getId().equals(125L)) {
            whyType = 1;
        }
        /**是否优先空板出库*/
        Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "OutStockOrderByEmpty"));
        if (!Objects.isNull(config) && Boolean.parseBoolean(config.getValue())) {
            LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
                    // todo 根据物料种类,区分库区类型
                    .eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type)
                    .eq("whs_type", whyType)
                    .orderAsc(Arrays.asList("row1", "bay1", "lev1"))
                    .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
@@ -2361,6 +2384,7 @@
                LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
                        // todo 根据物料种类,区分库区类型
                        .eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type)
                        .eq("whs_type", whyType)
                        .orderAsc(Arrays.asList("row1", "bay1", "lev1"))
                        .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
@@ -2399,7 +2423,8 @@
            if (Cools.isEmpty(wrkMast1)) {
                Integer outSta = devp.getDevNo();
                // 获取路径
                StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), outSta);
                StaDesc staDesc = staDescService.queryCrnStnByLoc(ioType, locMast, outSta);
//                StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), outSta);
                // 生成工作档
                WrkMast wrkMast = new WrkMast();
@@ -2529,22 +2554,22 @@
        loc.setModiUser(userId);
        loc.setModiTime(new Date());
//        if (!) {
//            throw new CoolException("更新库位状态信息!!");
//        }
        locCacheService.update(loc, new EntityWrapper<LocCache>().eq("loc_no", loc.getLocNo()));
        if (!locCacheService.update(loc, new EntityWrapper<LocCache>().eq("loc_no", loc.getLocNo()))) {
            throw new CoolException("更新库位状态信息!!");
        }
        // 修改目标站点信息
        if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
            station.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.入库预约
            station.setModiTime(new Date());
            station.setModiUser(userId);
            if (!basStationService.updateById(station)) {
                throw new CoolException("更新目标库位状态失败");
            }
        } else {
            log.error("移转失败,目标库位状态:" + station.getLocSts());
//        if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
//
//        } else {
//            log.error("移转失败,目标库位状态:" + station.getLocSts());
//            throw new CoolException("移转失败,目标库位状态:" + station.getLocSts());
//        }
        station.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.入库预约
        station.setModiTime(new Date());
        station.setModiUser(userId);
        if (!basStationService.updateById(station)) {
            throw new CoolException("更新目标库位状态失败");
        }
    }
@@ -2651,6 +2676,7 @@
            // 修改目标库位状态
            loc.setLocSts(LocStsType.LOC_STS_TYPE_D.type); // S.入库预约
            loc.setModiTime(new Date());
            loc.setBarcode(barcode);
            loc.setModiUser(userId);
            if (!locCacheService.update(loc, new EntityWrapper<LocCache>().eq("loc_no", loc.getLocNo()))) {
                throw new CoolException("更新目标库位状态失败");
@@ -2661,11 +2687,12 @@
            if (Objects.isNull(station)) {
                throw new CoolException("站点不存在!!");
            }
            station.setLocSts("O");
            station.setBarcode(barcode);
            station.setLocSts(LocStsType.LOC_STS_TYPE_O.type); // S.入库预约
            station.setBarcode("");
            station.setModiTime(new Date());
            station.setModiUser(userId);
            if (!basStationService.updateById(station)) {
            if (!basStationService.update(station, new EntityWrapper<BasStation>().eq("dev_no", orgSite))) {
                throw new CoolException("更新目标库位状态失败");
            }
            basStationDetlService.delete(new EntityWrapper<BasStationDetl>().eq("dev_no", station.getDevNo()));
@@ -2753,13 +2780,9 @@
        if (Objects.isNull(station)) {
            throw new CoolException("站点不存在!!");
        }
        try {
            //空台车回库
            generateAgvTask("agv_back", locCache, callAgvBackParam.getOrgSite(), station.getBarcode(), userId, "M2");
        } catch (Exception e) {
            log.error(e.getMessage());
            throw new CoolException(e.getMessage());
        }
        //空台车回库
        generateAgvTask("agv_back", locCache, callAgvBackParam.getOrgSite(), station.getBarcode(), userId, "M2");
        return R.ok(locCache);
    }
@@ -3024,14 +3047,28 @@
                .eq("dev_no", params.getOrgSite())
                .eq("barcode", params.getCarBarcode()));
        if (Objects.isNull(station)) {
            throw new CoolException("台车与站点绑定关系不存在,请联系管理员!");
            LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("dev_no", params.getOrgSite()));
            if (!Objects.isNull(locCache)) {
                BasAreas whsTypeId = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_IN_CACHE.type));
                if (Objects.isNull(whsTypeId)) {
                    throw new CoolException("库区不存在!!");
                }
                List<LocDetl>  locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>()
                                .eq("area_id", whsTypeId.getId())
                        .eq("dev_no", params.getOrgSite()));
                if (!locDetls.isEmpty()) {
                    return R.ok().add(locDetls);
                }
            }
        } else {
            List<BasStationDetl> stationDetls = basStationDetlService.selectList(new EntityWrapper<BasStationDetl>()
                    .like(!Cools.isEmpty(params.getMatnr()), "matnr", params.getMatnr())
                    .eq("dev_no", station.getDevNo()));
            if (!stationDetls.isEmpty()) {
                return R.ok().add(stationDetls);
            }
        }
        List<BasStationDetl> stationDetls = basStationDetlService.selectList(new EntityWrapper<BasStationDetl>()
                .like(!Cools.isEmpty(params.getMatnr()), "matnr", params.getMatnr())
                .eq("dev_no", station.getDevNo()));
        if (!stationDetls.isEmpty()) {
            return R.ok().add(stationDetls);
        }
        return R.ok();
    }
@@ -3119,7 +3156,7 @@
                    }
                }
            } else {
                throw new CoolException("订单明细绑定关系不存在或已完成入库!!");
                throw new CoolException("订单明细绑定关系不存在!!");
            }
        }
        return R.ok();
@@ -3235,8 +3272,8 @@
                                    detl.setSupp(combMat.getSuppCode());
                                    if (!taskDetlService.update(detl, new EntityWrapper<TaskDetl>()
                                            .eq("matnr", detl.getMatnr())
                                            .eq("order_no", detl.getOrderNo())
                                            .eq("supp_code", detl.getSuppCode())
                                            .eq("order_no", detl.getOrderNo())
                                            .eq("wrk_no", task.getWrkNo()))) {
                                        throw new CoolException("任务号信息更新失败!!");
                                    }