#ZH
野心家
2025-05-27 1b9f41e12e3ee8ac8bbc388eab7585300bdab75a
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
package com.zy.core.cache;
 
import com.core.common.Cools;
import com.zy.core.model.protocol.RgvRunProtocol;
import com.zy.core.model.protocol.RgvTaskProtocol;
 
import java.util.concurrent.ConcurrentHashMap;
 
/**
 * Created by IX on 2025/02/21
 */
public class RgvRunCache {
    // 本地缓存,键为 currentPosition,值为 DeviceStatus
    private static final ConcurrentHashMap<String, RgvRunProtocol> cache = new ConcurrentHashMap<>();
 
    /**
     * 更新设备状态
     */
    public static void updateRgvStatus(RgvRunProtocol status) {
        try {
            cache.put(status.getDev(), status);
        } finally {
        }
    }
 
    /**
     * 获取设备状态
     */
    public static RgvRunProtocol getRgvRun() {
        try {
            RgvRunProtocol rgv = cache.get("RGV");
            if (Cools.isEmpty(rgv)){
                rgv = new RgvRunProtocol();
            }
            return rgv;
        } finally {
        }
    }
 
    /**
     * 获取设备状态
     */
    public static RgvRunProtocol getRgvStatus(String dev) {
        try {
            return cache.get(dev);
        } finally {
        }
    }
 
    /**
     * 获取所有设备状态
     */
    public static ConcurrentHashMap<String, RgvRunProtocol> getAllRgvStatus() {
        try {
            return new ConcurrentHashMap<>(cache); // 返回副本
        } finally {
        }
    }
 
}