|
@@ -7,15 +7,18 @@ 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.RecStatus;
|
|
|
+import com.fdkankan.common.constant.*;
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.common.util.CmdUtils;
|
|
|
import com.fdkankan.common.util.DateExtUtil;
|
|
|
import com.fdkankan.common.util.MD5;
|
|
|
import com.fdkankan.common.util.SnowflakeIdGenerator;
|
|
|
import com.fdkankan.contro.entity.SceneFileBuild;
|
|
|
+import com.fdkankan.contro.entity.SceneOrigBd;
|
|
|
import com.fdkankan.contro.httpclient.CustomHttpClient;
|
|
|
import com.fdkankan.contro.service.GzZcdjzxService;
|
|
|
import com.fdkankan.contro.service.ISceneFileBuildService;
|
|
|
+import com.fdkankan.contro.service.ISceneOrigBdService;
|
|
|
import com.fdkankan.contro.util.BdUtil;
|
|
|
import com.fdkankan.fyun.config.FYunFileConfig;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
@@ -25,6 +28,7 @@ import com.fdkankan.fyun.local.constant.LocalConstants;
|
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
|
import com.fdkankan.model.utils.SceneUtil;
|
|
|
+import com.fdkankan.web.response.ResultData;
|
|
|
import com.fdkankan.web.util.RSAEncrypt;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
@@ -34,7 +38,9 @@ import org.springframework.stereotype.Service;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -48,44 +54,43 @@ public class GzZcdjzxServiceImpl implements GzZcdjzxService {
|
|
|
private FYunFileConfig fYunFileConfig;
|
|
|
@Autowired
|
|
|
private ISceneFileBuildService sceneFileBuildService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneOrigBdService sceneOrigBdService;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public void bd() {
|
|
|
- String token = bdUtil.login();
|
|
|
- JSONArray jsonArray = bdUtil.searchDataFerryInner(token);
|
|
|
- if(CollUtil.isEmpty(jsonArray)){
|
|
|
- return;
|
|
|
- }
|
|
|
- jsonArray.stream().forEach(v->{
|
|
|
- JSONObject o = (JSONObject) v;
|
|
|
- String id = o.getString("id");
|
|
|
+
|
|
|
+ List<SceneOrigBd> list = sceneOrigBdService.list(new LambdaQueryWrapper<SceneOrigBd>().eq(SceneOrigBd::getStatus, CommonSuccessStatus.WAITING.code()));
|
|
|
+
|
|
|
+ list.stream().forEach(v->{
|
|
|
+ String uuid = UUID.randomUUID().toString();
|
|
|
+ String fileUrl = v.getFileUrl();
|
|
|
+ String zipName = FileUtil.getName(fileUrl);
|
|
|
+ String zipDir = ConstantFilePath.BUILD_MODEL_PATH + "bd/" + uuid + "/";
|
|
|
+ String taskId = v.getTaskId();
|
|
|
+ String kNo = v.getKNo();
|
|
|
try {
|
|
|
- String filePathFdfs = o.getString("filePathFdfs");
|
|
|
- String dataPoint = o.getString("dataPoint");
|
|
|
- String[] split = dataPoint.split("#");
|
|
|
- String snCode = split[0];
|
|
|
- String fileId = split[1];
|
|
|
- String unicode = snCode + "_" + split[2];
|
|
|
- String url = bdUtil.getDownloadUrl(filePathFdfs);
|
|
|
- String dataSource = ConstantFilePath.BUILD_MODEL_PATH + snCode + "/" + fileId + "/" + unicode;
|
|
|
- String ossHomePath = SceneUtil.getHomePath(dataSource);
|
|
|
- String ossHomeAbsolutePath = LocalConstants.BASE_PATH + fYunFileConfig.getBucket() + "/" + ossHomePath;
|
|
|
- String zipName = dataPoint.replaceAll("#", "_") + ".zip";
|
|
|
- httpClient.downloadFile(url, ossHomeAbsolutePath, zipName);
|
|
|
- String unzipCmd = "unzip -o -O GBK " + ossHomeAbsolutePath + zipName + " -d " + ossHomeAbsolutePath;
|
|
|
+ httpClient.downloadFile(fileUrl, zipDir, zipName);
|
|
|
+ String unzipCmd = "unzip -o -O GBK " + zipDir + zipName + " -d " + zipDir;
|
|
|
+
|
|
|
CmdUtils.callLine(unzipCmd);
|
|
|
+
|
|
|
//解压后删除压缩包
|
|
|
- FileUtil.del(ossHomeAbsolutePath + zipName);
|
|
|
+ FileUtil.del(zipDir + zipName);
|
|
|
|
|
|
- String dataFdagePath = ossHomeAbsolutePath + "/data.fdage";
|
|
|
+ String dataFdagePath = zipDir + "data.fdage";
|
|
|
JSONObject dataFdageJson = JSON.parseObject(FileUtil.readUtf8String(dataFdagePath));
|
|
|
- String taskId = dataFdageJson.getString("taskId");
|
|
|
- String kNo = dataFdageJson.getString("kNo");
|
|
|
if(StrUtil.isEmpty(taskId) && StrUtil.isEmpty(kNo)){
|
|
|
throw new RuntimeException("案件号、勘探号不能同时为空");
|
|
|
}
|
|
|
|
|
|
+ JSONObject camJson = dataFdageJson.getJSONObject("cam");
|
|
|
+ String snCode = camJson.getString("uuid");
|
|
|
+ Integer camType = camJson.getInteger("type");
|
|
|
+ String uuidtime = dataFdageJson.getString("uuidtime");
|
|
|
+ String unicode = snCode + "_" + uuidtime;
|
|
|
+
|
|
|
LambdaQueryWrapper<SceneFileBuild> wrapper = new LambdaQueryWrapper<>();
|
|
|
if(StrUtil.isNotEmpty(taskId)){
|
|
|
wrapper.eq(SceneFileBuild::getTaskId, taskId);
|
|
@@ -94,11 +99,11 @@ public class GzZcdjzxServiceImpl implements GzZcdjzxService {
|
|
|
wrapper.eq(SceneFileBuild::getKNo, kNo);
|
|
|
}
|
|
|
SceneFileBuild sceneFileBuild = sceneFileBuildService.getOne(wrapper);
|
|
|
- String realFileId = null;
|
|
|
+ String fileId = null;
|
|
|
if(Objects.isNull(sceneFileBuild)){
|
|
|
- realFileId = fileId + "_" + DateExtUtil.format(new Date(), "yyyyMMddHHmmss");
|
|
|
+ fileId = String.valueOf(new SnowflakeIdGenerator(0,0).nextId());
|
|
|
sceneFileBuild = new SceneFileBuild();
|
|
|
- sceneFileBuild.setFileId(realFileId);
|
|
|
+ sceneFileBuild.setFileId(fileId);
|
|
|
sceneFileBuild.setUnicode(unicode);
|
|
|
sceneFileBuild.setChildName(snCode);
|
|
|
sceneFileBuild.setCreateTime(new Date());
|
|
@@ -107,29 +112,41 @@ public class GzZcdjzxServiceImpl implements GzZcdjzxService {
|
|
|
sceneFileBuild.setKNo(kNo);
|
|
|
sceneFileBuildService.save(sceneFileBuild);
|
|
|
}else{
|
|
|
- realFileId = sceneFileBuild.getFileId();
|
|
|
+ fileId = sceneFileBuild.getFileId();
|
|
|
}
|
|
|
- String realDataSource = ConstantFilePath.BUILD_MODEL_PATH + snCode + "/" + realFileId + "/" + unicode;
|
|
|
+ String realDataSource = ConstantFilePath.BUILD_MODEL_PATH + snCode + "/" + fileId + "/" + 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);
|
|
|
+ FileUtil.listFileNames(zipDir).stream().forEach(fileName -> {
|
|
|
+ FileUtil.copy(zipDir + "/" + fileName, realOssHomeAbsolutePath + "/" + fileName, true);
|
|
|
});
|
|
|
|
|
|
|
|
|
// 私钥解密过程
|
|
|
- String paramsStr = snCode + "#" + realFileId + "#" + unicode;
|
|
|
+ String paramsStr = snCode + "#" + fileId + "#" + unicode;
|
|
|
byte[] res = RSAEncrypt.encrypt(RSAEncrypt.loadPublicKeyByStr(RSAEncrypt.loadPublicKeyByFile()),
|
|
|
paramsStr.getBytes(StandardCharsets.UTF_8));
|
|
|
String params = new Base64().encodeToString(res);
|
|
|
|
|
|
- sceneFileBuildService.turntableUploadSuccess(params);
|
|
|
+ Integer code = null;
|
|
|
+ try {
|
|
|
+ ResultData resultData = sceneFileBuildService.turntableUploadSuccess(params);
|
|
|
+ code = resultData.getCode();
|
|
|
+ }catch (BusinessException e){
|
|
|
+ code = e.getCode();
|
|
|
+ } catch (Exception e){
|
|
|
+ code = ServerCode.SYSTEM_ERROR.code();
|
|
|
+ }
|
|
|
|
|
|
- bdUtil.updateDataFerryInner(id, token, "1", "3");
|
|
|
- }catch (Exception e){
|
|
|
- log.error("场景摆渡失败,bd_data:{}", v, e);
|
|
|
- bdUtil.updateDataFerryInner(id, token, "1", "4");
|
|
|
+ if(code == ServerCode.SUCCESS.code()){//调用计算成功,修改状态为已成功
|
|
|
+ v.setStatus(CommonSuccessStatus.SUCCESS.code());
|
|
|
+ }else{
|
|
|
+ v.setStatus(CommonSuccessStatus.FAIL.code());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ v.setStatus(CommonSuccessStatus.FAIL.code());
|
|
|
}
|
|
|
+ sceneOrigBdService.updateById(v);
|
|
|
});
|
|
|
}
|
|
|
|