| | |
| | | import com.mes.interaction.workstation.config.WorkstationLogicConfig; |
| | | import com.mes.plc.client.PlcClient; |
| | | import com.mes.plc.factory.PlcClientFactory; |
| | | import com.mes.task.model.TaskExecutionContext; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | |
| | | Map<String, Object> logicParams, |
| | | Map<String, Object> params) { |
| | | |
| | | String deviceId = deviceConfig.getDeviceId(); |
| | | String deviceId = String.valueOf(deviceConfig.getId()); |
| | | PlcClient plcClient = getPlcClient(deviceConfig); |
| | | if (plcClient == null) { |
| | | return buildResult(deviceConfig, "checkAndProcess", false, |
| | |
| | | try { |
| | | if (params != null) { |
| | | Object ctxObj = params.get("_taskContext"); |
| | | if (ctxObj instanceof com.mes.task.model.TaskExecutionContext) { |
| | | com.mes.task.model.TaskExecutionContext ctx = |
| | | (com.mes.task.model.TaskExecutionContext) ctxObj; |
| | | if (ctxObj instanceof TaskExecutionContext) { |
| | | TaskExecutionContext ctx = (TaskExecutionContext) ctxObj; |
| | | List<String> batchGlassIds = batch.stream() |
| | | .map(GlassInfo::getGlassId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | if (!batchGlassIds.isEmpty()) { |
| | | ctx.getSharedData().put("transferReadyGlassIds", |
| | | new java.util.ArrayList<>(batchGlassIds)); |
| | | new ArrayList<>(batchGlassIds)); |
| | | log.info("卧转立已输出批次玻璃到任务上下文: deviceId={}, glassIds={}", |
| | | deviceConfig.getId(), batchGlassIds); |
| | | } |
| | |
| | | WorkstationLogicConfig config, |
| | | Map<String, Object> logicParams) { |
| | | |
| | | String deviceId = deviceConfig.getDeviceId(); |
| | | String deviceId = String.valueOf(deviceConfig.getId()); |
| | | |
| | | // 停止旧的监控任务 |
| | | handleStopMonitor(deviceConfig); |
| | |
| | | * 停止监控任务 |
| | | */ |
| | | private DevicePlcVO.OperationResult handleStopMonitor(DeviceConfig deviceConfig) { |
| | | String deviceId = deviceConfig.getDeviceId(); |
| | | String deviceId = String.valueOf(deviceConfig.getId()); |
| | | ScheduledFuture<?> future = monitorTasks.remove(deviceId); |
| | | if (future != null && !future.isCancelled()) { |
| | | future.cancel(false); |
| | |
| | | * 清空缓冲队列 |
| | | */ |
| | | private DevicePlcVO.OperationResult handleClearBuffer(DeviceConfig deviceConfig) { |
| | | String deviceId = deviceConfig.getDeviceId(); |
| | | String deviceId = String.valueOf(deviceConfig.getId()); |
| | | glassBuffer.remove(deviceId); |
| | | lastScanTime.remove(deviceId); |
| | | log.info("已清空缓冲队列: deviceId={}", deviceId); |