|
@@ -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.config.ThreadPoolConfig;
|
|
|
import com.fdkankan.fusion.entity.CommonUpload;
|
|
|
import com.fdkankan.fusion.exception.BusinessException;
|
|
|
import com.fdkankan.fusion.service.ICommonUploadService;
|
|
@@ -34,58 +35,63 @@ public class OsgbToB3dmConsumer {
|
|
|
private String ossUrlPrefix;
|
|
|
@Autowired
|
|
|
UploadToOssUtil uploadToOssUtil;
|
|
|
+ @Autowired
|
|
|
+ ThreadPoolConfig threadPoolConfig;
|
|
|
+
|
|
|
|
|
|
- @Async
|
|
|
public void consumerQueue(Integer uploadId) {
|
|
|
- String sourcePath = null;
|
|
|
- String localPath = null;
|
|
|
- try {
|
|
|
- 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(uploadId,0);
|
|
|
- ///mnt/manage/media-library/result/ea041f3237df46568f4e83e723e743d4
|
|
|
- String dir = String.format(OssPath.MANAGE_MODEL_FILE_PATH ,UUID.randomUUID().toString().replace("-",""));
|
|
|
- sourcePath = CacheUtil.basePath + dir;
|
|
|
+ threadPoolConfig.taskExecutor().execute(() ->{
|
|
|
+ String sourcePath = null;
|
|
|
+ String localPath = null;
|
|
|
+ try {
|
|
|
+ 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(uploadId,0);
|
|
|
+ ///mnt/manage/media-library/result/ea041f3237df46568f4e83e723e743d4
|
|
|
+ String dir = String.format(OssPath.MANAGE_MODEL_FILE_PATH ,UUID.randomUUID().toString().replace("-",""));
|
|
|
+ sourcePath = CacheUtil.basePath + dir;
|
|
|
|
|
|
- OBJToGLBUtil.OsgbToB3dm(localPath,sourcePath);
|
|
|
- String b3dmJsonPath = FileWriterUtil.checkB3dmTileset(new File(sourcePath));
|
|
|
- if(b3dmJsonPath == null){
|
|
|
- log.info("osgbToB3dm-mq,msg:{},转化失败tileset.json不存在",localPath);
|
|
|
- throw new BusinessException(-1,"转化失败tileset.json不存在");
|
|
|
- }
|
|
|
- File jsonFile = new File(b3dmJsonPath);
|
|
|
- if(!jsonFile.exists()){
|
|
|
- log.info("osgbToB3dm-mq,msg:{},转化失败tileset.json不存在",localPath);
|
|
|
- throw new BusinessException(-1,"转化失败tileset.json不存在");
|
|
|
- }
|
|
|
+ OBJToGLBUtil.OsgbToB3dm(localPath,sourcePath);
|
|
|
+ String b3dmJsonPath = FileWriterUtil.checkB3dmTileset(new File(sourcePath));
|
|
|
+ if(b3dmJsonPath == null){
|
|
|
+ log.info("osgbToB3dm-mq,msg:{},转化失败tileset.json不存在",localPath);
|
|
|
+ throw new BusinessException(-1,"转化失败tileset.json不存在");
|
|
|
+ }
|
|
|
+ File jsonFile = new File(b3dmJsonPath);
|
|
|
+ if(!jsonFile.exists()){
|
|
|
+ log.info("osgbToB3dm-mq,msg:{},转化失败tileset.json不存在",localPath);
|
|
|
+ throw new BusinessException(-1,"转化失败tileset.json不存在");
|
|
|
+ }
|
|
|
|
|
|
- ShellUtil.yunUpload(sourcePath,dir);
|
|
|
- String url = ossUrlPrefix + dir + File.separator +jsonFile.getName();
|
|
|
- HashMap<String,String> resultMap = ReadXmlUtil.getLatMap(file);
|
|
|
- if(resultMap != null && !resultMap.isEmpty()){
|
|
|
- commonUploadService.updateByPath(uploadId,url,resultMap.get("wgs84"),resultMap.get("gcj02"));
|
|
|
- }else {
|
|
|
- commonUploadService.updateByPath(uploadId,url);
|
|
|
- }
|
|
|
+ ShellUtil.yunUpload(sourcePath,dir);
|
|
|
+ String url = ossUrlPrefix + dir + File.separator +jsonFile.getName();
|
|
|
+ HashMap<String,String> resultMap = ReadXmlUtil.getLatMap(file);
|
|
|
+ if(resultMap != null && !resultMap.isEmpty()){
|
|
|
+ commonUploadService.updateByPath(uploadId,url,resultMap.get("wgs84"),resultMap.get("gcj02"));
|
|
|
+ }else {
|
|
|
+ commonUploadService.updateByPath(uploadId,url);
|
|
|
+ }
|
|
|
|
|
|
- }catch (Exception e){
|
|
|
- log.info("osgbToB3dm-status----消费失败",e);
|
|
|
- if(localPath != null){
|
|
|
- commonUploadService.updateStatus(uploadId,-1);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("osgbToB3dm-status----消费失败",e);
|
|
|
+ if(localPath != null){
|
|
|
+ commonUploadService.updateStatus(uploadId,-1);
|
|
|
+ }
|
|
|
+ }finally {
|
|
|
+ try {
|
|
|
+ FileUtil.del(localPath);
|
|
|
+ FileUtil.del(sourcePath);
|
|
|
+ }catch ( Exception e){
|
|
|
+ log.info("删除文件失败:{}",e);
|
|
|
+ }
|
|
|
}
|
|
|
- }finally {
|
|
|
- try {
|
|
|
- FileUtil.del(localPath);
|
|
|
- FileUtil.del(sourcePath);
|
|
|
- }catch ( Exception e){
|
|
|
- log.info("删除文件失败:{}",e);
|
|
|
- }
|
|
|
- }
|
|
|
+ });
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|