| | |
| | | package com.lf.server.controller.show; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.lf.server.aspect.SysLog; |
| | | import com.lf.server.annotation.SysLog; |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.entity.all.HttpStatus; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.bd.DlgAgnpEntity; |
| | | import com.lf.server.entity.ctrl.ShpRecordEntity; |
| | | import com.lf.server.entity.all.StaticData; |
| | | import com.lf.server.entity.ctrl.MarkJsonEntity; |
| | | import com.lf.server.entity.data.DownloadEntity; |
| | | import com.lf.server.entity.data.MetaFileEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.service.data.UploaderService; |
| | | import com.lf.server.service.show.ComprehensiveService; |
| | | import com.lf.server.helper.PathHelper; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.mapper.show.MarkMapper; |
| | | import com.lf.server.service.all.BaseQueryService; |
| | | import com.lf.server.service.all.BaseUploadService; |
| | | import com.lf.server.service.data.DownloadService; |
| | | import com.lf.server.service.show.MarkService; |
| | | import com.lf.server.service.sys.DownlogService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | |
| | | @RequestMapping("/comprehensive") |
| | | public class ComprehensiveController extends BaseController { |
| | | @Autowired |
| | | BaseQueryService baseQueryService; |
| | | |
| | | @Autowired |
| | | MarkService markService; |
| | | |
| | | @Autowired |
| | | TokenService tokenService; |
| | | |
| | | @Autowired |
| | | UploaderService uploaderService; |
| | | BaseUploadService baseUploadService; |
| | | |
| | | @Autowired |
| | | ComprehensiveService comprehensiveService; |
| | | DownlogService downlogService; |
| | | |
| | | private final static int FOUR = 4; |
| | | @Autowired |
| | | DownloadService downloadService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询并返回记录数-地名地址") |
| | | @ApiOperation(value = "查询路网") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "多"), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | @ApiImplicitParam(name = "x1", value = "X1", dataType = "Double", paramType = "query", example = "116.78999"), |
| | | @ApiImplicitParam(name = "y1", value = "Y1", dataType = "Double", paramType = "query", example = "39.9468"), |
| | | @ApiImplicitParam(name = "x2", value = "X2", dataType = "Double", paramType = "query", example = "116.80458"), |
| | | @ApiImplicitParam(name = "y2", value = "Y2", dataType = "Double", paramType = "query", example = "39.94758") |
| | | }) |
| | | @GetMapping(value = "/selectAddrByPage") |
| | | public ResponseMsg<List<DlgAgnpEntity>> selectAddrByPage(String name, Integer pageSize, Integer pageIndex) { |
| | | @GetMapping(value = "/selectRoute") |
| | | public ResponseMsg<Object> selectRoute(double x1, double y1, double x2, double y2) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | String route = baseQueryService.selectRoute(x1, y1, x2, y2); |
| | | |
| | | Page<DlgAgnpEntity> paged = comprehensiveService.selectAddrByPage(name, pageSize, pageIndex); |
| | | |
| | | return success(paged.getTotal(), paged.getRecords()); |
| | | return success(route); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据ID查询WKT-地名地址") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectWktById") |
| | | public ResponseMsg<String> selectWktById(Integer id) { |
| | | try { |
| | | String wkt = comprehensiveService.selectWktById(id); |
| | | |
| | | return success(wkt); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "上传Shp文件获取第一条记录的WKT") |
| | | @ApiOperation(value = "上传ShapeFile文件") |
| | | @ResponseBody |
| | | @PostMapping(value = "/uploadShp") |
| | | public ResponseMsg<ShpRecordEntity> uploadShp(HttpServletRequest req, HttpServletResponse res) { |
| | | @PostMapping(value = "/uploadShp", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Object> uploadShp(HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return fail("用户未登录", null); |
| | | } |
| | | |
| | | List<MetaFileEntity> list = uploaderService.uploadData(null, ue, req, res); |
| | | if (list.size() < FOUR) { |
| | | List<MetaFileEntity> meList = baseUploadService.uploadData(null, null, false, req, res); |
| | | if (meList == null || meList.size() < StaticData.FOUR) { |
| | | return fail("没有找到已上传的数据或不完整", null); |
| | | } |
| | | |
| | | ShpRecordEntity sr = comprehensiveService.readShpFirstRecord(list); |
| | | return success(sr); |
| | | List<MarkJsonEntity> list = markService.readShpForMarks(meList); |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "下载ShapeFile文件") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "list", value = "标绘JSON实体类集合", dataType = "MarkJsonEntity", paramType = "body") |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/downloadShp", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<String> downloadShp(@RequestBody List<MarkJsonEntity> list, HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | return fail("用户未登录", null); |
| | | } |
| | | if (list == null || list.isEmpty()) { |
| | | return fail("找不到标绘数据", null); |
| | | } |
| | | |
| | | String guid = markService.downloadShp(ue, list); |
| | | if (StringHelper.isNull(guid)) { |
| | | return fail("生成ShapeFile文件失败", null); |
| | | } |
| | | |
| | | return success(guid); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "下载文件") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "guid", value = "文件GUID", dataType = "String", paramType = "query") |
| | | }) |
| | | @RequestMapping(value = "/downloadFile", method = RequestMethod.GET) |
| | | public void downloadFile(String guid, HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | WebHelper.write2Page(res, WebHelper.getErrJson(HttpStatus.UNAUTHORIZED, "用户未登录")); |
| | | } |
| | | |
| | | DownloadEntity de = downloadService.selectByGuid(guid); |
| | | if (de == null) { |
| | | WebHelper.write2Page(res, WebHelper.getErrJson(HttpStatus.NOT_FOUND, "文件不存在")); |
| | | } |
| | | |
| | | downlogService.updateInfos(ue, de, req); |
| | | |
| | | String filePath = markService.getDownloadFilePath(de); |
| | | WebHelper.download(filePath, de.getName(), res); |
| | | } catch (Exception ex) { |
| | | try { |
| | | WebHelper.write2Page(res, WebHelper.getErrJson(HttpStatus.UNAUTHORIZED, ex.getMessage())); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | } |
| | | } |