DataController.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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. * 上传数据包
  27. *
  28. * @param file 前端传入的zip压缩包
  29. * @return
  30. */
  31. @PostMapping("/upload")
  32. public RequestResult upload(MultipartFile file) {
  33. try {
  34. return dataService.upload(file);
  35. } catch (Exception e) {
  36. e.printStackTrace();
  37. return RequestResult.error("失败", null);
  38. }
  39. }
  40. /**
  41. * 导入数据 file/path 二选一 入库到spatialite
  42. *
  43. * @param file 前端传入的zip压缩包
  44. * @param path 前端选择的shp文件的位置
  45. * @return
  46. */
  47. @PostMapping("/import")
  48. public RequestResult importIn(MultipartFile file, String path, String type, String name, String ufield, String style) {
  49. try {
  50. return dataService.importIn(file, path, type, name, ufield, style);
  51. } catch (Exception e) {
  52. e.printStackTrace();
  53. return RequestResult.error("失败", null);
  54. }
  55. }
  56. /**
  57. * 获取shp文件字段集合
  58. *
  59. * @param path 前端选择的shp文件的位置
  60. * @return
  61. */
  62. @PostMapping("/getShpFields")
  63. public RequestResult getShpFields(String path) {
  64. try {
  65. return dataService.getShpFields(path);
  66. } catch (Exception e) {
  67. e.printStackTrace();
  68. return RequestResult.error("失败", null);
  69. }
  70. }
  71. /**
  72. * 查询模型列表
  73. *
  74. * @return
  75. */
  76. @RequestMapping("/modellist")
  77. public RequestResult modellist() {
  78. try {
  79. return dataService.modellist();
  80. } catch (Exception e) {
  81. e.printStackTrace();
  82. return RequestResult.error("失败", null);
  83. }
  84. }
  85. /**
  86. * 查询模型列表
  87. *
  88. * @return
  89. */
  90. @RequestMapping("/modeldetails")
  91. public RequestResult modeldetails(String modelname) {
  92. try {
  93. return dataService.modeldetails(modelname);
  94. } catch (Exception e) {
  95. e.printStackTrace();
  96. return RequestResult.error("失败", null);
  97. }
  98. }
  99. /**
  100. * 删除分析模型
  101. *
  102. * @return
  103. */
  104. @RequestMapping("/modeldelete")
  105. public RequestResult modeldelete(String modelname) {
  106. try {
  107. return dataService.modeldelete(modelname);
  108. } catch (Exception e) {
  109. e.printStackTrace();
  110. return RequestResult.error("失败", null);
  111. }
  112. }
  113. /**
  114. * 修改或新增模型
  115. *
  116. * @return
  117. */
  118. @RequestMapping("/modelupdate")
  119. public RequestResult modelupdate(HttpServletRequest request, HttpServletResponse response) {
  120. try {
  121. return dataService.modelupdate(request);
  122. } catch (Exception e) {
  123. e.printStackTrace();
  124. return RequestResult.error("失败", null);
  125. }
  126. }
  127. /**
  128. * 查询所有管控数据
  129. *
  130. * @return
  131. */
  132. @RequestMapping("/basevector")
  133. public RequestResult basevector() {
  134. try {
  135. return dataService.basevector();
  136. } catch (Exception e) {
  137. e.printStackTrace();
  138. return RequestResult.error("失败", null);
  139. }
  140. }
  141. /**
  142. * 删除指定管控数据
  143. *
  144. * @return
  145. */
  146. @RequestMapping("/basevectordelete")
  147. public RequestResult basevectordelete(String tablename) {
  148. try {
  149. return dataService.basevectordelete(tablename);
  150. } catch (Exception e) {
  151. e.printStackTrace();
  152. return RequestResult.error("失败", null);
  153. }
  154. }
  155. /**
  156. * 查询所有分析图斑数据列表
  157. *
  158. * @return
  159. */
  160. @RequestMapping("/analysevector")
  161. public RequestResult analysevector(String name) {
  162. try {
  163. return dataService.analysevector(name);
  164. } catch (Exception e) {
  165. e.printStackTrace();
  166. return RequestResult.error("失败", null);
  167. }
  168. }
  169. /**
  170. * 删除指定分析套合数据
  171. *
  172. * @return
  173. */
  174. @RequestMapping("/analysevectordelete")
  175. public RequestResult analysevectordelete(String tablename) {
  176. try {
  177. return dataService.analysevectordelete(tablename);
  178. } catch (Exception e) {
  179. e.printStackTrace();
  180. return RequestResult.error("失败", null);
  181. }
  182. }
  183. @GetMapping("/{tiftype}/{tableid}/{uuid}.{filetype}")
  184. public ResponseEntity<InputStreamResource> getTiff(@PathVariable("tiftype") String tiftype, @PathVariable("tableid") String tableid, @PathVariable("uuid") String uuid, @PathVariable("filetype") String filetype) {
  185. return dataService.getTiff(tiftype, tableid, uuid, filetype);
  186. }
  187. /**
  188. * 查询图斑前后时相影像地址
  189. *
  190. * @return
  191. */
  192. @RequestMapping("/getImageUrls")
  193. public RequestResult getImageUrls(String tableid, String uuid) {
  194. try {
  195. return dataService.getImageUrls(tableid, uuid);
  196. } catch (Exception e) {
  197. e.printStackTrace();
  198. return RequestResult.error("失败", null);
  199. }
  200. }
  201. /**
  202. * 获取空间表的全量空间数据
  203. *
  204. * @return
  205. */
  206. @RequestMapping("/getTableGeoms")
  207. public RequestResult getTableGeoms(String tablename) {
  208. try {
  209. return dataService.getTableGeoms(tablename);
  210. } catch (Exception e) {
  211. e.printStackTrace();
  212. return RequestResult.error("失败", null);
  213. }
  214. }
  215. /**
  216. * 根据swid获取空间表的属性信息
  217. *
  218. * @return
  219. */
  220. @RequestMapping("/getFeatureBySwid")
  221. public RequestResult getFeatureBySwid(String tablename, String swid) {
  222. try {
  223. return dataService.getFeatureBySwid(tablename, swid);
  224. } catch (Exception e) {
  225. e.printStackTrace();
  226. return RequestResult.error("失败", null);
  227. }
  228. }
  229. /**
  230. * 根据swid获取空间表的属性信息
  231. *
  232. * @return
  233. */
  234. @RequestMapping("/getTableRecord")
  235. public RequestResult getTableRecord(String tablename, Integer page, Integer limit) {
  236. try {
  237. return dataService.getTableRecord(tablename, page, limit);
  238. } catch (Exception e) {
  239. e.printStackTrace();
  240. return RequestResult.error("失败", null);
  241. }
  242. }
  243. /**
  244. * 获取地图配置
  245. *
  246. * @return
  247. */
  248. @RequestMapping("/getMapConfig")
  249. public RequestResult getMapConfig(String key) {
  250. try {
  251. return dataService.getMapConfig(key);
  252. } catch (Exception e) {
  253. e.printStackTrace();
  254. return RequestResult.error("失败", null);
  255. }
  256. }
  257. /**
  258. * 获取地图服务器信息
  259. *
  260. * @return
  261. */
  262. @RequestMapping("/getServerConfig")
  263. public RequestResult getServerConfig(String key) {
  264. try {
  265. return dataService.getServerConfig(key);
  266. } catch (Exception e) {
  267. e.printStackTrace();
  268. return RequestResult.error("失败", null);
  269. }
  270. }
  271. /**
  272. * 获取地图样式集合
  273. *
  274. * @return
  275. */
  276. @RequestMapping("/getGeoServerStyles")
  277. public RequestResult getGeoServerStyles() {
  278. try {
  279. return dataService.getGeoServerStyles();
  280. } catch (Exception e) {
  281. e.printStackTrace();
  282. return RequestResult.error("失败", null);
  283. }
  284. }
  285. /**
  286. * 修改地图配置
  287. *
  288. * @return
  289. */
  290. @RequestMapping("/updateMapConfig")
  291. public RequestResult updateMapConfig(HttpServletRequest request, HttpServletResponse response) {
  292. try {
  293. return dataService.updateMapConfig(request);
  294. } catch (Exception e) {
  295. e.printStackTrace();
  296. return RequestResult.error("失败", null);
  297. }
  298. }
  299. /**
  300. * 修改地图服务器信息
  301. *
  302. * @return
  303. */
  304. @RequestMapping("/updateServerConfig")
  305. public RequestResult updateServerConfig(HttpServletRequest request, HttpServletResponse response) {
  306. try {
  307. return dataService.updateServerConfig(request);
  308. } catch (Exception e) {
  309. e.printStackTrace();
  310. return RequestResult.error("失败", null);
  311. }
  312. }
  313. /**
  314. * 执行套合分析
  315. *
  316. * @return
  317. */
  318. @RequestMapping("/overlapAnalysis")
  319. public RequestResult overlapAnalysis(String modelname, String tablename) {
  320. try {
  321. return dataService.overlapAnalysis(modelname, tablename);
  322. } catch (Exception e) {
  323. e.printStackTrace();
  324. return RequestResult.error("失败", null);
  325. }
  326. }
  327. /**
  328. * 导出分析报告
  329. *
  330. * @return
  331. */
  332. @RequestMapping("/exportReport")
  333. public RequestResult exportReport(String modelname, String tablename, String layername, HttpServletRequest request, HttpServletResponse response) {
  334. try {
  335. return dataService.exportReport(modelname, tablename, layername, request, response);
  336. } catch (Exception e) {
  337. e.printStackTrace();
  338. return RequestResult.error("失败", null);
  339. }
  340. }
  341. /**
  342. * 生成套合分析成果包
  343. *
  344. * @return
  345. */
  346. @RequestMapping("/exportAchievementPackage")
  347. public RequestResult exportAchievementPackage(String tablename, String layername, HttpServletRequest request, HttpServletResponse response) {
  348. try {
  349. return dataService.exportAchievementPackage(tablename, layername, request, response);
  350. } catch (Exception e) {
  351. e.printStackTrace();
  352. return RequestResult.error("失败", null);
  353. }
  354. }
  355. /**
  356. * 获取分析结果--制作统计图
  357. *
  358. * @return
  359. */
  360. @RequestMapping("/getAnalyseResult")
  361. public RequestResult getAnalyseResult(String tablename) {
  362. try {
  363. return dataService.getAnalyseResult(tablename);
  364. } catch (Exception e) {
  365. e.printStackTrace();
  366. return RequestResult.error("失败", null);
  367. }
  368. }
  369. }