Commit 74a32d0b by 毛树良

<fix>:优化推送

1 parent 44712769
......@@ -59,26 +59,39 @@ public class DeviceSyncScheduled {
return;
}
//查询
DeviceModel deviceQry = new DeviceModel();
deviceQry.setModifyTime_gte(lastTimeUtc);
deviceQry.setModifyTime_lte(currentTimeUtc);
deviceQry.setOffset(0);
deviceQry.setLimit(20);
List<DeviceModel> deviceModels = trafficEventService.selectDeviceDatas(deviceQry);
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()) {
redisTemplate.opsForValue().set(RedisConstants.FANXING_TO_GB1400_DEVICE_LASTTIME, DateUtil.formatDate(deviceModels.get(deviceModels.size() - 1).getModifyTime(), DateUtil.TIMESTAMP_FORMAT));
int offset = 0;
int limit = 20;
int selectSize = 0;
int num = 0;
do {
DeviceModel deviceQry = new DeviceModel();
deviceQry.setModifyTime_gte(lastTimeUtc);
deviceQry.setModifyTime_lte(currentTimeUtc);
deviceQry.setOffset(offset);
deviceQry.setLimit(limit);
List<DeviceModel> deviceModels = trafficEventService.selectDeviceDatas(deviceQry);
selectSize = deviceModels.size();
num = num + 1;
offset = limit*num;
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("结束处理设备数据");
}
}
......@@ -59,26 +59,38 @@ public class LaneSyncScheduled {
return;
}
//查询
LaneModel laneQry = new LaneModel();
laneQry.setModifyTime_gte(lastTimeUtc);
laneQry.setModifyTime_lte(currentTimeUtc);
laneQry.setOffset(0);
laneQry.setLimit(20);
List<LaneModel> laneModels = trafficEventService.selectLaneDatas(laneQry);
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()) {
redisTemplate.opsForValue().set(RedisConstants.FANXING_TO_GB1400_LANE_LASTTIME, DateUtil.formatDate(laneModels.get(laneModels.size() - 1).getModifyTime(), DateUtil.TIMESTAMP_FORMAT));
int offset = 0;
int limit = 20;
int selectSize = 0;
int num = 0;
do {
LaneModel laneQry = new LaneModel();
laneQry.setModifyTime_gte(lastTimeUtc);
laneQry.setModifyTime_lte(currentTimeUtc);
laneQry.setOffset(offset);
laneQry.setLimit(limit);
List<LaneModel> laneModels = trafficEventService.selectLaneDatas(laneQry);
selectSize = laneModels.size();
num = num + 1;
offset = limit*num;
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("结束处理车道数据");
}
}
......@@ -60,26 +60,38 @@ public class TollgateSyncScheduled {
return;
}
//查询
TollgateModel tollgateQry = new TollgateModel();
tollgateQry.setModifyTime_gte(lastTimeUtc);
tollgateQry.setModifyTime_lte(currentTimeUtc);
tollgateQry.setOffset(0);
tollgateQry.setLimit(20);
List<TollgateModel> tollgateModels = trafficEventService.selectTollgateDatas(tollgateQry);
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()) {
redisTemplate.opsForValue().set(RedisConstants.FANXING_TO_GB1400_KAKOU_LASTTIME, DateUtil.formatDate(tollgateModels.get(tollgateModels.size() - 1).getModifyTime(), DateUtil.TIMESTAMP_FORMAT));
int offset = 0;
int limit = 20;
int selectSize = 0;
int num = 0;
do {
TollgateModel tollgateQry = new TollgateModel();
tollgateQry.setModifyTime_gte(lastTimeUtc);
tollgateQry.setModifyTime_lte(currentTimeUtc);
tollgateQry.setOffset(offset);
tollgateQry.setLimit(limit);
List<TollgateModel> tollgateModels = trafficEventService.selectTollgateDatas(tollgateQry);
selectSize = tollgateModels.size();
num = num + 1;
offset = limit*num;
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("结束处理卡口数据");
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!