管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-07-14 ac20dc99bf1f463365dba071973e08fffbd294b4
src/main/java/com/lf/server/controller/data/PublishController.java
@@ -56,7 +56,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 +73,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()
@@ -136,8 +172,8 @@
    @ApiImplicitParams({
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "PubEntity", paramType = "body")
    })
    @PostMapping(value = "/insert", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> insertForPub(@RequestBody PubEntity entity, HttpServletRequest req) {
    @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()) {
                return fail("实体类为空或找不到元数据ID", 0);
@@ -153,7 +189,7 @@
            }
            String method = getConvertMethod(entity.getType());
            int count = publishService.postForPub(entity, method, req);
            long count = publishService.postForPub(entity, method, req);
            return success(count);
        } catch (Exception ex) {
@@ -167,12 +203,19 @@
    private String getConvertMethod(String type) throws Exception {
        switch (type) {
            case "DOM":
                return "Convert/ToTiles";
                return "/Convert/ToTiles";
            case "DEM":
                return "/Convert/ToTerra";
            case "MPT":
            case "3DML":
                return "Convert/ToSG";
            case "CPT":
                return "/Convert/ToSG";
            case "BIM":
                return "Convert/ToTileset";
                return "/Convert/ToTileset";
            case "LAS":
                return "/Convert/ToLas";
            case "OSGB":
                return "/Convert/ToOsgb";
            default:
                throw new Exception("数据类型不匹配");
        }
@@ -184,13 +227,20 @@
            @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);
            return success(count);
        } catch (Exception ex) {