| | |
| | | package com.se.nsl.controller; |
| | | |
| | | import com.se.nsl.config.PropertiesConfig; |
| | | import com.se.nsl.domain.po.DataPo; |
| | | import com.se.nsl.domain.po.Region; |
| | | import com.se.nsl.domain.vo.R; |
| | |
| | | import com.se.nsl.helper.StringHelper; |
| | | import com.se.nsl.mapper.RegionMapper; |
| | | import com.se.nsl.service.*; |
| | | import io.netty.util.internal.StringUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.axis.utils.StringUtils; |
| | | import org.gdal.ogr.*; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Api(tags = "Test") |
| | | @Api(tags = "01-Test") |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/test") |
| | |
| | | @Resource |
| | | RegionMapper regionMapper; |
| | | |
| | | @ApiOperation(value = "当前时间 *") |
| | | @GetMapping("/getTime") |
| | | public Object getTime() { |
| | | return (Object) System.currentTimeMillis(); |
| | | } |
| | | @Resource |
| | | PropertiesConfig config; |
| | | |
| | | @ApiOperation(value = "testCallExe *") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query", example = "20241010095328") |
| | | }) |
| | | @GetMapping("/testCallExe") |
| | | public R<Object> testCallExe(String path) { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | data.setInPath(path); |
| | | |
| | | String str = uwService.callExe(data); |
| | | |
| | | return success(str); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "testResuslt *") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query", example = "20241107092342"), |
| | | @ApiImplicitParam(name = "time", value = "时间", dataType = "String", paramType = "query", example = "2024-11-07 09:23:42") |
| | | }) |
| | | @GetMapping("/testResuslt") |
| | | public R<Object> testResuslt(String path, String time) { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | data.setEpsg(Integer.valueOf(4548)); |
| | | data.setInPath(path); |
| | | data.setStartTime(StringHelper.YMDHMS_FORMAT.parse(time)); |
| | | |
| | | resultService.process(data); |
| | | |
| | | return success("ok"); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "testSww2Tif *") |
| | | @GetMapping("/testSww2Tif") |
| | | public R<Object> testSww2Tif() { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | data.setEpsg(Integer.valueOf(4548)); |
| | | data.setInPath("20241010095328"); |
| | | data.setStartTime(StringHelper.YMDHMS_FORMAT.parse("2024-09-30 00:00:00")); |
| | | |
| | | Object rs = uwService.copeDrainFiles(data); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "testRainfall *") |
| | | @GetMapping("/testRainfall") |
| | | public R<Object> testRainfall() { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | data.setEpsg(Integer.valueOf(4548)); |
| | | data.setTotal(Double.valueOf(60.0)); |
| | | data.setDuration(Integer.valueOf(60)); |
| | | data.setInPath("20241010095328"); |
| | | data.setStartTime(StringHelper.YMDHMS_FORMAT.parse("2024-07-01 00:00:00")); |
| | | |
| | | uwService.createRainFile(data); |
| | | |
| | | return success("ok"); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "testToken *") |
| | | @GetMapping("/testToken") |
| | | public R<Object> testToken() { |
| | | try { |
| | | String token = gedbService.getToken(); |
| | | |
| | | return success(token); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "testPolygonize *") |
| | | @GetMapping("/testPolygonize") |
| | | public R<Object> testPolygonize() { |
| | | try { |
| | | ShpHelper.test(); |
| | | |
| | | return success("ok"); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "testH5 *") |
| | | @GetMapping("/testH5") |
| | | public R<Object> testH5() { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | data.setEpsg(Integer.valueOf(4548)); |
| | | data.setInPath("20241010095328"); |
| | | data.setStartTime(StringHelper.YMDHMS_FORMAT.parse("2024-09-30 00:00:00")); |
| | | |
| | | hdf5Service.test(data); |
| | | |
| | | return success("ok"); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "testNsl <") |
| | | @GetMapping("/testNsl") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "inPath", value = "输入路径", dataType = "String", paramType = "query", example = "20250412"), |
| | | @ApiImplicitParam(name = "startTime", value = "开始时间", dataType = "Integer", paramType = "query", example = "2025-04-12 00:00:00"), |
| | | @ApiImplicitParam(name = "epsg", value = "坐标系ID", dataType = "Integer", paramType = "query", example = "4548") |
| | | }) |
| | | public R<Object> testNsl(String inPath, String startTime, Integer epsg) { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | data.setInPath(inPath); |
| | | data.setStartTime(StringHelper.YMDHMS_FORMAT.parse(startTime)); |
| | | data.setEpsg(epsg); |
| | | |
| | | testService.test(data); |
| | | |
| | | return success("ok"); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "insertRegion <") |
| | | @ApiOperation(value = "01.insertRegion <") |
| | | @GetMapping("/insertRegion") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "fileName", value = "文件名", dataType = "String", paramType = "query", example = "5.beijing.geoJson"), |
| | | @ApiImplicitParam(name = "type", value = "类型", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | public R<Object> insertRegion(String fileName, Integer type) { |
| | | return insertNsl(fileName, type); |
| | | } |
| | | |
| | | private R<Object> insertNsl(String fileName, Integer type) { |
| | | // 孙胡沟geometry.json,7.nsl_area.geojson,4.10000.geoJson,5.beijing.geoJson |
| | | String path = "D:\\terrait\\NslServer\\data\\" + fileName; |
| | | if (!new File(path).exists()) return fail(path + ",文件不存在", null); |
| | |
| | | return success(list.size() > 0 ? regionMapper.inserts(list) : 0); |
| | | } |
| | | |
| | | @ApiOperation(value = "testDepthFiles <") |
| | | @ApiOperation(value = "02.testDepthFiles <") |
| | | @GetMapping("/testDepthFiles") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "oldPath", value = "输入路径", dataType = "String", paramType = "query", example = "D:\\other\\simu\\uwsolver\\chicago"), |
| | |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "testTifFiles <") |
| | | @ApiOperation(value = "03.testTifFiles <") |
| | | @GetMapping("/testTifFiles") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "oldPath", value = "输入路径", dataType = "String", paramType = "query", example = "D:\\other\\simu\\uwsolver\\chicago\\depth"), |
| | |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "testPngList <") |
| | | @ApiOperation(value = "04.testPngList <") |
| | | @GetMapping("/testPngList") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query", example = "D:\\other\\simu\\out\\chicago\\waters"), |
| | |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "5.testNsl <") |
| | | @GetMapping("/testNsl") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "inPath", value = "输入路径", dataType = "String", paramType = "query", example = "20250412"), |
| | | @ApiImplicitParam(name = "startTime", value = "开始时间", dataType = "Integer", paramType = "query", example = "2025-04-12 00:00:00"), |
| | | @ApiImplicitParam(name = "epsg", value = "坐标系ID", dataType = "Integer", paramType = "query", example = "4548") |
| | | }) |
| | | public R<Object> testNsl(String inPath, String startTime, Integer epsg) { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | data.setInPath(inPath); |
| | | data.setStartTime(StringHelper.YMDHMS_FORMAT.parse(startTime)); |
| | | data.setEpsg(epsg); |
| | | |
| | | testService.test(data); |
| | | |
| | | return success("ok"); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "09.testCreateNsl <") |
| | | @GetMapping("/testCreateNsl") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "tifPath", value = "Tif路径", dataType = "String", paramType = "query", example = "D:\\other\\simu\\uwsolver\\chicago"), |
| | | @ApiImplicitParam(name = "inPath", value = "输入路径", dataType = "String", paramType = "query", example = "20250425"), |
| | | @ApiImplicitParam(name = "startTime", value = "开始时间", dataType = "Integer", paramType = "query", example = "2025-04-25 00:00:00"), |
| | | @ApiImplicitParam(name = "epsg", value = "坐标系ID", dataType = "Integer", paramType = "query", example = "4548") |
| | | }) |
| | | public R<Object> testCreateNsl(String tifPath, String inPath, String startTime, Integer epsg) { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | data.setInPath(inPath); |
| | | data.setStartTime(StringHelper.YMDHMS_FORMAT.parse(startTime)); |
| | | data.setEpsg(epsg); |
| | | |
| | | procTifs(tifPath, data.getStartTime()); |
| | | testService.test(data); |
| | | |
| | | return success("ok"); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | private void procTifs(String tifPath, Date startTime) { |
| | | if (StringUtils.isEmpty(tifPath)) return; |
| | | |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date(startTime.getYear() - 1900, startTime.getMonth() - 1, startTime.getDay(), 0, 0, 0)); |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | String newPath = config.getInPath() + File.separator + "depth"; |
| | | |
| | | for (File file : new File(tifPath).listFiles()) { |
| | | if (!file.exists() || !file.isDirectory()) continue; |
| | | |
| | | File tif = new File(tifPath + "\\" + file.getName() + File.separator + "depth.tif"); |
| | | if (!tif.exists() || tif.isDirectory()) continue; |
| | | |
| | | calendar.add(Calendar.SECOND, 1); |
| | | String newName = df.format(calendar.getTime()); |
| | | String newFile = newPath + File.separator + newName + ".tif"; |
| | | |
| | | System.out.println(newFile); |
| | | tif.renameTo(new File(newFile)); |
| | | file.delete(); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "10.当前时间 *") |
| | | @GetMapping("/getTime") |
| | | public Object getTime() { |
| | | return (Object) System.currentTimeMillis(); |
| | | } |
| | | |
| | | /*@ApiOperation(value = "12.testCallExe *") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query", example = "20241010095328") |
| | | }) |
| | | @GetMapping("/testCallExe") |
| | | public R<Object> testCallExe(String path) { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | data.setInPath(path); |
| | | |
| | | String str = uwService.callExe(data); |
| | | |
| | | return success(str); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "13.testResuslt *") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "path", value = "路径", dataType = "String", paramType = "query", example = "20241107092342"), |
| | | @ApiImplicitParam(name = "time", value = "时间", dataType = "String", paramType = "query", example = "2024-11-07 09:23:42") |
| | | }) |
| | | @GetMapping("/testResuslt") |
| | | public R<Object> testResuslt(String path, String time) { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | data.setEpsg(Integer.valueOf(4548)); |
| | | data.setInPath(path); |
| | | data.setStartTime(StringHelper.YMDHMS_FORMAT.parse(time)); |
| | | |
| | | resultService.process(data); |
| | | |
| | | return success("ok"); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "14.testSww2Tif *") |
| | | @GetMapping("/testSww2Tif") |
| | | public R<Object> testSww2Tif() { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | data.setEpsg(Integer.valueOf(4548)); |
| | | data.setInPath("20241010095328"); |
| | | data.setStartTime(StringHelper.YMDHMS_FORMAT.parse("2024-09-30 00:00:00")); |
| | | |
| | | Object rs = uwService.copeDrainFiles(data); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "15.testRainfall *") |
| | | @GetMapping("/testRainfall") |
| | | public R<Object> testRainfall() { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | data.setEpsg(Integer.valueOf(4548)); |
| | | data.setTotal(Double.valueOf(60.0)); |
| | | data.setDuration(Integer.valueOf(60)); |
| | | data.setInPath("20241010095328"); |
| | | data.setStartTime(StringHelper.YMDHMS_FORMAT.parse("2024-07-01 00:00:00")); |
| | | |
| | | uwService.createRainFile(data); |
| | | |
| | | return success("ok"); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "16.testToken *") |
| | | @GetMapping("/testToken") |
| | | public R<Object> testToken() { |
| | | try { |
| | | String token = gedbService.getToken(); |
| | | |
| | | return success(token); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "17.testPolygonize *") |
| | | @GetMapping("/testPolygonize") |
| | | public R<Object> testPolygonize() { |
| | | try { |
| | | ShpHelper.test(); |
| | | |
| | | return success("ok"); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "18.testH5 *") |
| | | @GetMapping("/testH5") |
| | | public R<Object> testH5() { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | data.setEpsg(Integer.valueOf(4548)); |
| | | data.setInPath("20241010095328"); |
| | | data.setStartTime(StringHelper.YMDHMS_FORMAT.parse("2024-09-30 00:00:00")); |
| | | |
| | | hdf5Service.test(data); |
| | | |
| | | return success("ok"); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | }*/ |
| | | } |