自动化立体仓库 - WMS系统
skyouc
3 天以前 3cb931b3799846e1b8ef708da6c447bb9a9e0a0e
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -6,8 +6,6 @@
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.core.common.*;
import com.core.exception.CoolException;
import com.zy.api.enums.MatLocType;
import com.zy.api.enums.MatType;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.*;
import com.zy.asrs.entity.result.FindLocNoAttributeVo;
@@ -29,7 +27,6 @@
import com.zy.common.model.LocTypeDto;
import com.zy.common.model.MesCombParam;
import com.zy.common.model.StartupDto;
import com.zy.common.model.enums.IoWorkType;
import com.zy.common.model.enums.WorkNoType;
import com.zy.common.service.CommonService;
import com.zy.common.utils.HttpHandler;
@@ -761,6 +758,7 @@
                waitPakin.setZpallet(param.getBarcode()); // 托盘码
                waitPakin.setThreeCode(detlDto.getThreeCode());
                waitPakin.setSuppCode(detlDto.getStandby1());
                waitPakin.setStandby1(detlDto.getStandby1());
                waitPakin.setIoStatus("N"); // 入出状态
                waitPakin.setAnfme(detlDto.getAnfme()); // 数量
                waitPakin.setStatus("Y"); // 状态
@@ -1333,7 +1331,9 @@
    @Transactional(rollbackFor = Exception.class)
    public R OutCallAgv(AgvCallParams params, Long userId) {
        BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_IN_CACHE.type));
        if (Objects.isNull(basAreas)) {
            throw new CoolException("库区不存在!!");
        }
        /**获取入库最早的一条数据**/
        List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>()
                .eq("loc_sts", LocStsType.LOC_STS_TYPE_F.type)
@@ -1348,10 +1348,6 @@
        for (LocCache locCache : locCaches) {
            //获取缓存区信息
//            BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_IN_CACHE.type));
            if (Objects.isNull(basAreas)) {
                throw new CoolException("库区不存在!!");
            }
            List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>()
                    .eq("area_id", basAreas.getId())
                    .eq("loc_no", locCache.getLocNo()));
@@ -1656,7 +1652,7 @@
            throw new CoolException("组托物料类型不一致,只有相同的物料分类才可以组托!!");
        }
        // 还可以放入多少种物料
        Integer suplus = container.getMixMax();
        Double suplus = container.getMixMax();
        Date now = new Date();
        for (DetlDto detlDto : detlDtos) {
            Mat mat = matService.selectByMatnr(detlDto.getMatnr());
@@ -1683,7 +1679,7 @@
                throw new CoolException("明细内容不存在!!");
            }
            Double v = stationDetl.getAnfme() - stationDetl.getWorkQty();
            Double v = Math.round((stationDetl.getAnfme() - stationDetl.getWorkQty()) * 10000) / 10000.0;
            if (detlDto.getAnfme().compareTo(v) > 0) {
                throw new CoolException("组托上限为:" + stationDetl.getAnfme() + ", 已组托:" + stationDetl.getWorkQty() + ", 还可组托:" + v);
            }
@@ -1714,19 +1710,31 @@
                throw new CoolException("保存入库通知档失败");
            }
            Double v1 = stationDetl.getWorkQty() + detlDto.getAnfme();
            Double v1 = Math.round((stationDetl.getWorkQty() + detlDto.getAnfme()) * 10000) / 10000.0;
            stationDetl.setWorkQty(v1);
            if (!basStationDetlService.updateById(stationDetl)) {
                throw new CoolException("站点明细修改失败");
            }
            if (v1.compareTo(stationDetl.getWorkQty()) >= 0) {
            if (v1.compareTo(stationDetl.getAnfme()) >= 0) {
                if (!basStationDetlService.deleteById(stationDetl)) {
                    throw new CoolException("原始数据移除失败!");
                }
            }
            List<BasStationDetl> stas = basStationDetlService.selectList(new EntityWrapper<BasStationDetl>()
                    .eq("dev_no", stationDetl.getDevNo()));
            if (Objects.isNull(stas) || stas.isEmpty()) {
                BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", stationDetl.getDevNo()));
                if (Objects.isNull(station)) {
                    throw new CoolException("数据错误,站点不存在!!");
                }
                station.setLocSts(LocStsType.LOC_STS_TYPE_O.type);
                if (!basStationService.updateById(station)) {
                    throw new CoolException("站点状态更新失败!!");
                }
            }
        }
    }
