1
13693261870
2024-07-17 6f260b13671fcef843d3ed0fdb73636d3f91693a
1
已添加1个文件
已修改5个文件
86 ■■■■■ 文件已修改
pom.xml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/SimuApplication.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/config/WebConfig.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/controller/WaterController.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/helper/WebHelper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/service/WaterService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml
@@ -13,7 +13,7 @@
    <groupId>com.se</groupId>
    <artifactId>simu</artifactId>
    <version>1.0.0</version>
    <name>simuserver</name>
    <name>SimuServer</name>
    <description>内涝仿真服务</description>
    <properties>
@@ -32,6 +32,7 @@
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.34</version>
            <optional>true</optional>
        </dependency>
        <!--hutool-->
@@ -40,12 +41,17 @@
            <artifactId>hutool-all</artifactId>
            <version>5.8.29</version>
        </dependency>
        <!--fastjson2-->
        <!--fastjson-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.83</version>
        </dependency>
        <!--dependency>
            <groupId>com.alibaba.fastjson2</groupId>
            <artifactId>fastjson2</artifactId>
            <version>2.0.52</version>
        </dependency>
        </dependency-->
    </dependencies>
    <build>
src/main/java/com/se/simu/SimuApplication.java
@@ -3,6 +3,8 @@
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;
/**
 * å¯åŠ¨ç¨‹åºç±»
@@ -11,8 +13,13 @@
 * @date 2024-07-16
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}, scanBasePackages = {"com.se.simu"})
public class SimuApplication {
public class SimuApplication  extends SpringBootServletInitializer {
    public static void main(String[] args) {
        SpringApplication.run(SimuApplication.class, args);
    }
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder springApplicationBuilder) {
        return springApplicationBuilder.sources(SimuApplication.class);
    }
}
src/main/java/com/se/simu/config/WebConfig.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,41 @@
package com.se.simu.config;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import java.nio.charset.StandardCharsets;
import java.util.List;
/**
 * Web配置类
 *
 * @author WWW
 * @date 2024-07-17
 */
@Configuration
public class WebConfig extends WebMvcConfigurationSupport {
    /**
     * å¤„理json格式,值null的转换为""
     */
    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
        FastJsonConfig config = new FastJsonConfig();
        config.setSerializerFeatures(
                SerializerFeature.WriteNullListAsEmpty,
                SerializerFeature.WriteMapNullValue,
                SerializerFeature.WriteNullStringAsEmpty,
                SerializerFeature.WriteNullNumberAsZero,
                SerializerFeature.WriteNullBooleanAsFalse);
        // ç»“果是否格式化,默认为false
        //SerializerFeature.PrettyFormat);
        converter.setFastJsonConfig(config);
        converter.setDefaultCharset(StandardCharsets.UTF_8);
        converters.add(converter);
    }
}
src/main/java/com/se/simu/controller/WaterController.java
@@ -33,11 +33,17 @@
    private final static long Y2000 = 949334400000L;
    /**
     * èŽ·å–å½“å‰æ—¶é—´
     */
    @GetMapping("/getTime")
    public Object getTime() {
        return System.currentTimeMillis();
    }
    /**
     * èŽ·å–å…ƒæ•°æ®ä¿¡æ¯
     */
    @GetMapping("/{serviceName}/layer.json")
    public void getLayer(@PathVariable String serviceName, HttpServletResponse res) {
        try {
@@ -54,6 +60,9 @@
        }
    }
    /**
     * èŽ·å–åœ°å½¢é«˜åº¦å›¾
     */
    @GetMapping("/{serviceName}/terrain")
    public void getTerraMap(@PathVariable String serviceName, Integer width, Integer height, HttpServletResponse res) {
        try {
@@ -69,6 +78,9 @@
        }
    }
    /**
     * èŽ·å–æ°´é¢é«˜åº¦å›¾
     */
    @GetMapping("/{serviceName}/waterMap")
    public void getWaterMap(@PathVariable String serviceName, Integer width, Integer height, Long timestamp, HttpServletResponse res) {
        try {
@@ -84,6 +96,9 @@
        }
    }
    /**
     * èŽ·å–æ°´æµå‘æµé€Ÿå›¾
     */
    @GetMapping("/{serviceName}/flowMap")
    public void getFlowMap(@PathVariable String serviceName, Integer width, Integer height, Long timestamp, HttpServletResponse res) {
        try {
src/main/java/com/se/simu/helper/WebHelper.java
@@ -1,6 +1,6 @@
package com.se.simu.helper;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.context.request.RequestContextHolder;
src/main/java/com/se/simu/service/WaterService.java
@@ -21,9 +21,6 @@
    @Value("${sys.ver}")
    String ver;
    @Value("${sys.path.gdal}")
    String gdalPath;
    @Value("${sys.path.data}")
    String dataPath;
@@ -49,6 +46,10 @@
    }
    public String getFlowMap(String serviceName, Integer width, Integer height, Long timestamp) {
        //com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
        return null;
    }
}