优化导出接口;增加洪水预报测试

master
chenxiwang 2024-07-26 13:19:17 +08:00
parent a7bee4ba37
commit 91dc3007c8
7 changed files with 69 additions and 21 deletions

20
pom.xml
View File

@ -71,7 +71,25 @@
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>1.2.79</version> <version>1.2.79</version>
</dependency> </dependency>
<dependency>
<groupId>org.gunshi</groupId>
<artifactId>flood_algorithm</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>--> <!-- <groupId>org.springframework.boot</groupId>-->

View File

@ -2,17 +2,10 @@ package com.gunshi.project.xyt.controller;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.gunshi.algorithm.RrainfallForecast;
import com.gunshi.project.xyt.entity.vo.StWaterRReorganizeVo; import com.gunshi.model.vo.FloodAlgorithemVo;
import com.gunshi.project.xyt.entity.vo.StWaterRReorganizeYearVo;
import com.gunshi.project.xyt.util.ConvertUtil;
import com.gunshi.project.xyt.util.DateUtil;
import com.gunshi.project.xyt.util.ExcelUtil;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
@ -29,14 +22,20 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.core.result.R; import com.gunshi.core.result.R;
import com.gunshi.project.xyt.entity.vo.StWaterRReorganizeVo;
import com.gunshi.project.xyt.entity.vo.StWaterRReorganizeYearVo;
import com.gunshi.project.xyt.model.StWaterRReorganize; import com.gunshi.project.xyt.model.StWaterRReorganize;
import com.gunshi.project.xyt.service.StWaterRReorganizeService; import com.gunshi.project.xyt.service.StWaterRReorganizeService;
import com.gunshi.project.xyt.util.ConvertUtil;
import com.gunshi.project.xyt.util.DateUtil;
import com.gunshi.project.xyt.util.ExcelUtil;
import com.gunshi.project.xyt.validate.markers.Insert; import com.gunshi.project.xyt.validate.markers.Insert;
import com.gunshi.project.xyt.validate.markers.Update; import com.gunshi.project.xyt.validate.markers.Update;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
/** /**
* : * :
* author: cxw * author: cxw
@ -163,4 +162,13 @@ public class StWaterRReorganizeController {
service.getYearStatisticAnalysis(year, resList); service.getYearStatisticAnalysis(year, resList);
ExcelUtil.exportExcel(resList, filename, StWaterRReorganizeYearVo.class, response, "统计分析"); ExcelUtil.exportExcel(resList, filename, StWaterRReorganizeYearVo.class, response, "统计分析");
} }
@Operation(summary = "洪水预报测试")
@PostMapping("/forecastTest")
public R<List<FloodAlgorithemVo>> forecastTest() throws Exception {
double[] PList = new double[] {6.5, 6.75, 7, 5.25, 3.5, 4, 4.5, 4, 3.5, 4.25, 5, 4, 3, 3, 3, 2.75, 2.5, 1.25, 0, 0.25, 0.5};
double[] u = new double[]{1.27, 0.75, 0.45, 0.27, 0.16, 0.09, 0.07, 0.03, 0.02, 0.01, 0.01};
return R.ok(RrainfallForecast.getData("2024-06-28 08:00:00", 0.93, 1.0, 120, 0.0, 675.94, 0.5, 100, PList, u));
}
} }

View File

@ -25,25 +25,25 @@ public class StWaterRReorganizeVo {
/** /**
* *
*/ */
@ExcelProperty({"${title}", "流量(生态供水)(m³/s)"}) @ExcelProperty({"${title}", "生态供水", "流量(m³/s)"})
private BigDecimal ecologyQ; private BigDecimal ecologyQ;
/** /**
* *
*/ */
@ExcelProperty({"${title}", "水量(生态供水)(万m³)"}) @ExcelProperty({"${title}", "生态供水", "水量(万m³)"})
private BigDecimal ecologyV; private BigDecimal ecologyV;
/** /**
* *
*/ */
@ExcelProperty({"${title}", "流量(生活供水)(m³/s)"}) @ExcelProperty({"${title}", "生活供水", "流量(m³/s)"})
private BigDecimal lifeQ; private BigDecimal lifeQ;
/** /**
* *
*/ */
@ExcelProperty({"${title}", "水量(生活供水)(万m³)"}) @ExcelProperty({"${title}", "生活供水", "水量(万m³)"})
private BigDecimal lifeV; private BigDecimal lifeV;
/** /**

View File

@ -1,10 +1,7 @@
package com.gunshi.project.xyt.entity.vo; package com.gunshi.project.xyt.entity.vo;
import java.math.BigDecimal;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
@ -20,53 +17,62 @@ import lombok.Data;
public class StWaterRReorganizeYearVo { public class StWaterRReorganizeYearVo {
@Schema(description="时间") @Schema(description="时间")
@ExcelProperty({"${title}", "时间"})
private String tm; private String tm;
/** /**
* *
*/ */
@Schema(description="年度占比(生态供水)") @Schema(description="年度占比(生态供水)")
@ExcelProperty({"${title}", "生态供水", "年度占比"})
private String ecologyYearRateV; private String ecologyYearRateV;
/** /**
* *
*/ */
@Schema(description="水量(生态供水)") @Schema(description="水量(生态供水)")
@ExcelProperty({"${title}", "生态供水", "水量"})
private String ecologyV; private String ecologyV;
/** /**
* *
*/ */
@Schema(description="水量(生态供水)") @Schema(description="同比(生态供水)")
@ExcelProperty({"${title}", "生态供水", "同比"})
private String ecologyYoyV; private String ecologyYoyV;
/** /**
* *
*/ */
@Schema(description="水量(生态供水)") @Schema(description="环比(生态供水)")
@ExcelProperty({"${title}", "生态供水", "环比"})
private String ecologyQoqV; private String ecologyQoqV;
/** /**
* *
*/ */
@Schema(description="年度占比(生活供水)") @Schema(description="年度占比(生活供水)")
@ExcelProperty({"${title}", "生活供水", "年度占比"})
private String lifeYearRateV; private String lifeYearRateV;
/** /**
* *
*/ */
@Schema(description="水量(生活供水)") @Schema(description="水量(生活供水)")
@ExcelProperty({"${title}", "生活供水", "水量"})
private String lifeV; private String lifeV;
/** /**
* *
*/ */
@Schema(description="同比(生活供水)") @Schema(description="同比(生活供水)")
@ExcelProperty({"${title}", "生活供水", "同比"})
private String lifeYoyV; private String lifeYoyV;
/** /**
* *
*/ */
@Schema(description="环比(生活供水)") @Schema(description="环比(生活供水)")
@ExcelProperty({"${title}", "生活供水", "环比"})
private String lifeQoqV; private String lifeQoqV;
} }

