|
@@ -49,12 +49,18 @@ public class SceneCleanOrigServiceImpl extends ServiceImpl<ISceneCleanOrigMapper
|
|
|
|
|
|
@Value("${scene.cleanOrig.month}")
|
|
@Value("${scene.cleanOrig.month}")
|
|
private Integer cleanOrigMonth;
|
|
private Integer cleanOrigMonth;
|
|
|
|
+ @Value("${scene.coldStorage.month}")
|
|
|
|
+ private Integer coldStorageMonth;
|
|
@Value("${scene.cleanDeleted.month}")
|
|
@Value("${scene.cleanDeleted.month}")
|
|
private Integer cleanDeletedMonth;
|
|
private Integer cleanDeletedMonth;
|
|
@Value("#{'${scene.cleanTestCamera.snCode:}'.split(',')}")
|
|
@Value("#{'${scene.cleanTestCamera.snCode:}'.split(',')}")
|
|
private List<String> testSnCodeList;
|
|
private List<String> testSnCodeList;
|
|
@Value("${scene.cleanTestCamera.month}")
|
|
@Value("${scene.cleanTestCamera.month}")
|
|
private Integer cleanTestCameraMonth;
|
|
private Integer cleanTestCameraMonth;
|
|
|
|
+ @Value("${fyun.bucket}")
|
|
|
|
+ private String bucket;
|
|
|
|
+ @Value("${fyun.coldBucket}")
|
|
|
|
+ private String coldBucket;
|
|
@Autowired
|
|
@Autowired
|
|
private ICameraService cameraService;
|
|
private ICameraService cameraService;
|
|
|
|
|
|
@@ -69,6 +75,8 @@ public class SceneCleanOrigServiceImpl extends ServiceImpl<ISceneCleanOrigMapper
|
|
private FYunFileServiceInterface fYunFileService;
|
|
private FYunFileServiceInterface fYunFileService;
|
|
@Autowired
|
|
@Autowired
|
|
private RedisUtil redisUtil;
|
|
private RedisUtil redisUtil;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISceneColdStorageLogService sceneColdStorageLogService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void cleanOrigV4() {
|
|
public void cleanOrigV4() {
|
|
@@ -231,4 +239,57 @@ public class SceneCleanOrigServiceImpl extends ServiceImpl<ISceneCleanOrigMapper
|
|
this.cleanOrig4Delete(sceneBeans, true, 3);
|
|
this.cleanOrig4Delete(sceneBeans, true, 3);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void coldStorageHomeV3() {
|
|
|
|
+ //查询所有计算时间超过限定时间的场景,计算成功、未被删除
|
|
|
|
+ List<SceneBean> sceneBeans = sceneProService.listColdStorageScene(coldStorageMonth);
|
|
|
|
+ this.coldStorage(sceneBeans);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void coldStorageHomeV4() {
|
|
|
|
+ //查询所有计算时间超过限定时间的场景,计算成功、未被删除
|
|
|
|
+ List<SceneBean> sceneBeans = scenePlusService.listColdStorageScene(coldStorageMonth);
|
|
|
|
+ this.coldStorage(sceneBeans);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void coldStorage(List<SceneBean> sceneBeans){
|
|
|
|
+ if(CollUtil.isEmpty(sceneBeans)){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ sceneBeans.parallelStream().forEach(scene->{
|
|
|
|
+ boolean lock = this.lock(scene.getDataSource());
|
|
|
|
+ try {
|
|
|
|
+ if(lock) {
|
|
|
|
+ this.coldStorageHandler(scene);
|
|
|
|
+ sceneColdStorageLogService.saveLog(scene.getNum(), scene.getDataSource(), 1, 1, null);
|
|
|
|
+ }
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.error("冷归档失败,num:{}" + scene.getNum(), e);
|
|
|
|
+ sceneColdStorageLogService.saveLog(scene.getNum(), scene.getDataSource(),1, CommonSuccessStatus.FAIL.code(), ExceptionUtil.stacktraceToString(e, 3000));
|
|
|
|
+ }finally {
|
|
|
|
+ this.releaseLock(scene.getDataSource());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void coldStorageHandler(SceneBean scene){
|
|
|
|
+ String dataSource = scene.getDataSource();
|
|
|
|
+ if(StrUtil.isEmpty(dataSource) || dataSource.length() < 10) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ String homePath = dataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, ConstantFilePath.OSS_PREFIX);
|
|
|
|
+
|
|
|
|
+ //将文件复制到冷归档bucket
|
|
|
|
+ fYunFileService.copyFileBetweenBucket(bucket, homePath, coldBucket, homePath);
|
|
|
|
+
|
|
|
|
+ List<String> origList = fYunFileService.listRemoteFiles(bucket, homePath);
|
|
|
|
+ List<String> coldList = fYunFileService.listRemoteFiles(coldBucket, homePath);
|
|
|
|
+ if(origList.size() != coldList.size()){
|
|
|
|
+ throw new RuntimeException("复制文件到冷归档bucket失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //删除标准bucket文件
|
|
|
|
+ fYunFileService.deleteFolder(homePath);
|
|
|
|
+ }
|
|
}
|
|
}
|