|
|
@@ -20,7 +20,10 @@ import java.time.Instant;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.function.Consumer;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -226,7 +229,7 @@ public class IotDataTransferService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 发送人防用电负荷情况
|
|
|
+ * 发送人防用电负荷情况(704)
|
|
|
*
|
|
|
* @return 是否发送成功
|
|
|
**/
|
|
|
@@ -378,17 +381,27 @@ public class IotDataTransferService {
|
|
|
|
|
|
public void synchronizeDeviceData() {
|
|
|
LambdaQueryWrapper<DmpDevice> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(DmpDevice::getTenantId, 1208);
|
|
|
+ queryWrapper.eq(DmpDevice::getTenantId, 1208)
|
|
|
+ .eq(DmpDevice::getDeleteFlag, 0);
|
|
|
List<DmpDevice> deviceList = dmpDeviceMapper.selectList(queryWrapper);
|
|
|
List<Integer> deviceTypeList = deviceList.stream().map(DmpDevice::getDeviceType).distinct().collect(Collectors.toList());
|
|
|
-
|
|
|
+ log.info("设备数据同步开始,涉及设备类型数:" + deviceTypeList.size() + "个,类型为:" + deviceTypeList);
|
|
|
+
|
|
|
+ Map<Integer, Consumer<JSONObject>> deviceTypeHandlerMap = new HashMap<>();
|
|
|
+ deviceTypeHandlerMap.put(701, this::sendEnvData);
|
|
|
+ deviceTypeHandlerMap.put(707, this::sendEnvData);
|
|
|
+ deviceTypeHandlerMap.put(708, this::sendEnvData);
|
|
|
+ deviceTypeHandlerMap.put(709, this::sendEnvData);
|
|
|
+ deviceTypeHandlerMap.put(710, this::sendEnvData);
|
|
|
+ deviceTypeHandlerMap.put(711, this::sendEnvData);
|
|
|
+ deviceTypeHandlerMap.put(702, this::sendWaterLeak);
|
|
|
+ deviceTypeHandlerMap.put(703, this::sendPersonPresence);
|
|
|
+ deviceTypeHandlerMap.put(704, this::sendElectricityLoad);
|
|
|
for (Integer deviceType : deviceTypeList) {
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("deviceType", deviceType);
|
|
|
- this.sendWaterLeak(json);
|
|
|
- this.sendEnvData(json);
|
|
|
- this.sendPersonPresence(json);
|
|
|
- this.sendElectricityLoad(json);
|
|
|
+ deviceTypeHandlerMap.get(deviceType).accept(json);
|
|
|
}
|
|
|
+ log.info("设备数据同步完成,涉及设备类型数:" + deviceTypeList.size() + "个");
|
|
|
}
|
|
|
}
|