自动化立体仓库 - WCS系统
Junjie
2023-05-23 75b207b2b53a89286dfb1515d47da25c3415fc9b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package com.zy.asrs.utils;
 
import com.alibaba.fastjson.JSON;
import com.core.common.SpringUtils;
import com.zy.asrs.entity.CommandInfo;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.service.CommandInfoService;
import com.zy.asrs.service.WrkMastService;
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.protocol.StaProtocol;
 
import java.util.Date;
import java.util.List;
 
public class CommandUtils {
 
    public static void offer(SlaveType type, Integer id, Task task) {
        CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class);
        if (commandInfoService == null) {
            return;
        }
        WrkMastService wrkMastService = SpringUtils.getBean(WrkMastService.class);
        if (wrkMastService == null) {
            return;
        }
 
        CommandInfo commandInfo = null;
        WrkMast wrkMast = null;
        int taskNo = 0;
        switch (type) {
            case Crn:
                CrnCommand command = (CrnCommand) task.getData();
                taskNo = command.getTaskNo();
                wrkMast = wrkMastService.selectById(taskNo);
 
                commandInfo = new CommandInfo();
                commandInfo.setWrkNo(taskNo);
                commandInfo.setWmsWrkNo(wrkMast.getWmsWrkNo());
                commandInfo.setCommandStatus(1);
                commandInfo.setStartTime(new Date());
                commandInfo.setDevice("crn");
                commandInfo.setCommand(JSON.toJSONString(command));
                commandInfoService.insert(commandInfo);
 
                command.setCommandInfo(commandInfo);
                break;
            case Devp:
                StaProtocol staProtocol = (StaProtocol) task.getData();
                taskNo = staProtocol.getWorkNo();
                wrkMast = wrkMastService.selectById(taskNo);
 
                commandInfo = new CommandInfo();
                commandInfo.setWrkNo(taskNo);
                commandInfo.setWmsWrkNo(wrkMast.getWmsWrkNo());
                commandInfo.setCommandStatus(1);
                commandInfo.setStartTime(new Date());
                commandInfo.setDevice("devp");
                commandInfo.setCommand(JSON.toJSONString(staProtocol));
                commandInfoService.insert(commandInfo);
 
                staProtocol.setCommandInfo(commandInfo);
                break;
            case Led:
                List<LedCommand> data = (List<LedCommand>) task.getData();
                for (LedCommand ledCommand : data) {
                    taskNo = ledCommand.getWorkNo();
                    wrkMast = wrkMastService.selectById(taskNo);
 
                    commandInfo = new CommandInfo();
                    commandInfo.setWrkNo(ledCommand.getWorkNo());
                    commandInfo.setWmsWrkNo(wrkMast.getWmsWrkNo());
                    commandInfo.setCommandStatus(1);
                    commandInfo.setStartTime(new Date());
                    commandInfo.setDevice("led");
                    commandInfo.setCommand(JSON.toJSONString(ledCommand));
                    commandInfoService.insert(commandInfo);
 
                    ledCommand.setCommandInfo(commandInfo);
                }
                break;
        }
 
    }
 
}