|
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.lang.UUID;
|
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.core.util.ZipUtil;
|
|
@@ -230,6 +231,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
private IOrigFileUploadService origFileUploadService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private IOrigFileUploadBatchService origFileUploadBatchService;
|
|
|
|
|
|
@Override
|
|
|
public SceneFileBuild findByFileId(String fileId) {
|
|
@@ -2207,8 +2209,11 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
- final String s = AesUtil.encryptCBC("Aa123456", "0000000856753656", "pwel781esd6wglxm", AesUtil.ALMODE_CBC_NOPADDING);
|
|
|
- System.out.println(s);
|
|
|
+// final String s = AesUtil.encryptCBC("Aa123456", "0000000856753656", "pwel781esd6wglxm", AesUtil.ALMODE_CBC_NOPADDING);
|
|
|
+// System.out.println(s);
|
|
|
+// System.out.println(UUID.fastUUID());
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -2234,23 +2239,113 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
|
|
|
throw new BusinessException(ErrorCode.PARAM_REQUIRED.code(), "fileName不能为空");
|
|
|
}
|
|
|
|
|
|
- // TODO: 2023/11/22 查询是否有等待通知计算的上传记录,如果有则加入,没有则新增
|
|
|
- Long uploadOperId = null;
|
|
|
+ //查询是否有等待通知计算的上传批次记录,如果有则加入,没有则新增
|
|
|
+ OrigFileUploadBatch origFileUploadBatch = origFileUploadBatchService.getWaitingBatchByUuid(uuid);
|
|
|
+ if(Objects.isNull(origFileUploadBatch)){
|
|
|
+ origFileUploadBatch = new OrigFileUploadBatch();
|
|
|
+ origFileUploadBatch.setUuid(uuid);
|
|
|
+ origFileUploadBatch.setBatchId(UUID.fastUUID().toString().replace("-", ""));
|
|
|
+ origFileUploadBatchService.save(origFileUploadBatch);
|
|
|
+ }
|
|
|
|
|
|
+ //插入上传明细表
|
|
|
+ OrigFileUpload origFileUpload = new OrigFileUpload();
|
|
|
+ origFileUpload.setFileUrl(filePath);
|
|
|
+ origFileUpload.setFileName(fileName);
|
|
|
+ origFileUpload.setBatchId(origFileUploadBatch.getBatchId());
|
|
|
+ origFileUploadService.save(origFileUpload);
|
|
|
|
|
|
- // TODO: 2023/11/23 插入上传明细表
|
|
|
+ if(fileName.equals("config.json")){
|
|
|
+ HttpUtil.downloadFile(filePath, sendCallAlgorithmPath.concat(uuid).concat("/config.json"));
|
|
|
+ if(!FileUtil.exist(sendCallAlgorithmPath.concat(uuid).concat("/config.json"))){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_4002.code(), ErrorCode.FAILURE_CODE_4002.formatMessage("config.json"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(fileName.equals("data.fdage")){
|
|
|
+ HttpUtil.downloadFile(filePath, sendCallAlgorithmPath.concat(uuid).concat("/data.fdage"));
|
|
|
+ if(!FileUtil.exist(sendCallAlgorithmPath.concat(uuid).concat("/config.json"))){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_4002.code(), ErrorCode.FAILURE_CODE_4002.formatMessage("data.fdage"));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public ResultData noticeBuild(String uuid) throws Exception {
|
|
|
+ log.info("通知计算,uuid:{} " + uuid);
|
|
|
|
|
|
+ String[] uuidArr = uuid.split("_");
|
|
|
|
|
|
+ String snCode = uuidArr[0];
|
|
|
+ //获取fileId
|
|
|
+ String fileId = this.getFileId(snCode, uuid);
|
|
|
+ StringBuilder prefixBuffer = new StringBuilder(snCode).append(File.separator).append(fileId).append(File.separator).append(uuid).append(File.separator);
|
|
|
|
|
|
+ String buildType = "V2";
|
|
|
+ Long cameraType = 13L;//默认为看见相机
|
|
|
|
|
|
+ Camera camera = cameraService.getBySnCode(snCode);
|
|
|
+ if(Objects.isNull(camera)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_7010);
|
|
|
+ }
|
|
|
+ CameraDetail cameraDetail = cameraDetailService.getByCameraId(camera.getId());
|
|
|
+ if(Objects.isNull(cameraDetail)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_7010);
|
|
|
+ }
|
|
|
+ Integer camType = cameraDetail.getType();
|
|
|
+ if(camType == 10 || camType == 11){//深时或者深光
|
|
|
+ cameraType = 14L;
|
|
|
+ }else{
|
|
|
+ cameraType = 10L;
|
|
|
+ }
|
|
|
|
|
|
+// if(!fYunFileService.fileExist(ConstantFilePath.OSS_PREFIX + prefixBuffer + "data.fdage")){
|
|
|
+// log.error("data.fdage文件不存在");
|
|
|
+// throw new BusinessException(CameraConstant.FAILURE_6009);
|
|
|
+// }
|
|
|
+//
|
|
|
+// JSONObject fdageJson = JSONObject.parseObject(fYunFileService.getFileContent(ConstantFilePath.OSS_PREFIX + prefixBuffer + "data.fdage"));
|
|
|
+// if(ObjectUtils.isEmpty(fdageJson)){
|
|
|
+// log.info("data.fdage文件为空!");
|
|
|
+// throw new BusinessException(CameraConstant.FAILURE_6009);
|
|
|
+// }
|
|
|
+// //根据videoVersion判断是V2还是V3版本的算法和页面
|
|
|
+// if (fdageJson.containsKey("videoVersion") && StrUtil.isNotEmpty(fdageJson.getString("videoVersion"))) {
|
|
|
+// if (fdageJson.getIntValue("videoVersion") >= 4) {
|
|
|
+// buildType = "V3";
|
|
|
+// cameraType = 11L;
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+// buildScene(fileId, prefixBuffer.toString(),fdageJson,buildType,cameraType);
|
|
|
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
|
|
|
+ public String getFileId(String snCode, String uuid) throws Exception {
|
|
|
|
|
|
+ // 检测是否有生成
|
|
|
+ String fileId = null;
|
|
|
+ SceneFileBuild sceneFileBuild = this.findByUnicode(uuid);
|
|
|
+ if(Objects.nonNull(sceneFileBuild)){
|
|
|
+ fileId = sceneFileBuild.getFileId();
|
|
|
+ return fileId;
|
|
|
+ }
|
|
|
|
|
|
+ fileId = new SnowflakeIdGenerator(0, 0).nextId() + "";
|
|
|
+ log.info("新场景,fileid:{}", fileId);
|
|
|
|
|
|
- return ResultData.ok();
|
|
|
+ sceneFileBuild = new SceneFileBuild();
|
|
|
+ sceneFileBuild.setChildName(snCode);
|
|
|
+ sceneFileBuild.setFileId(fileId);
|
|
|
+ sceneFileBuild.setRecStatus("A");
|
|
|
+ sceneFileBuild.setUnicode(uuid);
|
|
|
+ sceneFileBuild.setCreateTime(new Date());
|
|
|
+ this.save(sceneFileBuild);
|
|
|
+
|
|
|
+ return fileId;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|