完成第一版的功能
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package com.xkrs.microservice.common.config;
|
||||
|
||||
import it.geosolutions.geoserver.rest.GeoServerRESTManager;
|
||||
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
|
||||
import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
|
||||
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.coverage.GSCoverageEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.datastore.GSGeoTIFFDatastoreEncoder;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
@Component
|
||||
public class GeoUtil {
|
||||
|
||||
private static String SRS = "EPSG:4326";
|
||||
|
||||
@Value("${my.GeoserverAddress}")
|
||||
private String url;
|
||||
|
||||
@Value("${my.GeoUsername}")
|
||||
private String userName;
|
||||
|
||||
@Value("${my.GeoPassword}")
|
||||
private String password;
|
||||
|
||||
@Value("${my.GeoWorkSpace}")
|
||||
private String workSpaceName;
|
||||
|
||||
private GeoServerRESTManager manager;
|
||||
|
||||
@PostConstruct
|
||||
public void setManager(){
|
||||
try {
|
||||
manager = new GeoServerRESTManager(new URL(url),userName,password);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传到tiff文件,发布到GeoServer里面去
|
||||
* @param coverageStoreName
|
||||
* @param filePath
|
||||
*/
|
||||
public void publishTiff(String coverageStoreName,String filePath){
|
||||
GeoServerRESTPublisher publisher = manager.getPublisher();
|
||||
try {
|
||||
publisher.publishExternalGeoTIFF(workSpaceName, coverageStoreName,
|
||||
new File(filePath), coverageStoreName,"EPSG:4326",
|
||||
GSResourceEncoder.ProjectionPolicy.NONE, "raster");
|
||||
}catch (FileNotFoundException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -8,7 +8,6 @@ import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 监听redis key 过期事件
|
||||
@@ -28,11 +27,9 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
String expiredKey = message.toString();
|
||||
if (expiredKey.contains("runFile_")){
|
||||
String[] key = expiredKey.split("_");
|
||||
Optional<DataFileEntity> optional = dataFileDao.findById(Integer.valueOf(key[1]));
|
||||
DataFileEntity dataFileEntity = dataFileDao.findById(Integer.valueOf(key[1])).get();
|
||||
//如果文件的状态还在运行中,就修改运行状态为 未运行
|
||||
if (optional.get().getRunFlag().equals("1")){
|
||||
DataFileEntity dataFileEntity = new DataFileEntity();
|
||||
dataFileEntity.setId(optional.get().getId());
|
||||
if (dataFileEntity.getRunFlag() == 1){
|
||||
dataFileEntity.setRunFlag(0);
|
||||
dataFileDao.save(dataFileEntity);
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.config.GeoUtil;
|
||||
import com.xkrs.microservice.common.config.RedisUtil;
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.entity.DataFileEntity;
|
||||
@@ -41,6 +42,9 @@ public class DataFileController {
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Resource
|
||||
private GeoUtil geoUtil;
|
||||
|
||||
|
||||
@RequestMapping(value="/get/all",method = RequestMethod.GET)
|
||||
public String getAllDataFile() {
|
||||
@@ -48,6 +52,17 @@ public class DataFileController {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/addTest",method = RequestMethod.POST)
|
||||
public String fb(@RequestParam("fileCode") String fileCode){
|
||||
DataFileEntity dataFileEntity = dataFileService.getDataFileByDataFileCode(fileCode);
|
||||
try {
|
||||
geoUtil.publishTiff(dataFileEntity.getDataFileCode() + "_left",dataFileEntity.getLeftFilePath());
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"ok",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传tif文件
|
||||
* @param dataFileQo 数据文件实体
|
||||
|
@@ -2,6 +2,8 @@ package com.xkrs.microservice.service;
|
||||
|
||||
public interface AsyncService {
|
||||
|
||||
public void publishTiff(Integer id);
|
||||
|
||||
/**
|
||||
* 异步执行exe文件
|
||||
* @param id 数据文件id
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.xkrs.microservice.service.impl;
|
||||
|
||||
import com.xkrs.microservice.common.config.GeoUtil;
|
||||
import com.xkrs.microservice.common.config.RedisUtil;
|
||||
import com.xkrs.microservice.dao.DataFileDao;
|
||||
import com.xkrs.microservice.model.entity.DataFileEntity;
|
||||
@@ -32,6 +33,22 @@ public class AsyncServiceImpl implements AsyncService {
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Resource
|
||||
private GeoUtil geoUtil;
|
||||
|
||||
@Override
|
||||
public void publishTiff(Integer id) {
|
||||
DataFileEntity dataFileEntity = dataFileDao.getById(id);
|
||||
if (dataFileEntity == null)
|
||||
return;
|
||||
//发布左影像图层
|
||||
geoUtil.publishTiff(dataFileEntity.getDataFileCode() + "_left",dataFileEntity.getLeftFilePath());
|
||||
//发布右影像图层
|
||||
geoUtil.publishTiff(dataFileEntity.getDataFileCode() + "_right",dataFileEntity.getRightFilePath());
|
||||
dataFileEntity.setPublishFlag(1);
|
||||
dataFileDao.save(dataFileEntity);
|
||||
}
|
||||
|
||||
@Async("threadPoolTaskExecutor")
|
||||
@Override
|
||||
public void executeRunData(Integer id,String dataFileCode,String leftFilePath,String rightFilePath,String maxX,String maxY,String minX,String minY){
|
||||
@@ -63,4 +80,6 @@ public class AsyncServiceImpl implements AsyncService {
|
||||
//不管运行结果怎么样都把文件锁去掉
|
||||
redisUtil.del("runFile_" + id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,14 @@
|
||||
package com.xkrs.microservice.service.impl;
|
||||
|
||||
import com.xkrs.microservice.common.config.RedisUtil;
|
||||
import com.xkrs.microservice.common.encapsulation.EncapsulationObject;
|
||||
import com.xkrs.microservice.dao.DataFileDao;
|
||||
import com.xkrs.microservice.dao.MapServiceDao;
|
||||
import com.xkrs.microservice.model.entity.DataFileEntity;
|
||||
import com.xkrs.microservice.model.entity.MapServiceEntity;
|
||||
import com.xkrs.microservice.model.qo.DataFileQo;
|
||||
import com.xkrs.microservice.model.qo.ZipFileInfoQo;
|
||||
import com.xkrs.microservice.model.vo.FileServiceResDetailVo;
|
||||
import com.xkrs.microservice.model.vo.ResultVo;
|
||||
import com.xkrs.microservice.service.AsyncService;
|
||||
import com.xkrs.microservice.service.DataFileService;
|
||||
import com.xkrs.microservice.service.FileServerService;
|
||||
import com.xkrs.microservice.util.CopyPropertiesUtil;
|
||||
import com.xkrs.microservice.util.OpenGeoGisUtil;
|
||||
import com.xkrs.microservice.util.SnowFlakeUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -23,22 +17,16 @@ import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.xkrs.microservice.util.DateTimeUtil.getNowTime;
|
||||
import static com.xkrs.microservice.util.DateTimeUtil.timeMillisToTime;
|
||||
import static com.xkrs.microservice.util.FileUtil.multipartToFile;
|
||||
import static com.xkrs.microservice.util.ZipUtil.unZip;
|
||||
|
||||
@@ -199,6 +187,7 @@ public class DataFileServiceImpl implements DataFileService {
|
||||
// 设置系统时间
|
||||
dataFileEntity.setCreatedTime(getNowTime());
|
||||
dataFileDao.save(dataFileEntity);
|
||||
asyncService.publishTiff(dataFileEntity.getId());
|
||||
return resultVo;
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,11 @@ spring.redis.lettuce.pool.min-idle = 1
|
||||
spring.redis.lettuce.shutdown-timeout = 0
|
||||
|
||||
# 自定义Geoserver服务器地址
|
||||
my.GeoserverAdress = http://192.168.2.9:9080/geoserver/
|
||||
my.GeoserverAddress = http://localhost:9080/geoserver
|
||||
my.GeoUsername = admin
|
||||
my.GeoPassword = geoserver
|
||||
my.GeoWorkSpace = gsm_gui
|
||||
|
||||
# 临时文件目录
|
||||
my.TempFilePath = D:/temp/
|
||||
#my.TempFilePath = /home/sc/web/rs-shandong/temp/
|
||||
@@ -41,16 +45,15 @@ my.FileServerPath = D:/gsm_gui/files/
|
||||
#my.FileServerPath = /home/docker/fastdfs/files/
|
||||
# 自定义文件服务器地址
|
||||
my.FileServerAdress = http://192.168.2.9:4096/
|
||||
#my.FileServerAdress = http://192.168.2.105:4096/
|
||||
#my.FileServerAdress = http://118.24.27.47:4096/
|
||||
my.FileServerAdminAdress = http://127.0.0.1:4096/
|
||||
|
||||
# GSMGUI.exe的文件路径
|
||||
my.gsmExePath = D:/gsm/2.cmd_GSM/Release/GSM_GUI.exe
|
||||
# GSMGUI.exe的运行文件的输出结果路径
|
||||
my.gsmOutPath = D:/gsm/out/
|
||||
|
||||
# 结果文件夹中点云的文件路径
|
||||
my.lasOutPath = /prj/DSM_Ortho/Point_clouds/
|
||||
|
||||
# 结果文件中需要QTM运行的文件路径
|
||||
my.dsmOutPath = /prj/DSM_Ortho/DSM/
|
||||
my.topPutPath = /prj/DSM_Ortho/TOP/
|
||||
|
@@ -32,18 +32,26 @@ spring.redis.lettuce.pool.min-idle = 1
|
||||
spring.redis.lettuce.shutdown-timeout = 0
|
||||
|
||||
# 自定义Geoserver服务器地址
|
||||
my.GeoserverAdress = http://192.168.2.9:9080/geoserver/
|
||||
my.GeoserverAdress = http://localhost:9080/geoserver/
|
||||
my.GeoUsername = admin
|
||||
my.GeoPassword = geoserver
|
||||
my.GeoWorkSpace = my_syg
|
||||
|
||||
# 临时文件目录
|
||||
my.TempFilePath = D:/temp/
|
||||
#my.TempFilePath = /home/sc/web/rs-shandong/temp/
|
||||
|
||||
my.TempFilePath = /home/gsm_gui/source/temp/
|
||||
# 文件服务器路径
|
||||
my.FileServerPath = D:/gsm-gui/files/
|
||||
#my.FileServerPath = /home/docker/fastdfs/files/
|
||||
|
||||
my.FileServerPath = /home/gsm_gui/source/files/
|
||||
# 自定义文件服务器地址
|
||||
my.FileServerAdress = http://192.168.2.9:4096/
|
||||
#my.FileServerAdress = http://192.168.2.105:4096/
|
||||
#my.FileServerAdress = http://118.24.27.47:4096/
|
||||
my.FileServerAdminAdress = http://127.0.0.1:4096/
|
||||
|
||||
# GSMGUI.exe的文件路径
|
||||
my.gsmExePath = /home/gsm/2.cmd_GSM/Release/GSM_GUI.exe
|
||||
# GSMGUI.exe的运行文件的输出结果路径
|
||||
my.gsmOutPath = /home/gsm/out/
|
||||
|
||||
# 结果文件夹中点云的文件路径
|
||||
my.lasOutPath = /prj/DSM_Ortho/Point_clouds/
|
||||
# 结果文件中需要QTM运行的文件路径
|
||||
my.dsmOutPath = /prj/DSM_Ortho/DSM/
|
||||
my.topPutPath = /prj/DSM_Ortho/TOP/
|
||||
|
Reference in New Issue
Block a user