Commit fdc1424a by 杨林龙

优化Gps基站消费逻辑

1 parent 793d5904
......@@ -122,14 +122,14 @@ public class TransitHandleService {
List<String> snTempList = Lists.newArrayList();
log.info("开始插入或者更新Gps和基站的数据大小===" + snSet.size());
snSet.forEach(sn -> {
Object obj = redisUtils.get(setKey(sn));
if ("1".equals(obj)) {
Integer lockValue = (Integer) redisUtils.get(setKey(sn));
if (null != lockValue && 1 == lockValue) {
log.info("设备号:" + sn + "已经在redis中加锁,在此服务器中不消费");
return;
}
snTempList.add(sn);
//消费的设备号进行加锁 保证只在一台机器上处理入库操作
redisUtils.setnx(setKey(sn), "1", 60);
redisUtils.setnx(setKey(sn), 1, 60);
});
// 清空缓存set
snSet.clear();
......@@ -167,7 +167,7 @@ public class TransitHandleService {
// 将sn解锁
snTempList.forEach(sn -> {
//对于已经入库的设备进行解锁
redisUtils.unlock(setKey(sn), "0");
redisUtils.unlock(setKey(sn), 0);
});
log.info("入库结束,已经同步解锁redis的锁");
// 临时时间设置为此次插入数据库的时间
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!