|
@@ -74,7 +74,8 @@ public class Scene3dNumServiceImpl extends ServiceImpl<IScene3dNumMapper, Scene3
|
|
CompletableFuture.runAsync(() -> batchCreateSceneNum(false));
|
|
CompletableFuture.runAsync(() -> batchCreateSceneNum(false));
|
|
}
|
|
}
|
|
redisUtil.lRightPushAll(RedisKey.FDKANKAN_SCENE_NUMS, nums);
|
|
redisUtil.lRightPushAll(RedisKey.FDKANKAN_SCENE_NUMS, nums);
|
|
- this.updateUsedStatus(nums);
|
|
|
|
|
|
+ this.update(new LambdaQueryWrapper<Scene3dNum>().in(Scene3dNum::getCode, nums));
|
|
|
|
+// this.updateUsedStatus(nums);
|
|
log.info("场景码加载缓存完成");
|
|
log.info("场景码加载缓存完成");
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("场景码加载缓存失败", e);
|
|
log.error("场景码加载缓存失败", e);
|
|
@@ -106,35 +107,26 @@ public class Scene3dNumServiceImpl extends ServiceImpl<IScene3dNumMapper, Scene3
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void batchCreateSceneNum(boolean force) {
|
|
public void batchCreateSceneNum(boolean force) {
|
|
- String lockKey = String.format(RedisLockKey.LOCK_BATCH_CREATE_NUM);
|
|
|
|
- boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_10_MINUTE);
|
|
|
|
- if(!lock){
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- try {
|
|
|
|
- if (!force) {
|
|
|
|
- long count = this.count(new LambdaQueryWrapper<Scene3dNum>().eq(Scene3dNum::getUsed, CommonStatus.NO.code()));
|
|
|
|
- if (count > threshold) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ if (!force) {
|
|
|
|
+ long count = this.count(new LambdaQueryWrapper<Scene3dNum>().eq(Scene3dNum::getUsed, CommonStatus.NO.code()));
|
|
|
|
+ if (count > threshold) {
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- int batchCnt = threshold / batchSize + (threshold % batchSize > 0 ? 1 : 0);
|
|
|
|
- for (int i = 0; i < batchCnt; i++){
|
|
|
|
- Set<String> numSet = this.turnCreateSceneNum(batchSize);
|
|
|
|
- List<Scene3dNum> scene3dNumList = numSet.parallelStream().map(num -> {
|
|
|
|
- Scene3dNum scene3dNum = new Scene3dNum();
|
|
|
|
- scene3dNum.setNum(num);
|
|
|
|
- return scene3dNum;
|
|
|
|
- }).collect(Collectors.toList());
|
|
|
|
- try{
|
|
|
|
- this.saveBatch(scene3dNumList);
|
|
|
|
- }catch (Exception e){
|
|
|
|
- log.error("场景码插入异常!");
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ int batchCnt = threshold / batchSize + (threshold % batchSize > 0 ? 1 : 0);
|
|
|
|
+ for (int i = 0; i < batchCnt; i++){
|
|
|
|
+ Set<String> numSet = this.turnCreateSceneNum(batchSize);
|
|
|
|
+ List<Scene3dNum> scene3dNumList = numSet.parallelStream().map(num -> {
|
|
|
|
+ Scene3dNum scene3dNum = new Scene3dNum();
|
|
|
|
+ scene3dNum.setCode(num);
|
|
|
|
+ return scene3dNum;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ try{
|
|
|
|
+ this.saveBatch(scene3dNumList);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.error("场景码插入异常!");
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
- }finally {
|
|
|
|
- redisLockUtil.unlockLua(lockKey);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|