From cb175aa022d74363e20fdfa543665923896142f9 Mon Sep 17 00:00:00 2001 From: wany <13995595726@qq.com> Date: Mon, 8 Jul 2024 17:41:17 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=8D=E9=9B=A8=E4=BF=A1=E6=81=AF=EF=BC=8C?= =?UTF-8?q?=E6=B0=B4=E5=BA=93=E6=B0=B4=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ReservoirWaterController.java | 59 +++ .../xyt/entity/so/DataQueryCommonSo.java | 33 ++ .../xyt/entity/so/ReservoirWaterCommonSo.java | 22 ++ .../project/xyt/entity/vo/AttResBaseVo.java | 226 ++++++++++++ .../xyt/entity/vo/AttResMonitorVo.java | 59 +++ .../project/xyt/entity/vo/StRsvrVo.java | 25 ++ .../project/xyt/mapper/AttResBaseMapper.java | 90 +++++ .../project/xyt/mapper/RescueGoodsMapper.java | 8 +- .../project/xyt/mapper/StZvarlBMapper.java | 23 ++ .../gunshi/project/xyt/model/AttResBase.java | 340 ++++++++++++++++++ .../gunshi/project/xyt/model/StImgRReal.java | 67 ++++ .../com/gunshi/project/xyt/model/StRsvrR.java | 119 ++++++ .../gunshi/project/xyt/model/StZvarlB.java | 96 +++++ .../xyt/service/ReservoirWaterService.java | 164 +++++++++ .../project/xyt/util/DataHandleUtil.java | 37 ++ .../com/gunshi/project/xyt/util/DateUtil.java | 140 ++++++++ 16 files changed, 1504 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/gunshi/project/xyt/controller/ReservoirWaterController.java create mode 100644 src/main/java/com/gunshi/project/xyt/entity/so/DataQueryCommonSo.java create mode 100644 src/main/java/com/gunshi/project/xyt/entity/so/ReservoirWaterCommonSo.java create mode 100644 src/main/java/com/gunshi/project/xyt/entity/vo/AttResBaseVo.java create mode 100644 src/main/java/com/gunshi/project/xyt/entity/vo/AttResMonitorVo.java create mode 100644 src/main/java/com/gunshi/project/xyt/entity/vo/StRsvrVo.java create mode 100644 src/main/java/com/gunshi/project/xyt/mapper/AttResBaseMapper.java create mode 100644 src/main/java/com/gunshi/project/xyt/mapper/StZvarlBMapper.java create mode 100644 src/main/java/com/gunshi/project/xyt/model/AttResBase.java create mode 100644 src/main/java/com/gunshi/project/xyt/model/StImgRReal.java create mode 100644 src/main/java/com/gunshi/project/xyt/model/StRsvrR.java create mode 100644 src/main/java/com/gunshi/project/xyt/model/StZvarlB.java create mode 100644 src/main/java/com/gunshi/project/xyt/service/ReservoirWaterService.java create mode 100644 src/main/java/com/gunshi/project/xyt/util/DataHandleUtil.java create mode 100644 src/main/java/com/gunshi/project/xyt/util/DateUtil.java diff --git a/src/main/java/com/gunshi/project/xyt/controller/ReservoirWaterController.java b/src/main/java/com/gunshi/project/xyt/controller/ReservoirWaterController.java new file mode 100644 index 0000000..f174a0c --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/controller/ReservoirWaterController.java @@ -0,0 +1,59 @@ +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.DataQueryCommonSo; +import com.gunshi.project.xyt.entity.so.ReservoirWaterCommonSo; +import com.gunshi.project.xyt.entity.vo.AttResBaseVo; +import com.gunshi.project.xyt.entity.vo.AttResMonitorVo; +import com.gunshi.project.xyt.entity.vo.StRsvrVo; +import com.gunshi.project.xyt.model.StImgRReal; +import com.gunshi.project.xyt.service.ReservoirWaterService; +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.RestController; + +import java.util.List; + +/** + * Description: + * Created by wanyan on 2024/2/20 + * + * @author wanyan + * @version 1.0 + */ +@RestController +@RequestMapping("/reservoir/water") +@Tag(name = "水库水情") +public class ReservoirWaterController { + + + @Autowired + private ReservoirWaterService reservoirWaterService; + + @Post(path = "/rz", summary = "水库水位") + public R rz(@RequestBody ReservoirWaterCommonSo reservoirWaterCommonSo) { + return R.ok(reservoirWaterService.rz(reservoirWaterCommonSo)); + } + + @Post(path = "/list", summary = "水库水情列表") + public R> list() { + return R.ok(reservoirWaterService.list()); + } + + @Post(path = "/real/img", summary = "水库实时图像") + public R> realImg(@RequestBody ReservoirWaterCommonSo reservoirWaterCommonSo) { + return R.ok(reservoirWaterService.realImg(reservoirWaterCommonSo)); + } + + @Post(path = "/monitor/data", summary = "监测数据") + public R> monitorData(@RequestBody @Validated DataQueryCommonSo dataQueryCommonSo) { + return R.ok(reservoirWaterService.monitorData(dataQueryCommonSo)); + } + + +} diff --git a/src/main/java/com/gunshi/project/xyt/entity/so/DataQueryCommonSo.java b/src/main/java/com/gunshi/project/xyt/entity/so/DataQueryCommonSo.java new file mode 100644 index 0000000..5144be3 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/entity/so/DataQueryCommonSo.java @@ -0,0 +1,33 @@ +package com.gunshi.project.xyt.entity.so; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.Pattern; +import lombok.Data; + +/** + * + * Created by wanyan on 2024/2/2. + * + * @author wanyan + * @version 1.0 + */ +@Data +@Schema(description = "查询条件") +public class DataQueryCommonSo { + + @Schema(description="测站编码") + @NotEmpty(message = "测站编码不可为空") + private String stcd; + + @Schema(description = "开始时间") + @NotEmpty(message = "开始时间不能为空") + @Pattern(regexp = "^[1-9]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\\s+(20|21|22|23|[0-1]\\d):[0-5]\\d:[0-5]\\d$", message = "时间格式应为:yyyy-MM-dd HH:mm:ss") + private String stm; + + @Schema(description = "结束时间") + @NotEmpty(message = "结束时间不能为空") + @Pattern(regexp = "^[1-9]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\\s+(20|21|22|23|[0-1]\\d):[0-5]\\d:[0-5]\\d$", message = "时间格式应为:yyyy-MM-dd HH:mm:ss") + private String etm; + +} diff --git a/src/main/java/com/gunshi/project/xyt/entity/so/ReservoirWaterCommonSo.java b/src/main/java/com/gunshi/project/xyt/entity/so/ReservoirWaterCommonSo.java new file mode 100644 index 0000000..144d233 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/entity/so/ReservoirWaterCommonSo.java @@ -0,0 +1,22 @@ +package com.gunshi.project.xyt.entity.so; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import lombok.Data; + +/** + * + * Created by wanyan on 2024/2/2. + * + * @author wanyan + * @version 1.0 + */ +@Data +@Schema(description = "水库代码查询条件") +public class ReservoirWaterCommonSo { + + @Schema(description="水库代码") + @NotEmpty(message = "水库代码不可为空") + private String resCode; + +} diff --git a/src/main/java/com/gunshi/project/xyt/entity/vo/AttResBaseVo.java b/src/main/java/com/gunshi/project/xyt/entity/vo/AttResBaseVo.java new file mode 100644 index 0000000..4656596 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/entity/vo/AttResBaseVo.java @@ -0,0 +1,226 @@ +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; + +/** + * 水库水情 + * Created by wanyan on 2024/2/20 + * + * @author wanyan + * @version 1.0 + */ +@Data +public class AttResBaseVo { + + /** + * 测站编码 + */ + @Schema(description = "测站编码") + private String stcd; + + /** + * 测站名称 + */ + @Schema(description = "测站名称") + private String stnm; + + /** + * 站类 + */ + @Schema(description = "站类(RR水库水文站 ZQ,ZP河道水文站)") + private String sttp; + + /** + * 来源 + */ + @Schema(description = "来源") + private String source; + + /** + * 水库代码 + */ + @Schema(description = "水库代码") + private String resCode; + + /** + * 经度 + */ + @Schema(description = "经度") + private BigDecimal lgtd; + + /** + * 纬度 + */ + @Schema(description = "纬度") + private BigDecimal lttd; + + /** + * 行政区划代码 + */ + @Schema(description="行政区划代码") + private String adcd; + + /** + * 行政区划名称 + */ + @Schema(description="行政区划名称") + private String adnm; + + /** + * 站址 + */ + @Schema(description="站址") + private String stlc; + + + /** + * 主汛期防洪限制水位 + */ + @Schema(description = "主汛期防洪限制水位") + private BigDecimal flLowLimLev; + + /** + * 总库容 + */ + @Schema(description = "总库容") + private BigDecimal totCap; + + /** + * 流域名称 + */ + @Schema(description="流域名称") + private String lyname; + + /** + * 监测时间 + */ + @Schema(description="监测时间") + @JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8") + private Date tm; + + /** + * 监测水位 + */ + @Schema(description="监测水位") + private BigDecimal rz; + + /** + * 超讯限 + */ + @Schema(description="超讯限") + private BigDecimal aFsltdz; + + /** + * 水位涨跌情况 + */ + @Schema(description="水位涨跌情况(0无变化 1涨 2跌)") + private Integer state; + + /** + * 设计洪水位 + */ + @Schema(description="设计洪水位") + private BigDecimal desFloodLev; + + /** + * 校核洪水位 + */ + @Schema(description = "校核洪水位") + private BigDecimal calFloodLev; + + + /** + * 正常蓄水位 + */ + @Schema(description = "正常蓄水位") + private BigDecimal normWatLev; + + + /** + * 死水位 + */ + @Schema(description = "死水位") + private BigDecimal deadLev; + + + /** + * 坝顶高程 + */ + @Schema(description = "坝顶高程") + private BigDecimal crestElev; + + /** + * 兴利库容 + */ + @Schema(description = "兴利库容") + private BigDecimal benResCap; + + /** + * 水库当前库容 + */ + @Schema(description = "水库当前库容") + private BigDecimal nowCap; + + + /** + * 雨量时间 + */ + @Schema(description="雨量时间") + @JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8") + private Date drpTm; + + /** + * 小时雨量 + */ + @Schema(description="小时雨量") + private BigDecimal h1; + + /** + * 3小时雨量 + */ + @Schema(description="3小时雨量") + private BigDecimal h3; + + /** + * 6小时雨量 + */ + @Schema(description="6小时雨量") + private BigDecimal h6; + + /** + * 12小时雨量 + */ + @Schema(description="12小时雨量") + private BigDecimal h12; + + + /** + * 24小时雨量 + */ + @Schema(description="24小时雨量") + private BigDecimal h24; + + /** + * 今日雨量 + */ + @Schema(description="今日雨量") + private BigDecimal today; + + @Schema(description = "是否超校核水位(0否 1是)") + private Integer calState; + + @Schema(description = "是否超设计水位(0否 1是)") + private Integer desState; + + @Schema(description = "是否超汛限水位(0否 1是)") + private Integer flState; + + @Schema(description = "建站日期") + private String esstym; +} diff --git a/src/main/java/com/gunshi/project/xyt/entity/vo/AttResMonitorVo.java b/src/main/java/com/gunshi/project/xyt/entity/vo/AttResMonitorVo.java new file mode 100644 index 0000000..1b9bab8 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/entity/vo/AttResMonitorVo.java @@ -0,0 +1,59 @@ +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.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 水库监测数据 + * Created by wanyan on 2024/2/20 + * + * @author wanyan + * @version 1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AttResMonitorVo { + + /** + * 测站编码 + */ + @Schema(description = "测站编码") + private String stcd; + + /** + * 监测时间 + */ + @Schema(description="监测时间") + @JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8") + private Date tm; + + /** + * 雨量 + */ + @Schema(description="雨量") + private BigDecimal drp; + + /** + * 监测水位 + */ + @Schema(description="监测水位") + private BigDecimal rz; + + /** + * 库容 + */ + @Schema(description="库容") + private BigDecimal w; + + +} diff --git a/src/main/java/com/gunshi/project/xyt/entity/vo/StRsvrVo.java b/src/main/java/com/gunshi/project/xyt/entity/vo/StRsvrVo.java new file mode 100644 index 0000000..70680da --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/entity/vo/StRsvrVo.java @@ -0,0 +1,25 @@ +package com.gunshi.project.xyt.entity.vo; + +import com.gunshi.project.xyt.model.StRsvrR; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 水库水情 + * Created by wanyan on 2024/2/20 + * + * @author wanyan + * @version 1.0 + */ +@Data +public class StRsvrVo { + + @Schema(description = "汛限水位") + private BigDecimal flLowLimLev; + + @Schema(description = "库水位") + private List list; +} diff --git a/src/main/java/com/gunshi/project/xyt/mapper/AttResBaseMapper.java b/src/main/java/com/gunshi/project/xyt/mapper/AttResBaseMapper.java new file mode 100644 index 0000000..5e6ab3a --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/mapper/AttResBaseMapper.java @@ -0,0 +1,90 @@ +package com.gunshi.project.xyt.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.gunshi.project.xyt.entity.so.DataQueryCommonSo; +import com.gunshi.project.xyt.entity.vo.AttResBaseVo; +import com.gunshi.project.xyt.entity.vo.AttResMonitorVo; +import com.gunshi.project.xyt.model.AttResBase; +import com.gunshi.project.xyt.model.StImgRReal; +import com.gunshi.project.xyt.model.StRsvrR; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +@Mapper +public interface AttResBaseMapper extends BaseMapper { + int updateBatch(List list); + + int updateBatchSelective(List list); + + int batchInsert(@Param("list") List list); + + int insertOrUpdate(AttResBase record); + + int insertOrUpdateSelective(AttResBase record); + + @Select(""" + + """) + List queryList(); + + @Select(""" + + """) + List drpData(@Param("obj") DataQueryCommonSo dataQueryCommonSo); + + @Select(""" + + """) + List rzData(@Param("obj") DataQueryCommonSo dataQueryCommonSo); + + @Select(""" + + """) + List realImg(@Param("resCode") String resCode); + + @Select(""" + + """) + List queryRzList(@Param("stcd") String stcd,@Param("stm") String startTime,@Param("etm") String endTime); +} \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/mapper/RescueGoodsMapper.java b/src/main/java/com/gunshi/project/xyt/mapper/RescueGoodsMapper.java index 311b5b2..df6c6a1 100644 --- a/src/main/java/com/gunshi/project/xyt/mapper/RescueGoodsMapper.java +++ b/src/main/java/com/gunshi/project/xyt/mapper/RescueGoodsMapper.java @@ -21,12 +21,12 @@ public interface RescueGoodsMapper extends BaseMapper { from public.rescue_goods_b t - and t.goods_name LIKE concat('%',#{obj.goodsName},'%') - - - order by ${obj.sortField} asc + t.goods_name LIKE concat('%',#{obj.goodsName},'%') + + order by t.${obj.sortField} asc + """) Page pageQuery(@Param("page") Page page,@Param("obj") RescueGoodsPageSo RescueGoodsPageSo); diff --git a/src/main/java/com/gunshi/project/xyt/mapper/StZvarlBMapper.java b/src/main/java/com/gunshi/project/xyt/mapper/StZvarlBMapper.java new file mode 100644 index 0000000..8aba9a4 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/mapper/StZvarlBMapper.java @@ -0,0 +1,23 @@ +package com.gunshi.project.xyt.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.gunshi.project.xyt.model.StZvarlB; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface StZvarlBMapper extends BaseMapper { + int updateBatch(List list); + + int updateBatchSelective(List list); + + int batchInsert(@Param("list") List list); + + int insertOrUpdate(StZvarlB record); + + int insertOrUpdateSelective(StZvarlB record); + +} \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/model/AttResBase.java b/src/main/java/com/gunshi/project/xyt/model/AttResBase.java new file mode 100644 index 0000000..f4b3c51 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/model/AttResBase.java @@ -0,0 +1,340 @@ +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 com.gunshi.project.xyt.validate.markers.Insert; +import com.gunshi.project.xyt.validate.markers.Update; +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 = "public.att_res_base") +public class AttResBase implements Serializable { + /** + * 水库代码 + */ + @TableId(value = "res_code", type = IdType.INPUT) + @Schema(description = "水库代码") + @Size(max = 18, message = "水库代码最大长度要小于 18") + @NotBlank(message = "水库代码不能为空", groups = {Insert.class, Update.class}) + private String resCode; + + /** + * 水库名称 + */ + @TableField(value = "res_name") + @Schema(description = "水库名称") + @Size(max = 100, message = "水库名称最大长度要小于 100") + @NotBlank(message = "水库名称不能为空", groups = {Insert.class, Update.class}) + private String resName; + + @Schema(description = "左下角经度") + @TableField(value = "low_left_long") + private BigDecimal lowLeftLong; + + @Schema(description = "左下角纬度") + @TableField(value = "low_left_lat") + private BigDecimal lowLeftLat; + + @Schema(description = "右上角经度") + @TableField(value = "up_right_long") + private BigDecimal upRightLong; + + @Schema(description = "右上角纬度") + @TableField(value = "up_right_lat") + private BigDecimal upRightLat; + + @Schema(description = "水库所在位置") + @TableField(value = "res_loc") + private String resLoc; + + @Schema(description = "水库类型 山丘水库 1 平原水库 2 地下水库 3") + @TableField(value = "res_type") + private String resType; + + @Schema(description = "工程等别 Ⅰ 1 Ⅱ 2 Ⅲ 3 Ⅳ 4 Ⅴ 5") + @TableField(value = "eng_grad") + private String engGrad; + + @Schema(description = "工程规模 大 (1)型 1 大 (2)型 2 中型 3 小 (1)型 4 小 (2)型 5 其他 9") + @TableField(value = "eng_scal") + @NotBlank(message = "工程规模不能为空", groups = {Insert.class, Update.class}) + private String engScal; + + @Schema(description = "坝址控制流域面积") + @TableField(value = "wat_shed_area") + private BigDecimal watShedArea; + + @Schema(description = "防洪高水位") + @TableField(value = "upp_lev_flco") + private BigDecimal uppLevFlco; + + @Schema(description = "正常蓄水位") + @TableField(value = "norm_wat_lev") + private BigDecimal normWatLev; + + @Schema(description = "正常蓄水位相应水面面积") + @TableField(value = "norm_pool_stag_area") + private BigDecimal normPoolStagArea; + + @Schema(description = "正常蓄水位相应库容") + @TableField(value = "norm_pool_stag_cap") + private BigDecimal normPoolStagCap; + + @Schema(description = "主汛期防洪限制水位") + @TableField(value = "fl_low_lim_lev") + private BigDecimal flLowLimLev; + + @Schema(description = "防洪限制水位库容") + @TableField(value = "fl_low_lim_lev_cap") + private BigDecimal flLowLimLevCap; + + @Schema(description = "死水位") + @TableField(value = "dead_lev") + private BigDecimal deadLev; + + @Schema(description = "总库容") + @TableField(value = "tot_cap") + private BigDecimal totCap; + + @Schema(description = "兴利库容") + @TableField(value = "ben_res_cap") + private BigDecimal benResCap; + + @Schema(description = "死库容") + @TableField(value = "dead_cap") + private BigDecimal deadCap; + + @Schema(description = "调洪库容") + @TableField(value = "stor_fl_cap") + private BigDecimal storFlCap; + + @Schema(description = "防洪库容") + @TableField(value = "flco_cap") + private BigDecimal flcoCap; + + @Schema(description = "工程建设情况 在建 0 已建 1") + @TableField(value = "eng_stat") + private String engStat; + + @Schema(description = "开工时间") + @TableField(value = "start_date") + private Date startDate; + + @Schema(description = "建成时间") + @TableField(value = "comp_date") + private Date compDate; + + @Schema(description = "归口管理部门 水利部门 1 电力部门 2 农业部门 3 林业部门 4 城建部门 5 航运部门 6 环保部门 7 其他部门 9") + @TableField(value = "adm_dep") + private String admDep; + + @Schema(description = "备注") + @TableField(value = "note") + private String note; + + @Schema(description = "记录生效时间") + @TableField(value = "eff_date") + private Date effDate; + + @Schema(description = "记录失效时间") + @TableField(value = "expr_date") + private Date exprDate; + + @Schema(description = "所在行政区划 行政区划名称 格式:省-市-县-镇") + @TableField(value = "adnm") + @NotBlank(message = "所属行政位置不能为空", groups = {Insert.class, Update.class}) + private String adnm; + + @Schema(description = "所在流域 流域名称") + @TableField(value = "bas_name") + private String basName; + + @Schema(description = "所在水系 水系名称") + @TableField(value = "ws_name") + private String wsName; + + @Schema(description = "所在河流名称") + @TableField(value = "rv_name") + private String rvName; + + @Schema(description = "注册时间") + @TableField(value = "reg_time") + @JsonFormat(pattern = DateFormatString.YYYY_MM_DD, timezone = "GMT+8") + private Date regTime; + + @Schema(description = "注册登记号") + @TableField(value = "reg_sn") + private String regSn; + + @Schema(description = "管理单位 管理单位名称") + @TableField(value = "manag_name") + private String managName; + + @Schema(description = "高程基准面 基面名称") + @TableField(value = "elev_dat") + private String elevDat; + + @Schema(description = "水库功能 功能名称") + @TableField(value = "rsv_function") + private String rsvFunction; + + @Schema(description = "溢洪道是否有闸 1:有 0:无") + @TableField(value = "spillway_gate") + private String spillwayGate; + + @Schema(description = "校核洪水位") + @TableField(value = "cal_flood_lev") + private BigDecimal calFloodLev; + + @Schema(description = "设计洪水位") + @TableField(value = "des_flood_lev") + private BigDecimal desFloodLev; + + @Schema(description = "坝顶高程") + @TableField(value = "crest_elev") + private BigDecimal crestElev; + + @Schema(description = "最大坝高") + @TableField(value = "max_dam_heig") + private BigDecimal maxDamHeig; + + @Schema(description = "设计洪水位时最大下泄流量") + @TableField(value = "max_des_flood_flow") + private BigDecimal maxDesFloodFlow; + + @Schema(description = "校核洪水位时最大下泄流量") + @TableField(value = "max_cal_flood_flow") + private BigDecimal maxCalFloodFlow; + + @Schema(description = "下游河道安全流量") + @TableField(value = "ds_saft_flow") + private BigDecimal dsSaftFlow; + + @Schema(description = "工程概况") + @TableField(value = "proj_overview") + private String projOverview; + + @Schema(description = "关联测站") + @TableField(value = "stcd") + private String stcd; + + @Schema(description = "是否病险") + @TableField(value = "is_danger") + private Integer isDanger; + + @Schema(description = "病险概况") + @TableField(value = "danger_overview") + private String dangerOverview; + + @Schema(description = "重点水库") + @TableField(value = "is_important") + private Integer isImportant; + + @Schema(description = "经度 (°)") + @TableField(value = "lgtd") + @NotNull(message = "经度不能为空", groups = {Insert.class, Update.class}) + private BigDecimal lgtd; + + @Schema(description = "纬度 (°)") + @TableField(value = "lttd") + @NotNull(message = "纬度不能为空", groups = {Insert.class, Update.class}) + private BigDecimal lttd; + + @Schema(description = "是否有大坝安监数据") + @TableField(value = "has_wypress") + private Integer hasWypress; + + @TableField(value = "adcd") + @Schema(description="行政区划代码") + private String adcd; + + private static final long serialVersionUID = 1L; + + public static final String COL_RES_CODE = "res_code"; + + public static final String COL_RES_NAME = "res_name"; + + public static final String COL_LOW_LEFT_LONG = "low_left_long"; + + public static final String COL_LOW_LEFT_LAT = "low_left_lat"; + + public static final String COL_UP_RIGHT_LONG = "up_right_long"; + + public static final String COL_UP_RIGHT_LAT = "up_right_lat"; + + public static final String COL_RES_LOC = "res_loc"; + + public static final String COL_RES_TYPE = "res_type"; + + public static final String COL_ENG_GRAD = "eng_grad"; + + public static final String COL_ENG_SCAL = "eng_scal"; + + public static final String COL_WAT_SHED_AREA = "wat_shed_area"; + + public static final String COL_UPP_LEV_FLCO = "upp_lev_flco"; + + public static final String COL_NORM_WAT_LEV = "norm_wat_lev"; + + public static final String COL_NORM_POOL_STAG_AREA = "norm_pool_stag_area"; + + public static final String COL_NORM_POOL_STAG_CAP = "norm_pool_stag_cap"; + + public static final String COL_FL_LOW_LIM_LEV = "fl_low_lim_lev"; + + public static final String COL_FL_LOW_LIM_LEV_CAP = "fl_low_lim_lev_cap"; + + public static final String COL_DEAD_LEV = "dead_lev"; + + public static final String COL_TOT_CAP = "tot_cap"; + + public static final String COL_BEN_RES_CAP = "ben_res_cap"; + + public static final String COL_DEAD_CAP = "dead_cap"; + + public static final String COL_STOR_FL_CAP = "stor_fl_cap"; + + public static final String COL_FLCO_CAP = "flco_cap"; + + public static final String COL_ENG_STAT = "eng_stat"; + + public static final String COL_START_DATE = "start_date"; + + public static final String COL_COMP_DATE = "comp_date"; + + public static final String COL_ADM_DEP = "adm_dep"; + + public static final String COL_NOTE = "note"; + + public static final String COL_EFF_DATE = "eff_date"; + + public static final String COL_EXPR_DATE = "expr_date"; + + public static final String COL_IS_DANGER = "is_danger"; + + public static final String COL_DANGER_OVERVIEW = "danger_overview"; + + public static final String COL_STCD = "stcd"; + + public static final String COL_IS_IMPORTANT = "is_important"; + + public static final String COL_LGTD = "lgtd"; + + public static final String COL_LTTD = "lttd"; +} \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/model/StImgRReal.java b/src/main/java/com/gunshi/project/xyt/model/StImgRReal.java new file mode 100644 index 0000000..c9b6f36 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/model/StImgRReal.java @@ -0,0 +1,67 @@ +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.util.Date; + +@Schema +@Data +@TableName(value = "st_img_r_real") +public class StImgRReal implements Serializable { + @TableField(value = "stcd") + @MppMultiId + @Schema(description="") + @Size(max = 20,message = "最大长度要小于 20") + @NotBlank(message = "不能为空") + private String stcd; + + @TableField(value = "tm") + @MppMultiId + @Schema(description="") + @NotNull(message = "不能为null") + private Date tm; + + @TableField(value = "chtm") + @Schema(description="") + @NotNull(message = "不能为null") + private Date chtm; + + @TableField(value = "img_path") + @Schema(description="") + @Size(max = 256,message = "最大长度要小于 256") + @NotBlank(message = "不能为空") + private String imgPath; + + @TableField(value = "chid") + @Schema(description="") + @Size(max = 10,message = "最大长度要小于 10") + @NotBlank(message = "不能为空") + private String chid; + + @TableField(value = "\"source\"") + @Schema(description="") + @Size(max = 50,message = "最大长度要小于 50") + private String source; + + 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_CHTM = "chtm"; + + public static final String COL_IMG_PATH = "img_path"; + + public static final String COL_CHID = "chid"; + + public static final String COL_SOURCE = "source"; +} \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/model/StRsvrR.java b/src/main/java/com/gunshi/project/xyt/model/StRsvrR.java new file mode 100644 index 0000000..ac621ec --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/model/StRsvrR.java @@ -0,0 +1,119 @@ +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 +@Data +@TableName(value = "st_rsvr_r") +public class StRsvrR implements Serializable { + @TableField(value = "stcd") + @MppMultiId + @Schema(description="") + @Size(max = 20,message = "最大长度要小于 20") + @NotBlank(message = "不能为空") + private String stcd; + + @TableField(value = "tm") + @MppMultiId + @Schema(description="") + @NotNull(message = "不能为null") + private Date tm; + + @TableField(value = "rz") + @Schema(description="") + private BigDecimal rz; + + @TableField(value = "inq") + @Schema(description="") + private BigDecimal inq; + + @TableField(value = "w") + @Schema(description="") + private BigDecimal w; + + @TableField(value = "blrz") + @Schema(description="") + private BigDecimal blrz; + + @TableField(value = "otq") + @Schema(description="") + private BigDecimal otq; + + @TableField(value = "rwchrcd") + @Schema(description="") + @Size(max = 4,message = "最大长度要小于 4") + private String rwchrcd; + + @TableField(value = "rwptn") + @Schema(description="") + @Size(max = 4,message = "最大长度要小于 4") + private String rwptn; + + @TableField(value = "inqdr") + @Schema(description="") + private BigDecimal inqdr; + + @TableField(value = "msqmt") + @Schema(description="") + @Size(max = 4,message = "最大长度要小于 4") + private String msqmt; + + @TableField(value = "chtm") + @Schema(description="") + private Date chtm; + + @TableField(value = "sendtm") + @Schema(description="") + private Date sendtm; + + @TableField(value = "receivetm") + @Schema(description="") + private Date receivetm; + + @TableField(value = "source_int") + @Schema(description="") + private Short sourceInt; + + 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_RZ = "rz"; + + public static final String COL_INQ = "inq"; + + public static final String COL_W = "w"; + + public static final String COL_BLRZ = "blrz"; + + public static final String COL_OTQ = "otq"; + + public static final String COL_RWCHRCD = "rwchrcd"; + + public static final String COL_RWPTN = "rwptn"; + + public static final String COL_INQDR = "inqdr"; + + public static final String COL_MSQMT = "msqmt"; + + public static final String COL_CHTM = "chtm"; + + public static final String COL_SENDTM = "sendtm"; + + public static final String COL_RECEIVETM = "receivetm"; + + public static final String COL_SOURCE_INT = "source_int"; +} \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/model/StZvarlB.java b/src/main/java/com/gunshi/project/xyt/model/StZvarlB.java new file mode 100644 index 0000000..4ca2954 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/model/StZvarlB.java @@ -0,0 +1,96 @@ +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 = "public.st_zvarl_b") +public class StZvarlB implements Serializable { + /** + * 测站编码 + */ + @MppMultiId + @TableField(value = "stcd") + @Schema(description="测站编码") + @Size(max = 8,message = "测站编码最大长度要小于 8") + @NotBlank(message = "测站编码不能为空") + private String stcd; + + /** + * 施测时间 + */ + @MppMultiId + @TableField(value = "mstm") + @Schema(description="施测时间") + @NotNull(message = "施测时间不能为null") + private Date mstm; + + /** + * 点序号 + */ + @MppMultiId + @TableField(value = "ptno") + @Schema(description="点序号") + @NotNull(message = "点序号不能为null") + private Integer ptno; + + /** + * 库水位 + */ + @TableField(value = "rz") + @Schema(description="库水位") + @NotNull(message = "库水位不能为null") + private BigDecimal rz; + + /** + * 蓄水量 + */ + @TableField(value = "w") + @Schema(description="蓄水量") + @NotNull(message = "蓄水量不能为null") + private BigDecimal w; + + /** + * 水面面积 + */ + @TableField(value = "wsfa") + @Schema(description="水面面积") + private Integer wsfa; + + /** + * 时间戳 + */ + @TableField(value = "moditime") + @Schema(description="时间戳") + private Date moditime; + + private static final long serialVersionUID = 1L; + + public static final String COL_STCD = "stcd"; + + public static final String COL_MSTM = "mstm"; + + public static final String COL_PTNO = "ptno"; + + public static final String COL_RZ = "rz"; + + public static final String COL_W = "w"; + + public static final String COL_WSFA = "wsfa"; + + public static final String COL_MODITIME = "moditime"; +} \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/service/ReservoirWaterService.java b/src/main/java/com/gunshi/project/xyt/service/ReservoirWaterService.java new file mode 100644 index 0000000..0802aa5 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/service/ReservoirWaterService.java @@ -0,0 +1,164 @@ +package com.gunshi.project.xyt.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.gunshi.project.xyt.entity.so.DataQueryCommonSo; +import com.gunshi.project.xyt.entity.so.ReservoirWaterCommonSo; +import com.gunshi.project.xyt.entity.vo.AttResBaseVo; +import com.gunshi.project.xyt.entity.vo.AttResMonitorVo; +import com.gunshi.project.xyt.entity.vo.StRsvrVo; +import com.gunshi.project.xyt.mapper.AttResBaseMapper; +import com.gunshi.project.xyt.mapper.StZvarlBMapper; +import com.gunshi.project.xyt.model.AttResBase; +import com.gunshi.project.xyt.model.StImgRReal; +import com.gunshi.project.xyt.model.StZvarlB; +import com.gunshi.project.xyt.util.DataHandleUtil; +import com.gunshi.project.xyt.util.DateUtil; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * Description: + * Created by wanyan on 2024/7/8 + * + * @author wanyan + * @version 1.0 + */ +@Service +@Slf4j +public class ReservoirWaterService { + + @Resource + private AttResBaseMapper attResBaseMapper; + + @Resource + private StZvarlBMapper stZvarlBMapper; + + public List list() { + List attResBaseVos = attResBaseMapper.queryList(); + if(CollectionUtils.isEmpty(attResBaseVos)){ + return attResBaseVos; + } + attResBaseVos.stream().map(o->{ + if(o.getCalState() == 1){ + o.setDesState(0); + o.setFlState(0); + }else if(o.getCalState() == 0 && o.getDesState() ==1){ + o.setFlState(0); + } + return o; + }).collect(Collectors.toList()); + //查询所有测站的库容曲线 + List zvarlList = queryZval(attResBaseVos.stream().map(AttResBaseVo::getStcd).collect(Collectors.toList())); + Map> zvalMap = zvarlList.stream().collect(Collectors.groupingBy(StZvarlB::getStcd)); + for(AttResBaseVo vo : attResBaseVos){ + String stcd = vo.getStcd(); + BigDecimal rz = vo.getRz(); + //计算当前库容 + List zvarlBS = zvalMap.get(stcd); + if(rz != null && CollectionUtils.isNotEmpty(zvarlBS)){ + BigDecimal maxRz = zvarlBS.stream().max(Comparator.comparing(StZvarlB::getRz)).get().getRz(); + BigDecimal minRz = zvarlBS.stream().min(Comparator.comparing(StZvarlB::getRz)).get().getRz(); + if(rz.compareTo(minRz) < 0 || rz.compareTo(maxRz) > 0){ + continue; + } + Map stZvalMap = zvarlBS.stream().collect(Collectors.toMap(StZvarlB::getRz, StZvarlB::getW)); + List list = zvarlBS.stream().map(StZvarlB::getRz).collect(Collectors.toList()); + vo.setNowCap(DataHandleUtil.calcData(rz,stZvalMap,list)); + } + } + return attResBaseVos; + } + + private List queryZval(List stcdList) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); + queryWrapper.in(StZvarlB::getStcd, stcdList); + return stZvarlBMapper.selectList(queryWrapper); + } + + public List realImg(ReservoirWaterCommonSo reservoirWaterCommonSo) { + return attResBaseMapper.realImg(reservoirWaterCommonSo.getResCode()); + } + + public List zvarl(String stcd) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); + queryWrapper.eq(StZvarlB::getStcd, stcd) + .orderByAsc(StZvarlB::getPtno); + return stZvarlBMapper.selectList(queryWrapper); + } + + public List monitorData(DataQueryCommonSo dataQueryCommonSo) { + String stcd = dataQueryCommonSo.getStcd(); + //雨量数据 + List drpData = attResBaseMapper.drpData(dataQueryCommonSo); + //水位数据 + List rzData = attResBaseMapper.rzData(dataQueryCommonSo); + //获取库容曲线关系,算出库容 + List zvarl = zvarl(stcd); + if(CollectionUtils.isNotEmpty(zvarl)){ + calcTqData(rzData,zvarl); + } + //根据监测时间合并雨量和水位数据 + return bindData(stcd,drpData,rzData); + } + + private void calcTqData(List rzData, List zqrl) { + BigDecimal maxRz = zqrl.stream().max(Comparator.comparing(StZvarlB::getRz)).get().getRz(); + BigDecimal minRz = zqrl.stream().min(Comparator.comparing(StZvarlB::getRz)).get().getRz(); + Map map = zqrl.stream().collect(Collectors.toMap(StZvarlB::getRz, StZvarlB::getW)); + /** + * 根据监测水位和库容曲线计算出当前库容 + * 计算规则:1.监测水位不在库容曲线范围内,无法计算当前库容 + * 2.找出与监测水位最接近的一组水位值,算出比例,根据比例计算库容:如监测水位为10,最相近的一组水位值为9-11,对应的库容为4-5 + * 则计算公式为1/2 = x/1 x=0.5 当前库容=4+0.5=4.5 + */ + List list = zqrl.stream().map(StZvarlB::getRz).collect(Collectors.toList()); + for (AttResMonitorVo vo : rzData) { + BigDecimal rz = vo.getRz(); + if (rz.compareTo(minRz) < 0 || rz.compareTo(maxRz) > 0) { + continue; + } + vo.setW(DataHandleUtil.calcData(rz, map, list)); + } + } + + private List bindData(String stcd,List drpData, List rzData) { + HashSet strings = new HashSet<>(); + drpData.stream().forEach(v1 -> strings.add(v1.getTm())); + rzData.stream().forEach(v1 -> strings.add(v1.getTm())); + + ArrayList result = new ArrayList<>(); + strings.stream().forEach(v1 -> result.add(AttResMonitorVo.builder().stcd(stcd).tm(v1).build())); + + List list = result.stream().map(v1 -> { + drpData.stream().filter(v2 -> v1.getTm().equals(v2.getTm())).forEach(v2 -> { + v1.setDrp(v2.getDrp()); + }); + + rzData.stream().filter(v2 -> v1.getTm().equals(v2.getTm())).forEach(v2 -> { + v1.setRz(v2.getRz()); + v1.setW(v2.getW()); + }); + return v1; + }).collect(Collectors.toList()); + return list.stream().sorted(Comparator.comparing(AttResMonitorVo::getTm).reversed()).collect(Collectors.toList()); + } + + public StRsvrVo rz(ReservoirWaterCommonSo reservoirWaterCommonSo) { + StRsvrVo vo = new StRsvrVo(); + String resCode = reservoirWaterCommonSo.getResCode(); + AttResBase attResBase = attResBaseMapper.selectById(resCode); + vo.setFlLowLimLev(attResBase.getFlLowLimLev()); + //默认查询近一周水位 + String endTime = DateUtil.convertDateToString(new Date()); + String startTime = DateUtil.getMinusTime(endTime, 7 * 24); + vo.setList(attResBaseMapper.queryRzList(attResBase.getStcd(),startTime,endTime)); + return vo; + } +} diff --git a/src/main/java/com/gunshi/project/xyt/util/DataHandleUtil.java b/src/main/java/com/gunshi/project/xyt/util/DataHandleUtil.java new file mode 100644 index 0000000..d2d74ed --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/util/DataHandleUtil.java @@ -0,0 +1,37 @@ +package com.gunshi.project.xyt.util; + + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.List; +import java.util.Map; + + +public class DataHandleUtil { + + + public static BigDecimal calcData(BigDecimal rz, Map map,List list) { + //库容曲线中最近的一组水位 + BigDecimal lowerRz = new BigDecimal(0); + BigDecimal upperRz = new BigDecimal(0); + + //库容曲线中最近的一组水位对应的库容 + BigDecimal lowerW = new BigDecimal(0); + BigDecimal upperW = new BigDecimal(0); + + for(int i=0;i= 0 && rz.compareTo(list.get(i+1)) <= 0) { + lowerRz = list.get(i); + upperRz = list.get(i+1); + + lowerW = map.get(lowerRz); + upperW = map.get(upperRz); + break; + } + } + BigDecimal diff = rz.subtract(lowerRz); + return lowerW.add(diff.multiply(upperW.subtract(lowerW)).divide(upperRz.subtract(lowerRz),2,RoundingMode.UP)); + } + + +} diff --git a/src/main/java/com/gunshi/project/xyt/util/DateUtil.java b/src/main/java/com/gunshi/project/xyt/util/DateUtil.java new file mode 100644 index 0000000..df86990 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/util/DateUtil.java @@ -0,0 +1,140 @@ +package com.gunshi.project.xyt.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.Optional; + +/** + * Description: + * Created by wanyan on 2024/2/28 + * + * @author wanyan + * @version 1.0 + */ +public class DateUtil { + + private static SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + private static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + private static DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd日HH时"); + + private static DateTimeFormatter ym = DateTimeFormatter.ofPattern("YYYYMM"); + + public static Date convertStringToDate(String str){ + try { + return df.parse(str); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + + public static String convertDateToString(Date date){ + return sdf.format(date); + } + + public static String convertDateToMDSString(Date date){ + return df.format(date); + } + + /** + * 年初 + * @param year + * @return + */ + public static LocalDateTime beginningOfYear(Integer year){ + return LocalDateTime.of(year, 1, 1, 0, 0, 0, 0); + } + + /** + * 年末 + * @param year + * @return + */ + public static LocalDateTime endOfYear(Integer year){ + return beginningOfYear(year).plusYears(1).minusSeconds(1); + } + + + + /** + * 将Date对象转换为LocalDateTime对象. + * + * @param date 需要转换的Date对象 + * @return 转换后的LocalDateTime对象 + */ + public static Optional convertFromDate(Date date) { + if (date == null) { + throw new IllegalArgumentException("date is null"); + } + + Instant instant = date.toInstant(); + return Optional.of(instant.atZone(ZoneId.systemDefault()).toLocalDateTime()); + } + + + public static String getIntegerTime(){ + LocalDateTime now = LocalDateTime.now(); + LocalDateTime roundedTime = now.withMinute(0).withSecond(0).withNano(0); + return roundedTime.format(formatter); + } + + public static String getMinusIntegerTime(){ + LocalDateTime yesterday = LocalDateTime.now().minusDays(1); + LocalDateTime roundedTime = yesterday.withMinute(0).withSecond(0).withNano(0); + return roundedTime.format(formatter); + } + + public static String convertDH(String str){ + LocalDateTime dateTime = LocalDateTime.parse(str, formatter); + return dateTime.format(dtf); + } + + public static String getMinusTime(String str,long hour){ + LocalDateTime dateTime = LocalDateTime.parse(str, formatter); + LocalDateTime minusTime = dateTime.minusHours(hour); + return minusTime.format(formatter); + } + + public static String getPlusTime(String str,long hour){ + LocalDateTime dateTime = LocalDateTime.parse(str, formatter); + LocalDateTime minusTime = dateTime.plusHours(hour); + return minusTime.format(formatter); + } + + public static String getTodayEight(){ + LocalDateTime now = LocalDateTime.now(); + LocalDateTime roundedTime = now.withHour(8).withMinute(0).withSecond(0).withNano(0); + return roundedTime.format(formatter); + } + + public static Integer getMD(int year, int month) { + if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { + return 31; + } else if (month == 4 || month == 6 || month == 9 || month == 11) { + return 30; + } else if (month == 2) { + //判断是否是闰年 + if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) { + return 29; + } else { + return 28; + } + } + return 31; + } + + public static String getYM() { + LocalDateTime now = LocalDateTime.now(); + return now.format(ym); + } + + +}