diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java index 5907301..7ff4dea 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java @@ -2089,41 +2089,33 @@ public class DeviceDataHandler { sensorData.setDeviceName(deviceName); // 解析传感器数据(根据实际字段映射) - // 支持小写和驼峰命名两种格式 - if (params.containsKey("dissolvedoxygen") || params.containsKey("dissolvedOxygen")) { - Double value = params.containsKey("dissolvedOxygen") ? - params.getDouble("dissolvedOxygen") : params.getDouble("dissolvedoxygen"); + if (params.containsKey("dissolvedOxygen")) { + Double value = params.getDouble("dissolvedOxygen"); sensorData.setDissolvedOxygen(value); } - if (params.containsKey("temperature")) { - sensorData.setTemperature(params.getDouble("temperature")); - } if (params.containsKey("currentTemperature")) { sensorData.setTemperature(params.getDouble("currentTemperature")); } - if (params.containsKey("saturability") || params.containsKey("dosat")) { - Double value = params.containsKey("dosat") ? - params.getDouble("dosat") : params.getDouble("saturability"); + if (params.containsKey("dosat")) { + Double value = params.getDouble("dosat") ; sensorData.setSaturability(value); } - if (params.containsKey("ph")) { - sensorData.setPh(params.getDouble("ph")); + if (params.containsKey("PH")) { + sensorData.setPh(params.getDouble("PH")); } if (params.containsKey("salinity")) { sensorData.setSalinity(params.getDouble("salinity")); } - if (params.containsKey("treference") || params.containsKey("Treference")) { - Double value = params.containsKey("Treference") ? - params.getDouble("Treference") : params.getDouble("treference"); + if (params.containsKey("Treference")) { + Double value = params.getDouble("Treference"); sensorData.setTreference(value); } - if (params.containsKey("tfluorescence") || params.containsKey("Tfluorescence")) { - Double value = params.containsKey("Tfluorescence") ? - params.getDouble("Tfluorescence") : params.getDouble("tfluorescence"); + if (params.containsKey("Tfluorescence")) { + Double value = params.getDouble("Tfluorescence"); sensorData.setTfluorescence(value); } - if (params.containsKey("phasedifference")) { - sensorData.setPhaseDifference(params.getDouble("phasedifference")); + if (params.containsKey("Phasedifference")) { + sensorData.setPhaseDifference(params.getDouble("Phasedifference")); } if (params.containsKey("battery")) { sensorData.setBattery(params.getDouble("battery")); diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/mapper/AquWarnCallNoticeMapper.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/mapper/AquWarnCallNoticeMapper.java index d8fe517..14b7589 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/mapper/AquWarnCallNoticeMapper.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/mapper/AquWarnCallNoticeMapper.java @@ -115,4 +115,16 @@ public interface AquWarnCallNoticeMapper extends BaseMapper { "INNER JOIN aqu_map_message_warn_call_notice m ON m.message_warn_id = w.id " + "WHERE m.call_notice_id = #{callNoticeId} LIMIT 1") String selectWarnMessageByCallNoticeId(@Param("callNoticeId") Long callNoticeId); + + /** + * 通过 callNoticeId 查询关联的第一条告警消息标题(title) + * 用于定时任务重发时作为 TTS warnMessage 参数,避免将完整消息内容传入导致 TTS 播报异常 + * + * @param callNoticeId 通知记录ID + * @return 告警标题,不存在时返回 null + */ + @Select("SELECT w.title FROM aqu_message_warn w " + + "INNER JOIN aqu_map_message_warn_call_notice m ON m.message_warn_id = w.id " + + "WHERE m.call_notice_id = #{callNoticeId} LIMIT 1") + String selectWarnTitleByCallNoticeId(@Param("callNoticeId") Long callNoticeId); } diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/service/impl/WarnCallNoticeServiceImpl.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/service/impl/WarnCallNoticeServiceImpl.java index 833fea6..5b11637 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/service/impl/WarnCallNoticeServiceImpl.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/service/impl/WarnCallNoticeServiceImpl.java @@ -254,16 +254,18 @@ public class WarnCallNoticeServiceImpl implements WarnCallNoticeService { int sentCount = 0; for (AquWarnCallNotice notice : pendingList) { try { - // 查询关联的告警消息内容,用于构建 TTS 参数 - String rawMessage = warnCallNoticeMapper.selectWarnMessageByCallNoticeId(notice.getId()); - String warnMessageShort = parseWarnMessageShort(rawMessage); + // 查询关联的告警标题(title),作为 TTS warnMessage 参数 + // 使用 title(如"设备离线"、"溶解氧")而非完整 message,避免长字符串被 TTS 逐字播报 + String warnTitle = warnCallNoticeMapper.selectWarnTitleByCallNoticeId(notice.getId()); + String warnMessageShort = (warnTitle != null && !warnTitle.isEmpty()) ? warnTitle : "异常"; // 通过 deviceId 查询设备名称 + // 注意:不使用 serialNum 作为 fallback,避免数字序列号被 TTS 逐位播报 String deviceName = null; if (notice.getDeviceId() != null) { Device device = deviceMapper.selectById(notice.getDeviceId()); - if (device != null) { - deviceName = device.getDeviceName() != null ? device.getDeviceName() : device.getSerialNum(); + if (device != null && device.getDeviceName() != null && !device.getDeviceName().isEmpty()) { + deviceName = device.getDeviceName(); } }