自动化立体仓库 - WCS系统
#
Junjie
2025-01-08 97821c4acc241cd65fd4ae890a44201df065c590
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
package com.zy.common.utils;
 
import com.core.common.SpringUtils;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.NavigateNode;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.ForkLiftSlave;
import com.zy.core.model.protocol.ForkLiftStaProtocol;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.ForkLiftThread;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * 货叉提升机工具类
 */
public class ForkLiftUtils {
 
    //获取提升机站点
    public static ForkLiftStaProtocol getLiftStaByStaNo(Integer staNo) {
        SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class);
        for (ForkLiftSlave liftSlave : slaveProperties.getForkLift()) {
            ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftSlave.getId());
            if (forkLiftThread == null) {
                return null;
            }
 
            for (ForkLiftStaProtocol forkLiftStaProtocol : forkLiftThread.getForkLiftStaProtocols()) {
                if (forkLiftStaProtocol.getStaNo().equals(staNo)) {
                    return forkLiftStaProtocol;
                }
            }
        }
 
        return null;
    }
 
 
    //获取提升机站点
    public static ForkLiftStaProtocol getLiftStaByLev(Integer liftNo, Integer lev) {
        ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo);
        if (forkLiftThread == null) {
            return null;
        }
 
        for (ForkLiftStaProtocol forkLiftStaProtocol : forkLiftThread.getForkLiftStaProtocols()) {
            if (forkLiftStaProtocol.getLev().equals(lev)) {
                return forkLiftStaProtocol;
            }
        }
 
        return null;
    }
 
    //获取提升机输送站及其前一站节点
    public static List<NavigateNode> getLiftStaNodes(Integer staNo) {
        List<NavigateNode> targetNodes = new ArrayList<>();
        //获取目标站
        ForkLiftStaProtocol targetLiftSta = ForkLiftUtils.getLiftStaByStaNo(staNo);
        if (targetLiftSta == null) {
            return null;//找不到站点
        }
        NavigateNode targetNode = NavigatePositionConvert.locNoToNode(targetLiftSta.getLocNo());//目标节点
        String targetLastLocNo = Utils.getLocNo(Utils.getRow(targetLiftSta.getLocNo()) - 1, Utils.getBay(targetLiftSta.getLocNo()), Utils.getLev(targetLiftSta.getLocNo()));//目标节点前一站
        NavigateNode targetLastNode = NavigatePositionConvert.locNoToNode(targetLastLocNo);//目标节点前一站
        targetNodes.add(targetNode);
        targetNodes.add(targetLastNode);
 
        return targetNodes;
    }
 
}