DataController.java 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. package com.onemap.overlap.controller;
  2. import cn.hutool.json.JSONObject;
  3. import com.onemap.common.core.web.domain.RequestResult;
  4. import com.onemap.overlap.service.DataService;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.core.io.InputStreamResource;
  7. import org.springframework.http.ResponseEntity;
  8. import org.springframework.web.bind.annotation.*;
  9. import org.springframework.web.multipart.MultipartFile;
  10. import javax.servlet.http.HttpServletRequest;
  11. import javax.servlet.http.HttpServletResponse;
  12. @RestController
  13. @RequestMapping("/data")
  14. public class DataController {
  15. @Autowired
  16. private DataService dataService;
  17. @RequestMapping("/start")
  18. public void start() {
  19. try {
  20. dataService.start();
  21. } catch (Exception e) {
  22. e.printStackTrace();
  23. }
  24. }
  25. /**
  26. * 导入数据 file/path 二选一 入库到spatialite
  27. *
  28. * @param file 前端传入的zip压缩包
  29. * @param path 前端选择的shp文件的位置
  30. * @return
  31. */
  32. @PostMapping("/import")
  33. public RequestResult importIn(MultipartFile file, String path, String type, String name, String ufield) {
  34. try {
  35. return dataService.importIn(file, path, type, name, ufield);
  36. } catch (Exception e) {
  37. e.printStackTrace();
  38. return RequestResult.error("失败", null);
  39. }
  40. }
  41. /**
  42. * 获取shp文件字段集合
  43. *
  44. * @param path 前端选择的shp文件的位置
  45. * @return
  46. */
  47. @PostMapping("/getShpFields")
  48. public RequestResult getShpFields(String path) {
  49. try {
  50. return dataService.getShpFields(path);
  51. } catch (Exception e) {
  52. e.printStackTrace();
  53. return RequestResult.error("失败", null);
  54. }
  55. }
  56. /**
  57. * 查询模型列表
  58. *
  59. * @return
  60. */
  61. @RequestMapping("/modellist")
  62. public RequestResult modellist() {
  63. try {
  64. return dataService.modellist();
  65. } catch (Exception e) {
  66. e.printStackTrace();
  67. return RequestResult.error("失败", null);
  68. }
  69. }
  70. /**
  71. * 查询模型列表
  72. *
  73. * @return
  74. */
  75. @RequestMapping("/modeldetails")
  76. public RequestResult modeldetails(String modelname) {
  77. try {
  78. return dataService.modeldetails(modelname);
  79. } catch (Exception e) {
  80. e.printStackTrace();
  81. return RequestResult.error("失败", null);
  82. }
  83. }
  84. /**
  85. * 删除分析模型
  86. *
  87. * @return
  88. */
  89. @RequestMapping("/modeldelete")
  90. public RequestResult modeldelete(String modelname) {
  91. try {
  92. return dataService.modeldelete(modelname);
  93. } catch (Exception e) {
  94. e.printStackTrace();
  95. return RequestResult.error("失败", null);
  96. }
  97. }
  98. /**
  99. * 修改或新增模型
  100. *
  101. * @return
  102. */
  103. @RequestMapping("/modelupdate")
  104. public RequestResult modelupdate(HttpServletRequest request, HttpServletResponse response) {
  105. try {
  106. return dataService.modelupdate(request);
  107. } catch (Exception e) {
  108. e.printStackTrace();
  109. return RequestResult.error("失败", null);
  110. }
  111. }
  112. /**
  113. * 查询所有管控数据
  114. *
  115. * @return
  116. */
  117. @RequestMapping("/basevector")
  118. public RequestResult basevector() {
  119. try {
  120. return dataService.basevector();
  121. } catch (Exception e) {
  122. e.printStackTrace();
  123. return RequestResult.error("失败", null);
  124. }
  125. }
  126. /**
  127. * 删除指定管控数据
  128. *
  129. * @return
  130. */
  131. @RequestMapping("/basevectordelete")
  132. public RequestResult basevectordelete(String tablename) {
  133. try {
  134. return dataService.basevectordelete(tablename);
  135. } catch (Exception e) {
  136. e.printStackTrace();
  137. return RequestResult.error("失败", null);
  138. }
  139. }
  140. /**
  141. * 查询所有分析图斑数据列表
  142. *
  143. * @return
  144. */
  145. @RequestMapping("/analysevector")
  146. public RequestResult analysevector() {
  147. try {
  148. return dataService.analysevector();
  149. } catch (Exception e) {
  150. e.printStackTrace();
  151. return RequestResult.error("失败", null);
  152. }
  153. }
  154. @GetMapping("/{tiftype}/{tableid}/{uuid}.{filetype}")
  155. public ResponseEntity<InputStreamResource> getTiff(@PathVariable("tiftype") String tiftype, @PathVariable("tableid") String tableid, @PathVariable("uuid") String uuid, @PathVariable("filetype") String filetype) {
  156. return dataService.getTiff(tiftype, tableid, uuid, filetype);
  157. }
  158. /**
  159. * 查询图斑前后时相影像地址
  160. *
  161. * @return
  162. */
  163. @RequestMapping("/getImageUrls")
  164. public RequestResult getImageUrls(String tableid, String uuid) {
  165. try {
  166. return dataService.getImageUrls(tableid, uuid);
  167. } catch (Exception e) {
  168. e.printStackTrace();
  169. return RequestResult.error("失败", null);
  170. }
  171. }
  172. /**
  173. * 获取空间表的全量空间数据
  174. *
  175. * @return
  176. */
  177. @RequestMapping("/getTableGeoms")
  178. public RequestResult getTableGeoms(String tablename) {
  179. try {
  180. return dataService.getTableGeoms(tablename);
  181. } catch (Exception e) {
  182. e.printStackTrace();
  183. return RequestResult.error("失败", null);
  184. }
  185. }
  186. /**
  187. * 根据swid获取空间表的属性信息
  188. *
  189. * @return
  190. */
  191. @RequestMapping("/getFeatureBySwid")
  192. public RequestResult getFeatureBySwid(String tablename, String swid) {
  193. try {
  194. return dataService.getFeatureBySwid(tablename, swid);
  195. } catch (Exception e) {
  196. e.printStackTrace();
  197. return RequestResult.error("失败", null);
  198. }
  199. }
  200. /**
  201. * 根据swid获取空间表的属性信息
  202. *
  203. * @return
  204. */
  205. @RequestMapping("/getTableRecord")
  206. public RequestResult getTableRecord(String tablename, Integer page, Integer limit) {
  207. try {
  208. return dataService.getTableRecord(tablename, page, limit);
  209. } catch (Exception e) {
  210. e.printStackTrace();
  211. return RequestResult.error("失败", null);
  212. }
  213. }
  214. }