#
Junjie
2025-02-11 ed265ddfb8f08f69af064a9adf65fcbf06289ffe
#
6个文件已修改
95 ■■■■ 已修改文件
src/main/java/com/zy/asrs/domain/NotifyDto.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/domain/enums/NotifyMsgType.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/task/WrkMastScheduler.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/utils/NotifyUtils.java 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/CommonService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/enums/RedisKeyType.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/domain/NotifyDto.java
@@ -7,8 +7,8 @@
    private Long id;
    //设备类型
    private String deviceType;
    //通知类型
    private String notifyType;
    //设备号
    private Integer device;
@@ -19,8 +19,11 @@
    //消息类型
    private String msgType;
    //消息内容
    private String content;
    //消息描述
    private String msgDesc;
    //消息数据
    private String data;
    //失败重试次数
    private Integer failTimes = 3;
src/main/java/com/zy/asrs/domain/enums/NotifyMsgType.java
@@ -11,6 +11,11 @@
    SHUTTLE_POWER_COMPLETE("shuttle_power_complete", "小车充电完成"),
    SHUTTLE_ERROR("shuttle_error", "小车异常"),
    FORK_LIFT_ERROR("fork_lift_error", "货叉提升机异常"),
    //任务
    TASK_COMPLETE("task_complete", "任务完成"),
    TASK_CHARGE_COMPLETE("task_charge_complete", "充电任务完成"),
    TASK_CANCEL("task_cancel", "任务取消"),
    ;
    public String flag;
src/main/java/com/zy/asrs/task/WrkMastScheduler.java
@@ -1,12 +1,20 @@
package com.zy.asrs.task;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.asrs.domain.enums.NotifyMsgType;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.service.WrkMastLogService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.NotifyUtils;
import com.zy.common.utils.HttpHandler;
import com.zy.core.enums.SlaveType;
import com.zy.core.enums.WrkStsType;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
@@ -27,6 +35,8 @@
    private WrkMastLogService wrkMastLogService;
    @Autowired
    private LocMastService locMastService;
    @Autowired
    private NotifyUtils notifyUtils;
    @Scheduled(cron = "0/1 * * * * ? ")
    @Transactional
@@ -65,6 +75,9 @@
            if (!wrkMastService.deleteById(wrkMast)) {
                log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo());
            }
            //上报
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
        }
    }
@@ -105,6 +118,9 @@
            if (!wrkMastService.deleteById(wrkMast)) {
                log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo());
            }
            //上报
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
        }
    }
@@ -165,6 +181,9 @@
            if (!wrkMastService.deleteById(wrkMast)) {
                log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo());
            }
            //上报
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
        }
    }
@@ -205,6 +224,32 @@
            if (!wrkMastService.deleteById(wrkMast)) {
                log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo());
            }
            //上报
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_CHARGE_COMPLETE, JSON.toJSONString(wrkMast));
        }
    }
    @Scheduled(cron = "0/1 * * * * ? ")
    @Transactional
    public void executeCancelTask(){
        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("mk", "taskCancel"));
        if (wrkMasts.isEmpty()) {
            return;
        }
        for (WrkMast wrkMast : wrkMasts) {
            // 保存工作主档历史档
            if (!wrkMastLogService.save(wrkMast.getWrkNo())) {
                log.info("保存工作历史档[workNo={}]失败", wrkMast.getWrkNo());
            }
            // 删除工作主档
            if (!wrkMastService.deleteById(wrkMast)) {
                log.info("删除工作主档[workNo={}]失败", wrkMast.getWrkNo());
            }
            //上报
            notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), NotifyMsgType.TASK_CANCEL, JSON.toJSONString(wrkMast));
        }
    }
src/main/java/com/zy/asrs/utils/NotifyUtils.java
@@ -27,12 +27,12 @@
    @Autowired
    private ConfigService configService;
    public synchronized boolean notify(String deviceType, Integer device, String taskNo, NotifyMsgType msgType) {
        SlaveType type = SlaveType.findInstance(deviceType);
        if (type == null) {
            return false;
    public synchronized boolean notify(String notifyType, Integer device, String taskNo, NotifyMsgType msgType) {
        return append(notifyType, device, taskNo, msgType, null);
        }
        return append(type, device, taskNo, msgType);
    public synchronized boolean notify(String notifyType, Integer device, String taskNo, NotifyMsgType msgType, String data) {
        return append(notifyType, device, taskNo, msgType, data);
    }
    public synchronized List<String> takeKeys(String deviceType, Integer device) {
@@ -73,25 +73,25 @@
        return key;
    }
    private boolean append(SlaveType deviceType, Integer device, String taskNo, NotifyMsgType msgType) {
    private boolean append(String notifyType, Integer device, String taskNo, NotifyMsgType msgType, String data) {
        String key = null;
        switch (deviceType) {
            case Shuttle:
        if (notifyType.equals(String.valueOf(SlaveType.Shuttle))) {
                key = RedisKeyType.QUEUE_SHUTTLE.key + device;
                break;
            case ForkLift:
        } else if (notifyType.equals(String.valueOf(SlaveType.ForkLift))) {
                key = RedisKeyType.QUEUE_FORK_LIFT.key + device;
                break;
            default:
        } else if (notifyType.equals("task")) {
            key = RedisKeyType.QUEUE_FORK_LIFT.key + device;
        } else {
                return false;
        }
        NotifyDto dto = new NotifyDto();
        dto.setId(snowflakeIdWorker.nextId());
        dto.setDeviceType(String.valueOf(deviceType));
        dto.setNotifyType(notifyType);
        dto.setDevice(device);
        dto.setMsgType(msgType.flag);
        dto.setContent(msgType.desc);
        dto.setMsgDesc(msgType.desc);
        dto.setData(data);
        dto.setTaskNo(taskNo);
        //重试次数
src/main/java/com/zy/common/service/CommonService.java
@@ -110,8 +110,9 @@
            throw new CoolException("任务不存在");
        }
        wrkMastLogService.save(wrkNo);
        wrkMastService.deleteById(wrkNo);
        wrkMast.setMk("taskCancel");
        wrkMast.setModiTime(new Date());
        wrkMastService.updateById(wrkMast);
        return true;
    }
src/main/java/com/zy/core/enums/RedisKeyType.java
@@ -10,6 +10,7 @@
    BASIC_MAP("basicMap_"),
    QUEUE_SHUTTLE("queue_shuttle_"),
    QUEUE_FORK_LIFT("queue_fork_lift_"),
    QUEUE_TASK("queue_task_"),
    ;
    public String key;