| | |
| | | import com.baomidou.mybatisplus.core.metadata.OrderItem; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.lf.server.annotation.SysLog; |
| | | import com.lf.server.entity.all.BaseGeoEntity; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.all.StaticData; |
| | | import com.lf.server.entity.ctrl.DownloadReqEntity; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParam(name = "wkt", value = "WKT(著名文本)", dataType = "String", paramType = "query", example = ""), |
| | | //@ApiImplicitParam(name = "srid", value = "空间引用标识符", dataType = "Integer", paramType = "query", example = "4326"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1"), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10") |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "hasGeom", value = "是/否包含空间信息", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPage") |
| | | @PostMapping(value = "/selectByPage") |
| | | public ResponseMsg<List<Object>> selectByPage(String name, String depcode, String dirs, String filter, String wkt, Integer pageIndex, Integer pageSize) { |
| | | public ResponseMsg<List<Object>> selectByPage(String name, String depcode, String dirs, String filter, String wkt, Integer pageIndex, Integer pageSize, Integer hasGeom) { |
| | | try { |
| | | BasicMapper baseMapper = ClassHelper.getBasicMapper(name); |
| | | if (baseMapper == null) { |
| | | if (null == baseMapper) { |
| | | return fail("查询对象不存在", null); |
| | | } |
| | | |
| | |
| | | wrapper.apply(dirs); |
| | | } |
| | | |
| | | boolean hasWkt = null != hasGeom && hasGeom > 0 && baseMapper instanceof GeomBaseMapper; |
| | | if (hasWkt) { |
| | | wrapper.select("ST_AsText(geom) as geom, *"); |
| | | } |
| | | |
| | | Page<Object> page = new Page<>(pageIndex, pageSize); |
| | | page.addOrder(OrderItem.desc("gid")); |
| | | IPage<Object> paged = baseMapper.selectPage(page, wrapper); |
| | | if (hasWkt && null != paged.getRecords()) { |
| | | copeWkt(paged.getRecords()); |
| | | } |
| | | |
| | | return success(paged.getTotal(), paged.getRecords()); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理WKT |
| | | */ |
| | | private void copeWkt(List<?> list) { |
| | | for (int i = 0, c = list.size(); i < c; i++) { |
| | | Object obj = list.get(i); |
| | | setWktEncrypt(obj); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置WKT加密 |
| | | */ |
| | | private void setWktEncrypt(Object obj) { |
| | | if (obj instanceof BaseGeoEntity) { |
| | | BaseGeoEntity entity = (BaseGeoEntity) obj; |
| | | if (StringHelper.isEmpty(entity.getGeom())) { |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | String wkt = AesHelper.encrypt(entity.getGeom()); |
| | | entity.setGeom(wkt); |
| | | } catch (Exception ex) { |
| | | entity.setGeom(null); |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | public ResponseMsg<String> selectWktById(String name, Integer gid) { |
| | | try { |
| | | GeomBaseMapper baseMapper = ClassHelper.getGeoBaseMapper(name); |
| | | if (baseMapper == null) { |
| | | return fail("查询对象不存在", null); |
| | | if (null == baseMapper) { |
| | | return fail("查询对象不存在或不是空间表", null); |
| | | } |
| | | |
| | | String tab = BaseQueryService.getTabName(baseMapper); |
| | | if (StringHelper.isNull(tab)) { |
| | | return fail("查询对象不存在", null); |
| | | return fail("查询对象的表名不存在", null); |
| | | } |
| | | |
| | | String wkt = baseMapper.selectWktById(tab, gid); |
| | |
| | | @GetMapping(value = "/selectByGid") |
| | | public ResponseMsg<Object> selectByGid(String name, int gid) { |
| | | try { |
| | | GeomBaseMapper baseMapper = ClassHelper.getGeoBaseMapper(name); |
| | | if (baseMapper == null) { |
| | | BasicMapper baseMapper = ClassHelper.getBasicMapper(name); |
| | | if (null == baseMapper) { |
| | | return fail("查询对象不存在", null); |
| | | } |
| | | |
| | | QueryWrapper wrapper = new QueryWrapper(); |
| | | wrapper.select("ST_AsText(geom) as geom, *"); |
| | | if (baseMapper instanceof GeomBaseMapper) { |
| | | wrapper.select("ST_AsText(geom) as geom, *"); |
| | | } |
| | | wrapper.eq("gid", gid); |
| | | |
| | | Object obj = baseMapper.selectOne(wrapper); |
| | | setWktEncrypt(obj); |
| | | |
| | | return success(null == obj ? 0 : 1, obj); |
| | | } catch (Exception ex) { |
| | |
| | | } |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (StaticData.ADMIN.equals(ue.getUid())) { |
| | | return success(new ArrayList<String>()); |
| | | } |
| | | |
| | | List<String> list = dataLibService.selectDbOverflowDep(ue, dr); |
| | | |
| | | return success(list); |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "请求DB数据下载") |
| | | @ApiOperation(value = "下载DB数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "dr", value = "请求下载实体", dataType = "DownloadReqEntity", paramType = "body") |
| | | }) |
| | |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | String guid = dataLibService.downloadDbReq(ue, dr); |
| | | |
| | | return success(guid); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "请求DB数据下载") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "dr", value = "请求下载实体", dataType = "DownloadReqEntity", paramType = "body") |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/downloadDbReq") |
| | | public ResponseMsg<Object> downloadDbReq(@RequestBody DownloadReqEntity dr, HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | if (null == dr || StringHelper.isEmpty(dr.getPwd())) { |
| | | return fail("密码不能为空"); |
| | | } |
| | | if (null == dr.getEntities() || dr.getEntities().isEmpty()) { |
| | | return fail("请选择要下载的实体名"); |
| | | } |
| | | dr.setWkt(AesHelper.decrypt(dr.getWkt())); |
| | | if (StringHelper.isEmpty(dr.getWkt())) { |
| | | return fail("请选择要下载的WKT范围"); |
| | | } |
| | | if (!DownloadService.decryptPwd(dr)) { |
| | | return fail("密码解密失败", null); |
| | | } |
| | | if (StringHelper.isPwdInvalid(dr.getPwd())) { |
| | | return fail("密码不符合要求"); |
| | | } |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | String guid = dataLibService.downloadDbReq(ue, dr); |
| | | |
| | | return success(guid); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "请求实体数据下载") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "dre", value = "请求下载实体", dataType = "DownloadReqEntity", paramType = "body") |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/downloadEntityReq") |
| | | public ResponseMsg<Object> downloadEntityReq(@RequestBody DownloadReqEntity dr, HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | if (null == dr || StringHelper.isEmpty(dr.getPwd())) { |
| | | return fail("密码不能为空"); |
| | | } |
| | | if (null == dr.getEntities() || dr.getEntities().isEmpty()) { |
| | | return fail("请选择要下载的实体名"); |
| | | } |
| | | if (!DownloadService.decryptPwd(dr)) { |
| | | return fail("密码解密失败", null); |
| | | } |
| | | if (StringHelper.isPwdInvalid(dr.getPwd())) { |
| | | return fail("密码不符合要求"); |
| | | } |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | String guid = dataLibService.downloadDbReq4Prop(ue, dr); |
| | | |
| | | return success(guid); |
| | | } catch (Exception ex) { |