自动化立体仓库 - WCS系统
野心家
2023-10-27 77c5a9937bd6a2ffbb2a45c10fa5d65d66015397
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -569,12 +569,53 @@
//            if(crnThread.isBackHpFlag()){
//                continue;
//            }
            // 只有当堆垛机空闲 并且 无任务时才继续执行
            if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO
                    && crnProtocol.getLoaded() == 0 && crnProtocol.getForkPos() == 0) {
                // 库位移转
                this.stnToStn(crn, crnProtocol);
            }else {
                continue;
            }
            try{
                Thread.sleep(1000);
            }catch (Exception e){
                continue;
            }
            crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
            crnProtocol = crnThread.getCrnProtocol();
            if (crnProtocol == null) { continue; }
            basCrnp = basCrnpService.selectById(crn.getId());
            if (basCrnp == null) {
                log.error("{}号堆垛机尚未在数据库进行维护!", crn.getId());
                continue;
            }
            // 只有当堆垛机空闲 并且 无任务时才继续执行
            if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO
                    && crnProtocol.getLoaded() == 0 && crnProtocol.getForkPos() == 0) {
                // 库位移转
                this.locToLoc(crn, crnProtocol);
            }else {
                continue;
            }
            try{
                Thread.sleep(1000);
            }catch (Exception e){
                continue;
            }
            crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
            crnProtocol = crnThread.getCrnProtocol();
            if (crnProtocol == null) { continue; }
            basCrnp = basCrnpService.selectById(crn.getId());
            if (basCrnp == null) {
                log.error("{}号堆垛机尚未在数据库进行维护!", crn.getId());
                continue;
            }
            // 只有当堆垛机空闲 并且 无任务时才继续执行
            if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO
                    && crnProtocol.getLoaded() == 0 && crnProtocol.getForkPos() == 0) {
                // 如果最近一次是入库模式
                if (crnProtocol.getLastIo().equals("I")) {
                    if (basCrnp.getInEnable().equals("Y")) {
@@ -597,7 +638,6 @@
                }
            }
            // 库位移转
            this.locToLoc(crn, crnProtocol);
//            this.crnRebackHp(crnProtocol, crnThread);
        }
@@ -2378,23 +2418,28 @@
                                locMast.setPackStatus(2);
                                testMast.setModiTime(new Date());
                                //NG转OK需要还原源库位和目标库位状态,OK转NG 删除任务档
                                WrkMast wrkMast=wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("source_loc_no",locMast.getLocNo()));
                                WrkMast wrkMast=wrkMastService.selectOne(new EntityWrapper<WrkMast>()
                                        .eq("source_loc_no",locMast.getLocNo())
                                        .eq("wrk_sts",11));
                                if(!Cools.isEmpty(wrkMast)){
                                    if(wrkMast.getWrkSts()==11){
                                    if(wrkMast.getIoType()==11){
                                        LocMast locMast1=locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no",wrkMast.getLocNo()));
                                        locMast1.setLocSts("O");
                                        locMastService.update(locMast1,new EntityWrapper<LocMast>().eq("loc_no",wrkMast.getLocNo()));
                                    }
                                    wrkMastMapper.delete(new EntityWrapper<WrkMast>().eq("source_loc_no",locMast.getLocNo()));
                                    wrkMastMapper.delete(new EntityWrapper<WrkMast>()
                                                .eq("wrk_sts",11)
                                                .eq("source_loc_no",locMast.getLocNo()));
                                    locMast.setLocSts("F");
                                    wrkDetlService.delete(new EntityWrapper<WrkDetl>().eq("zpallet",locMast.getBarcode()));
                                    wrkDetlService.delete(new EntityWrapper<WrkDetl>().eq("zpallet",wrkMast.getBarcode()));
                                    if(!locMastService.update(locMast,new EntityWrapper<LocMast>()
                                            .eq("channel",i+1))){
                                        log.error("修改测试库位状态失败"+locMast.getLocNo(),locMast);
                                    }else{
                                        fig=true;
                                    }
                                }
                                }}
                            }else if(devpThread.startSignal[i][0]==3){
                                locMast.setPackStatus(7);
                                testMast.setModiTime(new Date());
@@ -2415,6 +2460,14 @@
                            //通道启动按钮状态,1:可以启动出库或者移库,0:不能启动出库或者移库
                            locMast.setCtnKind(devpThread.startSignal[i][2]);
                            if(devpThread.startSignal[i][2]==1){
                                WrkMast wrkMast=wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("source_loc_no",locMast.getLocNo()));
                                if(!Cools.isEmpty(wrkMast)){
                                    wrkMast.setMk("Y");
                                    if(!wrkMastService.update(wrkMast,new EntityWrapper<WrkMast>()
                                            .eq("source_loc_no",locMast.getLocNo()))){
                                        log.error("修改任务档启动按钮状态,任务档状态失败"+wrkMast.getSourceLocNo(),wrkMast);
                                    }
                                }
                                if(!locMastService.update(locMast,new EntityWrapper<LocMast>()
                                        .eq("loc_sts","R")
                                        .eq("channel",i+1))){
@@ -2444,7 +2497,7 @@
                        TestMast testMast=testMastService.selectOne(new EntityWrapper<TestMast>()
                                .eq("loc_no",locMast.getLocNo())
                                .eq("user_id",locMast.getBarcode()));
                        if(locMast.getLocSts().equals("O")&&devpThread.startSignal[i][0]!=8){
                        if((locMast.getLocSts().equals("O")||locMast.getLocSts().equals("S"))&&devpThread.startSignal[i][0]!=8){
                            Thread.sleep(1000);
                            MessageQueue.offer(SlaveType.Devp, 1, new Task(6,locMast.getChannel()-1));
                        }