Commit c645cf01 authored by 周健威's avatar 周健威

修改代码

parent 0b8fbd79
......@@ -14,6 +14,23 @@
<artifactId>rs-datacenter-api</artifactId>
<version>2.0-rscp-SNAPSHOT</version>
<repositories>
<repository>
<id>osgeo</id>
<name>OSGeo Release Repository</name>
<url>https://repo.osgeo.org/repository/release/</url>
<snapshots><enabled>false</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</repository>
<repository>
<id>osgeo-snapshot</id>
<name>OSGeo Snapshot Repository</name>
<url>https://repo.osgeo.org/repository/snapshot/</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>false</enabled></releases>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
......
......@@ -14,6 +14,27 @@
<groupId>com.upyuns.platform.rs</groupId>
<artifactId>rs-datacenter-server</artifactId>
<repositories>
<repository>
<id>osgeo</id>
<name>OSGeo Release Repository</name>
<url>https://repo.osgeo.org/repository/release/</url>
<snapshots><enabled>false</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</repository>
<repository>
<id>osgeo-snapshot</id>
<name>OSGeo Snapshot Repository</name>
<url>https://repo.osgeo.org/repository/snapshot/</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>false</enabled></releases>
</repository>
</repositories>
<properties>
<geotools.version>17.0</geotools.version>
</properties>
<dependencies>
<dependency>
<groupId>com.github.wxiaoqi</groupId>
......@@ -44,6 +65,43 @@
<optional>true</optional>
<version>2.8.3</version>
</dependency>
<dependency>
<groupId>com.vividsolutions</groupId>
<artifactId>jts</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geojson</artifactId>
<version>24.3</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-main</artifactId>
<version>24.3</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>24.3</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-swing</artifactId>
<version>24.3</version>
</dependency>
<!-- 添加geotools-jdbc -->
<dependency>
<groupId>org.geotools.jdbc</groupId>
<artifactId>gt-jdbc-postgis</artifactId>
<version>24.3</version>
</dependency>
</dependencies>
<build>
......
......@@ -130,6 +130,14 @@ public class UploadController{
return JsonResultUtil.createSuccessResultWithObj(uploadService.uploadFile(file,prefix));
}
@RequestMapping(value = "/app/unauth/shp/upload", method = RequestMethod.POST)
public JSONObject shpUploads(
@RequestParam("file") MultipartFile file,
@RequestParam(value = "prefix",defaultValue = "shp")String prefix
)throws Exception {
return JsonResultUtil.createSuccessResultWithObj(uploadService.uploadShpFile(file,prefix));
}
@IgnoreUserToken
@RequestMapping(value = "/app/unauth/download", method = RequestMethod.GET) //匹配的是href中的download请求
public ResponseEntity<byte[]> download(@RequestParam("realFileRelPath") String realFileRelPath) throws Exception {
......
......@@ -42,6 +42,31 @@ public class UploadService {
@Autowired
private RedisTemplate redisTemplate;
/**
* 写入上传文件,返回相对路径
* @param file
* @return
*/
public String uploadShpFile(MultipartFile file,String prefix) throws Exception{
//创建本日存放目录
DateTime now = DateTime.now();
String dirPathToday = "/"+prefix+ "/" + now.toString(DEFAULT_DATE_TIME_FORMATTER);
String redisNoKey = RedisKey.UPLOAD_FILE_NO_PREFIX + now.toString(DEFAULT_DATE_TIME_FORMATTER);
Long no = redisTemplate.opsForValue().increment(redisNoKey);
if(no.equals(1l)){
redisTemplate.expire(redisNoKey,1, TimeUnit.DAYS);
}
String fileName = file.getOriginalFilename();
String realFileRelPath = dirPathToday + "/" + no + fileName.substring(fileName.lastIndexOf("."));
//文件存放路径
String filePath = baseUploadPath + realFileRelPath;
//将文件写入指定位置
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
redisTemplate.opsForValue().setIfAbsent(realFileRelPath, filePath);
// realFileRelPath=xx_url+SystemConfig.XXMP_URL+realFileRelPath;
return realFileRelPath;
}
/**
* 写入上传文件,返回相对路径
* @param file
......@@ -61,7 +86,7 @@ public class UploadService {
//文件存放路径
String filePath = baseUploadPath + realFileRelPath;
//将文件写入指定位置
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(filePath));
realFileRelPath=xx_url+SystemConfig.XXMP_URL+realFileRelPath;
return realFileRelPath;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment