| | |
| | | package com.lf.server.controller.show; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.metadata.OrderItem; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.lf.server.aspect.SysLog; |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.annotation.SysLog; |
| | | import com.lf.server.controller.all.BaseQueryController; |
| | | import com.lf.server.entity.all.HttpStatus; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.all.StaticData; |
| | | import com.lf.server.entity.ctrl.DownloadTileEntity; |
| | | import com.lf.server.entity.ctrl.ShpRecordEntity; |
| | | import com.lf.server.entity.data.DownloadEntity; |
| | | 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.AesHelper; |
| | | import com.lf.server.helper.ClassHelper; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.mapper.all.GeomBaseMapper; |
| | | import com.lf.server.service.data.UploaderService; |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.service.all.BaseUploadService; |
| | | import com.lf.server.service.data.DownloadService; |
| | | import com.lf.server.service.data.PublishService; |
| | | import com.lf.server.service.show.InquiryService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | |
| | | @Api(tags = "综合展示\\查询") |
| | | @RestController |
| | | @RequestMapping("/inquiry") |
| | | public class InquiryController extends BaseController { |
| | | private final static int FOUR = 4; |
| | | |
| | | public class InquiryController extends BaseQueryController { |
| | | @Autowired |
| | | TokenService tokenService; |
| | | |
| | | @Autowired |
| | | UploaderService uploaderService; |
| | | BaseUploadService baseUploadService; |
| | | |
| | | @Autowired |
| | | InquiryService inquiryService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询记录数") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "映射名称", dataType = "String", paramType = "query", example = "dlgAgnp") |
| | | }) |
| | | @GetMapping({"/selectCount"}) |
| | | public ResponseMsg<Long> selectCount(String name) { |
| | | try { |
| | | if (StringHelper.isEmpty(name)) { |
| | | return fail("名称空间和实体名称不能为空", null); |
| | | } |
| | | |
| | | Object obj = ClassHelper.getBean(name.trim() + "Mapper"); |
| | | if (!(obj instanceof BaseMapper)) { |
| | | return fail("查询对象不存在", null); |
| | | } |
| | | |
| | | BaseMapper baseMapper = (BaseMapper) obj; |
| | | long count = baseMapper.selectCount(null); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "映射名称", dataType = "String", paramType = "query", example = "dlgAgnp"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1"), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10") |
| | | }) |
| | | @GetMapping(value = "/selectByPage") |
| | | public ResponseMsg<List<Object>> selectByPage(String name, Integer pageIndex, Integer pageSize) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | if (StringHelper.isEmpty(name)) { |
| | | return fail("名称空间和实体名称不能为空", null); |
| | | } |
| | | |
| | | Object obj = ClassHelper.getBean(name.trim() + "Mapper"); |
| | | if (!(obj instanceof BaseMapper)) { |
| | | return fail("查询对象不存在", null); |
| | | } |
| | | |
| | | BaseMapper baseMapper = (BaseMapper) obj; |
| | | Page<Object> page = new Page<>(pageIndex, pageSize); |
| | | page.addOrder(OrderItem.asc("gid")); |
| | | |
| | | IPage<Object> paged = baseMapper.selectPage(page, null); |
| | | |
| | | return success(paged.getTotal(), paged.getRecords()); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据ID查询WKT") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "映射名称", dataType = "String", paramType = "query", example = "dlgAgnp"), |
| | | @ApiImplicitParam(name = "gid", value = "GID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectWktById") |
| | | public ResponseMsg<String> selectWktById(String name, Integer gid) { |
| | | try { |
| | | if (StringHelper.isEmpty(name)) { |
| | | return fail("名称空间和实体名称不能为空", null); |
| | | } |
| | | |
| | | Object obj = ClassHelper.getBean(name.trim() + "Mapper"); |
| | | if (!(obj instanceof GeomBaseMapper)) { |
| | | return fail("查询对象不存在", null); |
| | | } |
| | | |
| | | GeomBaseMapper baseMapper = (GeomBaseMapper) obj; |
| | | String wkt = baseMapper.selectWktById(gid); |
| | | if (!StringHelper.isEmpty(wkt)) { |
| | | wkt = AesHelper.encrypt(wkt); |
| | | } |
| | | |
| | | return success(wkt); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | @Resource |
| | | PublishService publishService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "上传Shp文件读取第一条记录的WKT") |
| | |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | List<MetaFileEntity> list = uploaderService.uploadData(null, ue, req, res); |
| | | if (list.size() < FOUR) { |
| | | List<MetaFileEntity> list = baseUploadService.uploadData(null, null, false, req, res); |
| | | if (list == null || list.size() < StaticData.FOUR) { |
| | | return fail("没有找到已上传的数据或不完整", null); |
| | | } |
| | | |
| | |
| | | |
| | | return success(sr); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "下载瓦片") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "dt", value = "下载瓦片实体类", dataType = "DownloadTileEntity", paramType = "body") |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/downloadTiles") |
| | | public ResponseMsg<Object> downloadTiles(@RequestBody DownloadTileEntity dt, HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | if (null == dt || null == dt.getPubid() || StringHelper.isEmpty(dt.getPwd())) { |
| | | return fail("发布ID和密码不能为空"); |
| | | } |
| | | String err = dt.verifyCoords(); |
| | | if (null != err) { |
| | | return fail(err); |
| | | } |
| | | if (!DownloadService.decryptPwd(dt)) { |
| | | return fail("密码解密失败", null); |
| | | } |
| | | |
| | | PublishEntity pub = publishService.selectById(dt.getPubid()); |
| | | if (null == pub) { |
| | | return fail("发布数据不存在"); |
| | | } |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | String guid = inquiryService.zipTiles(dt, pub, ue); |
| | | if (null == guid) { |
| | | return fail("没有瓦片需要打包下载"); |
| | | } |
| | | |
| | | return success(guid); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "下载文件") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "guid", value = "文件GUID", dataType = "String", paramType = "query") |
| | | }) |
| | | @ResponseBody |
| | | @GetMapping(value = "/downloadFile") |
| | | public void downloadFile(String guid, HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | DownloadEntity de = downloadService.selectByGuid(guid); |
| | | if (null == de) { |
| | | WebHelper.writeInfo(HttpStatus.NOT_FOUND, "文件不存在", res); |
| | | return; |
| | | } |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | downlogService.updateInfos(ue, de, req); |
| | | |
| | | String filePath = downloadService.getDownloadFilePath(de); |
| | | WebHelper.download(filePath, de.getName(), res); |
| | | } catch (Exception ex) { |
| | | WebHelper.writeInfo(HttpStatus.ERROR, ex.getMessage(), res); |
| | | } |
| | | } |
| | | } |