Parcourir la source

Merge branch 'hotfix-激光场景3月份前不支持计算-20221215' into release

dsx il y a 2 ans
Parent
commit
eb9a9d1018

+ 46 - 0
src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java

@@ -42,6 +42,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.http.*;
 import org.springframework.stereotype.Service;
 import org.springframework.util.LinkedMultiValueMap;
@@ -62,6 +63,7 @@ import java.util.*;
  * @author dengsixing
  * @since 2021-12-23
  */
+@RefreshScope
 @Slf4j
 @Service
 public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper, SceneFileBuild> implements ISceneFileBuildService {
@@ -83,6 +85,9 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
     @Value("${v3.controlUrl:#{null}}")
     private String v3controlUrl;
 
+    @Value("${build.notSupport.beforeTime:202203}")
+    private String jgNotSupportBuildTime;
+
     @Autowired
     private RedisUtil redisUtil;
 
@@ -703,6 +708,10 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         // 判断是否是V3的场景
         ScenePro scenePro = sceneProService.getOne(
                 new LambdaQueryWrapper<ScenePro>().like(ScenePro::getDataSource, fileId));
+
+        //激光场景校验是否能够计算
+        this.checkJgCanBuild(scenePro);
+
         if (ObjectUtils.isEmpty(scenePro) || (!ObjectUtils.isEmpty(scenePro.getIsUpgrade()) && scenePro.getIsUpgrade() == 1)) {
             scenePlusVO = buildScene(fileId, prefixBuffer.toString(), fdageJson, buildType, cameraType);
         } else {
@@ -1056,6 +1065,10 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
     public ResultData rebuildScene(String num,Boolean force,Boolean deleteExtras) throws IOException {
 
         ScenePro scenePro = sceneProService.getByNum(num);
+
+        //激光场景校验是否能够计算
+        this.checkJgCanBuild(scenePro);
+
         //如果是v3场景,不允许重算,需要升级v4后再调此接口进行重算
         if(Objects.nonNull(scenePro) && (Objects.isNull(scenePro.getIsUpgrade())
             || scenePro.getIsUpgrade() != CommonStatus.YES.code().intValue())){
@@ -1134,6 +1147,39 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         return ResultData.ok();
     }
 
+    /**
+     * 由于算法不支持2022年三月份前的激光场景计算,这里需要校验是否是能计算,不能就退出重算
+     * @return
+     */
+    private void checkJgCanBuild(ScenePro scenePro){
+
+        if(Objects.isNull(scenePro) || StrUtil.isEmpty(scenePro.getDataSource())){
+            return;
+        }
+        cn.hutool.core.date.DateTime limitTime = DateExtUtil.parse(jgNotSupportBuildTime, DateExtUtil.dateStyle10);
+        String dataSource = scenePro.getDataSource();
+        String sceneDateTimeStr = dataSource.substring(dataSource.lastIndexOf("_") + 1).substring(0, 6);
+        //如果截取的时间串是空的,无法判断时间,就退出,正常走计算逻辑
+        if(StrUtil.isEmpty(sceneDateTimeStr)){
+            return;
+        }
+        cn.hutool.core.date.DateTime sceneDateTime = null;
+        try{
+            sceneDateTime = DateExtUtil.parse(sceneDateTimeStr, DateExtUtil.dateStyle10);
+            if(Objects.isNull(sceneDateTime)){
+                return;
+            }
+        }catch (Exception e){
+            //如果截取的时间串转换日期错误,无法判断时间,退出函数
+            return;
+        }
+
+        if(sceneDateTime.before(limitTime)){
+            throw new BusinessException(ErrorCode.FAILURE_CODE_5067);
+        }
+
+    }
+
     public ResultData rebuildV3Scene(ScenePro scenePro,String num,Boolean force) throws IOException {