降雨信息

master
wany 2024-07-08 14:47:19 +08:00
parent 40e0c17e72
commit bf332170aa
16 changed files with 1703 additions and 0 deletions

View File

@ -0,0 +1,58 @@
package com.gunshi.project.xyt.controller;
import com.gunshi.core.annotation.Get;
import com.gunshi.core.annotation.Post;
import com.gunshi.core.result.R;
import com.gunshi.project.xyt.entity.so.StPptnSo;
import com.gunshi.project.xyt.entity.vo.CartogramVo;
import com.gunshi.project.xyt.entity.vo.StPptnDetailsVo;
import com.gunshi.project.xyt.entity.vo.StPptnVo;
import com.gunshi.project.xyt.service.RainBasinDivisionService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/attResBase")
@Tag(name = "雨情站详细信息查询接口")
public class RainBasinDivisionController {
@Autowired
private RainBasinDivisionService rainBasinDivisionService;
@Post(path = "/rainBasinDivision/queryStStbprpPerHour/StcdAndStartTimeAndEndTime",summary = "根据测站编码查询时间段内每小时的雨量")
public R<List<StPptnVo>> queryStPptnPerHourByStcdAndStartTimeAndEndTime(@RequestBody @Validated StPptnSo stPptnSo){
return R.ok(rainBasinDivisionService.queryStPptnPerHourByStcdAndStartTimeAndEndTime(stPptnSo));
}
@Post(path = "/rainBasinDivision/queryStStbprpPerHourChart/StcdAndStartTimeAndEndTime",summary = "根据测站编码查询时间段内每小时的雨量统计")
public R<CartogramVo> queryStPptnPerHourChartByStcdAndStartTimeAndEndTime(@RequestBody @Validated StPptnSo stPptnSo){
return R.ok(rainBasinDivisionService.queryStPptnPerHourChartByStcdAndStartTimeAndEndTime(stPptnSo));
}
@Post(path = "/rainBasinDivision/queryStStbprpPerDay/StcdAndStartTimeAndEndTime",summary = "根据测站编码查询时间段内每天的雨量")
public R<List<StPptnVo>> queryStPptnPerDayByStcdAndStartTimeAndEndTime(@RequestBody @Validated StPptnSo stPptnSo){
return R.ok(rainBasinDivisionService.queryStPptnPerDayByStcdAndStartTimeAndEndTime(stPptnSo).reversed());
}
@Post(path = "/rainBasinDivision/queryStStbprpPerDayChart/StcdAndStartTimeAndEndTime",summary = "根据测站编码查询时间段内每天的雨量统计")
public R<CartogramVo> queryStPptnPerDayChartChartByStcdAndStartTimeAndEndTime(@RequestBody @Validated StPptnSo stPptnSo){
return R.ok(rainBasinDivisionService.queryStPptnPerDayChartChartByStcdAndStartTimeAndEndTime(stPptnSo));
}
@Get(path = "/rainBasinDivision/queryStPptnDetails/stcd",summary = "根据测站编码查询详细雨量情况")
public R<StPptnDetailsVo> queryStPptnDetailsByStcd(@RequestParam("stcd") @Parameter(description = "测站编码") String stcd){
return R.ok(rainBasinDivisionService.queryStPptnDetailsByStcd(stcd));
}
}

View File

@ -0,0 +1,44 @@
package com.gunshi.project.xyt.controller;
import com.gunshi.core.annotation.Post;
import com.gunshi.core.result.R;
import com.gunshi.project.xyt.entity.so.RealRainBaseSo;
import com.gunshi.project.xyt.entity.vo.RealRainListVo;
import com.gunshi.project.xyt.service.RealRainService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/real/rain")
@Tag(name = "降雨信息查询接口")
@Data
public class RealRainController {
@Autowired
private RealRainService realRainService;
@Post(path="/list", summary = "实时雨情-降雨信息-查询接口")
public R<List<RealRainListVo>> getRealRainList(@RequestBody RealRainBaseSo realRainBaseSo) {
List<RealRainListVo> list = realRainService.getRealRainList(realRainBaseSo);
//按RealRainListVo.drp倒序排列null的排在最后面
list.sort((o1, o2) -> {
if (o1.getDrp() == null) {
return 1;
}
if (o2.getDrp() == null) {
return -1;
}
return o2.getDrp().compareTo(o1.getDrp());
});
return R.ok(list);
}
}

View File

@ -0,0 +1,18 @@
package com.gunshi.project.xyt.entity.so;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
@Data
public class RealRainBaseSo {
@Schema(description="开始时间 格式yyyy-MM-dd HH:mm:ss")
@NotBlank(message = "开始时间不能为空")
private String stm;
@Schema(description="结束时间 格式yyyy-MM-dd HH:mm:ss")
@NotBlank(message = "结束时间不能为空")
private String etm;
}

View File

@ -0,0 +1,57 @@
package com.gunshi.project.xyt.entity.so;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gunshi.core.dateformat.DateFormatString;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.Date;
/**
* TODO
*
* @ClassName StPptnSo
* @Author Huang Qianxiang
* @Date 2024/2/21 14:20
*/
@Data
@Schema(description = "雨量站降雨量查询参数")
public class StPptnSo {
/**
*
*/
@Schema(description = "测站名称")
private String stnm;
/**
*
*/
@Schema(description = "时间段")
private Integer timeQuantum;
/**
*
*/
@Schema(description="测站编码")
private String stcd;
/**
*
*/
@Schema(description = "选择的起始时间")
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
private Date startTime;
/**
*
*/
@Schema(description = "选择的结束时间")
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
private Date endTime;
}