@@ -1827,11 +1835,13 @@
                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())
                        .setSuppCode(combMat.getStandby1())
                        .setStandby1(combMat.getStandby1())
                        .setAnfme(combMat.getWorkQty().doubleValue());
                if (!basStationDetlService.insert(basStationDetl)) {
@@ -1844,7 +1854,6 @@
                if (!basStationDetlService.updateById(basStationDetl)) {
                    throw new CoolException("更新明细数据失败");
                }
            }
        }
        if (basStation.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type)
@@ -1943,7 +1952,7 @@
        wrkMast.setSourceStaNo(dto.getSourceStaNo() + "");
        wrkMast.setStaNo(dto.getStaNo() + "");
        wrkMast.setLocNo(dto.getLocNo());
        wrkMast.setBarcode(pakin.getBarcode()); // 托盘码
        wrkMast.setBarcode(pakin.getZpallet()); // 托盘码
        wrkMast.setFullPlt("Y"); // 满板:Y
        wrkMast.setPicking("N"); // 拣料
        wrkMast.setExitMk("N"); // 退出
@@ -2066,13 +2075,14 @@
        BasDevp basDevp = devps.stream().findFirst().get();
        List<LocMast> locMasts = new ArrayList<>();
        Map<String, List<LocDetl>> listMap = locDetls.stream().collect(Collectors.groupingBy(LocDetl::getMatnr));
        AtomicReference<Double> totalOut = new AtomicReference<>(
                locDetls.stream().mapToDouble(LocDetl::getAnfme).sum());
        //获取查库存总数量
        AtomicReference<Double> totalOut = new AtomicReference<>(0.0);
        listMap.forEach((matnr, detls) -> {
            // 根据supId(供应商)分类,得到出库总数
            Map<String, List<LocDetl>> supIds = detls.stream().collect(Collectors.groupingBy(LocDetl::getStandby1));
            supIds.forEach((supId, sups) -> {
                // 根据supId(供应商)分类,得到需要存放的总空库存数量
                Double sum = sups.stream().mapToDouble(LocDetl::getAnfme).sum();
                AtomicReference<Double> itemed = new AtomicReference<>(0.0);
                // 获取当前供应商+ 物料在库
                List<LocDetl> detlList = locDetlService.selectList(new EntityWrapper<LocDetl>()
                        .eq("matnr", matnr)
@@ -2095,17 +2105,20 @@
                        Set<String> sets = adetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet());
                        // 判断容器是否还可混放,及当前物料可放多少
                        if (container.getMixMax() > sets.size()) {
                            int suplus = container.getMixMax() - sets.size();
                            //余下可混放种类
                            long suplus = Math.round((container.getMixMax() - sets.size()) * 10000) / 10000;
                            Mat mats = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", matnr));
                            if (Objects.isNull(mats)) {
                                throw new CoolException("物料不存在!!");
                            }
                            Double v = mats.getUpQty() * suplus;
                            // 小于零
                            if (sum.compareTo(v) <= 0) {
                            //余下最大可放数量
                            Double v = Math.round((mats.getUpQty() * suplus) * 10000) / 10000.0;
                            // 入库数量小于零且入库数量减去已出数量大于零()
                            if (sum.compareTo(v) <= 0 && sum.compareTo(itemed.get()) > 0) {
                                itemed.set(Math.round((itemed.get() + v) * 10000) / 10000.0);
                                // 可放下
                                locMasts.add(locMast);
                                totalOut.set(Math.round((totalOut.get() - sum) * 10000) / 10000.0);
                                totalOut.set(Math.round((totalOut.get() + itemed.get()) * 10000) / 10000.0);
                            }
                        }
                    });
@@ -2115,10 +2128,9 @@
        // 判断根据分拣出库后,还需要出多少托盘或料箱;如果余料大于0, 出新托盘或料箱
        if (totalOut.get().compareTo(0.0) > 0) {
            // Set<String> matnrs =
            // locDetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet());
            // List<Mat> mats = matService.selectList(new EntityWrapper<Mat>().in("matnr",
            // matnrs));
            generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId);
            //TODO 细化区分,当前出库托盘是滞满足拣货数量
        } else {
            LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
                    // todo 根据物料种类,区分库区类型
                    .eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type)
@@ -2127,12 +2139,6 @@
            locMasts.add(locMast);
            // 空板出库
            generateTask(locMasts, TaskIOType.EMPTY_OUT.type, basDevp, userId);
        } else {
            // 生成堆垛机出库任务
            generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId);
            // if (!locMasts.isEmpty()) {
            //
            // }
        }
    }