自动化立体仓库 - WMS系统
whycq
2024-11-13 99bd76a0949cb844b421c8c9a9e381785b630597
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -10,10 +10,7 @@
import com.core.common.SnowflakeIdWorker;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.EmptyPlateOutParam;
import com.zy.asrs.entity.param.FullStoreParam;
import com.zy.asrs.entity.param.LocDetlAdjustParam;
import com.zy.asrs.entity.param.StockOutParam;
import com.zy.asrs.entity.param.*;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.*;
@@ -164,6 +161,7 @@
    public void startupFullTakeStore(StockOutParam param, Long userId) {
        List<StockOutParam.LocDetl> locDetls = new ArrayList<>();
        List<String> locs = new ArrayList<>();
        List<SameMatCount> sameMatCounts = new ArrayList<>();
        for(StockOutParam.LocDetl one : param.getLocDetls()){
            locs.add(one.getLocNo());
        }
@@ -171,9 +169,37 @@
        List<StockOutParam.LocDetl> stockOutParamLocDetlSort = Utils.getStockOutParamLocDetlSort(param.getLocDetls());
        boolean sign = true;
        boolean isfull = false; // 是否够数量
        Double isOut = 0.0;
        //Double isOut = 0.0;
        Map<String, Double> isOuts = new HashMap<>();
        List<String> locNoWeighting = new ArrayList<>();
        log.info("canshu:{}", stockOutParamLocDetlSort);
        for (StockOutParam.LocDetl locDetl : stockOutParamLocDetlSort) {
            if (isOuts.get(locDetl.getMatnr()) == null) {
                isOuts.put(locDetl.getMatnr(), locDetl.getCount());
            } else {
                isOuts.put(locDetl.getMatnr(), isOuts.get(locDetl.getMatnr()) + locDetl.getCount());
            }
        }
        log.info("canshu:{}", JSON.toJSONString(isOuts));
        for (StockOutParam.LocDetl locDetl : stockOutParamLocDetlSort) {
//            SameMatCount smc = new SameMatCount();
//            if (Cools.isEmpty(sameMatCounts)) {
//                smc.setMatnr(locDetl.getMatnr());
//                smc.setNeedOutCount(locDetl.getCount());
//                sameMatCounts.add(smc);
//            } else {
//                for (SameMatCount sameMatCount : sameMatCounts) {
//                    if (sameMatCount.getMatnr().equals(locDetl.getMatnr())) {
//                        sameMatCount.setNeedOutCount(locDetl.getCount() + sameMatCount.getNeedOutCount());
//                        //smc.setMatnr(sameMatCount.getMatnr());
//                        smc.setNeedOutCount(sameMatCount.getNeedOutCount());
//                    }
//                }
//            }
            if (Cools.isEmpty(locNoWeighting)){
                locNoWeighting.add(locDetl.getLocNo());
            }else {
@@ -182,6 +208,7 @@
                    sign = true;
                }
            }
            if (sign){
                LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo()));
                //获取同一库位组的外侧库位号
@@ -202,29 +229,44 @@
                            //不是相同物料
                            if (!sign){
                                locDetls.add(new StockOutParam.LocDetl(detl.getLocNo(), detl.getMatnr(), detl.getBatch(), detl.getAnfme()));
                                System.out.println("1");
                            }
                            continue;
                        }
                        if (!param.getOutSite().equals(214) && !param.getOutSite().equals(114)){
                            if (detl.getAnfme() >= locDetl.getCount()) {
                                locDetls.add(new StockOutParam.LocDetl(detl.getLocNo(), detl.getMatnr(), detl.getBatch(), locDetl.getCount()));
                                isOut = locDetl.getCount();
                            if (detl.getAnfme() >= isOuts.get(detl.getMatnr())) {
                                // if (detl.getAnfme() >= locDetl.getCount()) {
                                locDetls.add(new StockOutParam.LocDetl(detl.getLocNo(), detl.getMatnr(), detl.getBatch(), isOuts.get(detl.getMatnr())));
                                System.out.println("2");
                                //isOut = locDetl.getCount();
                                isfull = true;
                                break;
                            } else {
                                locDetls.add(new StockOutParam.LocDetl(detl.getLocNo(), detl.getMatnr(), detl.getBatch(), detl.getAnfme()));
                                isOut = detl.getAnfme();
                                isOuts.put(detl.getMatnr(), isOuts.get(detl.getMatnr()) - detl.getAnfme());
                                System.out.println(isOuts.get(locDetl.getMatnr()));
                            }
                        } else {
                            //强制不是相同物料
                            locDetls.add(new StockOutParam.LocDetl(detl.getLocNo(), detl.getMatnr(), detl.getBatch(), detl.getAnfme()));
//                            System.out.println("4");
                        }
                    }
                }
            }
            if (!isfull) {
            if (!isfull && isOuts.get(locDetl.getMatnr()) != null && isOuts.get(locDetl.getMatnr()) > 0) {
                if (locDetl.getCount() >= isOuts.get(locDetl.getMatnr())) {
                    locDetls.add(new StockOutParam.LocDetl(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), isOuts.get(locDetl.getMatnr())));
                    isOuts.put(locDetl.getMatnr(), isOuts.get(locDetl.getMatnr()) - locDetl.getCount());
//                    System.out.println(23);
                } else {
                    locDetls.add(new StockOutParam.LocDetl(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), locDetl.getCount()));
                    isOuts.put(locDetl.getMatnr(), isOuts.get(locDetl.getMatnr()) - locDetl.getCount());
//                    System.out.println("1222");
                }
                locDetls.add(new StockOutParam.LocDetl(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), locDetl.getCount() - isOut));
                //locDetls.add(new StockOutParam.LocDetl(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), locDetl.getCount() - isOut));
//                locDetls.add(locDetl);
            }
        }
@@ -287,7 +329,6 @@
//            }
//        }
//        List<StockOutParam.LocDetl> locDetls = param.getLocDetls();
//        ArrayList<String> locNos = new ArrayList<>();
@@ -995,9 +1036,14 @@
            wrkMast.setModiTime(now);
            if (!wrkMastService.insert(wrkMast)) {
                throw new CoolException("保存工作档失败,出库库位号:" + dto.getLocNo());
            } else {
                log.info("出库插入工作主档成功===>>" + JSON.toJSONString(wrkMast));
            }
            // 生成工作档明细
            for (LocDetlDto detlDto : dto.getLocDetlDtos()) {
                log.info("开始插入工作明细===>>工作号:" + workNo + "明细:" + JSON.toJSONString(detlDto));
                if (detlDto.getCount() == null || detlDto.getCount() <= 0.0D) {
                    continue;
                }
@@ -1016,7 +1062,9 @@
                wrkDetl.setMatType(detlDto.getLocDetl().getMatType());
                wrkDetl.setZpallet(locMast.getBarcode());
                if (!wrkDetlService.insert(wrkDetl)) {
                    throw new CoolException("保存工作档明细失败");
                    throw new CoolException("stockOut2:保存工作档明细失败===>>" + JSON.toJSONString(wrkDetl));
                } else {
                    log.info("出库插入工作明细成功===>>" + JSON.toJSONString(wrkDetl));
                }
            }
            // 修改库位状态:   F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中