#
Junjie
2 天以前 2d2fd991826837d7189cc488aee6f309a6f5e216
src/main/java/com/zy/asrs/utils/NotifyUtils.java
@@ -1,6 +1,6 @@
package com.zy.asrs.utils;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.core.common.SnowflakeIdWorker;
import com.zy.asrs.domain.NotifyDto;
import com.zy.asrs.domain.enums.NotifyMsgType;
@@ -13,6 +13,7 @@
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
@@ -40,7 +41,7 @@
            return null;
        }
        Set keys = redisUtil.keys(key + "*");
        Set keys = redisUtil.keys(key + "_*");
        if (keys == null) {
            return null;
        }
@@ -52,28 +53,57 @@
        return list;
    }
    public String getKey(String notifyType, Integer device) {
        String key = null;
    public List<String> getSupportedNotifyTypes() {
        return Arrays.asList(
                String.valueOf(SlaveType.Crn),
                String.valueOf(SlaveType.Devp),
                String.valueOf(SlaveType.DualCrn),
                String.valueOf(SlaveType.Rgv),
                "task"
        );
    }
    public String getKeyPrefix(String notifyType) {
        if (notifyType.equals(String.valueOf(SlaveType.Crn))) {
            key = RedisKeyType.QUEUE_CRN.key + device;
            return RedisKeyType.QUEUE_CRN.key;
        } else if (notifyType.equals(String.valueOf(SlaveType.Devp))) {
            key = RedisKeyType.QUEUE_DEVP.key + device;
            return RedisKeyType.QUEUE_DEVP.key;
        } else if (notifyType.equals(String.valueOf(SlaveType.DualCrn))) {
            key = RedisKeyType.QUEUE_DUAL_CRN.key + device;
            return RedisKeyType.QUEUE_DUAL_CRN.key;
        } else if (notifyType.equals(String.valueOf(SlaveType.Rgv))) {
            key = RedisKeyType.QUEUE_RGV.key + device;
            return RedisKeyType.QUEUE_RGV.key;
        } else if (notifyType.equals("task")) {
            key = RedisKeyType.QUEUE_TASK.key + device;
        } else {
            return RedisKeyType.QUEUE_TASK.key;
        }
        return null;
    }
    public String getNotifyTypeDesc(String notifyType) {
        if (notifyType.equals(String.valueOf(SlaveType.Crn))) {
            return "堆垛机";
        } else if (notifyType.equals(String.valueOf(SlaveType.Devp))) {
            return "输送线";
        } else if (notifyType.equals(String.valueOf(SlaveType.DualCrn))) {
            return "双伸位堆垛机";
        } else if (notifyType.equals(String.valueOf(SlaveType.Rgv))) {
            return "RGV";
        } else if (notifyType.equals("task")) {
            return "任务";
        }
        return notifyType;
    }
    public String getKey(String notifyType, Integer device) {
        String prefix = getKeyPrefix(notifyType);
        if (prefix == null) {
            return null;
        }
        return key;
        return prefix + device;
    }
    private boolean append(String notifyType, Integer device, String taskNo, String superTaskNo, NotifyMsgType msgType, String data) {
        boolean notifyEnable = true;
        Config notifyEnableConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "notifyEnable"));
        Config notifyEnableConfig = configService.getOne(new QueryWrapper<Config>().eq("code", "notifyEnable"));
        if (notifyEnableConfig != null) {
            notifyEnable = notifyEnableConfig.getValue().equals("Y");
        }
@@ -98,13 +128,13 @@
        dto.setSuperTaskNo(superTaskNo);
        //重试次数
        Config notifyFailTimesConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "notifyFailTimes"));
        Config notifyFailTimesConfig = configService.getOne(new QueryWrapper<Config>().eq("code", "notifyFailTimes"));
        if (notifyFailTimesConfig != null) {
            dto.setFailTimes(Integer.parseInt(notifyFailTimesConfig.getValue()));
        }
        //重试间隔
        Config notifyRetryTimeConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "notifyRetryTime"));
        Config notifyRetryTimeConfig = configService.getOne(new QueryWrapper<Config>().eq("code", "notifyRetryTime"));
        if (notifyRetryTimeConfig != null) {
            dto.setRetryTime(Integer.parseInt(notifyRetryTimeConfig.getValue()));
        }