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 LoadVehicleInteraction implements DeviceInteraction { @Override public String getDeviceType() { return DeviceConfig.DeviceType.LOAD_VEHICLE; } @Override public InteractionResult execute(InteractionContext context) { List glassIds = context.getParameters().getGlassIds(); if (CollectionUtils.isEmpty(glassIds)) { return InteractionResult.waitResult("未提供玻璃ID,等待输入", null); } List copied = new ArrayList<>(glassIds); context.setLoadedGlassIds(copied); context.getSharedData().put("glassesFromVehicle", copied); Map data = new HashMap<>(); data.put("loaded", copied); data.put("glassCount", copied.size()); return InteractionResult.success(data); } }