lty
2025-03-29 c588ec9236ef644fe13af957920198bdcb4e05e8
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -158,12 +158,16 @@
                        if (staProtocol.getSiteId() == 107 || staProtocol.getSiteId() == 109) {
                            StaProtocol staProtocol5 = getClonedStation(devpThread, staProtocol.getSiteId() - 1);
                            if (staProtocol5 != null && (staProtocol5.isLoading() && (staProtocol5.getStaNo() == 107 || staProtocol5.getStaNo() == 109))) {
                                short workNo = staProtocol5.getWorkNo();
                                staProtocol5.setWorkNo(workNo);
                                staProtocol5.setStaNo((short) 112);
                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol5));
                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol5));
                            }
                        } else {
                            short workNo = staProtocol.getWorkNo();
                            staProtocol.setWorkNo(workNo);
                            staProtocol.setStaNo((short) 112);
                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol));
                        }
                    }
                }
@@ -181,31 +185,60 @@
        return (staProtocol != null) ? staProtocol.clone() : null;
    }
    //112循环站点至出库站
    public synchronized void shiftCyclePointToTarget() throws IOException, InterruptedException{
        try{
    // 112循环站点至出库站
    public synchronized void shiftCyclePointToTarget() throws IOException, InterruptedException {
        try {
            for (DevpSlave devp : slaveProperties.getDevp()) {
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                if (devpThread == null) {
                    continue;
                }
                StaProtocol staProtocol = devpThread.getStation().get(112);
                if (staProtocol == null) {
                    continue;
                } else {
                    staProtocol = staProtocol.clone();
                }
                if(staProtocol.getWorkNo() == 0){
                StaProtocol staProtocol2 = devpThread.getStation().get(116);
//                StaProtocol staProtocol3 = devpThread.getStation().get(117);
//                if(Objects.equals(staProtocol3.getWorkNo(), staProtocol.getWorkNo()) && staProtocol.getWorkNo() != 0){
//                    staProtocol.setWorkNo((short) 0);
//                    staProtocol.setStaNo((short) 0);
//                    MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//                    Thread.sleep(100); // 让 PLC 识别变化
//                }
                if (staProtocol == null || staProtocol.getWorkNo() == 0 || !staProtocol.isLoading() ) {
                    continue;
                }
                if(staProtocol.getStaNo() != 112){
                    continue;
                }
                if(staProtocol.getWorkNo() == staProtocol2.getWorkNo()) {
                    continue;
                }
                // 查询任务信息
                TaskWrk taskWrk = taskWrkMapper.selectStaWorking(Integer.valueOf(staProtocol.getWorkNo()));
                if(taskWrk != null &&  taskWrk.getWrkNo() < 9001 && taskWrk.getWrkNo() > 6000){
                    staProtocol.setStaNo(Short.valueOf(taskWrk.getTargetPoint()));
                    MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                if (taskWrk == null || taskWrk.getWrkNo() < 6001 || taskWrk.getWrkNo() > 9000) {
                    continue;
                }
//                 先清零
                short workNo = staProtocol.getWorkNo();
                short oldStaNo = staProtocol.getStaNo();
//                staProtocol.setWorkNo((short) 0);
//                staProtocol.setStaNo((short) 0);
//                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//                Thread.sleep(100); // 让 PLC 识别变化
                // 再写入目标站点
                staProtocol.setWorkNo(workNo);
                staProtocol.setStaNo(Short.valueOf(taskWrk.getTargetPoint()));
                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, staProtocol));
                Thread.sleep(200);
                log.info("Shifted from cycle station 112 to target {}, workNo: {}", taskWrk.getTargetPoint(), workNo);
            }
        }catch (Exception e) {
            log.error("generateStoreWrkFile e", e);
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        } catch (Exception e) {
            log.error("shiftCyclePointToTarget error", e);
        }
    }
@@ -949,9 +982,9 @@
                        if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) {
                            break;
                        }
                        int storeCount = taskWrkService.getStoreCount(taskWrk.getCrnNo());
                        int storeCount = basDevpService.getStoreCount();
                        if(storeCount >= maxCount){
                            log.error("{}号堆垛机暂存数已满!", taskWrk.getCrnNo());
                            log.error("输送线暂存数达到上限");
                            break;
                        }