自动化立体仓库 - WCS系统
#
Junjie
2023-08-08 8ee999ed31c9c45b3acefdcdda51e97f236ee9c5
src/main/java/com/zy/asrs/utils/CommandUtils.java
@@ -6,14 +6,15 @@
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.service.CommandInfoService;
import com.zy.asrs.service.WrkMastService;
import com.zy.common.utils.RedisUtil;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.Task;
import com.zy.core.model.command.CrnCommand;
import com.zy.core.model.command.LedCommand;
import com.zy.core.model.command.RedisCommand;
import com.zy.core.model.protocol.StaProtocol;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class CommandUtils {
@@ -26,13 +27,20 @@
        if (wrkMastService == null) {
            return;
        }
        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
        if (redisUtil == null) {
            return;
        }
        CommandInfo commandInfo = null;
        WrkMast wrkMast = null;
        int wrkNo = 0;
        String taskNo = null;
        switch (type) {
            case Crn:
        if (type == SlaveType.Crn) {
            RedisCommand<CrnCommand> redisCommand = new RedisCommand();
            ArrayList<CrnCommand> commands = new ArrayList<>();
                CrnCommand command = (CrnCommand) task.getData();
                wrkNo = command.getTaskNo();
                if (wrkNo != 0) {
@@ -48,10 +56,15 @@
                commandInfo.setDevice("crn");
                commandInfo.setCommand(JSON.toJSONString(command));
                commandInfoService.insert(commandInfo);
                command.setCommandInfo(commandInfo);
                break;
            case Devp:
            commands.add(command);
            redisCommand.setWrkNo(wrkNo);
            redisCommand.setCommands(commands);
        } else if (type == SlaveType.Devp) {
            RedisCommand<StaProtocol> redisCommand = new RedisCommand();
            ArrayList<StaProtocol> commands = new ArrayList<>();
                StaProtocol staProtocol = (StaProtocol) task.getData();
                wrkNo = staProtocol.getWorkNo();
                if (wrkNo != 0) {
@@ -69,28 +82,10 @@
                commandInfoService.insert(commandInfo);
                staProtocol.setCommandInfo(commandInfo);
                break;
            case Led:
                List<LedCommand> data = (List<LedCommand>) task.getData();
                for (LedCommand ledCommand : data) {
                    wrkNo = ledCommand.getWorkNo();
                    if (wrkNo != 0) {
                        wrkMast = wrkMastService.selectById(wrkNo);
                        taskNo = wrkMast.getTaskNo();
                    }
                    commandInfo = new CommandInfo();
                    commandInfo.setWrkNo(ledCommand.getWorkNo());
                    commandInfo.setTaskNo(taskNo);
                    commandInfo.setCommandStatus(1);
                    commandInfo.setStartTime(new Date());
                    commandInfo.setDevice("led");
                    commandInfo.setCommand(JSON.toJSONString(ledCommand));
                    commandInfoService.insert(commandInfo);
                    ledCommand.setCommandInfo(commandInfo);
                }
                break;
            commands.add(staProtocol);
            redisCommand.setWrkNo(wrkNo);
            redisCommand.setCommands(commands);
        }
    }