Explorar o código

计算完成时间

lyhzzz hai 5 meses
pai
achega
60e9e7760d

+ 9 - 7
src/main/java/com/fdkankan/fusion/mq/consumer/OsgbToB3dmConsumer.java

@@ -7,6 +7,7 @@ import com.fdkankan.fusion.common.OssPath;
 import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.common.util.*;
 import com.fdkankan.fusion.config.CacheUtil;
+import com.fdkankan.fusion.entity.CommonUpload;
 import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.service.ICommonUploadService;
 import com.fdkankan.redis.util.RedisUtil;
@@ -41,17 +42,18 @@ public class OsgbToB3dmConsumer {
     LocalToOssUtil localToOssUtil;
 
     @Async
-    public void consumerQueue(String localPath)  {
+    public void consumerQueue(Integer uploadId)  {
         String sourcePath = null;
+        String localPath = null;
         try {
-
-            localPath = CacheUtil.basePath+ localPath;
+            CommonUpload commonUpload = commonUploadService.getById(uploadId);
+            localPath = commonUpload.getUnzipPath();
             File file = new File(localPath);
             if(!file.exists()){
                 log.info("osgbToB3dm-mq--,msg:{},文件不存在",localPath);
                 return;
             }
-            commonUploadService.updateStatus(localPath,0);
+            commonUploadService.updateStatus(uploadId,0);
             ///mnt/manage/media-library/result/ea041f3237df46568f4e83e723e743d4
             String dir = String.format(OssPath.MANAGE_MODEL_FILE_PATH ,UUID.randomUUID().toString().replace("-",""));
             sourcePath = CacheUtil.basePath +File.separator+ dir;
@@ -72,15 +74,15 @@ public class OsgbToB3dmConsumer {
             String url = CacheUtil.mapping + dir+ File.separator +jsonFile.getName();
             HashMap<String,String> resultMap = ReadXmlUtil.getLatMap(file);
             if(resultMap != null && !resultMap.isEmpty()){
-                commonUploadService.updateByPath(localPath,url,resultMap.get("wgs84"),resultMap.get("gcj02"));
+                commonUploadService.updateByPath(uploadId,url,resultMap.get("wgs84"),resultMap.get("gcj02"));
             }else {
-                commonUploadService.updateByPath(localPath,url);
+                commonUploadService.updateByPath(uploadId,url);
             }
 
         }catch (Exception e){
             log.info("osgbToB3dm-status----消费失败",e);
             if(localPath != null){
-                commonUploadService.updateStatus(localPath,-1);
+                commonUploadService.updateStatus(uploadId,-1);
             }
         }finally {
             try {

+ 3 - 3
src/main/java/com/fdkankan/fusion/service/ICommonUploadService.java

@@ -22,10 +22,10 @@ public interface ICommonUploadService extends IService<CommonUpload> {
 
     CommonUpload add(String replace, String url, String s, String uuid, FileTypeEnum fileTypeEnum,String resultFormat, String replace1, Integer status, String unzipPath, Integer dictId);
 
-    void updateStatus(String localPath, Integer i);
+    void updateStatus(Integer localPath, Integer i);
 
-    void updateByPath(String localPath, String url, String wgs84, String gcj02);
-    void updateByPath(String localPath, String url);
+    void updateByPath(Integer uploadId, String url, String wgs84, String gcj02);
+    void updateByPath(Integer uploadId, String url);
 
     List<CommonUpload> getDelData();
 

+ 14 - 10
src/main/java/com/fdkankan/fusion/service/impl/CommonUploadServiceImpl.java

@@ -140,8 +140,9 @@ public class CommonUploadServiceImpl extends ServiceImpl<ICommonUploadMapper, Co
             case "b3dm" :  url = uploadB3dm(ossZipPath,modelFile); break;
             case "las" :
             case "ply" :  url = uploadLasOrPly(ossZipPath,modelFile);break;
-            case "osgb":  resultFormat = "b3dm";
-                    uploadOsgb(ossZipPath,modelFile) ;break;
+            case "osgb":
+                    resultFormat = "b3dm";
+                   break;
             default: break;
         }
         FileTypeEnum fileTypeEnum = FileTypeEnum.getByType(modelFileFormat);
@@ -152,6 +153,9 @@ public class CommonUploadServiceImpl extends ServiceImpl<ICommonUploadMapper, Co
         url = StringUtils.isNotBlank(url) ?CacheUtil.mapping + url:null;
         CommonUpload commonUpload = commonUploadService.add(oldName,url, String.valueOf(getDirectorySize(unZipFile)),
                 null, fileTypeEnum, modelFileFormat,resultFormat,status,unZipFile.getPath(),dictId);
+        if(modelFileFormat.equals("osgb")){
+            uploadOsgb(ossZipPath,modelFile,commonUpload.getId()) ;
+        }
         return ResultData.ok(commonUpload);
     }
 
@@ -182,9 +186,9 @@ public class CommonUploadServiceImpl extends ServiceImpl<ICommonUploadMapper, Co
     @Autowired
     OsgbToB3dmConsumer osgbToB3dmConsumer;
 
-    private void uploadOsgb(String unzipPath, File modelFile) {
+    private void uploadOsgb(Integer uploadId) {
          //osgbToB3dmConsumer.consumerQueue(CacheUtil.basePath + unzipPath);
-         osgbToB3dmConsumer.consumerQueue(unzipPath);
+         osgbToB3dmConsumer.consumerQueue(uploadId);
     }
 
     private String uploadLazOss(String unzipPath,File modelFile) {
@@ -242,26 +246,26 @@ public class CommonUploadServiceImpl extends ServiceImpl<ICommonUploadMapper, Co
     }
 
     @Override
-    public void updateByPath(String msg, String url) {
+    public void updateByPath(Integer uploadId, String url) {
         LambdaUpdateWrapper<CommonUpload> wrapper = new LambdaUpdateWrapper<>();
-        wrapper.eq(CommonUpload::getUnzipPath,msg);
+        wrapper.eq(CommonUpload::getId,uploadId);
         wrapper.set(CommonUpload::getStatus,1);
         wrapper.set(CommonUpload::getFileUrl,url);
         this.update(wrapper);
     }
 
     @Override
-    public void updateStatus(String localPath,Integer status) {
+    public void updateStatus(Integer uploadId,Integer status) {
         LambdaUpdateWrapper<CommonUpload> wrapper = new LambdaUpdateWrapper<>();
-        wrapper.eq(CommonUpload::getUnzipPath,localPath);
+        wrapper.eq(CommonUpload::getId,uploadId);
         wrapper.set(CommonUpload::getStatus,status);
         this.update(wrapper);
     }
 
     @Override
-    public void updateByPath(String msg, String url,String wgs84 ,String gcj02) {
+    public void updateByPath(Integer uploadId, String url,String wgs84 ,String gcj02) {
         LambdaUpdateWrapper<CommonUpload> wrapper = new LambdaUpdateWrapper<>();
-        wrapper.eq(CommonUpload::getUnzipPath,msg);
+        wrapper.eq(CommonUpload::getId,uploadId);
         wrapper.set(CommonUpload::getStatus,1);
         wrapper.set(CommonUpload::getFileUrl,url);
         wrapper.set(CommonUpload::getWgs84,wgs84);