diff --git a/src/main/java/com/gunshi/project/xyt/controller/OsmoticPressRController.java b/src/main/java/com/gunshi/project/xyt/controller/OsmoticPressRController.java index 36b4f3a..806cc26 100644 --- a/src/main/java/com/gunshi/project/xyt/controller/OsmoticPressRController.java +++ b/src/main/java/com/gunshi/project/xyt/controller/OsmoticPressRController.java @@ -2,9 +2,11 @@ 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.OsmoticPressDetailVo; import com.gunshi.project.xyt.entity.vo.OsmoticPressVo; import com.gunshi.project.xyt.entity.vo.OsmoticStationVo; import com.gunshi.project.xyt.model.OsmoticPressR; @@ -68,10 +70,16 @@ public class OsmoticPressRController { return R.ok(service.queryPage(osmoticQueryPageSo)); } - @Operation(summary = "布置图-渗压监测") + @Operation(summary = "布置图-渗压/渗流监测") @GetMapping("/list/value") - public R> listValue() { - return R.ok(service.listValue()); + public R> listValue(@Schema(name = "type",description = "类型(1渗压 2渗流)") @RequestParam("type") Integer type) { + return R.ok(service.listValue(type)); + } + + @Operation(summary = "布置图-按测站查询渗压/渗流监测数据") + @PostMapping("/detail/value") + public R> detailValue(@RequestBody @Validated OsmoticDetailQuerySo so) { + return R.ok(service.detailValue(so)); } @Operation(summary = "测值查询(数据表)") 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 new file mode 100644 index 0000000..5a7dc0d --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/entity/so/OsmoticDetailQuerySo.java @@ -0,0 +1,32 @@ +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: + * Created by wanyan on 2024/3/19 + * + * @author wanyan + * @version 1.0 + */ +@Data +@Schema(description = "布置图详细数据查询对象") +public class OsmoticDetailQuerySo { + + @Schema(description = "类型(1渗压 2渗流)") + @NotNull(message = "类型不可为空") + @Range(min = 1,max = 2) + private Integer type = 1; + + @Schema(description = "时间") + private DateTimeRangeSo dateTimeRangeSo; + + @Schema(description = "测点编号") + @NotEmpty(message = "测点编号不可为空") + private String stationCode; +} diff --git a/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticPressDetailVo.java b/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticPressDetailVo.java new file mode 100644 index 0000000..a722bf6 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticPressDetailVo.java @@ -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; + +/** + * Description: + * Created by wanyan on 2024/7/9 + * + * @author wanyan + * @version 1.0 + */ +@Data +public class OsmoticPressDetailVo { + + + @Schema(description="监测时间") + private String tm; + + @Schema(description="监测值") + private BigDecimal value; + + @Schema(description="库水位") + private BigDecimal rz; + +} 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 7f8c06a..05472d2 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,9 +1,13 @@ package com.gunshi.project.xyt.entity.vo; -import com.gunshi.project.xyt.model.OsmoticPressR; +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: * Created by wanyan on 2024/7/9 @@ -12,7 +16,20 @@ import lombok.Data; * @version 1.0 */ @Data -public class OsmoticPressVo extends OsmoticPressR { +public class OsmoticPressVo { + + @Schema(description="测点编码") + private String stationCode; + + @Schema(description = "断面名称") + private String profileName; + + @Schema(description="监测时间") + @JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8") + private Date tm; + + @Schema(description="监测值") + private BigDecimal value; @Schema(description = "监测时间是否离当前时间超过2天(0否 1是)") private Integer flag = 0; 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 f5d58d6..1a2fefc 100644 --- a/src/main/java/com/gunshi/project/xyt/mapper/OsmoticPressRMapper.java +++ b/src/main/java/com/gunshi/project/xyt/mapper/OsmoticPressRMapper.java @@ -2,8 +2,10 @@ package com.gunshi.project.xyt.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +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.OsmoticPressDetailVo; import com.gunshi.project.xyt.entity.vo.OsmoticPressVo; import com.gunshi.project.xyt.entity.vo.OsmoticValueVo; import com.gunshi.project.xyt.entity.vo.StRzVo; @@ -162,4 +164,35 @@ public interface OsmoticPressRMapper extends BaseMapper { """) List listValue(); + + @Select(""" + + """) + List flowListValue(); + + @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 4639e17..a4067db 100644 --- a/src/main/java/com/gunshi/project/xyt/service/OsmoticPressRService.java +++ b/src/main/java/com/gunshi/project/xyt/service/OsmoticPressRService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; 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.*; @@ -16,6 +17,7 @@ import com.gunshi.project.xyt.util.MyBeanUtil; 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; @@ -375,10 +377,15 @@ public class OsmoticPressRService extends ServiceImpl listValue() { - List list = mapper.listValue(); + public List listValue(Integer type) { + List list; + if(type == 1){ + list = mapper.listValue(); + }else { + list = mapper.flowListValue(); + } OsmoticQuerySo so = new OsmoticQuerySo(); - List stationCodes = list.stream().map(OsmoticPressR::getStationCode).collect(Collectors.toList()); + List 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(); so.setStationCodes(stationCodes); @@ -399,6 +406,39 @@ public class OsmoticPressRService extends ServiceImpl detailValue(OsmoticDetailQuerySo so) { + List list = mapper.detailValue(so); + OsmoticQuerySo osmoticQuerySo = new OsmoticQuerySo(); + BeanUtils.copyProperties(so,osmoticQuerySo); + List stRzVos = mapper.queryLineRz(osmoticQuerySo); + return bindPressDetail(list,stRzVos); + } + + private List bindPressDetail(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 ->{ + OsmoticPressDetailVo v = new OsmoticPressDetailVo(); + 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.setValue(v2.getValue()); + }); + return v1; + }).collect(Collectors.toList()); + return resList.stream().sorted(Comparator.comparing(OsmoticPressDetailVo::getTm)).collect(Collectors.toList()); + } }