自动化立体仓库 - WMS系统
#
野心家
2023-05-25 4ce0a1b6c7712691a74f76890310f97c48215945
src/main/java/com/zy/common/web/WcsController.java
@@ -49,6 +49,8 @@
    private  LocDetlService locDetlService;
    @Autowired
    private  TestMastService testMastService;
    @Autowired
    private  MatService matService;
    @Value("mes.url")
    private String mesUrl;
@@ -66,16 +68,50 @@
        if (Cools.isEmpty(param.getSourceStaNo())) {
            return R.error("源站编号不能为空");
        }
        if (Cools.isEmpty(param.getPackNo())) {
            return R.error("packNo不能为空");
        }
        Date now = new Date();
        if (true){
            try{
                Mat mat = matService.selectByMatnr(param.getPackNo());
                if (Cools.isEmpty(mat)){
                    return R.error("商品信息档案未查询到pack信息"+param.getPackNo());
                }
                WaitPakin waitPakin = new WaitPakin();
                int i = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode()));
                if(i==0){
                    waitPakin.setMatnr(mat.getMatnr());// Pack码
                    waitPakin.setMaktx(mat.getMaktx());
                    waitPakin.setZpallet(param.getBarcode());   //托盘码
                    waitPakin.setIoStatus("N");     // 入出状态
                    waitPakin.setAnfme(1.0);  // 数量
                    waitPakin.setStatus("Y");    // 状态
                    waitPakin.setManuDate(mat.getManuDate());
                    waitPakin.setAppeUser(null);
                    waitPakin.setAppeTime(now);
                    waitPakin.setModiUser(null);
                    waitPakin.setModiTime(now);
                    waitPakin.setDeadWarn(mat.getDeadWarn());
                    if (!waitPakinService.insert(waitPakin)) {
                        throw new CoolException("保存入库通知档失败");
                    }
                }
            }catch (Exception e){
            }
        }
        List<WaitPakin> waitPakins = null;
        if (param.getIoType() == 1) {
            if (Cools.isEmpty(param.getBarcode())) {
                return R.error("条码不能为空");
            }
            waitPakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode()));
            if (Cools.isEmpty(waitPakins)) {
            if (Cools.isEmpty(waitPakins) || waitPakins.size() !=1) {
                WrkMast wrkMast = wrkMastService.selectByBarcode(param.getBarcode());
                if (wrkMast != null && wrkMast.getIoType() == 103) {
                    return R.parse(CodeRes.PICK_600);
                if (wrkMast != null || waitPakins.size() !=1) {
                    return R.parse("600-重复组托");
                }
                return R.parse(CodeRes.NO_COMB_700);
            }
@@ -152,6 +188,9 @@
        if (!res) {
            throw new CoolException("保存工作档失败");
        }
        // 目标库位
        LocMast locMast = locMastService.selectById(dto.getLocNo());
        // 生成工作档明细
        waitPakins.forEach(waitPakin -> {
            WrkDetl wrkDetl = new WrkDetl();
@@ -163,6 +202,24 @@
            wrkDetl.setDeadWarn(waitPakin.getDeadWarn());
            if (!wrkDetlService.insert(wrkDetl)) {
                throw new CoolException("保存工作明细失败");
            }
            TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>().eq("barcode", wrkMast.getBarcode()));
            if (Cools.isEmpty(testMast)){
                //生成测试档
                testMast=new TestMast();
                testMast.setChannel(locMast.getChannel());
                testMast.setUserId(locMast.getLocNo());
                testMast.setStatus(1);
                testMast.setBarcode(wrkDetl.getMatnr());
                testMast.setLocNo(locMast.getLocNo());
                testMast.setModiTime(now);
                testMast.setAppeTime(now);
                if (!testMastService.insert(testMast)){
                    throw new CoolException(wrkDetl.getMatnr()+"生成测试档失败");
                }
            }else {
                throw new CoolException(wrkDetl.getMatnr()+"已存在测试档");
            }
        });
        // 更新入库通知档 ioStatus ===>> Y
@@ -182,41 +239,25 @@
            throw new CoolException("更新源站失败");
        }
        // 更新目标库位状态
        LocMast locMast = locMastService.selectById(dto.getLocNo());
        if (locMast.getLocSts().equals("O")){
            locMast.setLocSts("S"); // S.入库预约
            locMast.setModiTime(now);
            if (!locMastService.updateById(locMast)){
                throw new CoolException("改变库位状态失败");
            }else{
                //1.扫码上报
                CombParam combParam = new CombParam();
                combParam.setPackNo(locMast.getBarcode());
                combParam.setLocNo(locMast.getLocNo());
                combParam.setPackSts(1);
                combParam.setRequestTime(DateUtils.convert(new Date()));
                new PostMesDataUtils().postMesData("MES系统",mesUrl,inpath,combParam);
                if (locMast.getRow1()<3){
                    //1.扫码上报
                    CombParam combParam = new CombParam();
                    combParam.setPackNo(wrkMast.getBarcode());
                    combParam.setLocNo(wrkMast.getLocNo());
                    combParam.setPackSts(0);
                    combParam.setStepSts(1);
                    combParam.setRequestTime(DateUtils.convert(now));
                    new PostMesDataUtils().postMesData("MES系统",mesUrl,inpath,combParam);
                }
            }
        } else {
            throw new CoolException(dto.getLocNo()+"目标库位已被占用");
        }
        TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>().eq("barcode", wrkMast.getBarcode()));
        if (Cools.isEmpty(testMast)){
            //生成测试档
            testMast=new TestMast();
            testMast.setChannel(locMast.getChannel());
            testMast.setUserId(locMast.getLocNo());
            testMast.setStatus(1);
            testMast.setBarcode(wrkMast.getBarcode());
            testMast.setLocNo(locMast.getLocNo());
            testMast.setModiTime(now);
            testMast.setAppeTime(now);
            if (!testMastService.insert(testMast)){
                throw new CoolException(wrkMast.getBarcode()+"生成测试档失败");
            }
        }else {
            throw new CoolException(wrkMast.getBarcode()+"已存在测试档");
        }
        return dto;