From bc5e5cd30efa1a06a56a958959874aba3e90034f Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期六, 15 七月 2023 21:02:41 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/controller/data/PublishController.java | 107 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 98 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 9ff5f52..c38880a 100644 --- a/src/main/java/com/lf/server/controller/data/PublishController.java +++ b/src/main/java/com/lf/server/controller/data/PublishController.java @@ -9,16 +9,18 @@ import com.lf.server.entity.sys.UserEntity; 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.PublishService; 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.util.Arrays; import java.util.List; /** @@ -29,11 +31,14 @@ @RestController @RequestMapping("/publish") public class PublishController extends BaseController { - @Autowired + @Resource PublishService publishService; - @Autowired + @Resource TokenService tokenService; + + @Resource + LayerService layerService; @SysLog() @ApiOperation(value = "鍒嗛〉鏌ヨ鍏冩暟鎹�") @@ -56,7 +61,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,19 +78,55 @@ /** * 鑾峰彇绫诲瀷 */ - 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')"; + 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() @@ -132,11 +173,36 @@ } @SysLog() + @ApiOperation(value = "鏌ヨLas鏂囦欢鍧愭爣绯籌D") + @ApiImplicitParams({ + @ApiImplicitParam(name = "ids", value = "鍏冩暟鎹甀D闆嗗悎", dataType = "Integer[]", paramType = "query", example = "10285, 10481, 10456, 10483") + }) + @GetMapping(value = "/selectLasCs") + public ResponseMsg<Object> selectLasCs(@RequestParam(value = "ids[]") 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 = "鎻掑叆鍙戝竷鏁版嵁") @ApiImplicitParams({ @ApiImplicitParam(name = "entity", value = "瀹炰綋绫�", dataType = "PubEntity", paramType = "body") }) - @PostMapping(value = "/insert", produces = "application/json; charset=UTF-8") + @PostMapping(value = "/insertForPub", produces = "application/json; charset=UTF-8") public ResponseMsg<Object> insertForPub(@RequestBody PubEntity entity, HttpServletRequest req) { try { if (null == entity || null == entity.getIds() || entity.getIds().isEmpty()) { @@ -154,6 +220,9 @@ String method = getConvertMethod(entity.getType()); long count = publishService.postForPub(entity, method, req); + if (count > 0) { + layerService.clearCache(); + } return success(count); } catch (Exception ex) { @@ -168,11 +237,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/ToLas"; + case "OSGB": + return "/Convert/ToOsgb"; default: throw new Exception("鏁版嵁绫诲瀷涓嶅尮閰�"); } @@ -184,13 +260,23 @@ @ApiImplicitParam(name = "ids", value = "ID鏁扮粍", dataType = "Integer", paramType = "query", allowMultiple = true, example = "1") }) @GetMapping(value = "/deletes") - public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids) { + public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids, HttpServletRequest req) { try { if (ids == null || ids.isEmpty()) { return fail("id鏁扮粍涓嶈兘涓虹┖", -1); } - int count = publishService.deletes(StringHelper.join(ids, ",")); + String strs = StringHelper.join(ids, ","); + List<PublishEntity> list = publishService.selectByIds(strs); + if (null == list || list.isEmpty()) { + return fail("娌℃湁鎵惧埌瑕佸垹闄ょ殑鏁版嵁", -1); + } + + publishService.deleteFiles(list); + int count = publishService.deletes(ids, req); + if (count > 0) { + layerService.clearCache(); + } return success(count); } catch (Exception ex) { @@ -213,6 +299,9 @@ } int count = publishService.update(entity); + if (count > 0) { + layerService.clearCache(); + } return success(count); } catch (Exception ex) { -- Gitblit v1.9.3