|
@@ -13,6 +13,8 @@ import com.fd.util.FileUtils;
|
|
|
import com.fd.util.R;
|
|
|
import com.fd.util.RegexUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -35,7 +37,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
/**
|
|
|
* Created by Owen on 2019/11/12 0012 9:40
|
|
|
- *
|
|
|
+ * <p>
|
|
|
* 栅格数据
|
|
|
*/
|
|
|
@Api(tags = "栅格模块")
|
|
@@ -68,13 +70,11 @@ public class RasterController {
|
|
|
private static BlockingQueue<Integer> coordQueue = new LinkedBlockingQueue<Integer>(2);
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ @ApiImplicitParam(name = "fileName", value = "文件名", required = true)
|
|
|
@ApiOperation("上传数据,校验文件名")
|
|
|
@GetMapping("check/{fileName}/")
|
|
|
public R checkFileName(@PathVariable("fileName") String fileName) {
|
|
|
- log.info("run checkFileName: {}",fileName);
|
|
|
-
|
|
|
+ log.info("run checkFileName: {}", fileName);
|
|
|
|
|
|
|
|
|
// 文件是否包含中文字符
|
|
@@ -86,20 +86,25 @@ public class RasterController {
|
|
|
String s = StringUtils.substringAfterLast(fileName, ".");
|
|
|
if (!"tif".equals(s)) {
|
|
|
log.info(MsgCode.E50008);
|
|
|
- return new R(50008,MsgCode.E50008);
|
|
|
+ return new R(50008, MsgCode.E50008);
|
|
|
}
|
|
|
|
|
|
List<FileEntity> list = rasterServer.findByFileName(fileName);
|
|
|
if (list.size() > 0) {
|
|
|
- log.info( MsgCode.E51006);
|
|
|
+ log.info(MsgCode.E51006);
|
|
|
return new R(51006, MsgCode.E51006);
|
|
|
}
|
|
|
return new R(200, MsgCode.SUCCESS);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation("上传栅格数据,只能上传tif文件")
|
|
|
- @PostMapping(value = "upload", consumes = { "multipart/form-data" })
|
|
|
- public R upload(@RequestParam("file") MultipartFile file, @RequestParam(value = "coord",required = false) String[] coord, HttpServletRequest req){
|
|
|
+
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "file", value = "只能上传tif文件", required = true),
|
|
|
+ @ApiImplicitParam(name = "coord", value = "坐标参数", dataType = "String"),
|
|
|
+ })
|
|
|
+ @ApiOperation("上传栅格数据")
|
|
|
+ @PostMapping(value = "upload", consumes = {"multipart/form-data"})
|
|
|
+ public R upload(@RequestParam("file") MultipartFile file, @RequestParam(value = "coord", required = false) String[] coord, HttpServletRequest req) {
|
|
|
log.info("run upload");
|
|
|
log.info("coord: {}", Arrays.toString(coord));
|
|
|
String strCoord = Arrays.toString(coord);
|
|
@@ -116,7 +121,7 @@ public class RasterController {
|
|
|
|
|
|
String s = StringUtils.substringAfterLast(fileName, ".");
|
|
|
if (!"tif".equals(s)) {
|
|
|
- return new R(50008,MsgCode.E50008);
|
|
|
+ return new R(50008, MsgCode.E50008);
|
|
|
}
|
|
|
|
|
|
List<FileEntity> list = rasterServer.findByFileName(fileName);
|
|
@@ -138,9 +143,10 @@ public class RasterController {
|
|
|
|
|
|
/**
|
|
|
* 上传后判断坐标,显示原始坐标
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
- private OutputFileEntity JudgeCoord(OutputFileEntity entity, RasterServer rasterServer){
|
|
|
+ private OutputFileEntity JudgeCoord(OutputFileEntity entity, RasterServer rasterServer) {
|
|
|
|
|
|
String cmd = Command.RASTER_JUDGE_COORD;
|
|
|
cmd = cmd.replace("@inputFile", entity.getUploadPath());
|
|
@@ -150,12 +156,12 @@ public class RasterController {
|
|
|
Integer isJudge = rasterServer.cmdJudgeCoord(cmd);
|
|
|
|
|
|
|
|
|
- if (1000 == isJudge){
|
|
|
+ if (1000 == isJudge) {
|
|
|
log.info("need to transform");
|
|
|
// 严格坐标转换
|
|
|
entity.setCoordType(TypeCode.COORD_XIAN_1980);
|
|
|
|
|
|
- } else if (0 == isJudge){
|
|
|
+ } else if (0 == isJudge) {
|
|
|
log.info("not to transform");
|
|
|
entity.setCoordType(TypeCode.COORD_WGS84);
|
|
|
|
|
@@ -172,15 +178,14 @@ public class RasterController {
|
|
|
|
|
|
@ApiOperation("获取栅格数据列表")
|
|
|
@PostMapping(value = "list")
|
|
|
- public R list(@RequestBody PageDto param, HttpServletRequest req){
|
|
|
+ public R list(@RequestBody PageDto param, HttpServletRequest req) {
|
|
|
String token = req.getHeader("Authorization");
|
|
|
Page<OutputFileEntity> page = rasterServer.findByList(TypeCode.FILE_TYPE_RASTER, param, token);
|
|
|
return new R(200, page);
|
|
|
// return rasterServer.findByType(TypeCode.FILE_TYPE_RASTER, param);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ @ApiImplicitParam(name = "fileId", value = "文件id", required = true)
|
|
|
@ApiOperation("删除文件")
|
|
|
@GetMapping("delete/{fileId}/")
|
|
|
public R deleteFile(@PathVariable("fileId") Long fileId) {
|
|
@@ -200,10 +205,7 @@ public class RasterController {
|
|
|
return new R(200, MsgCode.SUCCESS);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ @ApiImplicitParam(name = "fileId", value = "文件id", required = true)
|
|
|
@ApiOperation("栅格数据判断坐标")
|
|
|
@GetMapping("command/judge/coord/{fileId}/")
|
|
|
public R cmdJudgeCoord(@PathVariable("fileId") Long fileId) {
|
|
@@ -218,7 +220,6 @@ public class RasterController {
|
|
|
log.info("cmd: {}", cmd);
|
|
|
|
|
|
|
|
|
-
|
|
|
// 把数据放入队列中
|
|
|
boolean offer = false;
|
|
|
try {
|
|
@@ -234,7 +235,7 @@ public class RasterController {
|
|
|
entity.setStatus(9);
|
|
|
entity.setUpdateTime(new Date());
|
|
|
entity = rasterServer.save(entity);
|
|
|
- log.info("coord entity: {}",entity);
|
|
|
+ log.info("coord entity: {}", entity);
|
|
|
log.info("coord producer update time: {}", entity.getUpdateTime());
|
|
|
|
|
|
asyncTask.rasterJudgeCoordConsumerThread(coordQueue, rasterServer, OUTPUT_FILE_PATH, entity);
|
|
@@ -245,17 +246,21 @@ public class RasterController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "fileId", value = "文件id", required = true),
|
|
|
+ @ApiImplicitParam(name = "layerMin", value = "图片级别(最小值)", required = true),
|
|
|
+ @ApiImplicitParam(name = "layerMax", value = "图片级别(最大值)", required = true)
|
|
|
+ })
|
|
|
@ApiOperation("栅格数据切片命令")
|
|
|
@GetMapping("command/osgeo/{fileId}/{layerMin}/{layerMax}/")
|
|
|
public R cmdSlice(@PathVariable("fileId") Long fileId, @PathVariable("layerMin") String layerMin, @PathVariable("layerMax") String layerMax) {
|
|
|
log.info("run cmdSlice: {}", fileId);
|
|
|
|
|
|
- if (!RegexUtils.regexInt(layerMin)){
|
|
|
- return new R(50010, MsgCode.E50010) ;
|
|
|
+ if (!RegexUtils.regexInt(layerMin)) {
|
|
|
+ return new R(50010, MsgCode.E50010);
|
|
|
}
|
|
|
- if (!RegexUtils.regexInt(layerMax)){
|
|
|
- return new R(50010, MsgCode.E50010) ;
|
|
|
+ if (!RegexUtils.regexInt(layerMax)) {
|
|
|
+ return new R(50010, MsgCode.E50010);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -275,7 +280,6 @@ public class RasterController {
|
|
|
log.info("cmd: {}", cmd);
|
|
|
|
|
|
|
|
|
-
|
|
|
// 把数据放入队列中
|
|
|
boolean offer = false;
|
|
|
|
|
@@ -300,13 +304,12 @@ public class RasterController {
|
|
|
|
|
|
asyncTask.rasterSliceThread(sliceQueue, rasterServer, entity, cmd);
|
|
|
|
|
|
- return new R(200, entity) ;
|
|
|
+ return new R(200, entity);
|
|
|
}
|
|
|
return new R(52000, MsgCode.E52000);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ @ApiImplicitParam(name = "fileId", value = "文件id", required = true)
|
|
|
@ApiOperation("栅格数据进度查询")
|
|
|
@GetMapping("progress/{fileId}/")
|
|
|
public R getProgress(@PathVariable("fileId") Long fileId) {
|
|
@@ -314,6 +317,7 @@ public class RasterController {
|
|
|
return new R(200, entity);
|
|
|
}
|
|
|
|
|
|
+ @ApiImplicitParam(name = "fileId", value = "文件id", required = true)
|
|
|
@RequiresRoles("admin")
|
|
|
@ApiOperation("移动数据到服务器上")
|
|
|
@PostMapping("move/{fileId}/")
|