Sfoglia il codice sorgente

增加修改相机使用容量逻辑

dsx 2 anni fa
parent
commit
1cabe5e9b0

+ 2 - 2
src/main/java/com/fdkankan/contro/entity/Scene3dNum.java

@@ -40,8 +40,8 @@ public class Scene3dNum implements Serializable {
     /**
      * 记录的状态,A: 生效,I: 禁用
      */
-    @TableField("num")
-    private String num;
+    @TableField("code")
+    private String code;
 
     /**
      * 更新时间

+ 1 - 0
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

@@ -188,6 +188,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             scenePlus.setUpdateTime(new Date());
             scenePlus.setSceneStatus(SceneStatus.NO_DISPLAY.code());
             scenePlusService.updateById(scenePlus);
+            cameraDetailService.updateCameraDetailByCameraIdAndSpace(scenePlus.getCameraId(), space);
 
 
             Integer videoVersion = fdageData.getInteger("videoVersion");

+ 20 - 28
src/main/java/com/fdkankan/contro/service/impl/Scene3dNumServiceImpl.java

@@ -74,7 +74,8 @@ public class Scene3dNumServiceImpl extends ServiceImpl<IScene3dNumMapper, Scene3
                     CompletableFuture.runAsync(() -> batchCreateSceneNum(false));
                 }
                 redisUtil.lRightPushAll(RedisKey.FDKANKAN_SCENE_NUMS, nums);
-                this.updateUsedStatus(nums);
+                this.update(new LambdaQueryWrapper<Scene3dNum>().in(Scene3dNum::getCode, nums));
+//                this.updateUsedStatus(nums);
                 log.info("场景码加载缓存完成");
             } catch (Exception e) {
                 log.error("场景码加载缓存失败", e);
@@ -106,35 +107,26 @@ public class Scene3dNumServiceImpl extends ServiceImpl<IScene3dNumMapper, Scene3
 
     @Override
     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);
         }
     }