|
@@ -1,26 +1,39 @@
|
|
|
package com.fdkankan.contro.controller;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.common.constant.RecStatus;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.common.util.CmdUtils;
|
|
|
+import com.fdkankan.common.util.DateExtUtil;
|
|
|
+import com.fdkankan.contro.entity.SceneFileBuild;
|
|
|
import com.fdkankan.contro.service.GzZcdjzxService;
|
|
|
import com.fdkankan.contro.service.ISceneFileBuildService;
|
|
|
import com.fdkankan.contro.vo.ResponseSceneFile;
|
|
|
+import com.fdkankan.fyun.config.FYunFileConfig;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.fyun.local.constant.LocalConstants;
|
|
|
+import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
+import com.fdkankan.model.utils.SceneUtil;
|
|
|
import com.fdkankan.web.response.ResultData;
|
|
|
+import com.fdkankan.web.util.RSAEncrypt;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
+import org.apache.commons.codec.binary.Base64;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 场景文件上传模块
|
|
@@ -153,4 +166,54 @@ public class SceneFileController{
|
|
|
gzZcdjzxService.bd();
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private FYunFileConfig fYunFileConfig;
|
|
|
+
|
|
|
+ @GetMapping("bd2")
|
|
|
+ public ResultData bd2(String taskId, String kNo, String fileId, String snCode, String unicode) throws Exception {
|
|
|
+ String dataSource = ConstantFilePath.BUILD_MODEL_PATH + snCode + "/" + fileId + "/" + unicode;
|
|
|
+ String ossHomePath = SceneUtil.getHomePath(dataSource);
|
|
|
+ String ossHomeAbsolutePath = LocalConstants.BASE_PATH + fYunFileConfig.getBucket() + "/" + ossHomePath;
|
|
|
+ LambdaQueryWrapper<SceneFileBuild> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ if(StrUtil.isNotEmpty(taskId)){
|
|
|
+ wrapper.eq(SceneFileBuild::getTaskId, taskId);
|
|
|
+ }
|
|
|
+ if(StrUtil.isNotEmpty(kNo)){
|
|
|
+ wrapper.eq(SceneFileBuild::getKNo, kNo);
|
|
|
+ }
|
|
|
+ SceneFileBuild sceneFileBuild = sceneFileBuildService.getOne(wrapper);
|
|
|
+ String realFileId = null;
|
|
|
+ if(Objects.isNull(sceneFileBuild)){
|
|
|
+ realFileId = fileId + "_" + DateExtUtil.format(new Date(), "yyyyMMddHHmmss");
|
|
|
+ sceneFileBuild = new SceneFileBuild();
|
|
|
+ sceneFileBuild.setFileId(realFileId);
|
|
|
+ sceneFileBuild.setUnicode(unicode);
|
|
|
+ sceneFileBuild.setChildName(snCode);
|
|
|
+ sceneFileBuild.setCreateTime(new Date());
|
|
|
+ sceneFileBuild.setRecStatus(RecStatus.VALID.code());
|
|
|
+ sceneFileBuild.setTaskId(taskId);
|
|
|
+ sceneFileBuild.setKNo(kNo);
|
|
|
+ sceneFileBuildService.save(sceneFileBuild);
|
|
|
+ }else{
|
|
|
+ realFileId = sceneFileBuild.getFileId();
|
|
|
+ }
|
|
|
+ String realDataSource = ConstantFilePath.BUILD_MODEL_PATH + snCode + "/" + realFileId + "/" + unicode;
|
|
|
+ String realOssHomePath = SceneUtil.getHomePath(realDataSource);
|
|
|
+ String realOssHomeAbsolutePath = LocalConstants.BASE_PATH + fYunFileConfig.getBucket() + "/" + realOssHomePath;
|
|
|
+ FileUtil.listFileNames(ossHomeAbsolutePath).stream().forEach(fileName -> {
|
|
|
+ FileUtil.copy(ossHomeAbsolutePath + "/" + fileName, realOssHomeAbsolutePath + "/" + fileName, true);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ // 私钥解密过程
|
|
|
+ String paramsStr = snCode + "#" + realFileId + "#" + unicode;
|
|
|
+ byte[] res = RSAEncrypt.encrypt(RSAEncrypt.loadPublicKeyByStr(RSAEncrypt.loadPublicKeyByFile()),
|
|
|
+ paramsStr.getBytes(StandardCharsets.UTF_8));
|
|
|
+ String params = new Base64().encodeToString(res);
|
|
|
+
|
|
|
+ sceneFileBuildService.turntableUploadSuccess(params);
|
|
|
+
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
}
|