#
Administrator
1 天以前 a03b6ca1541d4351017bdfaf51de03f9fd3d655c
src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
@@ -61,7 +61,7 @@
    @Autowired
    private MainProcessTaskSubmitter mainProcessTaskSubmitter;
    public synchronized void crnIoExecute() {
    public void crnIoExecute() {
        Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
        if (systemConfigMapObj != null) {
            HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj;
@@ -91,7 +91,7 @@
    }
    //入出库  ===>>  堆垛机入出库作业下发
    public synchronized void crnIoExecuteNormal() {
    public void crnIoExecuteNormal() {
        List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>());
        for (BasCrnp basCrnp : basCrnps) {
            crnIoExecuteNormal(basCrnp);
@@ -173,7 +173,7 @@
        }
    }
    private synchronized boolean crnExecuteIn(BasCrnp basCrnp, CrnThread crnThread) {
    private boolean crnExecuteIn(BasCrnp basCrnp, CrnThread crnThread) {
        CrnProtocol crnProtocol = crnThread.getStatus();
        if(crnProtocol == null){
            return false;
@@ -218,6 +218,12 @@
            if (!stationProtocol.isInEnable()) {
                News.taskInfo(stationProtocol.getTaskNo(), "取货站点:{} 没有可入信号", stationObjModel.getStationId());
                logTraceLimited("crn_in_wait_signal_" + crnNo + "_" + stationObjModel.getStationId(), 3,
                        "[WCS Trace][堆垛机入库] 取货站点不可入。crnNo={},stationId={},stationTaskNo={},autoing={},loading={},inEnable={},outEnable={},runBlock={},barcode={},targetStaNo={},crnStatus={},crnTaskNo={},crnAlarm={}",
                        crnNo, stationObjModel.getStationId(), stationProtocol.getTaskNo(),
                        stationProtocol.isAutoing(), stationProtocol.isLoading(), stationProtocol.isInEnable(),
                        stationProtocol.isOutEnable(), stationProtocol.isRunBlock(), stationProtocol.getBarcode(),
                        stationProtocol.getTargetStaNo(), crnProtocol.getStatus(), crnProtocol.getTaskNo(), crnProtocol.getAlarm());
                continue;
            }
@@ -254,6 +260,10 @@
            String sourceLocNo = Utils.getLocNo(stationObjModel.getDeviceRow(), stationObjModel.getDeviceBay(), stationObjModel.getDeviceLev());
            CrnCommand command = crnThread.getPickAndPutCommand(sourceLocNo, wrkMast.getLocNo(), wrkMast.getWrkNo(), crnNo);
            logTraceLimited("crn_in_dispatch_" + wrkMast.getWrkNo(), 3,
                    "[WCS Trace][堆垛机入库] 准备下发堆垛机入库命令。crnNo={},wrkNo={},sourceStationId={},sourceLocNo={},targetLocNo={},stationTaskNo={},crnStatus={},crnTaskNo={},crnAlarm={}",
                    crnNo, wrkMast.getWrkNo(), stationObjModel.getStationId(), sourceLocNo, wrkMast.getLocNo(),
                    stationProtocol.getTaskNo(), crnProtocol.getStatus(), crnProtocol.getTaskNo(), crnProtocol.getAlarm());
            wrkMast.setWrkSts(WrkStsType.INBOUND_RUN.sts);
            wrkMast.setCrnNo(crnNo);
@@ -269,7 +279,7 @@
        return false;
    }
    private synchronized boolean crnExecuteOut(BasCrnp basCrnp, CrnThread crnThread) {
    private boolean crnExecuteOut(BasCrnp basCrnp, CrnThread crnThread) {
        CrnProtocol crnProtocol = crnThread.getStatus();
        if(crnProtocol == null){
            return false;
@@ -336,6 +346,12 @@
                if (!stationProtocol.isOutEnable()) {
                    News.info("放货站点:{} 没有可出信号", stationObjModel.getStationId());
                    logTraceLimited("crn_out_wait_signal_" + crnNo + "_" + stationObjModel.getStationId(), 3,
                            "[WCS Trace][堆垛机出库] 放货站点不可出。crnNo={},stationId={},wrkNo={},autoing={},loading={},inEnable={},outEnable={},runBlock={},stationTaskNo={},targetStaNo={},crnStatus={},crnTaskNo={},crnAlarm={}",
                            crnNo, stationObjModel.getStationId(), wrkMast.getWrkNo(),
                            stationProtocol.isAutoing(), stationProtocol.isLoading(), stationProtocol.isInEnable(),
                            stationProtocol.isOutEnable(), stationProtocol.isRunBlock(), stationProtocol.getTaskNo(),
                            stationProtocol.getTargetStaNo(), crnProtocol.getStatus(), crnProtocol.getTaskNo(), crnProtocol.getAlarm());
                    continue;
                }
@@ -361,6 +377,11 @@
                String targetLocNo = Utils.getLocNo(stationObjModel.getDeviceRow(), stationObjModel.getDeviceBay(), stationObjModel.getDeviceLev());
                CrnCommand command = crnThread.getPickAndPutCommand(wrkMast.getSourceLocNo(), targetLocNo, wrkMast.getWrkNo(), crnNo);
                logTraceLimited("crn_out_dispatch_" + wrkMast.getWrkNo(), 3,
                        "[WCS Trace][堆垛机出库] 准备下发堆垛机出库命令。crnNo={},wrkNo={},targetStationId={},sourceLocNo={},targetLocNo={},crnStatus={},crnTaskNo={},crnAlarm={}",
                        crnNo, wrkMast.getWrkNo(), stationObjModel.getStationId(),
                        wrkMast.getSourceLocNo(), targetLocNo, crnProtocol.getStatus(),
                        crnProtocol.getTaskNo(), crnProtocol.getAlarm());
                wrkMast.setWrkSts(WrkStsType.OUTBOUND_RUN.sts);
                wrkMast.setCrnNo(crnNo);
@@ -377,7 +398,7 @@
        return false;
    }
    private synchronized boolean crnExecuteInPlanner(BasCrnp basCrnp, CrnThread crnThread, WrkMast wrkMast) {
    private boolean crnExecuteInPlanner(BasCrnp basCrnp, CrnThread crnThread, WrkMast wrkMast) {
        CrnProtocol crnProtocol = crnThread.getStatus();
        if (crnProtocol == null) {
            return false;
@@ -470,7 +491,7 @@
        return false;
    }
    private synchronized boolean crnExecuteOutPlanner(BasCrnp basCrnp, CrnThread crnThread, WrkMast wrkMast) {
    private boolean crnExecuteOutPlanner(BasCrnp basCrnp, CrnThread crnThread, WrkMast wrkMast) {
        CrnProtocol crnProtocol = crnThread.getStatus();
        if (crnProtocol == null) {
            return false;
@@ -555,7 +576,7 @@
        return false;
    }
    private synchronized boolean crnExecuteLocTransfer(BasCrnp basCrnp, CrnThread crnThread) {
    private boolean crnExecuteLocTransfer(BasCrnp basCrnp, CrnThread crnThread) {
        CrnProtocol crnProtocol = crnThread.getStatus();
        if(crnProtocol == null){
            return false;
@@ -610,7 +631,7 @@
    }
    //堆垛机任务执行完成
    public synchronized void crnIoExecuteFinish() {
    public void crnIoExecuteFinish() {
        List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>());
        for (BasCrnp basCrnp : basCrnps) {
            crnIoExecuteFinish(basCrnp);
@@ -691,7 +712,7 @@
        }
    }
    public synchronized void plannerExecute() {
    public void plannerExecute() {
        List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>());
        for (BasCrnp basCrnp : basCrnps) {
            plannerExecute(basCrnp);
@@ -796,7 +817,7 @@
        }
    }
    private synchronized boolean crnExecuteMovePlanner(BasCrnp basCrnp, CrnThread crnThread, WrkMast wrkMast) {
    private boolean crnExecuteMovePlanner(BasCrnp basCrnp, CrnThread crnThread, WrkMast wrkMast) {
        CrnProtocol crnProtocol = crnThread.getStatus();
        if (crnProtocol == null) {
            return false;
@@ -852,6 +873,15 @@
    }
    public void submitCrnIoTasks(MainProcessLane lane, long minIntervalMs) {
        mainProcessTaskSubmitter.submitSerialTask(
                MainProcessLane.CRN_SCAN,
                "submitCrnIoTasks",
                minIntervalMs,
                () -> submitCrnIoTasksInternal(lane, minIntervalMs)
        );
    }
    private void submitCrnIoTasksInternal(MainProcessLane lane, long minIntervalMs) {
        List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>());
        for (BasCrnp basCrnp : basCrnps) {
            if (basCrnp == null || basCrnp.getCrnNo() == null) {
@@ -873,6 +903,15 @@
    }
    public void submitCrnIoExecuteFinishTasks(MainProcessLane lane, long minIntervalMs) {
        mainProcessTaskSubmitter.submitSerialTask(
                MainProcessLane.CRN_SCAN,
                "submitCrnIoExecuteFinishTasks",
                minIntervalMs,
                () -> submitCrnIoExecuteFinishTasksInternal(lane, minIntervalMs)
        );
    }
    private void submitCrnIoExecuteFinishTasksInternal(MainProcessLane lane, long minIntervalMs) {
        List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>());
        for (BasCrnp basCrnp : basCrnps) {
            if (basCrnp == null || basCrnp.getCrnNo() == null) {
@@ -889,8 +928,22 @@
        }
    }
    private void logTraceLimited(String lockKey, int seconds, String format, Object... arguments) {
        String redisKey = RedisKeyType.LOG_LIMIT.key + "wcs_trace_" + lockKey;
        try {
            Object lock = redisUtil.get(redisKey);
            if (lock != null) {
                return;
            }
            redisUtil.set(redisKey, "lock", seconds);
        } catch (Exception e) {
            // 诊断日志不能影响主流程。
        }
        News.info(format, arguments);
    }
    //检测浅库位状态
    public synchronized boolean checkShallowLocStatus(String locNo, Integer taskNo) {
    public boolean checkShallowLocStatus(String locNo, Integer taskNo) {
        String checkDeepLocOutTaskBlockReport = "Y";
        Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
        if (systemConfigMapObj != null) {