| | |
| | | import com.lf.server.aspect.SysLog; |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.bd.DlgAgnp; |
| | | import com.lf.server.entity.bd.DlgAgnpEntity; |
| | | import com.lf.server.entity.ctrl.ShpRecordEntity; |
| | | import com.lf.server.entity.data.MetaFileEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.AesHelper; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.service.data.UploaderService; |
| | | import com.lf.server.service.show.ComprehensiveService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @RequestMapping("/comprehensive") |
| | | public class ComprehensiveController extends BaseController { |
| | | @Autowired |
| | | TokenService tokenService; |
| | | |
| | | @Autowired |
| | | UploaderService uploaderService; |
| | | |
| | | @Autowired |
| | | ComprehensiveService comprehensiveService; |
| | | |
| | | private final static int FOUR = 4; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "分页查询并返回记录数-地名地址") |
| | |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectAddrByPage") |
| | | public ResponseMsg<List<DlgAgnp>> selectAddrByPage(String name, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<List<DlgAgnpEntity>> selectAddrByPage(String name, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | Page<DlgAgnp> paged = comprehensiveService.selectAddrByPage(name, pageSize, pageIndex); |
| | | Page<DlgAgnpEntity> paged = comprehensiveService.selectAddrByPage(name, pageSize, pageIndex); |
| | | |
| | | return success(paged.getTotal(), paged.getRecords()); |
| | | } catch (Exception ex) { |
| | |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "根据ID查询-地名地址") |
| | | @ApiOperation(value = "根据ID查询WKT-地名地址") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectAddrById") |
| | | public ResponseMsg<DlgAgnp> selectAddrById(Integer id) { |
| | | @GetMapping(value = "/selectWktById") |
| | | public ResponseMsg<String> selectWktById(Integer id) { |
| | | try { |
| | | DlgAgnp entity = comprehensiveService.selectAddrById(id); |
| | | String wkt = comprehensiveService.selectWktById(id); |
| | | |
| | | return success(entity); |
| | | return success(wkt); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "上传Shp文件获取第一条记录的WKT") |
| | | @ResponseBody |
| | | @PostMapping(value = "/uploadShp") |
| | | public ResponseMsg<ShpRecordEntity> 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) { |
| | | return fail("没有找到已上传的数据或不完整", null); |
| | | } |
| | | |
| | | ShpRecordEntity sr = comprehensiveService.readShpFirstRecord(list); |
| | | if (sr != null && !StringHelper.isEmpty(sr.getWkt())) { |
| | | sr.setWkt(AesHelper.encrypt(sr.getWkt())); |
| | | } |
| | | |
| | | return success(sr); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |