Commit 37dd53e2 by 毛树良

<fix>:优化

1 parent ac4e063b
......@@ -6,6 +6,7 @@ import com.viontech.constant.SystemConstants;
import com.viontech.handler.TrafficDataConvertHandler;
import com.viontech.service.Gb1400Service;
import com.viontech.service.TrafficEventService;
import com.viontech.utils.CheckUtil;
import com.viontech.utils.DateUtil;
import com.viontech.utils.JavaBean2Json;
import com.viontech.utils.JsonMessage;
......@@ -76,7 +77,12 @@ public class TrafficIllegalScheduled {
if (!CollectionUtils.isEmpty(trafficModels)) {
List<TrafficMongoModel> trafficMongoModels = new ArrayList<>();
for (Object model : trafficModels) {
trafficMongoModels.add(JavaBean2Json.Json2JavaBean(JavaBean2Json.javaBean2Json(model), TrafficMongoModel.class));
TrafficMongoModel trafficModel = JavaBean2Json.Json2JavaBean(JavaBean2Json.javaBean2Json(model), TrafficMongoModel.class);
if (CheckUtil.checkDeviceId(trafficModel)) {
trafficMongoModels.add(trafficModel);
} else {
redisTemplate.opsForValue().set(RedisConstants.FANXING_TO_GB1400_LASTTIME, trafficModel.getEvent_dt());
}
}
//List<TrafficMongoModel> 转 SubscribeNotificationsObj
SubscribeNotificationsObj subscribeNotificationsObj = trafficDataConvertHandler.trafficIllegalToSubscribeNotifications(trafficMongoModels);
......
......@@ -6,6 +6,7 @@ import com.viontech.constant.SystemConstants;
import com.viontech.handler.TrafficDataConvertHandler;
import com.viontech.service.Gb1400Service;
import com.viontech.service.TrafficEventService;
import com.viontech.utils.CheckUtil;
import com.viontech.utils.DateUtil;
import com.viontech.utils.JavaBean2Json;
import com.viontech.utils.JsonMessage;
......@@ -76,7 +77,12 @@ public class TrafficVehicleScheduled {
if (!CollectionUtils.isEmpty(trafficModels)) {
List<TrafficMongoModel> trafficMongoModels = new ArrayList<>();
for (Object model : trafficModels) {
trafficMongoModels.add(JavaBean2Json.Json2JavaBean(JavaBean2Json.javaBean2Json(model), TrafficMongoModel.class));
TrafficMongoModel trafficModel = JavaBean2Json.Json2JavaBean(JavaBean2Json.javaBean2Json(model), TrafficMongoModel.class);
if (CheckUtil.checkDeviceId(trafficModel)) {
trafficMongoModels.add(trafficModel);
} else {
redisTemplate.opsForValue().set(RedisConstants.FANXING_TO_GB1400_VEHICLE_LASTTIME, trafficModel.getEvent_dt());
}
}
//List<TrafficMongoModel> 转 SubscribeNotificationsObj
SubscribeNotificationsObj subscribeNotificationsObj = trafficDataConvertHandler.trafficVehicleToSubscribeNotifications(trafficMongoModels);
......
package com.viontech.utils;
import com.viontech.vo.traffic.TrafficMongoModel;
import java.util.Map;
import java.util.Optional;
public class CheckUtil {
public static boolean checkDeviceId(TrafficMongoModel model) {
String deviceId = Optional.ofNullable(model)
.map(x -> x.getEvent_data())
.map(x -> x.get("device"))
.map(x -> (String) ((Map) x).get("code")).orElse("");
if (20 == deviceId.length()) {
return true;
}
return false;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!