View File

@ -0,0 +1,28 @@
package com.gunshi.project.xyt.entity.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* TODO
*
* @ClassName CartogramVo
* @Author Huang Qianxiang
* @Date 2024/3/26 14:24
*/
@Data
public class CartogramVo {
@Schema(description = "时间")
private List<String> time;
@Schema(description = "实测")
private List<BigDecimal> actual;
@Schema(description = "累计")
private List<BigDecimal> total;
}

View File

@ -0,0 +1,48 @@
package com.gunshi.project.xyt.entity.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class RealRainListVo {
private String stcd;
private String sttp;
private String stnm;
private String stlc;
@Schema(description = "时段雨量(mm)")
private Double drp;
private String adcd;
private String adnm;
private String resCode;
private String resName;
private String lgtd;
private String lttd;
@Schema(description="降雨量级 0:无降雨 1:小雨 2:中雨 3:大雨 4:暴雨 5:大暴雨 6:特大暴雨")
private Integer rainTag;
@Schema(description = "站点类型")
private String sType;
public void setDrp(Double drp){
this.drp = drp;
if (this.drp == 0) {
this.rainTag = 0;
} else if (this.drp > 0 && this.drp < 10) {
this.rainTag = 1;
} else if (this.drp >= 10 && this.drp < 25) {
this.rainTag = 2;
} else if (this.drp >= 25 && this.drp < 50) {
this.rainTag = 3;
} else if (this.drp >= 50 && this.drp < 100) {
this.rainTag = 4;
} else if (this.drp >= 100 && this.drp < 250) {
this.rainTag = 5;
} else if (this.drp >= 250) {
this.rainTag = 6;
}
}
}

View File

@ -0,0 +1,46 @@
package com.gunshi.project.xyt.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gunshi.core.dateformat.DateFormatString;
import com.gunshi.project.xyt.model.StPptnRReal;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
/**
* TODO
*
* @ClassName StPptnDetailsVo
* @Author Huang Qianxiang
* @Date 2024/2/23 10:53
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class StPptnDetailsVo extends StPptnRReal {
@Schema(description="昨日降雨量")
private BigDecimal yesterdayDrp;
@Schema(description="本月降雨量")
private BigDecimal monthDrp;
@Schema(description="本年降雨量")
private BigDecimal yearDrp;
@Schema(description="本年降雨天数")
private Long yearDrpDay;
@Schema(description="本年天数")
private Long yearDay;
@Schema(description="本年最大日雨量")
private BigDecimal maxDrp;
@Schema(description="本年最大日雨量时间")
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
private Date maxDrpTime;
}

View File

@ -0,0 +1,39 @@
package com.gunshi.project.xyt.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gunshi.core.dateformat.DateFormatString;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* TODO
*
* @ClassName StPptnVo
* @Author Huang Qianxiang
* @Date 2024/2/23 9:51
*/
@Data
public class StPptnVo {
/**
*
*/
@Schema(description = "时段降雨量对应的时间")
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
private Date time;
/**
*
*/
@Schema(description = "选择时段降雨量")
private BigDecimal sumDrp;
@Schema(description = "时间格式化字符串")
private String timeStr;
@Schema(description = "个数")
private Integer count;
}

View File

