diff --git a/src/main/java/com/gunshi/project/xyt/controller/OsmoticShiftRController.java b/src/main/java/com/gunshi/project/xyt/controller/OsmoticShiftRController.java index d641782..bd74e04 100644 --- a/src/main/java/com/gunshi/project/xyt/controller/OsmoticShiftRController.java +++ b/src/main/java/com/gunshi/project/xyt/controller/OsmoticShiftRController.java @@ -2,10 +2,10 @@ package com.gunshi.project.xyt.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.gunshi.core.result.R; +import com.gunshi.project.xyt.entity.so.OsmoticDetailQuerySo; import com.gunshi.project.xyt.entity.so.OsmoticQueryPageSo; import com.gunshi.project.xyt.entity.so.OsmoticQuerySo; -import com.gunshi.project.xyt.entity.vo.OsmoticChartVo; -import com.gunshi.project.xyt.entity.vo.OsmoticShiftVo; +import com.gunshi.project.xyt.entity.vo.*; import com.gunshi.project.xyt.model.OsmoticShiftR; import com.gunshi.project.xyt.service.OsmoticShiftRService; import com.gunshi.project.xyt.validate.markers.Insert; @@ -84,4 +84,16 @@ public class OsmoticShiftRController { service.yearStatExport(osmoticQuerySo,response); } + @Operation(summary = "布置图-位移监测") + @GetMapping("/list/value") + public R> listValue() { + return R.ok(service.listValue()); + } + + @Operation(summary = "布置图-按测站查询位移监测数据") + @PostMapping("/detail/value") + public R> detailValue(@RequestBody @Validated OsmoticDetailQuerySo so) { + return R.ok(service.detailValue(so)); + } + } \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/entity/so/OsmoticDetailQuerySo.java b/src/main/java/com/gunshi/project/xyt/entity/so/OsmoticDetailQuerySo.java index 5a7dc0d..be1469a 100644 --- a/src/main/java/com/gunshi/project/xyt/entity/so/OsmoticDetailQuerySo.java +++ b/src/main/java/com/gunshi/project/xyt/entity/so/OsmoticDetailQuerySo.java @@ -3,9 +3,7 @@ package com.gunshi.project.xyt.entity.so; import com.gunshi.db.dto.DateTimeRangeSo; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; import lombok.Data; -import org.hibernate.validator.constraints.Range; /** * Description: @@ -18,9 +16,7 @@ import org.hibernate.validator.constraints.Range; @Schema(description = "布置图详细数据查询对象") public class OsmoticDetailQuerySo { - @Schema(description = "类型(1渗压 2渗流)") - @NotNull(message = "类型不可为空") - @Range(min = 1,max = 2) + @Schema(description = "类型(2渗流 其他可不传)") private Integer type = 1; @Schema(description = "时间") diff --git a/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticPressVo.java b/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticPressVo.java index 05472d2..b38cfb3 100644 --- a/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticPressVo.java +++ b/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticPressVo.java @@ -1,12 +1,9 @@ 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; /** * Description: @@ -25,8 +22,7 @@ public class OsmoticPressVo { private String profileName; @Schema(description="监测时间") - @JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8") - private Date tm; + private String tm; @Schema(description="监测值") private BigDecimal value; diff --git a/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticShiftListVo.java b/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticShiftListVo.java new file mode 100644 index 0000000..9153df4 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticShiftListVo.java @@ -0,0 +1,64 @@ +package com.gunshi.project.xyt.entity.vo; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * Description: + * Created by wanyan on 2024/7/9 + * + * @author wanyan + * @version 1.0 + */ +@Data +public class OsmoticShiftListVo { + + /** + * 测点编号 + */ + @Schema(description="测点编号") + private String stationCode; + + /** + * 时间 + */ + @Schema(description="时间") + private String tm; + + @Schema(description = "监测时间是否离当前时间超过2天(0否 1是)") + private Integer flag = 0; + + /** + * x方向 + */ + @Schema(description="x方向") + private BigDecimal x; + + @Schema(description = "x方向是否超过预警(0否 1是)") + private Integer xStatus = 0; + + /** + * y方向 + */ + @Schema(description="y方向") + private BigDecimal y; + + @Schema(description = "y方向是否超过预警(0否 1是)") + private Integer yStatus = 0; + + /** + * h方向 + */ + @Schema(description="h方向") + private BigDecimal h; + + @Schema(description = "h方向是否超过预警(0否 1是)") + private Integer hStatus = 0; + + @JsonIgnore + private String direction; + +} diff --git a/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticShiftValueVo.java b/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticShiftValueVo.java index de8a014..460bad7 100644 --- a/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticShiftValueVo.java +++ b/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticShiftValueVo.java @@ -45,4 +45,10 @@ public class OsmoticShiftValueVo { @Schema(description="h方向") private BigDecimal h; + /** + * 库水位 + */ + @Schema(description="库水位") + private BigDecimal rz; + } diff --git a/src/main/java/com/gunshi/project/xyt/mapper/OsmoticPressRMapper.java b/src/main/java/com/gunshi/project/xyt/mapper/OsmoticPressRMapper.java index 1a2fefc..cdc5a6a 100644 --- a/src/main/java/com/gunshi/project/xyt/mapper/OsmoticPressRMapper.java +++ b/src/main/java/com/gunshi/project/xyt/mapper/OsmoticPressRMapper.java @@ -156,21 +156,21 @@ public interface OsmoticPressRMapper extends BaseMapper { @Select(""" """) List listValue(); @Select(""" """) List flowListValue(); diff --git a/src/main/java/com/gunshi/project/xyt/mapper/OsmoticShiftRMapper.java b/src/main/java/com/gunshi/project/xyt/mapper/OsmoticShiftRMapper.java index c06c3fa..5e83fd6 100644 --- a/src/main/java/com/gunshi/project/xyt/mapper/OsmoticShiftRMapper.java +++ b/src/main/java/com/gunshi/project/xyt/mapper/OsmoticShiftRMapper.java @@ -1,7 +1,9 @@ package com.gunshi.project.xyt.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.gunshi.project.xyt.entity.so.OsmoticDetailQuerySo; import com.gunshi.project.xyt.entity.so.OsmoticQuerySo; +import com.gunshi.project.xyt.entity.vo.OsmoticShiftListVo; import com.gunshi.project.xyt.entity.vo.OsmoticShiftValueVo; import com.gunshi.project.xyt.model.OsmoticShiftR; import org.apache.ibatis.annotations.Mapper; @@ -37,4 +39,49 @@ public interface OsmoticShiftRMapper extends BaseMapper { """) List queryValue(@Param("obj") OsmoticQuerySo osmoticQuerySo); + + @Select(""" + + """) + List listValue(); + + @Select(""" + + """) + List queryWarn(@Param("obj") OsmoticQuerySo so); + + @Select(""" + + """) + List detailValue(@Param("obj") OsmoticDetailQuerySo so); } \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/service/OsmoticPressRService.java b/src/main/java/com/gunshi/project/xyt/service/OsmoticPressRService.java index a4067db..3dfbc54 100644 --- a/src/main/java/com/gunshi/project/xyt/service/OsmoticPressRService.java +++ b/src/main/java/com/gunshi/project/xyt/service/OsmoticPressRService.java @@ -386,19 +386,19 @@ public class OsmoticPressRService extends ServiceImpl stationCodes = list.stream().map(OsmoticPressVo::getStationCode).collect(Collectors.toList()); - Date maxTm = list.stream().filter(o->o.getTm() != null).max(Comparator.comparing(OsmoticPressVo::getTm)).get().getTm(); - Date minTm = list.stream().filter(o->o.getTm() != null).min(Comparator.comparing(OsmoticPressVo::getTm)).get().getTm(); + String maxTm = list.stream().filter(o->o.getTm() != null).max(Comparator.comparing(OsmoticPressVo::getTm)).get().getTm(); + String minTm = list.stream().filter(o->o.getTm() != null).min(Comparator.comparing(OsmoticPressVo::getTm)).get().getTm(); so.setStationCodes(stationCodes); DateTimeRangeSo dateTimeRangeSo = new DateTimeRangeSo(); - dateTimeRangeSo.setStart(minTm); - dateTimeRangeSo.setEnd(maxTm); + dateTimeRangeSo.setStart(DateUtil.convertStringToDate(minTm)); + dateTimeRangeSo.setEnd(DateUtil.convertStringToDate(maxTm)); so.setDateTimeRangeSo(dateTimeRangeSo); List warnList = mapper.queryWarn(so); list.stream().map(o->{ - if(o.getTm() != null && DateUtil.hoursBetweenDate(o.getTm(), new Date()) > 48){ + if(o.getTm() != null && DateUtil.hoursBetweenDate(DateUtil.convertStringToDate(o.getTm()), new Date()) > 48){ o.setFlag(1); } - Boolean b = warnList.stream().filter(t->t.getStationCode().equals(o.getStationCode()) && t.getTm().equals(DateUtil.convertDateToMDSString(o.getTm()))).findAny().isPresent(); + Boolean b = warnList.stream().filter(t->t.getStationCode().equals(o.getStationCode()) && t.getTm().equals(o.getTm())).findAny().isPresent(); if(b){ o.setStatus(1); } diff --git a/src/main/java/com/gunshi/project/xyt/service/OsmoticShiftRService.java b/src/main/java/com/gunshi/project/xyt/service/OsmoticShiftRService.java index 08bfdae..277676e 100644 --- a/src/main/java/com/gunshi/project/xyt/service/OsmoticShiftRService.java +++ b/src/main/java/com/gunshi/project/xyt/service/OsmoticShiftRService.java @@ -6,11 +6,11 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gunshi.db.dto.DateTimeRangeSo; +import com.gunshi.project.xyt.entity.so.OsmoticDetailQuerySo; import com.gunshi.project.xyt.entity.so.OsmoticQueryPageSo; import com.gunshi.project.xyt.entity.so.OsmoticQuerySo; -import com.gunshi.project.xyt.entity.vo.OsmoticChartVo; -import com.gunshi.project.xyt.entity.vo.OsmoticShiftValueVo; -import com.gunshi.project.xyt.entity.vo.OsmoticShiftVo; +import com.gunshi.project.xyt.entity.vo.*; +import com.gunshi.project.xyt.mapper.OsmoticPressRMapper; import com.gunshi.project.xyt.mapper.OsmoticShiftRMapper; import com.gunshi.project.xyt.model.OsmoticShiftR; import com.gunshi.project.xyt.util.DataHandleUtil; @@ -19,6 +19,7 @@ import com.gunshi.project.xyt.util.ExcelUtil; import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -38,6 +39,9 @@ public class OsmoticShiftRService extends ServiceImpl listValue() { + List list = mapper.listValue(); + OsmoticQuerySo so = new OsmoticQuerySo(); + List stationCodes = list.stream().map(OsmoticShiftListVo::getStationCode).collect(Collectors.toList()); + String maxTm = list.stream().filter(o->o.getTm() != null).max(Comparator.comparing(OsmoticShiftListVo::getTm)).get().getTm(); + String minTm = list.stream().filter(o->o.getTm() != null).min(Comparator.comparing(OsmoticShiftListVo::getTm)).get().getTm(); + so.setStationCodes(stationCodes); + DateTimeRangeSo dateTimeRangeSo = new DateTimeRangeSo(); + dateTimeRangeSo.setStart(DateUtil.convertStringToDate(minTm)); + dateTimeRangeSo.setEnd(DateUtil.convertStringToDate(maxTm)); + so.setDateTimeRangeSo(dateTimeRangeSo); + List warnList = mapper.queryWarn(so); + list.stream().map(o->{ + if(o.getTm() != null && DateUtil.hoursBetweenDate(DateUtil.convertStringToDate(o.getTm()), new Date()) > 48){ + o.setFlag(1); + } + Boolean a = warnList.stream().filter(t->t.getStationCode().equals(o.getStationCode()) && t.getTm().equals(o.getTm()) && t.getDirection().equals("X")).findAny().isPresent(); + if(a){ + o.setXStatus(1); + } + Boolean b = warnList.stream().filter(t->t.getStationCode().equals(o.getStationCode()) && t.getTm().equals(o.getTm()) && t.getDirection().equals("Y")).findAny().isPresent(); + if(b){ + o.setYStatus(1); + } + Boolean c = warnList.stream().filter(t->t.getStationCode().equals(o.getStationCode()) && t.getTm().equals(o.getTm()) && t.getDirection().equals("H")).findAny().isPresent(); + if(c){ + o.setHStatus(1); + } + return o; + }).collect(Collectors.toList()); + return list; + } + + public List detailValue(OsmoticDetailQuerySo so) { + List list = mapper.detailValue(so); + OsmoticQuerySo osmoticQuerySo = new OsmoticQuerySo(); + BeanUtils.copyProperties(so,osmoticQuerySo); + List stRzVos = pressRMapper.queryLineRz(osmoticQuerySo); + return bindShiftDetail(list,stRzVos); + } + + private List bindShiftDetail(List list, List stRzVos) { + HashSet strings = new HashSet<>(); + list.stream().forEach(v1 -> strings.add(v1.getTm())); + stRzVos.stream().forEach(v1 -> strings.add(v1.getTm())); + + List result = new ArrayList<>(); + strings.stream().forEach(v1 ->{ + OsmoticShiftValueVo v = new OsmoticShiftValueVo(); + v.setTm(v1); + result.add(v); + }); + + List resList = result.stream().map(v1 -> { + stRzVos.stream().filter(v2 -> v1.getTm().equals(v2.getTm())).forEach(v2 -> { + v1.setRz(v2.getRz()); + }); + + list.stream().filter(v2 -> v1.getTm().equals(v2.getTm())).forEach(v2 -> { + v1.setX(v2.getX()); + v1.setY(v2.getY()); + v1.setH(v2.getH()); + }); + return v1; + }).collect(Collectors.toList()); + return resList.stream().sorted(Comparator.comparing(OsmoticShiftValueVo::getTm)).collect(Collectors.toList()); + } }