自动化立体仓库 - WCS系统
#
lsh
2024-03-22 84988579b77ec4578af30d5c836690beeff3562c
src/main/java/com/zy/asrs/utils/CommandUtils.java
@@ -7,6 +7,8 @@
import com.zy.asrs.service.CommandInfoService;
import com.zy.asrs.service.TaskWrkService;
import com.zy.core.cache.MessageQueue;
import com.zy.core.enums.CommandStatusType;
import com.zy.core.enums.CommandType;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.Task;
import com.zy.core.model.command.CrnCommand;
@@ -18,6 +20,10 @@
public class CommandUtils {
    public static boolean offer(SlaveType type, Integer id, Task task) {
        return offer(type, id, task, true);
    }
    public static boolean offer(SlaveType type, Integer id, Task task, Boolean auto) {
        CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class);
        if (commandInfoService == null) {
            return false;
@@ -36,7 +42,7 @@
            CommandPackage<CrnCommand> commandPackage = new CommandPackage<>();
            CrnCommand command = (CrnCommand) task.getData();
            wrkNo = command.getTaskNo();
            if (wrkNo != 0) {
            if (auto && wrkNo != 0) {
                taskWrk = taskWrkService.selectByWrkNo(wrkNo);
                taskNo = taskWrk.getTaskNo();
            }
@@ -44,9 +50,10 @@
            commandInfo = new CommandInfo();
            commandInfo.setWrkNo(wrkNo);
            commandInfo.setTaskNo(taskNo);
            commandInfo.setCommandStatus(1);
            commandInfo.setCommandStatus(CommandStatusType.CREATE.id);
            commandInfo.setStartTime(new Date());
            commandInfo.setDevice(SlaveType.Crn.toString());
            commandInfo.setCommandType(auto? CommandType.AUTO.id : CommandType.MANUAL.id);
            commandInfoService.insert(commandInfo);//插入指令
@@ -57,16 +64,18 @@
            commandInfo.setCommand(JSON.toJSONString(commandPackage));
            commandInfoService.updateById(commandInfo);
            //将指令进行投递
            if (!MessageQueue.offer(type, id, task)) {
                return false;
            if (!auto) {
                //将指令进行投递
                if (!MessageQueue.offer(type, id, task)) {
                    return false;
                }
            }
            return true;
        } else if (type == SlaveType.Devp) {
            CommandPackage<StaProtocol> commandPackage = new CommandPackage<>();
            StaProtocol staProtocol = (StaProtocol) task.getData();
            wrkNo = staProtocol.getWorkNo();
            if (wrkNo != 0) {
            if (auto && wrkNo != 0) {
                taskWrk = taskWrkService.selectByWrkNo(wrkNo);
                taskNo = taskWrk.getTaskNo();
            }
@@ -74,9 +83,10 @@
            commandInfo = new CommandInfo();
            commandInfo.setWrkNo(wrkNo);
            commandInfo.setTaskNo(taskNo);
            commandInfo.setCommandStatus(1);
            commandInfo.setCommandStatus(CommandStatusType.CREATE.id);
            commandInfo.setStartTime(new Date());
            commandInfo.setDevice(SlaveType.Devp.toString());
            commandInfo.setCommandType(auto? CommandType.AUTO.id : CommandType.MANUAL.id);
            commandInfoService.insert(commandInfo);//插入指令
@@ -87,9 +97,11 @@
            commandInfo.setCommand(JSON.toJSONString(commandPackage));//保存命令报文
            commandInfoService.updateById(commandInfo);
            //将指令进行投递
            if (!MessageQueue.offer(type, id, task)) {
                return false;
            if (!auto) {
                //将指令进行投递
                if (!MessageQueue.offer(type, id, task)) {
                    return false;
                }
            }
            return true;
        }