From 9e80b0e01501851a2e37d3612d6f0fc03f58ce8d Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 20 九月 2023 16:50:03 +0800 Subject: [PATCH] 添加proj4j坐标转换接口 --- src/main/java/com/lf/server/controller/data/PublishController.java | 215 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 206 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/lf/server/controller/data/PublishController.java b/src/main/java/com/lf/server/controller/data/PublishController.java index 0393871..78b2bc0 100644 --- a/src/main/java/com/lf/server/controller/data/PublishController.java +++ b/src/main/java/com/lf/server/controller/data/PublishController.java @@ -3,22 +3,31 @@ import com.lf.server.annotation.SysLog; import com.lf.server.controller.all.BaseController; import com.lf.server.entity.all.ResponseMsg; +import com.lf.server.entity.all.StaticData; import com.lf.server.entity.ctrl.PubEntity; import com.lf.server.entity.data.MetaEntity; +import com.lf.server.entity.data.MetaFileEntity; import com.lf.server.entity.data.PublishEntity; import com.lf.server.entity.sys.UserEntity; +import com.lf.server.helper.PathHelper; import com.lf.server.helper.StringHelper; import com.lf.server.helper.WebHelper; +import com.lf.server.service.data.LayerService; +import com.lf.server.service.data.MetaService; import com.lf.server.service.data.PublishService; +import com.lf.server.service.data.RasterService; import com.lf.server.service.sys.TokenService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -29,11 +38,23 @@ @RestController @RequestMapping("/publish") public class PublishController extends BaseController { - @Autowired + @Resource PublishService publishService; - @Autowired + @Resource TokenService tokenService; + + @Resource + LayerService layerService; + + @Resource + MetaService metaService; + + @Resource + RasterService rasterService; + + @Resource + PathHelper pathHelper; @SysLog() @ApiOperation(value = "鍒嗛〉鏌ヨ鍏冩暟鎹�") @@ -56,7 +77,7 @@ return fail("鏁版嵁绫诲埆涓虹┖", null); } - String types = getType(type); + String types = getType(dircode, type); int count = publishService.selectMetasByCount(depcode, dircode, verid, types, name); if (count == 0) { return success(0, null); @@ -73,45 +94,114 @@ /** * 鑾峰彇绫诲瀷 */ - private String getType(String type) throws Exception { + private String getType(String dircode, String type) throws Exception { switch (type) { case "DOM": - return "type in ('tif', 'tiff', 'img', 'png', 'jpg')"; + return "type in ('tif', 'tiff', 'img')" + getFilter(dircode, type); + case "DEM": + return "type in ('tif', 'tiff')" + getFilter(dircode, type); case "MPT": return "type = 'mpt'"; case "3DML": return "type = '3dml'"; + case "CPT": + return "type = 'cpt'"; case "BIM": return "type in ('ifc', 'fbx', 'rvt')"; + case "LAS": + return "type in ('las', 'laz')"; + case "OSGB": + return "type = 'osgb'"; default: throw new Exception("鏁版嵁绫诲瀷涓嶅尮閰�"); } + } + + /** + * 鑾峰彇杩囨护鏉′欢 + */ + private String getFilter(String dircode, String type) { + dircode = StringHelper.isEmpty(dircode) ? "" : StringHelper.getRightLike(dircode); + + List<String> list = null; + switch (type) { + case "DOM": + list = publishService.selectCodesForDir(dircode, 0); + break; + case "DEM": + list = publishService.selectCodesForDir(dircode, 1); + break; + default: + break; + } + if (null == list || list.isEmpty()) { + return ""; + } + + for (int i = 0, c = list.size(); i < c; i++) { + list.set(i, "'" + list.get(i) + "'"); + } + + return " and dircode not in (" + StringHelper.join(list, ",") + ")"; } @SysLog() @ApiOperation(value = "鍒嗛〉鏌ヨ骞惰繑鍥炶褰曟暟") @ApiImplicitParams({ @ApiImplicitParam(name = "name", value = "鍚嶇О", dataType = "String", paramType = "query", example = ""), + @ApiImplicitParam(name = "dircode", value = "鐩綍", dataType = "String", paramType = "query", example = ""), + @ApiImplicitParam(name = "type", value = "绫诲埆", dataType = "String", paramType = "query", example = ""), @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"), @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", dataType = "Integer", paramType = "query", example = "1") }) @GetMapping(value = "/selectByPageAndCount") - public ResponseMsg<List<PublishEntity>> selectByPageAndCount(String name, Integer pageSize, Integer pageIndex) { + public ResponseMsg<List<PublishEntity>> selectByPageAndCount(String name, String dircode, String type, Integer pageSize, Integer pageIndex) { try { if (pageSize < 1 || pageIndex < 1) { return fail("姣忛〉椤垫暟鎴栧垎椤垫暟灏忎簬1", null); } + type = getPubType(type); - int count = publishService.selectCount(name); + int count = publishService.selectCount(name, dircode, type); if (count == 0) { return success(0, null); } - List<PublishEntity> rs = publishService.selectByPage(name, pageSize, pageSize * (pageIndex - 1)); + List<PublishEntity> rs = publishService.selectByPage(name, dircode, type, pageSize, pageSize * (pageIndex - 1)); return success(count, rs); } catch (Exception ex) { return fail(ex.getMessage(), null); + } + } + + /** + * 鑾峰彇鍙戝竷绫诲瀷 + */ + private String getPubType(String type) { + if (StringHelper.isEmpty(type)) { + return null; + } + + switch (type) { + case "DOM": + return "type = 'DOM'"; + case "DEM": + return "type = 'DEM'"; + case "MPT": + return "type = 'mpt'"; + case "3DML": + return "type = '3dml'"; + case "CPT": + return "type = 'cpt'"; + case "BIM": + return "type in ('ifc', 'fbx', 'rvt')"; + case "LAS": + return "type in ('las', 'laz')"; + case "OSGB": + return "type = 'osgb'"; + default: + return null; } } @@ -128,6 +218,94 @@ return success(entity); } catch (Exception ex) { return fail(ex.getMessage(), null); + } + } + + @SysLog() + @ApiOperation(value = "鏌ヨLas鏂囦欢鍧愭爣绯籌D") + @ApiImplicitParams({ + @ApiImplicitParam(name = "ids", value = "鍏冩暟鎹甀D闆嗗悎", dataType = "Integer[]", paramType = "query", example = "10483,10481,10456,10285") + }) + @GetMapping(value = "/selectLasCs") + public ResponseMsg<Object> selectLasCs(Integer[] ids, HttpServletRequest req) { + try { + if (null == ids || ids.length == 0) { + return fail("鍏冩暟鎹甀D闆嗗悎涓嶈兘涓虹┖"); + } + + PubEntity entity = new PubEntity(); + entity.setIds(Arrays.asList(ids)); + entity.setDircode("00"); + entity.setToken(WebHelper.getToken(req)); + + List<Integer> list = publishService.selectLasCs(entity, "/Convert/ReadLasCs", req); + + return success(list); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } + } + + @SysLog() + @ApiOperation(value = "鏌ヨ鏍呮牸鏁版嵁鐨勫潗鏍囩郴ID") + @ApiImplicitParams({ + @ApiImplicitParam(name = "ids", value = "鍏冩暟鎹甀D闆嗗悎", dataType = "Integer[]", paramType = "query", example = "10531,10527,10526") + }) + @GetMapping(value = "/selectRasterCs") + public ResponseMsg<Object> selectRasterCs(Integer[] ids, HttpServletRequest req) { + try { + if (null == ids || ids.length == 0) { + return fail("鍏冩暟鎹甀D闆嗗悎涓嶈兘涓虹┖"); + } + + List<MetaEntity> list = metaService.selectByIds(StringHelper.join(Arrays.asList(ids), ",")); + if (null == list || list.isEmpty()) { + return fail("鏌ユ棤鏁版嵁"); + } + + String basePath = pathHelper.getConfig().getUploadPath() + File.separator; + List<MetaEntity> errList = new ArrayList<>(); + for (MetaEntity me : list) { + if (!StaticData.RASTER_EXT.contains("." + me.getType())) { + me.setBak("涓嶆槸鏍呮牸鏁版嵁"); + errList.add(me); + continue; + } + + String filePath = basePath + me.getPath(); + File f = new File(filePath); + if (!f.exists() || f.isDirectory()) { + me.setBak("鏂囦欢涓嶅瓨鍦�"); + errList.add(me); + continue; + } + + Integer epsg = rasterService.getRaterEpsg(filePath); + if (null == epsg || epsg < 1) { + me.setBak("鍧愭爣绯籌D鏃犳晥"); + errList.add(me); + } + } + + return success(errList.size(), errList); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } + } + + @SysLog() + @ApiOperation(value = "鏌ヨ鍧愭爣杞崲") + @ApiImplicitParams({ + @ApiImplicitParam(name = "x", value = "X鍧愭爣", dataType = "double", paramType = "query", example = "400925.079"), + @ApiImplicitParam(name = "y", value = "Y鍧愭爣", dataType = "double", paramType = "query", example = "2541768.173"), + @ApiImplicitParam(name = "epsg", value = "EPSG缂栫爜", dataType = "int", paramType = "query", example = "4548") + }) + @GetMapping(value = "/selectCsTransform") + public Object selectCsTransform(double x, double y, int epsg) { + try { + return rasterService.transformByProj4j(x, y, epsg); + } catch (Exception ex) { + return null; } } @@ -152,6 +330,7 @@ entity.setToken(WebHelper.getToken(req)); } + layerService.clearCache(); String method = getConvertMethod(entity.getType()); long count = publishService.postForPub(entity, method, req); @@ -168,11 +347,18 @@ switch (type) { case "DOM": return "/Convert/ToTiles"; + case "DEM": + return "/Convert/ToTerra"; case "MPT": case "3DML": + case "CPT": return "/Convert/ToSG"; case "BIM": return "/Convert/ToTileset"; + case "LAS": + return "/Convert/ToLasByPy"; + case "OSGB": + return "/Convert/ToOsgb"; default: throw new Exception("鏁版嵁绫诲瀷涓嶅尮閰�"); } @@ -189,6 +375,16 @@ if (ids == null || ids.isEmpty()) { return fail("id鏁扮粍涓嶈兘涓虹┖", -1); } + + String strs = StringHelper.join(ids, ","); + List<PublishEntity> list = publishService.selectByIds(strs); + if (null == list || list.isEmpty()) { + return fail("娌℃湁鎵惧埌瑕佸垹闄ょ殑鏁版嵁", -1); + } + + // publishService.deleteFiles(list) + layerService.clearCache(); + publishService.deleteFiles(ids, req); int count = publishService.deletes(ids, req); @@ -212,6 +408,7 @@ entity.setUpdateUser(ue.getId()); } + layerService.clearCache(); int count = publishService.update(entity); return success(count); -- Gitblit v1.9.3