View File

@ -49,9 +49,9 @@ public class StWaterRReorganizeService extends ServiceImpl<StWaterRReorganizeMap
StWaterRReorganizeYearVo vo = new StWaterRReorganizeYearVo(); StWaterRReorganizeYearVo vo = new StWaterRReorganizeYearVo();
StWaterRReorganize nowStwrr = nowYearList.get(i); StWaterRReorganize nowStwrr = nowYearList.get(i);
vo.setTm(nowStwrr.getTm()); vo.setTm(nowStwrr.getTm());
vo.setEcologyYearRateV(nowStwrr.getEcologyV().divide(ecologyVSum, 1, BigDecimal.ROUND_HALF_UP).toString()); vo.setEcologyYearRateV(nowStwrr.getEcologyV().divide(ecologyVSum, 1, BigDecimal.ROUND_HALF_UP).toString().concat("%"));
vo.setEcologyV(nowStwrr.getEcologyV().toString()); vo.setEcologyV(nowStwrr.getEcologyV().toString());
vo.setLifeYearRateV(nowStwrr.getEcologyV().divide(lifeVSum, 1, BigDecimal.ROUND_HALF_UP).toString()); vo.setLifeYearRateV(nowStwrr.getEcologyV().divide(lifeVSum, 1, BigDecimal.ROUND_HALF_UP).toString().concat("%"));
vo.setLifeV(nowStwrr.getLifeV().toString()); vo.setLifeV(nowStwrr.getLifeV().toString());
StWaterRReorganize lastStwrr = lastYearList.stream() StWaterRReorganize lastStwrr = lastYearList.stream()

View File

@ -23,3 +23,11 @@ spring:
mybatis-plus: mybatis-plus:
configuration: configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 洪水预测数据库连接信息
algorithem:
datasource:
url: jdbc:postgresql://10.0.41.112:5432/xiaoyutan?stringtype=unspecified
username: gunshiiot
password: 1234567a
driver-class-name: org.postgresql.Driver

View File

@ -23,3 +23,11 @@ spring:
mybatis-plus: mybatis-plus:
configuration: configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# 洪水预测数据库连接信息
algorithem:
datasource:
url: jdbc:postgresql://10.0.41.112:5432/xiaoyutan?stringtype=unspecified
username: gunshiiot
password: 1234567a
driver-class-name: org.postgresql.Driver