月球大数据地理空间分析展示平台-【后端】-月球后台服务
1
13693261870
2024-11-11 fee67ca8a0760315047a52fc4101a8f4f80b7a7f
src/main/java/com/moon/server/controller/data/PublishController.java
@@ -8,9 +8,9 @@
import com.moon.server.entity.data.PublishEntity;
import com.moon.server.entity.sys.UserEntity;
import com.moon.server.helper.StringHelper;
import com.moon.server.helper.WebHelper;
import com.moon.server.service.all.PermsService;
import com.moon.server.service.data.PublishService;
import com.moon.server.service.data.ShuJianService;
import com.moon.server.service.sys.TokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -20,15 +20,12 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
 * 数据发布
 * @author WWW
 */
@Api(tags = "数据管理\\发布管理")
@RestController
@SuppressWarnings("ALL")
@RequestMapping("/publish")
public class PublishController extends BaseController {
    @Resource
@@ -39,6 +36,9 @@
    @Resource
    PermsService permsService;
    @Resource
    ShuJianService shuJianService;
    @SysLog()
    @ApiOperation(value = "分页查询元数据")
@@ -61,7 +61,7 @@
                return fail("数据类别为空", null);
            }
            String types = getType(dircode, type);
            String types = getType(type);
            int count = publishService.selectMetasByCount(depcode, dircode, verid, types, name);
            if (count == 0) {
                return success(0, null);
@@ -75,58 +75,19 @@
        }
    }
    /**
     * 获取类型
     */
    private String getType(String dircode, String type) throws Exception {
    private String getType(String type) throws Exception {
        switch (type) {
            case "DOM":
                return "type in ('tif', 'tiff', 'img')" + getFilter(dircode, type);
                return "type in ('tif', 'tiff', 'img', 'jp2', 'jpg') and mata_type in (1, 2, 3, 4, 5)";
            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'";
                return "type in ('tif', 'tiff', 'dem') and mata_type = 2";
            case "Vector":
                return "type in ('shp', 'gdb') and mata_type = 6";
            case "Model":
                return "type in ('ifc', 'gdb') and mata_type = 7";
            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()
@@ -159,33 +120,22 @@
        }
    }
    /**
     * 获取发布类型
     */
    private String getPubType(String type) {
    private String getPubType(String type) throws Exception {
        if (StringHelper.isEmpty(type)) {
            return null;
        }
        switch (type) {
            case "DOM":
                return "type = 'DOM'";
                return "a.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'";
                return "a.type = 'DEM'";
            case "Vector":
                return "a.type = 'Vector'";
            case "Model":
                return "a.type = 'Model'";
            default:
                return null;
                throw new Exception("数据类型不匹配");
        }
    }
@@ -206,105 +156,120 @@
    }
    @SysLog()
    @ApiOperation(value = "查询Las文件坐标系ID")
    @ApiOperation(value = "分页查询数简的颜色表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "元数据ID集合", dataType = "Integer[]", paramType = "query", example = "10483,10481,10456,10285")
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", example = "10"),
            @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "int", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectLasCs")
    public ResponseMsg<Object> selectLasCs(Integer[] ids, HttpServletRequest req) {
        try {
            if (null == ids || ids.length == 0) {
                return fail("元数据ID集合不能为空");
            }
    @GetMapping(value = "/selectSjColorTables")
    public void selectSjColorTables(int pageSize, int pageIndex, HttpServletRequest req, HttpServletResponse res) {
        pageIndex = Math.max(pageIndex, 1);
        pageSize = Math.max(pageSize, 5);
            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);
        }
        shuJianService.selectSjColorTables(pageSize, pageIndex, req, res);
    }
    @SysLog()
    @ApiOperation(value = "插入发布数据")
    @ApiOperation(value = "查询数简图层")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "port", value = "端口", dataType = "int", paramType = "query", example = "50001")
    })
    @GetMapping(value = "/selectSjLayers")
    public void selectSjLayers(Integer port, HttpServletRequest req, HttpServletResponse res) {
        shuJianService.selectSjLayers(port, req, res);
    }
    @SysLog()
    @ApiOperation(value = "查询数简任务状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "任务ID", dataType = "int", paramType = "query", example = "10008101")
    })
    @GetMapping(value = "/selectSjMissionStatus")
    public void selectSjMissionStatus(Integer id, HttpServletRequest req, HttpServletResponse res) {
        shuJianService.selectSjMissionStatus(id, req, res);
    }
    @SysLog()
    @ApiOperation(value = "插入数简服务")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "PubEntity", paramType = "body")
    })
    @PostMapping(value = "/insertForPub", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Object> insertForPub(@RequestBody PubEntity entity, HttpServletRequest req) {
    @ResponseBody
    @PostMapping(value = "/insertSjService", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Object> insertSjService(@RequestBody PubEntity entity, HttpServletRequest req, HttpServletResponse res) {
        try {
            if (null == entity || null == entity.getIds() || entity.getIds().isEmpty()) {
                return fail("实体类为空或找不到元数据ID", 0);
            }
            if (StringHelper.isEmpty(entity.getType())) {
                return fail("数据类别为空", null);
                return fail("发布类别为空", null);
            }
            if (!ShuJianService.TYPES.contains(entity.getType())) {
                return fail("发布类别不支持", null);
            }
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
            if (null != ue) {
                entity.setUserId(ue.getId());
                entity.setToken(WebHelper.getToken(req));
                entity.setDepcode(ue.getDepcode());
            }
            entity.setDefault();
            permsService.clearPermsCache();
            String method = getConvertMethod(entity.getType());
            long count = publishService.postForPub(entity, method, req);
            Integer rows = shuJianService.insertSjService(entity);
            return success(count);
            return success(rows);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    /**
     * 获取转换方法
     */
    private String getConvertMethod(String type) throws Exception {
        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("数据类型不匹配");
    @SysLog()
    @ApiOperation(value = "更新数简服务")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "PubEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/updateSjService", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Object> updateSjService(@RequestBody PubEntity entity, HttpServletRequest req, HttpServletResponse res) {
        try {
            if (null == entity || null == entity.getPubid()) {
                return fail("实体类为空或发布ID为空", 0);
            }
            if (StringHelper.isEmpty(entity.getType())) {
                return fail("发布类别为空", null);
            }
            UserEntity ue = tokenService.getCurrentUser(req);
            if (null != ue) {
                entity.setUserId(ue.getId());
                entity.setDepcode(ue.getDepcode());
            }
            entity.setDefault();
            permsService.clearPermsCache();
            Integer rows = shuJianService.updateSjService(entity);
            return success(rows);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "删除多条")
    @ApiOperation(value = "删除数简服务")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "ID数组", dataType = "Integer", paramType = "query", allowMultiple = true, example = "1")
    })
    @GetMapping(value = "/deletes")
    public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids, HttpServletRequest req) {
    @GetMapping(value = "/deletesSjServices")
    public ResponseMsg<Integer> deletesSjServices(@RequestParam List<Integer> ids) {
        try {
            if (ids == null || ids.isEmpty()) {
            if (null == ids || 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);
            }
            permsService.clearPermsCache();
            int count = publishService.deletes(ids, req);
            int count = shuJianService.deletesSjServices(ids);
            return success(count);
        } catch (Exception ex) {
@@ -325,6 +290,9 @@
            if (ue != null) {
                entity.setUpdateUser(ue.getId());
            }
            if (StringHelper.isEmpty(entity.getGeom())) {
                entity.setGeom("null");
            }
            permsService.clearPermsCache();
            int count = publishService.update(entity);
@@ -334,4 +302,31 @@
            return fail(ex.getMessage(), -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "更新数简图层的拉伸方式")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "PubEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/updateSjLayerStretch", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> updateSjLayerStretch(@RequestBody PubEntity entity, HttpServletRequest req) {
        try {
            if (null == entity || null == entity.getLayerId()) {
                return fail("实体类为空或图层ID为空", 0);
            }
            UserEntity ue = tokenService.getCurrentUser(req);
            if (null != ue) {
                entity.setUserId(ue.getId());
                entity.setDepcode(ue.getDepcode());
            }
            Integer rows = shuJianService.updateSjLayerStretch(entity);
            return success(rows);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
}