From a06e2ee872f15d747069645243341bd81c36e236 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 17 七月 2024 09:42:45 +0800 Subject: [PATCH] 1 --- src/main/java/com/se/simu/helper/WebHelper.java | 328 ++++++++++++------------------------ /dev/null | 13 - src/main/java/com/se/simu/controller/WaterController.java | 15 - src/main/java/com/se/simu/SimuApplication.java | 9 src/main/java/com/se/simu/service/WaterService.java | 22 - pom.xml | 92 ---------- src/main/resources/application.yml | 22 - 7 files changed, 126 insertions(+), 375 deletions(-) diff --git a/pom.xml b/pom.xml index 2f3583f..b42b6f8 100644 --- a/pom.xml +++ b/pom.xml @@ -34,78 +34,11 @@ <artifactId>lombok</artifactId> <optional>true</optional> </dependency> - <!--aop--> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-aop</artifactId> - </dependency> - <!--mybatis-plus - <dependency> - <groupId>com.baomidou</groupId> - <artifactId>mybatis-plus-boot-starter</artifactId> - <version>3.5.7</version> - </dependency>--> - <!--redis--> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-data-redis</artifactId> - </dependency> - <!--postgresql - <dependency> - <groupId>org.postgresql</groupId> - <artifactId>postgresql</artifactId> - <scope>runtime</scope> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-pool2</artifactId> - </dependency>--> - <!--鏁村悎druid鏁版嵁婧� - <dependency> - <groupId>com.alibaba</groupId> - <artifactId>druid</artifactId> - <version>1.1.22</version> - </dependency> - <dependency> - <groupId>com.alibaba</groupId> - <artifactId>druid-spring-boot-starter</artifactId> - <version>1.1.22</version> - </dependency>--> - <!--test--> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-test</artifactId> - <version>3.3.1</version> - <scope>test</scope> - </dependency> - <!--text--> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-text</artifactId> - <version>1.12.0</version> - </dependency> <!--hutool--> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.8.29</version> - </dependency> - <!--httpclient--> - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpclient</artifactId> - </dependency> - <!--knife4j--> - <dependency> - <groupId>com.github.xiaoymin</groupId> - <artifactId>knife4j-spring-boot-starter</artifactId> - <version>3.0.3</version> - </dependency> - <!--fast-md5--> - <dependency> - <groupId>com.joyent.util</groupId> - <artifactId>fast-md5</artifactId> - <version>2.7.1</version> </dependency> <!--fastjson2--> <dependency> @@ -113,32 +46,7 @@ <artifactId>fastjson2</artifactId> <version>2.0.52</version> </dependency> - <!--gdal--> - <dependency> - <groupId>org.gdal</groupId> - <artifactId>gdal</artifactId> - <!--<version>3.9.0</version>--> - <version>3.2.0</version> - </dependency> </dependencies> - - <profiles> - <profile> - <id>dev</id> - <properties> - <activatedProperties>dev</activatedProperties> - </properties> - <activation> - <activeByDefault>true</activeByDefault> - </activation> - </profile> - <profile> - <id>prod</id> - <properties> - <activatedProperties>prod</activatedProperties> - </properties> - </profile> - </profiles> <build> <finalName>SimuServer</finalName> diff --git a/src/main/java/com/se/simu/SimuApplication.java b/src/main/java/com/se/simu/SimuApplication.java index 3d99701..0ce7a55 100644 --- a/src/main/java/com/se/simu/SimuApplication.java +++ b/src/main/java/com/se/simu/SimuApplication.java @@ -3,8 +3,6 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; /** * 鍚姩绋嬪簭绫� @@ -13,13 +11,8 @@ * @date 2024-07-16 */ @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}, scanBasePackages = {"com.se.simu"}) -public class SimuApplication extends SpringBootServletInitializer { +public class SimuApplication { public static void main(String[] args) { SpringApplication.run(SimuApplication.class, args); - } - - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder springApplicationBuilder) { - return springApplicationBuilder.sources(SimuApplication.class); } } diff --git a/src/main/java/com/se/simu/config/InitConfig.java b/src/main/java/com/se/simu/config/InitConfig.java deleted file mode 100644 index 491bb3e..0000000 --- a/src/main/java/com/se/simu/config/InitConfig.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.se.simu.config; - -import com.se.simu.helper.GdalHelper; -import com.se.simu.helper.WebHelper; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.ApplicationArguments; -import org.springframework.boot.ApplicationRunner; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; - -/** - * 鍒濆鍖栭厤缃被 - * - * @author WWW - * @date 2024-07-16 - */ -@Slf4j -@Component -public class InitConfig implements ApplicationRunner { - @Resource - Environment env; - - @Value("${server.port}") - String serverPort; - - @Value("${server.servlet.context-path}") - String contextPath; - - @Override - public void run(ApplicationArguments args) { - // noinspection AlibabaRemoveCommentedCode - try { - log.info("***************** 鍒濆鍖� GDAL *****************" + "\n"); - GdalHelper.init(env.getProperty("sys.path.gdal")); - - String path = null != contextPath && contextPath.length() > 1 ? contextPath : ""; - log.info("API鏂囨。:http://localhost:" + serverPort + path + "/doc.html"); - log.info("API鏂囨。:http://{}:{}{}/doc.html", WebHelper.getHostIp(), serverPort, path); - - log.info("***************** 绯荤粺鍚姩瀹屾瘯 *****************" + "\n"); - } catch (Exception ex) { - log.error(ex.getMessage(), ex); - } - } -} diff --git a/src/main/java/com/se/simu/config/Knife4jConfig.java b/src/main/java/com/se/simu/config/Knife4jConfig.java deleted file mode 100644 index 10fc70b..0000000 --- a/src/main/java/com/se/simu/config/Knife4jConfig.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.se.simu.config; - -import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; - -/** - * Knife4j閰嶇疆绫� - * - * @author WWW - * @date 2024-07-16 - */ -@Configuration -@EnableKnife4j -public class Knife4jConfig { - @Value("${server.port}") - String serverPort; - - @Value("${knife4j.enabled}") - private boolean enabled; - - @Value("${knife4j.pathMapping}") - private String pathMapping; - - @Value("${server.servlet.context-path}") - String contextPath; - - @Bean - public Docket createRestApi() { - return new Docket(new DocumentationType("openApi", "3.0")) - // 鏄惁鍚敤Swagger - .enable(enabled) - // 鐢ㄦ潵鍒涘缓璇PI鐨勫熀鏈俊鎭紝灞曠ず鍦ㄦ枃妗g殑椤甸潰涓紙鑷畾涔夊睍绀虹殑淇℃伅锛� - .apiInfo(apiInfo()) - // 鍒嗙粍鍚嶇О - .groupName("鏈嶅姟") - // 璁剧疆鍝簺鎺ュ彛鏆撮湶缁橲wagger灞曠ず - .select() - // 鎵弿鎵�鏈夋湁娉ㄨВ鐨刟pi锛岀敤杩欑鏂瑰紡鏇寸伒娲� - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - // 鎵弿鎸囧畾鍖呬腑鐨剆wagger娉ㄨВ - // .apis(RequestHandlerSelectors.basePackage("com.cn.project.tool.swagger")) - // 鎵弿鎵�鏈� .apis(RequestHandlerSelectors.any()) - .paths(PathSelectors.any()) - .build() - /* 璁剧疆瀹夊叏妯″紡锛宻wagger鍙互璁剧疆璁块棶token */ - // .securitySchemes(securitySchemes()) - .pathMapping(pathMapping); - } - - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - //鎻忚堪瀛楁鏀寔Markdown璇硶 - .description("鎺ュ彛鏂囨。") - .contact(new Contact("WuWeiwei", "http://127.0.0.1:" + serverPort + contextPath + "/doc.html", "252740454@qq.com")) - .version("1.0.0") - .title("鍐呮稘浠跨湡鏈嶅姟API鎺ュ彛鏂囨。") - .build(); - } -} diff --git a/src/main/java/com/se/simu/controller/WaterController.java b/src/main/java/com/se/simu/controller/WaterController.java index 32a55a3..c40b73b 100644 --- a/src/main/java/com/se/simu/controller/WaterController.java +++ b/src/main/java/com/se/simu/controller/WaterController.java @@ -1,11 +1,8 @@ package com.se.simu.controller; import com.se.simu.domain.LayerVo; -import com.se.simu.helper.StringHelper; import com.se.simu.helper.WebHelper; import com.se.simu.service.WaterService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; @@ -23,7 +20,6 @@ * @author WWW * @date 2024-07-16 */ -@Api(tags = "鍐呮稘绠$悊") @Slf4j @RestController @RequestMapping("/waterlogging") @@ -37,13 +33,11 @@ private final static long Y2000 = 949334400000L; - @ApiOperation(value = "鑾峰彇褰撳墠鏃堕棿") @GetMapping("/getTime") public Object getTime() { return System.currentTimeMillis(); } - @ApiOperation(value = "鑾峰彇鍏冩暟鎹俊鎭�") @GetMapping("/{serviceName}/layer.json") public void getLayer(@PathVariable String serviceName, HttpServletResponse res) { try { @@ -60,7 +54,6 @@ } } - @ApiOperation(value = "鑾峰彇鍦板舰楂樺害鍥�") @GetMapping("/{serviceName}/terrain") public void getTerraMap(@PathVariable String serviceName, Integer width, Integer height, HttpServletResponse res) { try { @@ -76,7 +69,6 @@ } } - @ApiOperation(value = "鑾峰彇姘撮潰楂樺害鍥�") @GetMapping("/{serviceName}/waterMap") public void getWaterMap(@PathVariable String serviceName, Integer width, Integer height, Long timestamp, HttpServletResponse res) { try { @@ -92,7 +84,6 @@ } } - @ApiOperation(value = "鑾峰彇姘存祦鍚戞祦閫熷浘") @GetMapping("/{serviceName}/flowMap") public void getFlowMap(@PathVariable String serviceName, Integer width, Integer height, Long timestamp, HttpServletResponse res) { try { @@ -109,7 +100,7 @@ } private boolean validate(String serviceName, HttpServletResponse res) { - if (StringHelper.isEmpty(serviceName)) { + if (WebHelper.isEmpty(serviceName)) { return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "鏈嶅姟鍚嶄笉鑳戒负绌�"); } @@ -124,7 +115,7 @@ * 楠岃瘉 */ private boolean validate(String serviceName, Integer width, Integer height, Long timestamp, HttpServletResponse res) { - if (StringHelper.isEmpty(serviceName)) { + if (WebHelper.isEmpty(serviceName)) { return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "鏈嶅姟鍚嶄笉鑳戒负绌�"); } if (null == width || width < MIN_SIZE || width > MAX_SIZE) { @@ -144,7 +135,7 @@ * 鍐欐枃浠� */ private boolean writeFile(String path, HttpServletResponse res) throws Exception { - if (StringHelper.isEmpty(path)) { + if (WebHelper.isEmpty(path)) { return WebHelper.writeJson2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, "鐢熸垚PNG澶辫触"); } File file = new File(path); diff --git a/src/main/java/com/se/simu/helper/FileHelper.java b/src/main/java/com/se/simu/helper/FileHelper.java deleted file mode 100644 index 1b142a4..0000000 --- a/src/main/java/com/se/simu/helper/FileHelper.java +++ /dev/null @@ -1,444 +0,0 @@ -package com.se.simu.helper; - -import com.twmacinta.util.MD5; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.codec.digest.DigestUtils; - -import java.io.*; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.text.DecimalFormat; -import java.util.List; - -/** - * 鏂囦欢甯姪绫� - * - * @author WWW - * @date 2024-07-16 - */ -@Slf4j -public class FileHelper { - public final static String POINT = "."; - - public final static int I16 = 16; - - public static final double D1024 = 1024.0; - - public static final double D1050 = 1050.0; - - public final static int I1000000 = 1000000; - - public static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - - /** - * 鑾峰彇鏂囦欢鍚� - */ - public static String getFileName(String file) { - int idx = file.lastIndexOf(File.separator); - if (idx > -1) { - return file.substring(idx + 1); - } - - return ""; - } - - /** - * 鑾峰彇鏂囦欢鍚嶇О - */ - public static String getName(String file) { - String fileName = getFileName(file); - int idx = fileName.lastIndexOf("."); - if (idx > -1) { - return fileName.substring(0, idx); - } - - return fileName; - } - - /** - * 鑾峰彇鏂囦欢鎵╁睍鍚� - */ - public static String getExtension(File file) { - if (file == null) { - return null; - } - - String fileName = file.getName().toLowerCase(); - - int idx = fileName.indexOf(POINT); - if (idx == -1) { - return ""; - } - - return fileName.substring(idx); - } - - /** - * 鑾峰彇鏂囦欢鎵╁睍鍚� - */ - public static String getExtension(String fileName) { - if (StringHelper.isEmpty(fileName)) { - return ""; - } - - int idx = fileName.lastIndexOf(POINT); - if (idx == -1) { - return ""; - } - - return fileName.substring(idx).toLowerCase(); - } - - /** - * 鑾峰彇澶氱敤閫斾簰鑱旂綉閭欢鎵╁睍绫诲瀷 - */ - public static String getMime(String ext) { - switch (ext) { - // 鍥剧墖 - case ".tif": - case ".tiff": - return "image/tiff"; - case ".img": - return "application/x-img"; - case ".gif": - return "image/gif"; - case ".jpg": - case ".jpeg": - return "image/jpeg"; - case ".png": - return "image/png"; - // 闊�/瑙嗛 - case ".mp3": - return "audio/mp3"; - case ".mp4": - return "video/mpeg4"; - case ".avi": - return "video/avi"; - case ".mpg": - case ".mpeg": - return "video/mpg"; - case ".wav": - return "audio/wav"; - case ".wma": - return "audio/x-ms-wma"; - case ".swf": - return "application/x-shockwave-flash"; - case ".wmv": - return "video/x-ms-wmv"; - case ".rm": - return "application/vnd.rn-realmedia"; - case ".rmvb": - return "application/vnd.rn-realmedia-vbr"; - // 缃戦〉 - case ".js": - return "application/x-javascript"; - case ".css": - return "text/css"; - case ".asp": - return "text/asp"; - case ".mht": - return "message/rfc822"; - case ".jsp": - case ".htm": - case ".html": - case ".xhtml": - return "text/html"; - case ".xml": - case ".svg": - return "text/xml"; - // 鏂囦欢 - case ".txt": - return "text/plain"; - case ".dbf": - return "application/x-dbf"; - case ".mdb": - return "application/msaccess"; - case ".pdf": - return "application/pdf"; - case ".ppt": - case ".pptx": - return "application/x-ppt"; - case ".doc": - case ".docx": - return "application/msword"; - case ".xls": - case ".xlsx": - return "application/vnd.ms-excel"; - case ".dgn": - return "application/x-dgn"; - case ".dwg": - return "application/x-dwg"; - case ".ext": - return "application/x-msdownload"; - // 榛樿 - default: - return "application/octet-stream"; - } - } - - /** - * 瀛楄妭鍗曚綅鎹㈢畻 - */ - public static String formatByte(long byteNumber) { - double kbNumber = byteNumber / D1024; - if (kbNumber < D1024) { - return new DecimalFormat("#.##KB").format(kbNumber); - } - double mbNumber = kbNumber / D1024; - if (mbNumber < D1024) { - return new DecimalFormat("#.##MB").format(mbNumber); - } - double gbNumber = mbNumber / D1024; - if (gbNumber < D1024) { - return new DecimalFormat("#.##GB").format(gbNumber); - } - double tbNumber = gbNumber / D1024; - - return new DecimalFormat("#.##TB").format(tbNumber); - } - - /** - * 鑾峰彇骞虫柟绫� - */ - public static String getSquareMeter(double num) { - if (num < I1000000) { - return new DecimalFormat("#.##骞虫柟绫�").format(num); - } - - double knum = num / I1000000; - - return new DecimalFormat("#.##骞虫柟鍗冪背").format(knum); - } - - /** - * byte杞琈B - */ - public static double sizeToMb(long size) { - if (size < D1050) { - return 0.001; - } - - String str = String.format("%.3f", size / D1024 / D1024); - - return Double.parseDouble(str); - } - - /** - * 3.鑾峰彇鏂囦欢MD5鐮侊紙JDK锛� - */ - public static String getMd5ByJdk(String filePath) throws IOException { - FileInputStream fileStream = new FileInputStream(filePath); - String md5 = DigestUtils.md5Hex(fileStream); - fileStream.close(); - - return md5; - } - - /** - * 2.鑾峰彇蹇�� MD5 鐮� - */ - public static String getFastMd5(String filePath) throws IOException { - String hash = MD5.asHex(MD5.getHash(new File(filePath))); - - MD5 md5 = new MD5(); - md5.Update(hash, null); - - return md5.asHex(); - } - - /** - * 鍒犻櫎鏂囦欢澶� - * - * @param dir 鏂囦欢澶� - */ - public static void deleteDir(String dir) { - File file = new File(dir); - - deleteFiles(file); - } - - /** - * 绾ц仈鍒犻櫎鏂囦欢 - * - * @param file 鏂囦欢 - */ - public static void deleteFiles(File file) { - if (null == file || !file.exists()) { - return; - } - - if (file.isDirectory()) { - File[] files = file.listFiles(); - if (null != files && files.length > 0) { - for (File f : files) { - if (f.isDirectory()) { - deleteFiles(f); - } else { - f.delete(); - } - } - } - } - - file.delete(); - } - - /** - * 鑾峰彇鐩稿璺緞 - * - * @param file 鏂囦欢 - * @return 鐩稿璺緞 - */ - public static String getRelativePath(String file) { - if (StringHelper.isEmpty(file)) { - return null; - } - - int idx = file.lastIndexOf(File.separator); - int start = file.lastIndexOf(File.separator, idx - 1); - - return file.substring(start + 1); - } - - /** - * 鑾峰彇璺緞 - * - * @param file 鏂囦欢 - * @return 鏂囦欢璺緞 - */ - public static String getPath(String file) { - if (StringHelper.isEmpty(file)) { - return null; - } - - int end = file.lastIndexOf(File.separator); - - return file.substring(0, end); - } - - /** - * 1.鑾峰彇鏂囦欢鐨凪D5 - */ - @SuppressWarnings("unused") - public static String getFileMd5(String filePath) { - FileInputStream fis = null; - try { - MessageDigest md = MessageDigest.getInstance("MD5"); - - fis = new FileInputStream(new File(filePath)); - FileChannel fChannel = fis.getChannel(); - ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 1024); - - while (fChannel.read(buffer) != -1) { - buffer.flip(); - md.update(buffer); - buffer.compact(); - } - byte[] b = md.digest(); - - return byteToHexString(b); - } catch (Exception ex) { - ex.printStackTrace(); - return null; - } finally { - try { - if (null != fis) { - fis.close(); - } - } catch (IOException ex) { - ex.printStackTrace(); - } - } - } - - /** - * 瀛楄妭鐮佽浆16杩涘埗 - */ - public static String byteToHexString(byte[] tmp) { - // 姣忎釜瀛楄妭鐢� 16 杩涘埗琛ㄧず鐨勮瘽锛屼娇鐢ㄤ袱涓瓧绗︼紝 - char[] str = new char[16 * 2]; - - // 鎵�浠ヨ〃绀烘垚 16 杩涘埗闇�瑕� 32 涓瓧绗︼紝琛ㄧず杞崲缁撴灉涓搴旂殑瀛楃浣嶇疆 - int k = 0; - // 浠庣涓�涓瓧鑺傚紑濮嬶紝瀵� MD5 鐨勬瘡涓�涓瓧鑺� - for (int i = 0; i < I16; i++) { - // 杞崲鎴� 16 杩涘埗瀛楃鐨勮浆鎹� - byte byte0 = tmp[i]; - // 鍙栧瓧鑺備腑楂� 4 浣嶇殑鏁板瓧杞崲 - str[k++] = HEX_DIGITS[byte0 >>> 4 & 0xf]; - // >>> 涓洪�昏緫鍙崇Щ锛屽皢绗﹀彿浣嶄竴璧峰彸绉伙紝 鍙栧瓧鑺備腑浣� 4 浣嶇殑鏁板瓧杞崲 - str[k++] = HEX_DIGITS[byte0 & 0xf]; - } - // 鎹㈠悗鐨勭粨鏋滆浆鎹负瀛楃涓� - return new String(str); - } - - /** - * 鑾峰彇瀛楃涓茬殑MD5鐮� - */ - public static String getStringMd5(String text) { - StringBuilder builder = new StringBuilder(); - try { - MessageDigest md5 = MessageDigest.getInstance("MD5"); - - byte[] bytes = md5.digest(text.getBytes(StandardCharsets.UTF_8)); - for (byte aByte : bytes) { - builder.append(Integer.toHexString((0x000000FF & aByte) | 0xFFFFFF00).substring(6)); - } - } catch (Exception ex) { - log.error(ex.getMessage(), ex); - } - - return builder.toString(); - } - - /** - * 鏍规嵁璺緞鑾峰彇鏂囦欢 - */ - public static void getFilesByPath(List<String> list, String path) { - File file = new File(path); - if (file.isDirectory()) { - File[] files = file.listFiles(); - if (null == files) { - return; - } - - for (File f : files) { - if (f.isDirectory()) { - getFilesByPath(list, f.getPath()); - } else { - list.add(f.getPath()); - } - } - } else { - list.add(file.getPath()); - } - } - - /** - * 澶嶅埗鏂囦欢 - * - * @param src 婧愭枃浠� - * @param dest 鐩綍鏂囦欢 - */ - public static void copyFile(File src, File dest) throws IOException { - InputStream is = null; - OutputStream os = null; - try { - is = new FileInputStream(src); - os = new FileOutputStream(dest); - - byte[] buffer = new byte[1024]; - - int length; - while ((length = is.read(buffer)) > 0) { - os.write(buffer, 0, length); - } - } finally { - os.close(); - is.close(); - } - } -} diff --git a/src/main/java/com/se/simu/helper/GdalHelper.java b/src/main/java/com/se/simu/helper/GdalHelper.java deleted file mode 100644 index 51fe052..0000000 --- a/src/main/java/com/se/simu/helper/GdalHelper.java +++ /dev/null @@ -1,208 +0,0 @@ -package com.se.simu.helper; - -import com.se.simu.domain.LayerVo; -import lombok.extern.slf4j.Slf4j; -import org.gdal.gdal.Band; -import org.gdal.gdal.Dataset; -import org.gdal.gdal.gdal; -import org.gdal.gdalconst.gdalconst; -import org.gdal.ogr.Geometry; -import org.gdal.ogr.ogr; -import org.gdal.osr.SpatialReference; - -import java.io.File; - -/** - * GDAL甯姪绫� - * - * @author WWW - * @date 2024-07-16 - */ -@Slf4j -@SuppressWarnings("ALL") -public class GdalHelper { - public final static int I4326 = 4326; - - public final static int I4490 = 4490; - - public static SpatialReference SR4326; - - public static SpatialReference SR4490; - - public final static String CGCS2000 = "CGCS2000"; - - /** - * 鍒濆鍖� - */ - public static void init(String gdalPath) { - // 鏀寔涓枃璺緞 - gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES"); - // 灞炴�ц〃鏀寔涓枃锛欳P936 - gdal.SetConfigOption("SHAPE_ENCODING", ""); - gdal.SetConfigOption("PGEO_DRIVER_TEMPLATE", "DRIVER=Microsoft Access Driver (*.mdb, *.accdb);DBQ=%s"); - gdal.SetConfigOption("MDB_DRIVER_TEMPLATE", "DRIVER=Microsoft Access Driver (*.mdb, *.accdb);DBQ=%s"); - - // 閰嶇疆鐜鍙橀噺 - if (!StringHelper.isEmpty(gdalPath)) { - gdal.SetConfigOption("GDAL_DATA", gdalPath + "/gdal-data"); - gdal.SetConfigOption("PROJ_LIB", gdalPath + "/proj7/share"); - //System.setProperty("PROJ_LIB", gdalPath + "/proj7/share") - gdal.SetConfigOption("GDAL_DRIVER_PATH", gdalPath + "/gdalplugins"); - - String path = System.getenv("PATH"); - if (!path.contains(gdalPath)) { - System.setProperty("PATH", path + ";" + gdalPath); - } - } - - // 娉ㄥ唽鎵�鏈夌殑椹卞姩 - gdal.AllRegister(); - ogr.RegisterAll(); - initSr(); - } - - /** - * 鍒濆鍖栧潗鏍囩郴 - */ - public static void initSr() { - try { - SR4326 = new SpatialReference(); - SR4326.ImportFromEPSG(I4326); - - SR4490 = new SpatialReference(); - SR4490.ImportFromEPSG(I4490); - } catch (Exception ex) { - log.error(ex.getMessage(), ex); - } - } - - /** - * 璇诲彇DEM杈圭晫 - */ - public static LayerVo readDemExtent(String file) { - LayerVo layer = new LayerVo(); - Dataset ds = null; - - try { - File f = new File(file); - if (!f.exists() || f.isDirectory()) { - return null; - } - - ds = gdal.Open(file, gdalconst.GA_ReadOnly); - if (null == ds) { - return null; - } - - Band band = ds.GetRasterBand(1); - double[] mm = new double[2]; - band.ComputeRasterMinMax(mm); - - Geometry minPoint = getMinPoint(ds); - Geometry maxPoint = getMaxPoint(ds); - - layer.setExtension(new LayerVo.Extension(minPoint.GetX(), minPoint.GetY(), maxPoint.GetX(), maxPoint.GetY(), mm[0], mm[1])); - layer.setTerrain(new LayerVo.Terrain(band.getXSize(), band.getYSize())); - layer.setWater(new LayerVo.Water(band.getXSize(), band.getYSize(), null)); - } catch (Exception ex) { - log.error(ex.getMessage(), ex); - } finally { - if (null != ds) { - ds.delete(); - } - } - - return layer; - } - - /** - * 鑾峰彇Dataset鐨勬渶灏忕偣 - */ - private static Geometry getMinPoint(Dataset ds) { - double[] transform = new double[6]; - ds.GetGeoTransform(transform); - - double xMin = transform[0]; - double yMin = transform[3] - ds.getRasterYSize() * transform[1]; - - Geometry point = new Geometry(ogr.wkbPoint); - point.AddPoint(xMin, yMin, 0); - - return transform(ds, point); - } - - /** - * 鑾峰彇Dataset鐨勬渶澶х偣 - */ - private static Geometry getMaxPoint(Dataset ds) { - /* - * transform[0] 宸︿笂瑙抶鍧愭爣 - * transform[1] 涓滆タ鏂瑰悜鍒嗚鲸鐜� - * transform[2] 鏃嬭浆瑙掑害, 0琛ㄧず鍥惧儚 "鍖楁柟鏈濅笂" - * - * transform[3] 宸︿笂瑙抷鍧愭爣 - * transform[4] 鏃嬭浆瑙掑害, 0琛ㄧず鍥惧儚 "鍖楁柟鏈濅笂" - * transform[5] 鍗楀寳鏂瑰悜鍒嗚鲸鐜� - */ - double[] transform = new double[6]; - ds.GetGeoTransform(transform); - - double xMax = transform[0] + (ds.getRasterXSize() * transform[1]); - double yMax = transform[3]; - - Geometry point = new Geometry(ogr.wkbPoint); - point.AddPoint(xMax, yMax, 0); - - return transform(ds, point); - } - - /** - * 鍧愭爣杞崲 - */ - private static Geometry transform(Dataset ds, Geometry point) { - point.AssignSpatialReference(ds.GetSpatialRef()); - if (ds.GetSpatialRef().IsGeographic() > 0) { - return point; - } - - String srsName = ds.GetSpatialRef().GetName(); - if (srsName.contains(CGCS2000)) { - point.TransformTo(SR4490); - } else { - point.TransformTo(SR4326); - } - point.SwapXY(); - - return point; - } - - /** - * 鍒涘缓閲戝瓧濉� - */ - public static void createPyramid(String file) { - Dataset ds = null; - try { - File f = new File(file); - if (!f.exists() || f.isDirectory()) { - return; - } - - ds = gdal.Open(file, gdalconst.GA_ReadOnly); - if (null == ds) { - return; - } - - // 鍒涘缓閲戝瓧濉� - Band band = ds.GetRasterBand(1); - if (0 == band.GetOverviewCount()) { - ds.BuildOverviews("nearest", new int[]{2, 4, 6, 8, 16}, null); - } - } catch (Exception ex) { - log.error(ex.getMessage(), ex); - } finally { - if (null != ds) { - ds.delete(); - } - } - } -} diff --git a/src/main/java/com/se/simu/helper/StringHelper.java b/src/main/java/com/se/simu/helper/StringHelper.java deleted file mode 100644 index cd22752..0000000 --- a/src/main/java/com/se/simu/helper/StringHelper.java +++ /dev/null @@ -1,253 +0,0 @@ -package com.se.simu.helper; - -import java.sql.Timestamp; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.UUID; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * 瀛楃涓插府鍔╃被 - * - * @author WWW - * @date 2024-07-16 - */ -public class StringHelper { - public final static String COMMA = ","; - - public final static String PWD_REG = "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W!@#$%^&*`~()\\-_+=,.?;<>]+$)(?![a-z0-9]+$)(?![a-z\\W!@#$%^&*`~()\\-_+=,.?;<>]+$)(?![0-9\\W!@#$%^&*`~()\\-_+=,.?;<>]+$)[a-zA-Z0-9\\W!@#$%^&*`~()\\-_+=,.?;<>]{12,20}$"; - - /** - * 鏁板瓧姝e垯 - */ - public static final Pattern NUMBER_PATTERN = Pattern.compile("-?\\d+(\\.\\d+)?"); - - /** - * 鏍煎紡鍖栧綋鍓嶇郴缁熸棩鏈� 1 - */ - public static final SimpleDateFormat YMD_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); - - /** - * 鏍煎紡鍖栧綋鍓嶇郴缁熸棩鏈� 2 - */ - public static final SimpleDateFormat YMDHMS_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - /** - * 鏍煎紡鍖栧綋鍓嶇郴缁熸棩鏈� 3 - */ - public static final SimpleDateFormat YMD2_FORMAT = new SimpleDateFormat("yyyyMMdd"); - - /** - * 鏍煎紡鍖栧綋鍓嶇郴缁熸棩鏈� 4 - */ - public static final SimpleDateFormat YMDHMS2_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss"); - - /** - * 鍒ゆ柇瀛楃涓�,鏄惁涓烘暣鏁� - */ - public static boolean isInteger(String str) { - return str != null && str.matches("[0-9]+"); - } - - /** - * 鍒ゆ柇瀛楃涓�,鏄惁涓烘诞鐐规暟 - */ - public static boolean isNumeric(String str) { - return str != null && str.matches("-?\\d+(\\.\\d+)?"); - } - - /** - * 鍒ゆ柇瀛楃涓�,鏄惁涓烘诞鐐规暟 - */ - public static boolean isNumeric2(String str) { - return str != null && NUMBER_PATTERN.matcher(str).matches(); - } - - /** - * 鏃ユ湡姝e垯 - */ - public static Pattern datePattern = Pattern.compile("^((\\d{2}(([02468][048])|([13579][26]))[\\-\\/]((((0?[13578])|(1[02]))[\\-\\/]((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/]((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/]((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][1235679])|([13579][01345789]))[\\-\\/]((((0?[13578])|(1[02]))[\\-\\/]((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/]((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/]((0?[1-9])|(1[0-9])|(2[0-8]))))))(\\s(((0?[0-9])|([1-2][0-3]))\\:([0-5]?[0-9])((\\s)|(\\:([0-5]?[0-9])))))?$"); - - /** - * SQL姝e垯 - */ - public static Pattern sqlPattern = Pattern.compile("|and|exec|execute|insert|select|delete|update|count|drop|\\*|%|chr|mid|master|truncate|char|declare|sitename|net user|xp_cmdshell|;|or|-|\\+|,|like"); - - /** - * 瀛楃涓茶浆涓烘棩鏈� - */ - public static Date parseDate(String str) { - try { - return YMD_FORMAT.parse(str); - } catch (Exception ex) { - return null; - } - } - - /** - * 瀛楃涓茶浆涓烘棩鏈熸椂闂� - */ - public static Date parseTime(String str) { - try { - return YMDHMS_FORMAT.parse(str); - } catch (Exception e) { - return null; - } - } - - /** - * 鍒ゆ柇鍊兼槸鍚︿负鏃ユ湡鏍煎紡 - */ - public static boolean isDate(String strDate) { - Matcher m = datePattern.matcher(strDate); - - return m.matches(); - } - - /** - * 瀛楃涓诧紝鏄惁涓簄ull 鎴� "" - */ - public static boolean isNull(String str) { - return null == str || str.length() == 0; - } - - /** - * 瀛楃涓�,鏄惁涓虹┖null鍜岀┖鏍� - */ - public static boolean isEmpty(String str) { - return null == str || "".equals(str.trim()); - } - - /** - * 鑾峰彇 like 瀛楃涓� - */ - public static String getLikeStr(String str) { - return isEmpty(str) ? null : "%" + str.trim() + "%"; - } - - /** - * 鑾峰彇 like 瀛楃涓� - */ - public static String getLikeUpperStr(String str) { - return isEmpty(str) ? null : "%" + str.trim().toUpperCase() + "%"; - } - - /** - * 鑾峰彇 鍙砽ike 瀛楃涓� - */ - public static String getRightLike(String str) { - return isEmpty(str) ? null : str.trim() + "%"; - } - - /** - * 鑾峰彇鍥惧舰鐨刉KT瀛楃涓� - */ - public static String getGeomWkt(String wkt) { - if (isEmpty(wkt)) { - return "null"; - } - - return String.format("ST_GeomFromText('%s')", wkt); - } - - /** - * 棣栧瓧姣嶅ぇ鍐� - */ - public static String firstCharToUpperCase(String str) { - return str.substring(0, 1).toUpperCase() + str.substring(1); - } - - /** - * 棣栧瓧姣嶅皬鍐� - */ - public static String firstCharToLowerCase(String str) { - return str.substring(0, 1).toLowerCase() + str.substring(1); - } - - /** - * 鍒ゆ柇鍊兼槸鍚﹀瓨鍦⊿QL娉ㄥ叆 - * - * @param str 瀛楃涓� - * @return 鏄�/鍚� - */ - public static boolean isSqlInjection(String str) { - if (null == str) { - return false; - } - - Matcher m = sqlPattern.matcher(str); - - return m.matches(); - } - - /** - * 鏍¢獙瀵嗙爜鏄�/鍚﹀悎娉� - * - * @param pwd 瀵嗙爜 - * @return 鏄�/鍚︿负鏃犳晥鐨� - */ - public static boolean isPwdInvalid(String pwd) { - return !Pattern.matches(PWD_REG, pwd); - } - - /** - * 鑾峰彇GUID - */ - public static String getGuid() { - return UUID.randomUUID().toString(); - } - - /** - * 鑾峰彇鍒嗛挓宸暟 - */ - public static long getMinuteDifference(Timestamp ts) { - return (ts.getTime() - System.currentTimeMillis()) / 1000 / 60; - } - - /** - * 杩炴帴List闆嗗悎 - * - * @param list list 鏁存暟闆嗗悎 - * @param join join 杩炴帴瀛楃 - * @param <T> 娉涘瀷绫� - * @return 瀛楃涓� - */ - public static <T> String join(List<T> list, String join) { - if (null == list || list.isEmpty()) { - return ""; - } - - StringBuilder sb = new StringBuilder(); - for (T t : list) { - if (null != t) { - sb.append(t.toString()).append(join); - } - } - - if (sb.length() > 0 && sb.lastIndexOf(join) == sb.length() - join.length()) { - // 鍒犻櫎浠庣储寮� start 寮�濮嬪埌 end 涔嬮棿鐨勫瓧绗︼紝鍗� 鍓嶅寘鎷� 鍚庝笉鍖呮嫭銆� - sb.delete(sb.length() - join.length(), sb.length()); - } - - return sb.toString(); - } - - /** - * 瀛楃涓茶浆鏁存暟闆嗗悎 - */ - public static List<Integer> strToIntegers(String str) { - if (isEmpty(str)) { - return null; - } - - List<Integer> list = new ArrayList<>(); - for (String s : str.split(COMMA)) { - list.add(Integer.parseInt(s)); - } - - return list; - } -} diff --git a/src/main/java/com/se/simu/helper/WebHelper.java b/src/main/java/com/se/simu/helper/WebHelper.java index ba734c7..08db9f8 100644 --- a/src/main/java/com/se/simu/helper/WebHelper.java +++ b/src/main/java/com/se/simu/helper/WebHelper.java @@ -6,20 +6,16 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import javax.servlet.ServletContext; import javax.servlet.ServletOutputStream; -import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import java.io.BufferedReader; import java.io.FileInputStream; -import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.InetAddress; import java.net.URLEncoder; import java.net.UnknownHostException; import java.sql.Timestamp; +import java.text.SimpleDateFormat; import java.util.*; /** @@ -30,15 +26,23 @@ */ @Slf4j public class WebHelper { + public final static String POINT = "."; + private final static String COMMA = ","; private final static String UNKNOWN = "unknown"; - public final static String TOKEN_KEY = "token"; + /** + * 鏍煎紡鍖栧綋鍓嶇郴缁熸棩鏈� 4 + */ + public static final SimpleDateFormat YMDHMS = new SimpleDateFormat("yyyyMMddHHmmss"); - public final static String TOKEN_COOKIE_KEY = "token"; - - public final static int COOKIE_MAX_AGE = 4 * 60 * 60; + /** + * 瀛楃涓�,鏄惁涓虹┖null鍜岀┖鏍� + */ + public static boolean isEmpty(String str) { + return null == str || "".equals(str.trim()); + } /** * 鑾峰彇GUID @@ -114,131 +118,6 @@ } /** - * 鑾峰彇褰撳墠鏃堕棿鎸囧畾鍒嗛挓鏁板悗鐨凾imestamp - */ - public static Timestamp getTimestamp(int min) { - Calendar now = Calendar.getInstance(); - now.add(Calendar.MINUTE, min); - - return new Timestamp(now.getTimeInMillis()); - } - - /** - * 浠嶤ookie涓幏鍙杢oken - */ - public static String getTokenFromCookie(HttpServletRequest request) { - Cookie[] cookies = request.getCookies(); - if (cookies == null || cookies.length == 0) { - return null; - } - - for (Cookie cookie : cookies) { - switch (cookie.getName()) { - case TOKEN_COOKIE_KEY: - return cookie.getValue(); - default: - break; - } - } - - return null; - } - - /** - * 鍚慍ookie涓坊鍔爐oken - */ - public static void saveToken2Cookie(String token, HttpServletRequest request, HttpServletResponse response) { - // 鍏堝垹闄� - deleteCookies(request, response); - - // 鍐嶄繚瀛� - saveCookie(TOKEN_COOKIE_KEY, token, response); - } - - /** - * 淇濆瓨Cookie - */ - public static void saveCookie(String key, String value, HttpServletResponse response) { - Cookie cookie = new Cookie(key, value); - // 璁剧疆cookie澶辨晥鏃堕棿锛屽崟浣嶄负绉� - cookie.setMaxAge(COOKIE_MAX_AGE); - cookie.setHttpOnly(false); - cookie.setPath("/"); - //cookie.setDomain("*") - - response.setHeader("P3P", "CP=CAO PSA OUR"); - response.addCookie(cookie); - } - - /** - * 鍒犻櫎cookie涓殑鍊� - */ - public static void deleteCookie(String cookieKey, HttpServletRequest request, HttpServletResponse response) { - Cookie[] cookies = request.getCookies(); - if (cookies != null && cookies.length > 0) { - for (Cookie c : cookies) { - if (cookieKey.equalsIgnoreCase(c.getName())) { - c.setMaxAge(0); - c.setPath("/"); - response.addCookie(c); - } - } - } - } - - /** - * 鍒犻櫎鎵�鏈塁ookie - */ - public static void deleteCookies(HttpServletRequest request, HttpServletResponse response) { - Cookie[] cookies = request.getCookies(); - if (cookies != null && cookies.length > 0) { - for (Cookie c : cookies) { - c.setMaxAge(0); - c.setPath("/"); - response.addCookie(c); - } - } - } - - /** - * 鏍规嵁閿幏鍙朇ookie鍊� - */ - public static String getCookieByKey(String key, HttpServletRequest request) { - Cookie[] cookies = request.getCookies(); - if (cookies == null || cookies.length == 0) { - return null; - } - - for (Cookie c : cookies) { - if (key.equals(c.getName())) { - return c.getValue(); - } - } - - return null; - } - - /** - * 鑾峰彇Token - */ - public static String getToken(HttpServletRequest request) { - // 1.浠巙rl鍙傛暟涓紝鑾峰彇token - String token = request.getParameter(TOKEN_KEY); - - // 2.涓虹┖锛屽垯浠巋eader閲岃幏鍙� - if (token == null) { - token = request.getHeader(TOKEN_KEY); - } - - // 3.杩樹负绌猴紝鍒欎粠cookie閲岃幏鍙� - if (token == null) { - token = getTokenFromCookie(request); - } - - return token; - } - - /** * 鑾峰彇Request */ public static HttpServletRequest getRequest() { @@ -254,23 +133,6 @@ ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); return servletRequestAttributes.getResponse(); - } - - /** - * 鑾峰彇Session - */ - public static HttpSession getSession() { - return getRequest().getSession(); - } - - /** - * 鑾峰彇鐪熷疄璺緞 - */ - public static String getRealPath(String path) { - HttpServletRequest req = getRequest(); - ServletContext ctx = req.getSession().getServletContext(); - - return ctx.getRealPath("/" + path); } /** @@ -349,8 +211,8 @@ * @throws Exception 寮傚父 */ public static void download(String file, String fileName, boolean inline, HttpServletResponse res) throws Exception { - if (StringHelper.isEmpty(fileName)) { - fileName = StringHelper.YMDHMS2_FORMAT.format(new Date()); + if (isEmpty(fileName)) { + fileName = YMDHMS.format(new Date()); } fileName = URLEncoder.encode(fileName, "UTF-8").replace("+", "%20"); String dispose = inline ? "inline" : "attachment"; @@ -361,8 +223,8 @@ res.setCharacterEncoding("UTF-8"); // 閫氳繃response瀵硅薄璁剧疆鍝嶅簲鏁版嵁鏍煎紡(濡傦細"text/plain; charset=utf-8") - String ext = FileHelper.getExtension(file); - String mime = FileHelper.getMime(ext); + String ext = getExtension(file); + String mime = getMime(ext); res.setContentType(mime); // 閫氳繃response瀵硅薄锛岃幏鍙栧埌杈撳嚭娴� @@ -384,75 +246,105 @@ } /** - * 鎵ц鍛戒护 - * - * @param cmd 鍛戒护 + * 鑾峰彇鏂囦欢鎵╁睍鍚� */ - public static void exec(String cmd) { - try { - Runtime.getRuntime().exec(cmd); - } catch (Exception ex) { - log.error(ex.getMessage(), ex); + public static String getExtension(String fileName) { + if (isEmpty(fileName)) { + return ""; } + + int idx = fileName.lastIndexOf(POINT); + if (idx == -1) { + return ""; + } + + return fileName.substring(idx).toLowerCase(); } /** - * 鎵ц鍛戒护 - * - * @param cmd 鍛戒护 + * 鑾峰彇澶氱敤閫斾簰鑱旂綉閭欢鎵╁睍绫诲瀷 */ - public static String exec2(String cmd) { - try { - StringBuilder sb = new StringBuilder(); - Process process = Runtime.getRuntime().exec(cmd); - BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); - - String line; - while ((line = reader.readLine()) != null) { - sb.append(line).append("\n"); - } - reader.close(); - - return sb.toString(); - } catch (Exception ex) { - log.error(ex.getMessage(), ex); - return null; + public static String getMime(String ext) { + switch (ext) { + // 鍥剧墖 + case ".tif": + case ".tiff": + return "image/tiff"; + case ".img": + return "application/x-img"; + case ".gif": + return "image/gif"; + case ".jpg": + case ".jpeg": + return "image/jpeg"; + case ".png": + return "image/png"; + // 闊�/瑙嗛 + case ".mp3": + return "audio/mp3"; + case ".mp4": + return "video/mpeg4"; + case ".avi": + return "video/avi"; + case ".mpg": + case ".mpeg": + return "video/mpg"; + case ".wav": + return "audio/wav"; + case ".wma": + return "audio/x-ms-wma"; + case ".swf": + return "application/x-shockwave-flash"; + case ".wmv": + return "video/x-ms-wmv"; + case ".rm": + return "application/vnd.rn-realmedia"; + case ".rmvb": + return "application/vnd.rn-realmedia-vbr"; + // 缃戦〉 + case ".js": + return "application/x-javascript"; + case ".css": + return "text/css"; + case ".asp": + return "text/asp"; + case ".mht": + return "message/rfc822"; + case ".jsp": + case ".htm": + case ".html": + case ".xhtml": + return "text/html"; + case ".xml": + case ".svg": + return "text/xml"; + // 鏂囦欢 + case ".txt": + return "text/plain"; + case ".dbf": + return "application/x-dbf"; + case ".mdb": + return "application/msaccess"; + case ".pdf": + return "application/pdf"; + case ".ppt": + case ".pptx": + return "application/x-ppt"; + case ".doc": + case ".docx": + return "application/msword"; + case ".xls": + case ".xlsx": + return "application/vnd.ms-excel"; + case ".dgn": + return "application/x-dgn"; + case ".dwg": + return "application/x-dwg"; + case ".ext": + return "application/x-msdownload"; + // 榛樿 + default: + return "application/octet-stream"; } - } - - /** - * 鑾峰彇璇锋眰鐨勫弬鏁板�� - * - * @param req 璇锋眰 - * @param key 鍙傛暟鍚� - * @return 鍙傛暟鍊� - */ - public static String getReqParamVal(HttpServletRequest req, String key) { - Map<String, String[]> maps = req.getParameterMap(); - for (Map.Entry<String, String[]> entry : maps.entrySet()) { - if (entry.getKey().equalsIgnoreCase(key)) { - return null == entry.getValue() || 0 == entry.getValue().length ? null : entry.getValue()[0]; - } - } - - return null; - } - - /** - * 鑾峰彇璇锋眰鐨勫弬鏁板�� - * - * @param req 璇锋眰 - * @param key 鍙傛暟鍚� - * @return 鍙傛暟鍊� - */ - public static String[] getReqParamVals(HttpServletRequest req, String key) { - Map<String, String[]> maps = req.getParameterMap(); - for (Map.Entry<String, String[]> entry : maps.entrySet()) { - if (entry.getKey().equalsIgnoreCase(key)) { - return entry.getValue(); - } - } - - return null; } } diff --git a/src/main/java/com/se/simu/service/WaterService.java b/src/main/java/com/se/simu/service/WaterService.java index 4564fa1..04e408c 100644 --- a/src/main/java/com/se/simu/service/WaterService.java +++ b/src/main/java/com/se/simu/service/WaterService.java @@ -1,7 +1,6 @@ package com.se.simu.service; import com.se.simu.domain.LayerVo; -import com.se.simu.helper.GdalHelper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -29,23 +28,14 @@ String dataPath; public LayerVo getLayer(String serviceName) { - String file = "D:/simu/test/DEM_M.tif"; - GdalHelper.createPyramid(file); - - String file2 = "D:/simu/test/DOM_M.tif"; - GdalHelper.createPyramid(file2); - - LayerVo layer = GdalHelper.readDemExtent(file); - if (null == layer) { - return null; - } + LayerVo layer = new LayerVo(); layer.setVer(ver); - //layer.setDuration(new LayerVo.Duration(1719812810225L, 1719812810225L)); - //layer.setExtension(new LayerVo.Extension(2.11062743358, 0.53812160220, 2.11070827834, 0.53819799453, 1.151, 38.83)); - //layer.setTerrain(new LayerVo.Terrain(10000, 10000)); + layer.setDuration(new LayerVo.Duration(1719812810225L, 1719812810225L)); + layer.setExtension(new LayerVo.Extension(2.11062743358, 0.53812160220, 2.11070827834, 0.53819799453, 1.151, 38.83)); + layer.setTerrain(new LayerVo.Terrain(10000, 10000)); - //List<Long> data = new ArrayList<>(Arrays.asList(1719812812225L, 1719812812225L, 1719812812225L, 1719812812225L, 1719812812225L, 1719812812225L)); - //layer.setWater(new LayerVo.Water(10000, 10000, data)); + List<Long> data = new ArrayList<>(Arrays.asList(1719812812225L, 1719812812225L, 1719812812225L, 1719812812225L, 1719812812225L, 1719812812225L)); + layer.setWater(new LayerVo.Water(10000, 10000, data)); return layer; } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml deleted file mode 100644 index 2dfbdad..0000000 --- a/src/main/resources/application-dev.yml +++ /dev/null @@ -1,8 +0,0 @@ -# 绯荤粺閰嶇疆 -sys: - ver: 0.1 - path: - # Gdal椹卞姩鐩綍 - gdal: E:/terrait/TianJin/Zip/release-1928-x64-dev/release-1928-x64/bin - # 鍒嗘瀽鏁版嵁鏁版嵁 - data: D:/simu/ diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml deleted file mode 100644 index 2dfbdad..0000000 --- a/src/main/resources/application-prod.yml +++ /dev/null @@ -1,8 +0,0 @@ -# 绯荤粺閰嶇疆 -sys: - ver: 0.1 - path: - # Gdal椹卞姩鐩綍 - gdal: E:/terrait/TianJin/Zip/release-1928-x64-dev/release-1928-x64/bin - # 鍒嗘瀽鏁版嵁鏁版嵁 - data: D:/simu/ diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 1a85cef..0188b74 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,26 +1,16 @@ server: - tomcat: - uri-encoding: UTF-8 - max-connections: 5000 - max-http-form-post-size: 50MB - threads: - max: 2000 port: 8079 servlet: - context-path: /simuserver + context-path: / spring: mvc: pathmatch: - # 瑙e喅Knife4j杩愯鎶ラ敊 matching-strategy: ant_path_matcher application: - name: simuserver + name: SimuServer -knife4j: - # 鏄惁寮�鍚� - enabled: true - # 璇锋眰鍓嶇紑 - pathMapping: - # 鏄惁寮�鍚寮烘ā寮� - enable: true +sys: + ver: 0.1 + path: + data: D:/simu/ \ No newline at end of file diff --git a/src/test/java/com/se/simu/SimuApplicationTests.java b/src/test/java/com/se/simu/SimuApplicationTests.java deleted file mode 100644 index 415243b..0000000 --- a/src/test/java/com/se/simu/SimuApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.se.simu; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.TestPropertySource; - -@SpringBootTest -@TestPropertySource(properties = "spring.datasource.initialize=false") -class SimuserverApplicationTests { - @Test - void contextLoads() { - } -} -- Gitblit v1.9.3