| | |
| | | // 从配置中获取workLine,用于过滤(配置中是Integer类型) |
| | | Integer workLine = getLogicParam(logicParams, "workLine", null); |
| | | |
| | | // 查询最近2分钟内的玻璃记录(扩大时间窗口,确保不遗漏) |
| | | Date twoMinutesAgo = new Date(System.currentTimeMillis() - 120000); |
| | | |
| | | // 查询state=1的玻璃记录(已扫码交互完成,等待卧转立处理) |
| | | LambdaQueryWrapper<GlassInfo> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.in(GlassInfo::getStatus, GlassInfo.Status.PENDING, GlassInfo.Status.ACTIVE) |
| | | .ge(GlassInfo::getCreatedTime, twoMinutesAgo) |
| | | .eq(GlassInfo::getState, 1) // 只查询state=1的玻璃(已扫码完成) |
| | | .orderByDesc(GlassInfo::getCreatedTime) |
| | | .last("LIMIT 20"); // 限制查询数量,避免过多 |
| | | |
| | |
| | | // 写入玻璃数量 |
| | | payload.put("plcGlassCount", count); |
| | | |
| | | // 写入卧转立编号(优先从任务参数获取,其次从设备配置获取) |
| | | Integer inPosition = null; |
| | | // 写入卧转立编号(优先从任务参数获取,其次从设备配置获取,直接写入编号,不进行位置映射) |
| | | Object inPosition = null; |
| | | if (params != null) { |
| | | try { |
| | | 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; |
| | | Object positionObj = ctx.getParameters().getExtra() != null |
| | | inPosition = ctx.getParameters().getExtra() != null |
| | | ? ctx.getParameters().getExtra().get("inPosition") : null; |
| | | if (positionObj instanceof Number) { |
| | | inPosition = ((Number) positionObj).intValue(); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.debug("从任务参数获取卧转立编号失败: deviceId={}", deviceConfig.getId(), e); |
| | |
| | | inPosition = getLogicParam(logicParams, "inPosition", null); |
| | | } |
| | | if (inPosition != null) { |
| | | // 直接写入编号本身,不进行位置映射转换 |
| | | payload.put("inPosition", inPosition); |
| | | log.info("写入卧转立编号: deviceId={}, inPosition={}", deviceConfig.getId(), inPosition); |
| | | } else { |