huang
2025-11-18 1566e4c7604d85737ea67fe6757e71b8185fa48e
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
package com.mes.interaction.flow;
 
import com.mes.device.entity.DeviceConfig;
import com.mes.interaction.DeviceInteraction;
import com.mes.interaction.base.InteractionContext;
import com.mes.interaction.base.InteractionResult;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * 大理片交互实现
 */
@Component
public class LargeGlassInteraction implements DeviceInteraction {
 
    @Override
    public String getDeviceType() {
        return DeviceConfig.DeviceType.LARGE_GLASS;
    }
 
    @Override
    public InteractionResult execute(InteractionContext context) {
        Object source = context.getSharedData().get("glassesFromVehicle");
        List<String> glassQueue = castList(source);
        if (CollectionUtils.isEmpty(glassQueue)) {
            return InteractionResult.waitResult("等待上大车输出", null);
        }
 
        List<String> processed = new ArrayList<>(glassQueue);
        context.setProcessedGlassIds(processed);
        context.getSharedData().put("processedGlasses", processed);
 
        Map<String, Object> data = new HashMap<>();
        data.put("processedCount", processed.size());
        data.put("processedGlasses", processed);
        return InteractionResult.success(data);
    }
 
    @SuppressWarnings("unchecked")
    private List<String> castList(Object value) {
        if (value instanceof List) {
            return (List<String>) value;
        }
        return null;
    }
}