@ -0,0 +1,122 @@
package com.gunshi.project.xyt.mapper;
import com.gunshi.project.xyt.entity.vo.RealRainListVo;
import com.gunshi.project.xyt.entity.vo.StPptnVo;
import com.gunshi.project.xyt.model.StPptnRD;
import com.gunshi.project.xyt.model.StPptnRReal;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.Date;
import java.util.List;
@Mapper
public interface RealRainMapper {
@Select("""
<script>
with m1 as (select t1.stcd,
t1.sttp,
s1.adcd,
t1.stlc,
s1.adnm,
t1.stnm,
t3.res_code,
t3.res_name,
t1.lgtd,
t1.lttd
from st_stbprp_b t1
left join att_res_base t3 on t3.stcd = t1.stcd
left join st_addvcd_d s1 on s1.adcd = t1.adcd
left join st_stbprp_b_elem s2 on s2.stcd = t1.stcd
where s2.elem = 'drp' ),
m2 as (select t1.stcd, sum(t1.drp) drp
from public.st_pptn_r t1
WHERE t1.tm &gt; #{stm}::timestamp and t1.tm &lt;= #{etm}::timestamp
GROUP BY t1.stcd)
select m1.stcd,
m1.sttp,
m1.stnm,
m1.stlc,
m2.drp,
m1.adcd,
m1.adnm,
m1.res_code,
m1.res_name,
m1.lgtd,
m1.lttd
from m1
left join m2 on m1.stcd = m2.stcd
</script>
""")
List<RealRainListVo> getRealRainList(@Param("stm") String stm, @Param("etm") String etm);
@Select("""
<script>
select date_trunc('hour', t.tm) as time,sum(t.drp) as sumDrp from
(select t1.stcd,t1.tm + INTERVAL '1' HOUR AS tm,t1.drp
from public.st_pptn_r t1
WHERE t1.tm &gt; #{startTime} and t1.tm &lt;= #{endTime}
and to_char(t1.tm,'MI') != '00' and t1.stcd = #{stcd}
union all select t2.stcd,t2.tm,t2.drp
from public.st_pptn_r t2
WHERE t2.tm &gt; #{startTime} and t2.tm &lt;= #{endTime}
and to_char(t2.tm,'MI') = '00' and t2.stcd = #{stcd}) t
GROUP BY date_trunc('hour', t.tm)
ORDER BY date_trunc('hour', t.tm) DESC
</script>
""")
List<StPptnVo> queryStPptnPerHourByStcdAndStartTimeAndEndTime(@Param("stcd") String stcd, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
@Select("""
<script>
SELECT * FROM public.st_pptn_r_d
WHERE stcd=#{stcd} and tm=#{tm} and year=#{year}
</script>
""")
StPptnRD getStPptnRD(@Param("stcd") String stcd, @Param("tm") Date tm, @Param("year") Integer year);
@Select("""
<script>
SELECT *
FROM public.st_pptn_r_d
WHERE stcd = #{stcd}
AND year = #{year}
AND (drp, tm) = (
SELECT MAX(drp), MAX(tm)
FROM public.st_pptn_r_d
WHERE stcd = #{stcd}
AND year = #{year}
AND drp = (
SELECT MAX(drp)
FROM public.st_pptn_r_d
WHERE stcd = #{stcd}
AND year = #{year}
)
);
</script>
""")
StPptnRD getMaxOfYear(@Param("stcd") String stcd, @Param("year") Integer year);
@Select("""
<script>
SELECT count(*) FROM public.st_pptn_r_d
WHERE stcd= #{stcd}
AND year = #{year}
AND drp > 0
</script>
""")
Long getRainOfDayInYear(@Param("stcd") String stcd, @Param("year") Integer year);
@Select("""
<script>
SELECT * FROM "public".st_pptn_r_real
WHERE stcd = #{stcd}
ORDER BY tm DESC
limit 1
</script>
""")
StPptnRReal queryPptnByStcd(@Param("stcd") String stcd);
}

View File

@ -0,0 +1,52 @@
package com.gunshi.project.xyt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gunshi.project.xyt.model.StPptnR;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Mapper
public interface StPptnRMapper extends BaseMapper<StPptnR> {
int updateBatch(List<StPptnR> list);
int updateBatchSelective(List<StPptnR> list);
int batchInsert(@Param("list") List<StPptnR> list);
int insertOrUpdate(StPptnR record);
int insertOrUpdateSelective(StPptnR record);
@Select("""
<script>
with m1 as (
select stcd,drp from qx.st_pptn_r qxt WHERE
tm &gt; #{startTime} and tm &lt;= #{endTime} and exists(select 1 from public.st_stbprp_b stb where stb.stcd=qxt.stcd and source='QX')
union ALL
select stcd,drp from sh.st_pptn_r sht WHERE
tm &gt; #{startTime} and tm &lt;= #{endTime} and exists(select 1 from public.st_stbprp_b stb where stb.stcd=sht.stcd and source='SH')
union ALL
select stcd,drp from sk.st_pptn_r skt WHERE
tm &gt; #{startTime} and tm &lt;= #{endTime} and exists(select 1 from public.st_stbprp_b stb where stb.stcd=skt.stcd and source='SK')
union ALL
select stcd,drp from sw.st_pptn_r swt WHERE
tm &gt; #{startTime} and tm &lt;= #{endTime} and exists(select 1 from public.st_stbprp_b stb where stb.stcd=swt.stcd and source='SW'))
select SUM(m1.drp) as sumdrp FROM m1
GROUP BY m1.stcd
HAVING m1.stcd = #{stcd}
</script>
""")
BigDecimal queryStPptnTimeQuantumByStcdAndTime(@Param("stcd") String stcd, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
}

View File

@ -0,0 +1,98 @@
package com.gunshi.project.xyt.model;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
*
*/
@Schema(description="降水量表")
@Data
@TableName(value = "st_pptn_r")
public class StPptnR implements Serializable {
/**
*
*/
@TableField(value = "tm")
@MppMultiId
@Schema(description="时间")
@NotNull(message = "时间不能为null")
private Date tm;
/**
*
*/
@TableField(value = "stcd")
@MppMultiId
@Schema(description="测站编码")
@Size(max = 20,message = "测站编码最大长度要小于 20")
@NotBlank(message = "测站编码不能为空")
private String stcd;
/**
*
*/
@TableField(value = "drp")
@Schema(description="时段降水量")
private BigDecimal drp;
/**
*
*/
@TableField(value = "intv")
@Schema(description="时段长")
private BigDecimal intv;
/**
*
*/
@TableField(value = "pdr")
@Schema(description="降水历时")
private BigDecimal pdr;
/**
*
*/
@TableField(value = "dyp")
@Schema(description="日降水量")
private BigDecimal dyp;
/**
*
*/
@TableField(value = "wth")
@Schema(description="天气状况")
private String wth;
@TableField(value = "chtm")
@Schema(description="")
private Date chtm;
private static final long serialVersionUID = 1L;
public static final String COL_TM = "tm";
public static final String COL_STCD = "stcd";
public static final String COL_DRP = "drp";
public static final String COL_INTV = "intv";
public static final String COL_PDR = "pdr";
public static final String COL_DYP = "dyp";
public static final String COL_WTH = "wth";
public static final String COL_CHTM = "chtm";
}

View File

@ -0,0 +1,44 @@
package com.gunshi.project.xyt.model;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Schema
@Data
@TableName(value = "st_pptn_r_d")
public class StPptnRD implements Serializable {
/**
*
*/
@MppMultiId("tm")
@Schema(description="时间")
private Date tm;
/**
*
*/
@MppMultiId("stcd")
@Schema(description="测站编码")
private String stcd;
/**
*
*/
@TableField(value = "drp")
@Schema(description="时段降水量")
private BigDecimal drp;
/**
*
*/
@MppMultiId("year")
@Schema(description="年度")
private Integer year;
}

View File

@ -0,0 +1,126 @@
package com.gunshi.project.xyt.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gunshi.core.dateformat.DateFormatString;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Schema
@Data
@TableName(value = "st_pptn_r_real")
public class StPptnRReal implements Serializable {
@TableId(value = "stcd", type = IdType.INPUT)
@Schema(description="")
@Size(max = 20,message = "最大长度要小于 20")
@NotBlank(message = "不能为空")
private String stcd;
@TableField(value = "tm")
@Schema(description="")
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
private Date tm;
@TableField(value = "drp")
@Schema(description="")
private BigDecimal drp;
@TableField(value = "today")
@Schema(description="")
private BigDecimal today;
@TableField(value = "m10")
@Schema(description="")
private BigDecimal m10;
@TableField(value = "m30")
@Schema(description="")
private BigDecimal m30;
@TableField(value = "h1")
@Schema(description="")
private BigDecimal h1;
@TableField(value = "h3")
@Schema(description="")
private BigDecimal h3;
@TableField(value = "h6")
@Schema(description="")
private BigDecimal h6;
@TableField(value = "h12")
@Schema(description="")
private BigDecimal h12;
@TableField(value = "h24")
@Schema(description="")
private BigDecimal h24;
@TableField(value = "h48")
@Schema(description="")
private BigDecimal h48;
@TableField(value = "chtm")
@Schema(description="")
@NotNull(message = "不能为null")
private Date chtm;
@TableField(value = "warning")
@Schema(description="")
private Short warning;
@TableField(value = "\"status\"")
@Schema(description="")
private Short status;
@TableField(value = "\"cluster\"")
@Schema(description="")
@Size(max = 10,message = "最大长度要小于 10")
@NotBlank(message = "不能为空")
private String cluster;
private static final long serialVersionUID = 1L;
public static final String COL_STCD = "stcd";
public static final String COL_TM = "tm";
public static final String COL_DRP = "drp";
public static final String COL_TODAY = "today";
public static final String COL_M10 = "m10";
public static final String COL_M30 = "m30";
public static final String COL_H1 = "h1";
public static final String COL_H3 = "h3";
public static final String COL_H6 = "h6";
public static final String COL_H12 = "h12";
public static final String COL_H24 = "h24";
public static final String COL_H48 = "h48";
public static final String COL_CHTM = "chtm";
public static final String COL_WARNING = "warning";
public static final String COL_STATUS = "status";
public static final String COL_CLUSTER = "cluster";
}

View File

@ -0,0 +1,418 @@
package com.gunshi.project.xyt.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Schema
@Data
@TableName(value = "public.st_stbprp_b")
public class StStbprpB implements Serializable {
@TableId(value = "stcd", type = IdType.INPUT)
@TableField(value = "stcd")
@Schema(description="")
@Size(max = 20,message = "最大长度要小于 20")
@NotBlank(message = "不能为空")
private String stcd;
@TableField(value = "stnm")
@Schema(description="")
@Size(max = 150,message = "最大长度要小于 150")
private String stnm;
@TableField(value = "rvnm")
@Schema(description="")
@Size(max = 300,message = "最大长度要小于 300")
private String rvnm;
@TableField(value = "hnnm")
@Schema(description="")
@Size(max = 300,message = "最大长度要小于 300")
private String hnnm;
@TableField(value = "bsnm")
@Schema(description="")
@Size(max = 300,message = "最大长度要小于 300")
private String bsnm;
@TableField(value = "lgtd")
@Schema(description="")
private BigDecimal lgtd;
@TableField(value = "lttd")
@Schema(description="")
private BigDecimal lttd;
@TableField(value = "stlc")
@Schema(description="")
@Size(max = 500,message = "最大长度要小于 500")
private String stlc;
@TableField(value = "addvcd")
@Schema(description="")
@Size(max = 15,message = "最大长度要小于 15")
private String addvcd;
@TableField(value = "alt")
@Schema(description="")
private BigDecimal alt;
@TableField(value = "mdbz")
@Schema(description="")
private BigDecimal mdbz;
@TableField(value = "mdpr")
@Schema(description="")
private BigDecimal mdpr;
@TableField(value = "dtmnm")
@Schema(description="")
@Size(max = 160,message = "最大长度要小于 160")
private String dtmnm;
@TableField(value = "dtmel")
@Schema(description="")
private BigDecimal dtmel;
@TableField(value = "dtpr")
@Schema(description="")
private BigDecimal dtpr;
@TableField(value = "sttp")
@Schema(description="")
@Size(max = 30,message = "最大长度要小于 30")
private String sttp;
@TableField(value = "dfrtms")
@Schema(description="")
private Short dfrtms;
@TableField(value = "fritm")
@Schema(description="")
@Size(max = 320,message = "最大长度要小于 320")
private String fritm;
@TableField(value = "frgrd")
@Schema(description="")
@Size(max = 500,message = "最大长度要小于 500")
private String frgrd;
@TableField(value = "esstym")
@Schema(description="")
@Size(max = 60,message = "最大长度要小于 60")
private String esstym;
@TableField(value = "bgfrym")
@Schema(description="")
@Size(max = 60,message = "最大长度要小于 60")
private String bgfrym;
@TableField(value = "edfrym")
@Schema(description="")
@Size(max = 60,message = "最大长度要小于 60")
private String edfrym;
@TableField(value = "atcunit")
@Schema(description="")
@Size(max = 200,message = "最大长度要小于 200")
private String atcunit;
@TableField(value = "admauth")
@Schema(description="")
@Size(max = 500,message = "最大长度要小于 500")
private String admauth;
@TableField(value = "locality")
@Schema(description="")
@Size(max = 200,message = "最大长度要小于 200")
private String locality;
@TableField(value = "stbk")
@Schema(description="")
private String stbk;
@TableField(value = "stazt")
@Schema(description="")
private Short stazt;
@TableField(value = "dstrvm")
@Schema(description="")
private BigDecimal dstrvm;
@TableField(value = "drna")
@Schema(description="")
private Integer drna;
@TableField(value = "phcd")
@Schema(description="")
@Size(max = 60,message = "最大长度要小于 60")
private String phcd;
@TableField(value = "usfl")
@Schema(description="")
private String usfl;
@TableField(value = "comments")
@Schema(description="")
@Size(max = 200,message = "最大长度要小于 200")
private String comments;
@TableField(value = "moditime")
@Schema(description="")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date moditime;
@TableField(value = "rem_gd")
@Schema(description="")
@Size(max = 300,message = "最大长度要小于 300")
private String remGd;
@TableField(value = "ogid")
@Schema(description="")
@Size(max = 100,message = "最大长度要小于 100")
private String ogid;
@TableField(value = "vlfl")
@Schema(description="")
private Short vlfl;
@TableField(value = "atid")
@Schema(description="")
@Size(max = 180,message = "最大长度要小于 180")
private String atid;
@TableField(value = "sdfl")
@Schema(description="")
@Size(max = 500,message = "最大长度要小于 500")
private String sdfl;
@TableField(value = "rma")
@Schema(description="")
@Size(max = 256,message = "最大长度要小于 256")
private String rma;
@TableField(value = "mdps")
@Schema(description="")
@Size(max = 300,message = "最大长度要小于 300")
private String mdps;
@TableField(value = "mddt")
@Schema(description="")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date mddt;
@TableField(value = "stindex")
@Schema(description="")
private Integer stindex;
@TableField(value = "starea")
@Schema(description="")
@Size(max = 500,message = "最大长度要小于 500")
private String starea;
@TableField(value = "stlevel")
@Schema(description="")
private String stlevel;
@TableField(value = "code")
@Schema(description="")
@Size(max = 300,message = "最大长度要小于 300")
private String code;
@TableField(value = "ispbj")
@Schema(description="")
private String ispbj;
@TableField(value = "issxst")
@Schema(description="")
private String issxst;
@TableField(value = "stpq")
@Schema(description="")
@Size(max = 500,message = "最大长度要小于 500")
private String stpq;
@TableField(value = "sthday")
@Schema(description="")
private Integer sthday;
@TableField(value = "\"source\"")
@Schema(description="")
@Size(max = 2,message = "最大长度要小于 2")
@NotBlank(message = "不能为空")
private String source;
@TableField(value = "importancy")
@Schema(description="")
private Integer importancy;
@TableField(value = "clgtd")
@Schema(description="")
private BigDecimal clgtd;
@TableField(value = "clttd")
@Schema(description="")
private BigDecimal clttd;
@TableField(value = "elev")
@Schema(description="")
private BigDecimal elev;
@TableField(value = "crucial")
@Schema(description="")
private Integer crucial;
@TableField(value = "build_year")
@Schema(description="")
@Size(max = 50,message = "最大长度要小于 50")
private String buildYear;
@TableField(value = "adcd")
@Schema(description="行政区划编码")
@Size(max = 15,message = "最大长度要小于 15")
private String adcd;
@TableField(value = "lyid")
@Schema(description="流域编码")
private String lyid;
@TableField(value = "res_code")
@Schema(description="水库编码")
private String resCode;
@TableField(value = "rv_code")
@Schema(description="河流编码")
private String rvCode;
/**
* 1 0
*/
@TableField(value = "status")
@Schema(description="状态 1有效 0无效")
private Integer status;
private static final long serialVersionUID = 1L;
public static final String COL_STCD = "stcd";
public static final String COL_STNM = "stnm";
public static final String COL_RVNM = "rvnm";
public static final String COL_HNNM = "hnnm";
public static final String COL_BSNM = "bsnm";
public static final String COL_LGTD = "lgtd";
public static final String COL_LTTD = "lttd";
public static final String COL_STLC = "stlc";
public static final String COL_ADDVCD = "addvcd";
public static final String COL_ALT = "alt";
public static final String COL_MDBZ = "mdbz";
public static final String COL_MDPR = "mdpr";
public static final String COL_DTMNM = "dtmnm";
public static final String COL_DTMEL = "dtmel";
public static final String COL_DTPR = "dtpr";
public static final String COL_STTP = "sttp";
public static final String COL_DFRTMS = "dfrtms";
public static final String COL_FRITM = "fritm";
public static final String COL_FRGRD = "frgrd";
public static final String COL_ESSTYM = "esstym";
public static final String COL_BGFRYM = "bgfrym";
public static final String COL_EDFRYM = "edfrym";
public static final String COL_ATCUNIT = "atcunit";
public static final String COL_ADMAUTH = "admauth";
public static final String COL_LOCALITY = "locality";
public static final String COL_STBK = "stbk";
public static final String COL_STAZT = "stazt";
public static final String COL_DSTRVM = "dstrvm";
public static final String COL_DRNA = "drna";
public static final String COL_PHCD = "phcd";
public static final String COL_USFL = "usfl";
public static final String COL_COMMENTS = "comments";
public static final String COL_MODITIME = "moditime";
public static final String COL_REM_GD = "rem_gd";
public static final String COL_OGID = "ogid";
public static final String COL_VLFL = "vlfl";
public static final String COL_ATID = "atid";
public static final String COL_SDFL = "sdfl";
public static final String COL_RMA = "rma";
public static final String COL_MDPS = "mdps";
public static final String COL_MDDT = "mddt";
public static final String COL_STINDEX = "stindex";
public static final String COL_STAREA = "starea";
public static final String COL_STLEVEL = "stlevel";
public static final String COL_CODE = "code";
public static final String COL_ISPBJ = "ispbj";
public static final String COL_ISSXST = "issxst";
public static final String COL_STPQ = "stpq";
public static final String COL_STHDAY = "sthday";
public static final String COL_SOURCE = "source";
public static final String COL_IMPORTANCY = "importancy";
public static final String COL_CLGTD = "clgtd";
public static final String COL_CLTTD = "clttd";
public static final String COL_ELEV = "elev";
public static final String COL_CRUCIAL = "crucial";
public static final String COL_BUILD_YEAR = "build_year";
}

View File

@ -0,0 +1,460 @@
package com.gunshi.project.xyt.service;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gunshi.project.xyt.entity.so.StPptnSo;
import com.gunshi.project.xyt.entity.vo.CartogramVo;
import com.gunshi.project.xyt.entity.vo.StPptnDetailsVo;
import com.gunshi.project.xyt.entity.vo.StPptnVo;
import com.gunshi.project.xyt.mapper.RealRainMapper;
import com.gunshi.project.xyt.mapper.StPptnRMapper;
import com.gunshi.project.xyt.model.StPptnRD;
import com.gunshi.project.xyt.model.StPptnRReal;
import com.gunshi.project.xyt.model.StStbprpB;
import com.gunshi.project.xyt.model.StStbprpBAutoDao;
import jakarta.annotation.Resource;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.*;
/**
* Description:
* Created by wanyan on 2024/7/8
*
* @author wanyan
* @version 1.0
*/
@Service
@Slf4j
public class RainBasinDivisionService {
@Autowired
private RealRainMapper realRainMapper;
@Autowired
private StPptnRMapper stPptnRMapper;
@Resource
private StStbprpBAutoDao stStbprpBAutoDao;
/**
*
*
* @param stPptnSo
* @return
*/
public List<StPptnVo> queryStPptnPerHourByStcdAndStartTimeAndEndTime(StPptnSo stPptnSo) {
String stcd = stPptnSo.getStcd();
List<StPptnVo> stPptnVos = realRainMapper.queryStPptnPerHourByStcdAndStartTimeAndEndTime(stcd, stPptnSo.getStartTime(), stPptnSo.getEndTime());
SimpleDateFormat df = new SimpleDateFormat("MM-dd HH:mm");
for (StPptnVo stPptnVo : stPptnVos) {
Date time = stPptnVo.getTime();
stPptnVo.setTimeStr(df.format(time));
}
return stPptnVos;
}
/**
*
*
* @param stPptnSo
* @return
*/
public CartogramVo queryStPptnPerHourChartByStcdAndStartTimeAndEndTime(StPptnSo stPptnSo) {
//实测
List<StPptnVo> stPptnVos1 = queryStPptnPerHourNowByStcdAndStartTimeAndEndTime(stPptnSo);
//累计
List<StPptnVo> stPptnVos2 = queryStPptnPerHourSumByStcdAndStartTimeAndEndTime(stPptnSo);
CartogramVo cartogramVo = new CartogramVo();
List<String> time = new ArrayList<>();
List<BigDecimal> actual = new ArrayList<>();
List<BigDecimal> total = new ArrayList<>();
for (StPptnVo stPptnVo : stPptnVos1) {
time.add(stPptnVo.getTimeStr());
actual.add(stPptnVo.getSumDrp());
}
for (StPptnVo stPptnVo : stPptnVos2) {
total.add(stPptnVo.getSumDrp());
}
cartogramVo.setTime(time);
cartogramVo.setActual(actual);
cartogramVo.setTotal(total);
return cartogramVo;
}
/**
*
*
* @param stPptnSo
* @return
*/
public List<StPptnVo> queryStPptnPerHourNowByStcdAndStartTimeAndEndTime(StPptnSo stPptnSo) {
List<StPptnVo> stPptnVos = queryStPptnPerHourByStcdAndStartTimeAndEndTime(stPptnSo);
Collections.reverse(stPptnVos);
return stPptnVos;
}
/**
*
*
* @param stPptnSo
* @return
*/
public List<StPptnVo> queryStPptnPerHourSumByStcdAndStartTimeAndEndTime(StPptnSo stPptnSo) {
List<StPptnVo> stPptnVos = queryStPptnPerHourNowByStcdAndStartTimeAndEndTime(stPptnSo);
BigDecimal sumdrp = BigDecimal.valueOf(0);
for (StPptnVo stPptnVo : stPptnVos) {
sumdrp = sumdrp.add(stPptnVo.getSumDrp());
stPptnVo.setSumDrp(sumdrp);
}
return stPptnVos;
}
/**
*
*
* @param stPptnSo
* @return
*/
@SneakyThrows
public List<StPptnVo> queryStPptnPerDayByStcdAndStartTimeAndEndTime(StPptnSo stPptnSo) {
String stcd = stPptnSo.getStcd();
Date stm = stPptnSo.getStartTime();
Date etm = stPptnSo.getEndTime();
Date now = new Date();
if (etm.getTime() > now.getTime()) etm = now;
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
stm = df.parse(df.format(stm));
etm = df.parse(df.format(etm));
Calendar cal = Calendar.getInstance();
List<StPptnVo> stPptnVos = new ArrayList<>();
while (etm.getTime() >= stm.getTime()) {
cal.setTime(stm);
StPptnVo stPptnVo = new StPptnVo();
stPptnVo.setTime(stm);
stPptnVo.setTimeStr(df.format(stm));
int year = cal.get(Calendar.YEAR);
StPptnRD pptnrd = realRainMapper.getStPptnRD(
stcd, stm, year
);
if (pptnrd != null) {
stPptnVo.setSumDrp(pptnrd.getDrp());
}
stPptnVos.add(stPptnVo);
cal.add(Calendar.DAY_OF_MONTH, 1);
stm = cal.getTime();
}
return stPptnVos;
}
/**
*
*
* @param stPptnSo
* @return
*/
public CartogramVo queryStPptnPerDayChartChartByStcdAndStartTimeAndEndTime(StPptnSo stPptnSo) {
//实测
List<StPptnVo> stPptnVos1 = queryStPptnPerDayByStcdAndStartTimeAndEndTime(stPptnSo);
//累计
List<StPptnVo> stPptnVos2 = queryStPptnPerDaySumByStcdAndStartTimeAndEndTime(stPptnSo);
CartogramVo cartogramVo = new CartogramVo();
List<String> time = new ArrayList<>();
List<BigDecimal> actual = new ArrayList<>();
List<BigDecimal> total = new ArrayList<>();
for (StPptnVo stPptnVo : stPptnVos1) {
time.add(stPptnVo.getTimeStr());
actual.add(stPptnVo.getSumDrp());
}
for (StPptnVo stPptnVo : stPptnVos2) {
total.add(stPptnVo.getSumDrp());
}
cartogramVo.setTime(time);
cartogramVo.setActual(actual);
cartogramVo.setTotal(total);
return cartogramVo;
}
/**
*
*
* @param stPptnSo
* @return
*/
public List<StPptnVo> queryStPptnPerDaySumByStcdAndStartTimeAndEndTime(StPptnSo stPptnSo) {
List<StPptnVo> stPptnVos = queryStPptnPerDayByStcdAndStartTimeAndEndTime(stPptnSo);
BigDecimal sumdrp = BigDecimal.valueOf(0);
for (StPptnVo stPptnVo : stPptnVos) {
if (stPptnVo.getSumDrp() != null){
sumdrp = sumdrp.add(stPptnVo.getSumDrp());
}
stPptnVo.setSumDrp(sumdrp);
}
return stPptnVos;
}
/**
*
*
* @param stcd
* @return
*/
public StPptnDetailsVo queryStPptnDetailsByStcd(String stcd) {
// StPptnRStat stPptnRStat = stPptnRStatMapper.queryStPptnRStatByStcd(stcd);
StPptnRReal stPptnRReal = realRainMapper.queryPptnByStcd(stcd);
StPptnDetailsVo stPptnDetailsVo = new StPptnDetailsVo();
if (stPptnRReal != null){
BeanUtil.copyProperties(stPptnRReal, stPptnDetailsVo);
}else {
stPptnDetailsVo.setStcd(stcd);
}
BigDecimal value0 = new BigDecimal(0);
Date date = new Date();
// //48小时降雨量
// BigDecimal h48 = stStbprpBMapper.queryStPptn48HByStcd(stcd);
// if (h48 == null) {
// stPptnDetailsVo.setH48(value0);
// } else {
// stPptnDetailsVo.setH48(h48);
// }
//
// //今日雨量
// BigDecimal todayDrp = queryTodayDrpByStcdAndTime(stcd, date);
// if (todayDrp == null) {
// stPptnDetailsVo.setTodayDrp(value0);
// } else {
// stPptnDetailsVo.setTodayDrp(todayDrp);
// }
//昨日雨量
BigDecimal yesterdayDrp = queryYesterdayDrpByStcdAndTime(stcd, date);
if (yesterdayDrp == null) {
stPptnDetailsVo.setYesterdayDrp(value0);
} else {
stPptnDetailsVo.setYesterdayDrp(yesterdayDrp);
}
//本月降雨量
BigDecimal monthDay = queryMonthDrpByStcdAndTime(stcd, date);
if (monthDay == null) {
stPptnDetailsVo.setMonthDrp(value0);
} else {
stPptnDetailsVo.setMonthDrp(monthDay);
}
//本年降雨量
BigDecimal yearDrp = queryYearDrpByStcdAndTime(stcd, date);
if (yearDrp == null) {
stPptnDetailsVo.setYearDrp(value0);
} else {
stPptnDetailsVo.setYearDrp(yearDrp);
}
//本年天数
Long yearDay = countYearDay(date);
stPptnDetailsVo.setYearDay(yearDay);
Map<String, Object> map = queryYearDrpDayAndMaxDrpAndMaxDrpTimeByStcdAndTime(stcd, date);
//本年降雨天数
Long yearDrpDay = (Long) map.get("count");
stPptnDetailsVo.setYearDrpDay(yearDrpDay);
//本年最大日雨量
BigDecimal maxDrp = (BigDecimal) map.get("maxDrp");
stPptnDetailsVo.setMaxDrp(maxDrp);
//本年最大日雨量时间
Date maxDrpTime =(Date) map.get("maxDrpTime");
stPptnDetailsVo.setMaxDrpTime(maxDrpTime);
return stPptnDetailsVo;
}
/**
*
*
* @param stcd
* @param time
* @return
*/
public BigDecimal queryYesterdayDrpByStcdAndTime(String stcd, Date time) {
LocalDateTime now = LocalDateTime.ofInstant(time.toInstant(), ZoneId.systemDefault());
LocalDateTime startTime;
LocalDateTime endTime;
LocalDateTime yesterday = now.minusDays(1);
if (now.getHour() >= 8) {
startTime = LocalDateTime.of(
yesterday.getYear(),
yesterday.getMonthValue(),
yesterday.getDayOfMonth(),
8,
0,
0
);
endTime = LocalDateTime.of(
now.getYear(),
now.getMonthValue(),
now.getDayOfMonth(),
8,
0,
0
);
} else {
endTime = endTime = LocalDateTime.of(
yesterday.getYear(),
yesterday.getMonthValue(),
yesterday.getDayOfMonth(),
8,
0,
0
);
yesterday = yesterday.minusDays(1);
startTime = LocalDateTime.of(
yesterday.getYear(),
yesterday.getMonthValue(),
yesterday.getDayOfMonth(),
8,
0,
0
);
}
return stPptnRMapper.queryStPptnTimeQuantumByStcdAndTime(
stcd,
Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant()),
Date.from(endTime.atZone(ZoneId.systemDefault()).toInstant())
);
}
/**
*
*
* @param stcd
* @param time
* @return
*/
public BigDecimal queryMonthDrpByStcdAndTime(String stcd, Date time) {
LocalDateTime now = LocalDateTime.ofInstant(time.toInstant(), ZoneId.systemDefault());
LocalDateTime startTime;
LocalDateTime endTime;
if (now.getHour() >= 8 || (now.getHour() < 8 && now.getDayOfMonth() > 1)) {
startTime = LocalDateTime.of(
now.getYear(),
now.getMonthValue(),
1,
8,
0,
0
);
endTime = now;
return stPptnRMapper.queryStPptnTimeQuantumByStcdAndTime(
stcd,
Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant()),
Date.from(endTime.atZone(ZoneId.systemDefault()).toInstant())
);
}
BigDecimal monthdrp = BigDecimal.valueOf(0);
return monthdrp;
}
/**
*
*
* @param stcd
* @param time
* @return
*/
public BigDecimal queryYearDrpByStcdAndTime(String stcd, Date time) {
LocalDateTime now = LocalDateTime.ofInstant(time.toInstant(), ZoneId.systemDefault());
LocalDateTime startTime;
LocalDateTime endTime;
if (now.getHour() >= 8 || (now.getHour() < 8 && now.getMonthValue() > 1) || (now.getHour() < 8 && now.getMonthValue() == 1 && now.getDayOfMonth() >= 1)) {
startTime = LocalDateTime.of(
now.getYear(),
1,
1,
8,
0,
0
);
endTime = now;
return stPptnRMapper.queryStPptnTimeQuantumByStcdAndTime(
stcd,
Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant()),
Date.from(endTime.atZone(ZoneId.systemDefault()).toInstant())
);
}
BigDecimal monthDrp = BigDecimal.valueOf(0);
return monthDrp;
}
/**
*
*
* @param stcd
* @param time
* @return
*/
public Map<String, Object> queryYearDrpDayAndMaxDrpAndMaxDrpTimeByStcdAndTime(String stcd, Date time) {
Date now = new Date();
Date startTime = new Date(now.getYear(), 0, 1, 8, 0, 0);
BigDecimal maxDrp = BigDecimal.valueOf(0);
Date maxDrpTime = startTime;
Long count = 0L;
Map<String, Object> map = new HashMap<>();
map.put("count", count);
map.put("maxDrp", maxDrp);
map.put("maxDrpTime", maxDrpTime);
QueryWrapper<StStbprpB> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(StStbprpB.COL_STCD,stcd);
StStbprpB stStbprpB = stStbprpBAutoDao.getOne(queryWrapper);
StPptnRD stPptnRD = realRainMapper.getMaxOfYear(stcd,now.getYear() + 1900);
if (stPptnRD == null){
return map;
}
count = realRainMapper.getRainOfDayInYear(stcd, now.getYear()+1900);
map.put("count", count);
map.put("maxDrp", stPptnRD.getDrp());
map.put("maxDrpTime", stPptnRD.getTm());
return map;
}
/**
*
*
* @param time
* @return
*/
public Long countYearDay(Date time) {
LocalDateTime now = LocalDateTime.ofInstant(time.toInstant(), ZoneId.systemDefault());
LocalDateTime startTime = LocalDateTime.of(now.getYear(), 1, 1, 8, 0, 0);
long count = ChronoUnit.DAYS.between(startTime, now);
return count + 1;
}
}

View File

@ -0,0 +1,45 @@
package com.gunshi.project.xyt.service;
import com.gunshi.project.xyt.entity.so.RealRainBaseSo;
import com.gunshi.project.xyt.entity.vo.RealRainListVo;
import com.gunshi.project.xyt.mapper.RealRainMapper;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
/**
* Description:
* Created by wanyan on 2024/7/8
*
* @author wanyan
* @version 1.0
*/
@Service
@Data
@Slf4j
public class RealRainService {
@Autowired
private RealRainMapper realRainMapper;
/**
* --
*
* @param realRainBaseSo
* @return
*/
public List<RealRainListVo> getRealRainList(RealRainBaseSo realRainBaseSo) {
List<RealRainListVo> result = realRainMapper.getRealRainList(realRainBaseSo.getStm(), realRainBaseSo.getEtm());
result.sort(Comparator.comparing(RealRainListVo::getDrp, Comparator.nullsFirst(Double::compareTo)).reversed().thenComparing(RealRainListVo::getStcd));
return result;
}
}