wangfei
2025-08-13 936c2d13cf59ee671a034e18de5bf4a574f17386
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java
@@ -106,6 +106,7 @@
    private static final List<Integer> ONE_LINE_FIRST = Arrays.asList(930, 931, 932);
    private static final List<Integer> TWO_LINE_FIRST = Arrays.asList(931, 930, 932);
    private Integer lastTimeLine = -1;
    /**
     * 直通格子
     */
@@ -373,14 +374,14 @@
        //获取空闲且领取任务的数据信息,没有任务直接走玻璃调度
        HashMap<Integer, Boolean> map = new HashMap<>();
        Boolean oneState = Boolean.FALSE;
        Boolean twoState = Boolean.FALSE;
        Boolean threeState = Boolean.FALSE;
        try {
            if (CMJ1ModbusTcp.checkConnected()) {
                Boolean oneEntity = CMJ1ModbusTcp.readUInt16(42027 - 40001) != 0;
                map.put(930, oneEntity);
            } else {
                map.put(930, Boolean.FALSE);
                oneState = CMJ1ModbusTcp.readUInt16(42027 - 40001) != 0;
                map.put(930, oneState);
            }
        } catch (Exception e) {
            //nothing
            log.info("一线空闲状态获取异常");
@@ -388,45 +389,53 @@
        try {
            S7DataZKExtra s7DataZKExtra = s7SerializerZKQ2.read(S7DataZKExtra.class);
            log.info("中空额外读取{}", s7DataZKExtra);
            map.put(931, s7DataZKExtra.getIsFree());
            map.put(932, s7DataZKExtra.getIsFree03());
            twoState = s7DataZKExtra.getIsFree();
            threeState = s7DataZKExtra.getIsFree03();
            map.put(931, twoState);
            map.put(932, threeState);
        } catch (Exception e) {
            //nothing
            log.info("二/三线线空闲状态获取异常");
        }
        List<Integer> resultList = new ArrayList<>();
        if (redisUtil.getCacheObject("priorityHollowSwitch")) {
            resultList = TWO_LINE_FIRST;
        } else {
            resultList = ONE_LINE_FIRST;
        }
        HollowGlassOutRelationInfo hollowGlassOutRelationInfo = null;
        int cell = -1;
        for (Integer i : resultList) {
            if (null == hollowGlassOutRelationInfo) {
                Boolean entity = map.get(i);
                cell = i;
                if (null != entity && entity) {
        if (oneState && twoState || !(oneState || twoState)) {
            //获取上一次的任务信息线路
            List<Integer> resultList = lastTimeLine == 930 ? TWO_LINE_FIRST : ONE_LINE_FIRST;
            for (int i : resultList) {
                if (null == hollowGlassOutRelationInfo) {
                    cell = i;
                    hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
                            .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                                    .eq(HollowGlassOutRelationInfo::getCell, cell)
                                    .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
                            );
                }
            } else {
                break;
            }
        }
        for (Integer i : resultList) {
            if (null == hollowGlassOutRelationInfo) {
                cell = i;
                hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
                        .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                                .eq(HollowGlassOutRelationInfo::getCell, cell)
                                .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
                        );
            } else {
                break;
        } else {
            for (int i : ONE_LINE_FIRST) {
                if (null == hollowGlassOutRelationInfo) {
                    Boolean freeFlag = map.get(i);
                    cell = i;
                    if (freeFlag) {
                        hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
                                .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                                        .eq(HollowGlassOutRelationInfo::getCell, cell)
                                        .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
                                );
                    }
                }
            }
            for (int i : ONE_LINE_FIRST) {
                if (null == hollowGlassOutRelationInfo) {
                    cell = i;
                    hollowGlassOutRelationInfo = hollowGlassOutRelationInfoService
                            .getOne(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                                    .eq(HollowGlassOutRelationInfo::getCell, cell)
                                    .eq(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START)
                            );
                }
            }
        }
@@ -1064,6 +1073,7 @@
            s7DataZKDLPTwo = new S7DataZKDLPTwo();
            s7DataZKDLPTwo.setMesReply(1);
            s7SerializerZKDLPTwo.write(s7DataZKDLPTwo);
            lastTimeLine = targetSlot;
        } catch (Exception e) {
            e.printStackTrace();
        }