Commit 74a32d0b by 毛树良

<fix>:优化推送

1 parent 44712769
...@@ -59,26 +59,39 @@ public class DeviceSyncScheduled { ...@@ -59,26 +59,39 @@ public class DeviceSyncScheduled {
return; return;
} }
//查询 //查询
DeviceModel deviceQry = new DeviceModel(); int offset = 0;
deviceQry.setModifyTime_gte(lastTimeUtc); int limit = 20;
deviceQry.setModifyTime_lte(currentTimeUtc); int selectSize = 0;
deviceQry.setOffset(0); int num = 0;
deviceQry.setLimit(20); do {
List<DeviceModel> deviceModels = trafficEventService.selectDeviceDatas(deviceQry); DeviceModel deviceQry = new DeviceModel();
log.info("查询范围(lastTimeUtc,currentTimeUtc]=({},{}],本批次设备待同步数据总{}条。", lastTimeUtc, currentTimeUtc, deviceModels.size()); deviceQry.setModifyTime_gte(lastTimeUtc);
if (!CollectionUtils.isEmpty(deviceModels)) { deviceQry.setModifyTime_lte(currentTimeUtc);
//List<DeviceModel> 转 SubscribeNotificationsObj deviceQry.setOffset(offset);
SubscribeNotificationsObj subscribeNotificationsObj = trafficDataConvertHandler.deviceToSubscribeNotifications(deviceModels); deviceQry.setLimit(limit);
//将设备数据同步gb1400 List<DeviceModel> deviceModels = trafficEventService.selectDeviceDatas(deviceQry);
if (subscribeNotificationsObj != null) { selectSize = deviceModels.size();
JsonMessage resultVo = gb1400Service.subscribeNotifications(subscribeNotificationsObj); num = num + 1;
if (SystemConstants.APP_CODE_SUCCESS == resultVo.getCode()) { offset = limit*num;
redisTemplate.opsForValue().set(RedisConstants.FANXING_TO_GB1400_DEVICE_LASTTIME, DateUtil.formatDate(deviceModels.get(deviceModels.size() - 1).getModifyTime(), DateUtil.TIMESTAMP_FORMAT));
log.info("查询范围(lastTimeUtc,currentTimeUtc]=({},{}],本批次设备待同步数据总{}条。", lastTimeUtc, currentTimeUtc, deviceModels.size());
if (!CollectionUtils.isEmpty(deviceModels)) {
//List<DeviceModel> 转 SubscribeNotificationsObj
SubscribeNotificationsObj subscribeNotificationsObj = trafficDataConvertHandler.deviceToSubscribeNotifications(deviceModels);
//将设备数据同步gb1400
if (subscribeNotificationsObj != null) {
JsonMessage resultVo = gb1400Service.subscribeNotifications(subscribeNotificationsObj);
if (SystemConstants.APP_CODE_SUCCESS == resultVo.getCode()) {
Date lastDataUtc = DateUtil.addHours(deviceModels.get(deviceModels.size() - 1).getModifyTime(), -8);
redisTemplate.opsForValue().set(RedisConstants.FANXING_TO_GB1400_DEVICE_LASTTIME, DateUtil.formatDate(lastDataUtc, DateUtil.TIMESTAMP_FORMAT));
} else {
log.error("trafficDataConvertHandler.deviceToSubscribeNotifications.failed=(offset,limit)=({},{})", offset, limit);
}
} else {
log.error("trafficDataConvertHandler.deviceToSubscribeNotifications is null");
} }
} else {
log.error("trafficDataConvertHandler.deviceToSubscribeNotifications is null");
} }
} } while (selectSize >= limit);
log.info("结束处理设备数据"); log.info("结束处理设备数据");
} }
} }
...@@ -59,26 +59,38 @@ public class LaneSyncScheduled { ...@@ -59,26 +59,38 @@ public class LaneSyncScheduled {
return; return;
} }
//查询 //查询
LaneModel laneQry = new LaneModel(); int offset = 0;
laneQry.setModifyTime_gte(lastTimeUtc); int limit = 20;
laneQry.setModifyTime_lte(currentTimeUtc); int selectSize = 0;
laneQry.setOffset(0); int num = 0;
laneQry.setLimit(20); do {
List<LaneModel> laneModels = trafficEventService.selectLaneDatas(laneQry); LaneModel laneQry = new LaneModel();
log.info("查询范围(lastTimeUtc,currentTimeUtc]=({},{}],本批次车道待同步数据总{}条。", lastTimeUtc, currentTimeUtc, laneModels.size()); laneQry.setModifyTime_gte(lastTimeUtc);
if (!CollectionUtils.isEmpty(laneModels)) { laneQry.setModifyTime_lte(currentTimeUtc);
//List<LaneModel> 转 SubscribeNotificationsObj laneQry.setOffset(offset);
SubscribeNotificationsObj subscribeNotificationsObj = trafficDataConvertHandler.laneToSubscribeNotifications(laneModels); laneQry.setLimit(limit);
//将车道数据同步gb1400 List<LaneModel> laneModels = trafficEventService.selectLaneDatas(laneQry);
if (subscribeNotificationsObj != null) { selectSize = laneModels.size();
JsonMessage resultVo = gb1400Service.subscribeNotifications(subscribeNotificationsObj); num = num + 1;
if (SystemConstants.APP_CODE_SUCCESS == resultVo.getCode()) { offset = limit*num;
redisTemplate.opsForValue().set(RedisConstants.FANXING_TO_GB1400_LANE_LASTTIME, DateUtil.formatDate(laneModels.get(laneModels.size() - 1).getModifyTime(), DateUtil.TIMESTAMP_FORMAT)); log.info("查询范围(lastTimeUtc,currentTimeUtc]=({},{}],本批次车道待同步数据总{}条。", lastTimeUtc, currentTimeUtc, laneModels.size());
if (!CollectionUtils.isEmpty(laneModels)) {
//List<LaneModel> 转 SubscribeNotificationsObj
SubscribeNotificationsObj subscribeNotificationsObj = trafficDataConvertHandler.laneToSubscribeNotifications(laneModels);
//将车道数据同步gb1400
if (subscribeNotificationsObj != null) {
JsonMessage resultVo = gb1400Service.subscribeNotifications(subscribeNotificationsObj);
if (SystemConstants.APP_CODE_SUCCESS == resultVo.getCode()) {
Date lastDataUtc = DateUtil.addHours(laneModels.get(laneModels.size() - 1).getModifyTime(), -8);
redisTemplate.opsForValue().set(RedisConstants.FANXING_TO_GB1400_LANE_LASTTIME, DateUtil.formatDate(lastDataUtc, DateUtil.TIMESTAMP_FORMAT));
} else {
log.error("trafficDataConvertHandler.laneToSubscribeNotifications.failed=(offset,limit)=({},{})", offset, limit);
}
} else {
log.error("trafficDataConvertHandler.laneToSubscribeNotifications is null");
} }
} else {
log.error("trafficDataConvertHandler.laneToSubscribeNotifications is null");
} }
} } while (selectSize >= limit);
log.info("结束处理车道数据"); log.info("结束处理车道数据");
} }
} }
...@@ -60,26 +60,38 @@ public class TollgateSyncScheduled { ...@@ -60,26 +60,38 @@ public class TollgateSyncScheduled {
return; return;
} }
//查询 //查询
TollgateModel tollgateQry = new TollgateModel(); int offset = 0;
tollgateQry.setModifyTime_gte(lastTimeUtc); int limit = 20;
tollgateQry.setModifyTime_lte(currentTimeUtc); int selectSize = 0;
tollgateQry.setOffset(0); int num = 0;
tollgateQry.setLimit(20); do {
List<TollgateModel> tollgateModels = trafficEventService.selectTollgateDatas(tollgateQry); TollgateModel tollgateQry = new TollgateModel();
log.info("查询范围(lastTimeUtc,currentTimeUtc]=({},{}],本批次卡口待同步数据总{}条。", lastTimeUtc, currentTimeUtc, tollgateModels.size()); tollgateQry.setModifyTime_gte(lastTimeUtc);
if (!CollectionUtils.isEmpty(tollgateModels)) { tollgateQry.setModifyTime_lte(currentTimeUtc);
//List<TollgateModel> 转 SubscribeNotificationsObj tollgateQry.setOffset(offset);
SubscribeNotificationsObj subscribeNotificationsObj = trafficDataConvertHandler.tollgateToSubscribeNotifications(tollgateModels); tollgateQry.setLimit(limit);
//将卡口数据同步gb1400 List<TollgateModel> tollgateModels = trafficEventService.selectTollgateDatas(tollgateQry);
if (subscribeNotificationsObj != null) { selectSize = tollgateModels.size();
JsonMessage resultVo = gb1400Service.subscribeNotifications(subscribeNotificationsObj); num = num + 1;
if (SystemConstants.APP_CODE_SUCCESS == resultVo.getCode()) { offset = limit*num;
redisTemplate.opsForValue().set(RedisConstants.FANXING_TO_GB1400_KAKOU_LASTTIME, DateUtil.formatDate(tollgateModels.get(tollgateModels.size() - 1).getModifyTime(), DateUtil.TIMESTAMP_FORMAT)); log.info("查询范围(lastTimeUtc,currentTimeUtc]=({},{}],本批次卡口待同步数据总{}条。", lastTimeUtc, currentTimeUtc, tollgateModels.size());
if (!CollectionUtils.isEmpty(tollgateModels)) {
//List<TollgateModel> 转 SubscribeNotificationsObj
SubscribeNotificationsObj subscribeNotificationsObj = trafficDataConvertHandler.tollgateToSubscribeNotifications(tollgateModels);
//将卡口数据同步gb1400
if (subscribeNotificationsObj != null) {
JsonMessage resultVo = gb1400Service.subscribeNotifications(subscribeNotificationsObj);
if (SystemConstants.APP_CODE_SUCCESS == resultVo.getCode()) {
Date lastDataUtc = DateUtil.addHours(tollgateModels.get(tollgateModels.size() - 1).getModifyTime(), -8);
redisTemplate.opsForValue().set(RedisConstants.FANXING_TO_GB1400_KAKOU_LASTTIME, DateUtil.formatDate(lastDataUtc, DateUtil.TIMESTAMP_FORMAT));
} else {
log.error("trafficDataConvertHandler.tollgateToSubscribeNotifications.failed=(offset,limit)=({},{})", offset, limit);
}
} else {
log.error("trafficDataConvertHandler.tollgateToSubscribeNotifications is null");
} }
} else {
log.error("trafficDataConvertHandler.tollgateToSubscribeNotifications is null");
} }
} } while (selectSize >= limit);
log.info("结束处理卡口数据"); log.info("结束处理卡口数据");
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!