|
@@ -3,6 +3,7 @@ package com.zksy.environment.config;
|
|
|
import com.zksy.api.utils.SmsUtil;
|
|
import com.zksy.api.utils.SmsUtil;
|
|
|
import com.zksy.environment.domain.ERealTimeData;
|
|
import com.zksy.environment.domain.ERealTimeData;
|
|
|
import com.zksy.environment.mapper.ERealTimeDataMapper;
|
|
import com.zksy.environment.mapper.ERealTimeDataMapper;
|
|
|
|
|
+import com.zksy.environment.utils.DevicePhoneFetchUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
@@ -12,7 +13,6 @@ import javax.annotation.PostConstruct;
|
|
|
import javax.annotation.PreDestroy;
|
|
import javax.annotation.PreDestroy;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.Executors;
|
|
@@ -38,6 +38,8 @@ public class RSServerService {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private SmsUtil smsUtil;
|
|
private SmsUtil smsUtil;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DevicePhoneFetchUtil devicePhoneFetchUtil;
|
|
|
|
|
|
|
|
@PostConstruct
|
|
@PostConstruct
|
|
|
public void init() {
|
|
public void init() {
|
|
@@ -107,12 +109,7 @@ public class RSServerService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void receiveRealtimeData(RealTimeData data) {
|
|
public void receiveRealtimeData(RealTimeData data) {
|
|
|
- // 1. 定义必须传入的报警手机号列表(可根据实际场景从配置/数据库获取)
|
|
|
|
|
- List<String> mandatoryAlarmPhones = Arrays.asList(
|
|
|
|
|
- "15773238205",
|
|
|
|
|
- "19892389826"
|
|
|
|
|
- // 可根据设备类型/节点ID动态调整
|
|
|
|
|
- );
|
|
|
|
|
|
|
+
|
|
|
for (NodeData nd : data.getNodeList()) {
|
|
for (NodeData nd : data.getNodeList()) {
|
|
|
try {
|
|
try {
|
|
|
ERealTimeData realTimeData = new ERealTimeData();
|
|
ERealTimeData realTimeData = new ERealTimeData();
|
|
@@ -128,8 +125,11 @@ public class RSServerService {
|
|
|
realTimeData.setCreateTime(LocalDateTime.now());
|
|
realTimeData.setCreateTime(LocalDateTime.now());
|
|
|
realTimeDataMapper.insert(realTimeData);
|
|
realTimeDataMapper.insert(realTimeData);
|
|
|
|
|
|
|
|
- // 2. 必须传入第三个参数(报警手机号列表)
|
|
|
|
|
- smsUtil.checkDeviceAlarmAndSend(data, nd, mandatoryAlarmPhones);
|
|
|
|
|
|
|
+ //获取能够发送的手机号
|
|
|
|
|
+ List<String> devicePhoneList = devicePhoneFetchUtil.getPhoneListByDeviceId(String.valueOf(data.getDeviceId()));
|
|
|
|
|
+
|
|
|
|
|
+ //传入手机号参数
|
|
|
|
|
+ smsUtil.checkDeviceAlarmAndSend(data, nd, devicePhoneList);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("实时数据入库失败:设备ID={}, 节点ID={}", data.getDeviceId(), nd.getNodeId(), e);
|
|
log.error("实时数据入库失败:设备ID={}, 节点ID={}", data.getDeviceId(), nd.getNodeId(), e);
|
|
|
}
|
|
}
|