#
zwl
19 小时以前 2ae8d909b139ffecdad54e6d56d4576e38a79ebf
#
3个文件已修改
87 ■■■■ 已修改文件
src/main/java/com/zy/common/service/CommonService.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/enums/RedisKeyType.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/plugin/NormalProcess.java 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/CommonService.java
@@ -1,5 +1,6 @@
package com.zy.common.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.exception.CoolException;
@@ -12,21 +13,17 @@
import com.zy.common.utils.NavigateUtils;
import com.zy.common.utils.RedisUtil;
import com.zy.core.News;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.*;
import com.zy.core.model.StationObjModel;
import com.zy.core.model.Task;
import com.zy.core.model.command.StationCommand;
import com.zy.core.model.protocol.StationProtocol;
import com.zy.core.thread.StationThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.*;
@Slf4j
@Service
@@ -271,7 +268,16 @@
        StationCommand command = stationThread.getCommand(StationCommandType.WRITE_INFO,
                wrkMast.getWrkNo(), Integer.valueOf(param.getSourceStaNo()), Integer.valueOf(param.getSourceStaNo()), 0);
        MessageQueue.offer(SlaveType.Devp, 1, new Task(2, command));
        Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
        StationProtocol stationProtocol = statusMap.get(command.getStationId());
        JSONObject data = new JSONObject();
        data.put("oldTaskNo", wrkMast.getWrkNo());
        data.put("newTaskNo", stationProtocol.getTaskNo());
        data.put("command", command);
        data.put("stationId", command.getStationId());
        data.put("deviceNo", 1);
        redisUtil.set(RedisKeyType.RECEIVE_IN_TASK_CHANGE_STATION_TASK.key + command.getStationId(), JSONObject.toJSONString(data), 60 * 5);
        if (findCrnResult.getCrnType().equals(SlaveType.Crn)) {
            wrkMast.setCrnNo(findCrnResult.getCrnNo());
src/main/java/com/zy/core/enums/RedisKeyType.java
@@ -57,6 +57,9 @@
    AI_CHAT_META("ai_chat_meta_"),
    MAIN_PROCESS_PSEUDOCODE("main_process_pseudocode"),
    PLANNER_SCHEDULE("planner_schedule_"),
    RECEIVE_IN_TASK_CHANGE_STATION_TASK("receive_in_task_change_station_task_"),
    RECEIVE_IN_TASK_CHANGE_STATION_TASK_SEND_LIMIT("receive_in_task_change_station_task_send_limit_"),
    ;
    public String key;
src/main/java/com/zy/core/plugin/NormalProcess.java
@@ -34,10 +34,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@Slf4j
@Component
@@ -85,6 +82,8 @@
        //上报堆垛机DB110状态数据
        reportDb110();
        //跨区入库任务下发,修改站点任务号为入库任务号
        taskToNewAreaInTaskStationSend();
    }
    /**
@@ -317,4 +316,61 @@
        }
    }
    //跨区入库任务下发,修改站点任务号为入库任务号
    public synchronized void taskToNewAreaInTaskStationSend() {
        Set<String> list = redisUtil.searchKeys(RedisKeyType.RECEIVE_IN_TASK_CHANGE_STATION_TASK.key);
        for (String key : list) {
            Object dataStr = redisUtil.get(key);
            if (dataStr == null) {
                continue;
            }
            JSONObject data = JSON.parseObject(dataStr.toString());
            Integer oldTaskNo = data.getInteger("oldTaskNo");
            Integer newTaskNo = data.getInteger("newTaskNo");
            StationCommand command = data.getObject("command", StationCommand.class);
            Integer stationId = data.getInteger("stationId");
            Integer deviceNo = data.getInteger("deviceNo");
            Object lock = redisUtil.get(RedisKeyType.RECEIVE_IN_TASK_CHANGE_STATION_TASK_SEND_LIMIT.key + stationId);
            if(lock != null){
                continue;
            }
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, deviceNo);
            if(stationThread == null){
                continue;
            }
            Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
            StationProtocol stationProtocol = statusMap.get(stationId);
            if(stationProtocol == null){
                continue;
            }
            if (!stationProtocol.isAutoing()) {
                continue;
            }
            if (!stationProtocol.isLoading()) {
                continue;
            }
            if (stationProtocol.getTaskNo() == 0) {
                continue;
            }
            if (!stationProtocol.getTaskNo().equals(oldTaskNo)) {
                //和缓存命令不相同删除
                redisUtil.del(key);
                continue;
            }
            //缓存命令相同,下发命令改变入库任务号信息
            MessageQueue.offer(SlaveType.Devp, deviceNo, new Task(2, command));
            redisUtil.set(RedisKeyType.RECEIVE_IN_TASK_CHANGE_STATION_TASK_SEND_LIMIT.key + stationId, "lock", 5);
        }
    }
}