dengsixing преди 6 месеца
родител
ревизия
b33251b5f6

+ 13 - 2
src/main/java/com/fdkankan/contro/controller/HaixinController.java

@@ -1,5 +1,6 @@
 package com.fdkankan.contro.controller;
 
+
 import com.fdkankan.contro.dto.UploadSceneDTO;
 import com.fdkankan.contro.service.IHaixinService;
 import com.fdkankan.web.response.ResultData;
@@ -7,13 +8,22 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
 
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author
+ * @since 2025-02-13
+ */
 @RestController
-@RequestMapping("/api/scene/file")
-public class HaixinController {
+@RequestMapping("/api/scene/bd")
+public class SceneOrigBdController {
 
     @Autowired
     private IHaixinService haixinService;
@@ -24,3 +34,4 @@ public class HaixinController {
     }
 
 }
+

+ 72 - 0
src/main/java/com/fdkankan/contro/entity/SceneOrigBd.java

@@ -0,0 +1,72 @@
+package com.fdkankan.contro.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author
+ * @since 2025-02-13
+ */
+@Getter
+@Setter
+@TableName("t_scene_orig_bd")
+public class SceneOrigBd implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 原始资源url
+     */
+    @TableField("file_url")
+    private String fileUrl;
+
+    /**
+     * 案件号
+     */
+    @TableField("task_id")
+    private String taskId;
+
+    /**
+     * 勘探号
+     */
+    @TableField("k_no")
+    private String kNo;
+
+    /**
+     * 处理状态(-1-处理失败,0-等待中,1-成功推送计算)
+     */
+    @TableField("status")
+    private Integer status;
+
+    /**
+     * 删除状态
+     */
+    @TableField("rec_status")
+    @TableLogic(value = "A", delval = "I")
+    private String recStatus;
+
+    /**
+     * 创建时间
+     */
+    @TableField("create_time")
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    @TableField("update_time")
+    private Date updateTime;
+
+
+}

+ 18 - 0
src/main/java/com/fdkankan/contro/mapper/ISceneOrigBdMapper.java

@@ -0,0 +1,18 @@
+package com.fdkankan.contro.mapper;
+
+import com.fdkankan.contro.entity.SceneOrigBd;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2025-02-13
+ */
+@Mapper
+public interface ISceneOrigBdMapper extends BaseMapper<SceneOrigBd> {
+
+}

+ 3 - 1
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

@@ -140,7 +140,8 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
     private ISceneBuildProcessLogService sceneBuildProcessLogService;
     @Autowired
     private ISceneColdStorageService sceneColdStorageService;
-
+    @Autowired
+    private IHaixinService haixinService;
 
     @Override
     public void buildScenePre(BuildSceneCallMessage message) throws Exception{
@@ -382,6 +383,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             if("eur".equals(env)){
                 commonService.sendEmail(sceneCode);
             }
+            //打压缩包
 
             log.info("场景计算结果处理结束,场景码:{}", sceneCode);
 

+ 2 - 0
src/main/java/com/fdkankan/contro/service/IHaixinService.java

@@ -7,4 +7,6 @@ public interface IHaixinService {
 
     ResultData uploadScene(UploadSceneDTO dto);
 
+    void noticHaixin(String num, Integer sceneStatus) throws Exception;
+
 }

+ 16 - 0
src/main/java/com/fdkankan/contro/service/ISceneOrigBdService.java

@@ -0,0 +1,16 @@
+package com.fdkankan.contro.service;
+
+import com.fdkankan.contro.entity.SceneOrigBd;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 
+ * @since 2025-02-13
+ */
+public interface ISceneOrigBdService extends IService<SceneOrigBd> {
+
+}

+ 56 - 39
src/main/java/com/fdkankan/contro/service/impl/GzZcdjzxServiceImpl.java

@@ -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);
         });
     }
 

+ 42 - 1
src/main/java/com/fdkankan/contro/service/impl/HaixinServiceImpl.java

@@ -1,23 +1,64 @@
 package com.fdkankan.contro.service.impl;
 
+import cn.hutool.core.io.FileUtil;
+import com.fdkankan.common.constant.SceneStatus;
+import com.fdkankan.common.util.CmdUtils;
 import com.fdkankan.contro.dto.UploadSceneDTO;
+import com.fdkankan.contro.entity.SceneOrigBd;
 import com.fdkankan.contro.service.IHaixinService;
+import com.fdkankan.contro.service.ISceneOrigBdService;
+import com.fdkankan.fyun.config.FYunFileConfig;
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
+import com.fdkankan.model.constants.ConstantFilePath;
+import com.fdkankan.model.constants.UploadFilePath;
 import com.fdkankan.web.response.ResultData;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+
 @Slf4j
 @Service
 public class HaixinServiceImpl implements IHaixinService {
 
+    @Autowired
+    private ISceneOrigBdService sceneOrigBdService;
+    @Resource
+    private FYunFileConfig fYunFileConfig;
+    @Resource
+    private FYunFileServiceInterface fileServiceInterface;
+
     @Override
     public ResultData uploadScene(UploadSceneDTO dto) {
 
+        SceneOrigBd sceneOrigBd = new SceneOrigBd();
+        sceneOrigBd.setFileUrl(dto.getFileUrl());
+        sceneOrigBd.setTaskId(sceneOrigBd.getTaskId());
+        sceneOrigBd.setKNo(dto.getKNo());
 
+        sceneOrigBdService.save(sceneOrigBd);
 
-        return null;
+        return ResultData.ok();
     }
 
+    @Override
+    public void noticHaixin(String num, Integer sceneStatus) throws Exception {
+
+        String zipPath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + num + ".zip";
+        if(sceneStatus == SceneStatus.NO_DISPLAY.code()){//计算成功,把原始资源打压缩包
+            String viewPath = "/oss/4dkankan/" + String.format(UploadFilePath.VIEW_PATH, num);
+            this.zip(viewPath, zipPath);
+        }
 
+        // TODO: 2025/2/14 发送压缩包 推送计算状态
 
+
+    }
+
+    private void zip(String sourcePath, String zipPath) throws Exception {
+        FileUtil.mkParentDirs(zipPath);
+        String cmd = "cd " + sourcePath + " && zip -r " + zipPath + " *";//&& mv -f " + zipPath + " "  + target
+        CmdUtils.callLineSh(cmd, 200);
+    }
 }

+ 1 - 2
src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java

@@ -370,8 +370,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             sceneNum = scenePlus.getNum();
             sceneCopyLogService.checkCanBuild(sceneNum);
             if (scenePlus.getSceneStatus().equals(SceneStatus.wait.code())) {
-                log.info(scenePlus.getNum() + ":场景处于计算中,不能再计算");
-                return null;
+                throw new BusinessException(ErrorCode.FAILURE_CODE_5033);
             }
         }
         if (sceneNum == null) {

+ 20 - 0
src/main/java/com/fdkankan/contro/service/impl/SceneOrigBdServiceImpl.java

@@ -0,0 +1,20 @@
+package com.fdkankan.contro.service.impl;
+
+import com.fdkankan.contro.entity.SceneOrigBd;
+import com.fdkankan.contro.mapper.ISceneOrigBdMapper;
+import com.fdkankan.contro.service.ISceneOrigBdService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2025-02-13
+ */
+@Service
+public class SceneOrigBdServiceImpl extends ServiceImpl<ISceneOrigBdMapper, SceneOrigBd> implements ISceneOrigBdService {
+
+}

+ 5 - 0
src/main/resources/mapper/contro/SceneOrigBdMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fdkankan.contro.mapper.ISceneOrigBdMapper">
+
+</mapper>