布置图-按监测点查询渗压/渗流详细数据

master
wany 2024-07-16 11:43:18 +08:00
parent f0b98f3e8a
commit f29690ccd6
6 changed files with 166 additions and 8 deletions

View File

@ -2,9 +2,11 @@ package com.gunshi.project.xyt.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.core.result.R; import com.gunshi.core.result.R;
import com.gunshi.project.xyt.entity.so.OsmoticDetailQuerySo;
import com.gunshi.project.xyt.entity.so.OsmoticQueryPageSo; import com.gunshi.project.xyt.entity.so.OsmoticQueryPageSo;
import com.gunshi.project.xyt.entity.so.OsmoticQuerySo; import com.gunshi.project.xyt.entity.so.OsmoticQuerySo;
import com.gunshi.project.xyt.entity.vo.OsmoticChartVo; 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.OsmoticPressVo;
import com.gunshi.project.xyt.entity.vo.OsmoticStationVo; import com.gunshi.project.xyt.entity.vo.OsmoticStationVo;
import com.gunshi.project.xyt.model.OsmoticPressR; import com.gunshi.project.xyt.model.OsmoticPressR;
@ -68,10 +70,16 @@ public class OsmoticPressRController {
return R.ok(service.queryPage(osmoticQueryPageSo)); return R.ok(service.queryPage(osmoticQueryPageSo));
} }
@Operation(summary = "布置图-渗压监测") @Operation(summary = "布置图-渗压/渗流监测")
@GetMapping("/list/value") @GetMapping("/list/value")
public R<List<OsmoticPressVo>> listValue() { public R<List<OsmoticPressVo>> listValue(@Schema(name = "type",description = "类型1渗压 2渗流") @RequestParam("type") Integer type) {
return R.ok(service.listValue()); return R.ok(service.listValue(type));
}
@Operation(summary = "布置图-按测站查询渗压/渗流监测数据")
@PostMapping("/detail/value")
public R<List<OsmoticPressDetailVo>> detailValue(@RequestBody @Validated OsmoticDetailQuerySo so) {
return R.ok(service.detailValue(so));
} }
@Operation(summary = "测值查询(数据表)") @Operation(summary = "测值查询(数据表)")

View File

@ -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;
}

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;
/**
* 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;
}

View File

@ -1,9 +1,13 @@
package com.gunshi.project.xyt.entity.vo; 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 io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/** /**
* Description: * Description:
* Created by wanyan on 2024/7/9 * Created by wanyan on 2024/7/9
@ -12,7 +16,20 @@ import lombok.Data;
* @version 1.0 * @version 1.0
*/ */
@Data @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是") @Schema(description = "监测时间是否离当前时间超过2天0否 1是")
private Integer flag = 0; private Integer flag = 0;

View File

@ -2,8 +2,10 @@ package com.gunshi.project.xyt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.OsmoticQueryPageSo;
import com.gunshi.project.xyt.entity.so.OsmoticQuerySo; 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.OsmoticPressVo;
import com.gunshi.project.xyt.entity.vo.OsmoticValueVo; import com.gunshi.project.xyt.entity.vo.OsmoticValueVo;
import com.gunshi.project.xyt.entity.vo.StRzVo; import com.gunshi.project.xyt.entity.vo.StRzVo;
@ -162,4 +164,35 @@ public interface OsmoticPressRMapper extends BaseMapper<OsmoticPressR> {
</script> </script>
""") """)
List<OsmoticPressVo> listValue(); List<OsmoticPressVo> listValue();
@Select("""
<script>
SELECT st.station_code,r.q as value,r.tm FROM osmotic_flow_device st
LEFT JOIN (SELECT station_code,MAX(tm) tm FROM osmotic_flow_r GROUP BY station_code) maxr ON st.station_code = maxr.station_code
LEFT JOIN osmotic_flow_r r ON maxr.station_code = r.station_code AND maxr.tm = r.tm
ORDER BY st.station_code
</script>
""")
List<OsmoticPressVo> flowListValue();
@Select("""
<script>
select to_char(t.tm,'YYYY-MM-DD HH24:MI:SS') as tm,
<if test = "obj.type == 1">
t.value from public.osmotic_press_r t
</if>
<if test = "obj.type == 2">
t.q as value from public.osmotic_flow_r t
</if>
where t.station_code = #{obj.stationCode}
<if test="obj.dateTimeRangeSo != null and obj.dateTimeRangeSo.start != null">
and t.tm <![CDATA[>=]]> #{obj.dateTimeRangeSo.start}
</if>
<if test="obj.dateTimeRangeSo != null and obj.dateTimeRangeSo.end != null">
and t.tm <![CDATA[<=]]> #{obj.dateTimeRangeSo.end}
</if>
order by t.tm desc
</script>
""")
List<OsmoticPressDetailVo> detailValue(@Param("obj") OsmoticDetailQuerySo so);
} }

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.db.dto.DateTimeRangeSo; 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.OsmoticQueryPageSo;
import com.gunshi.project.xyt.entity.so.OsmoticQuerySo; import com.gunshi.project.xyt.entity.so.OsmoticQuerySo;
import com.gunshi.project.xyt.entity.vo.*; import com.gunshi.project.xyt.entity.vo.*;
@ -16,6 +17,7 @@ import com.gunshi.project.xyt.util.MyBeanUtil;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -375,10 +377,15 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
ExcelUtil.exportExcel(headList, DataHandleUtil.tableData(list),2,new int[]{0},fileName,response,sheetName); ExcelUtil.exportExcel(headList, DataHandleUtil.tableData(list),2,new int[]{0},fileName,response,sheetName);
} }
public List<OsmoticPressVo> listValue() { public List<OsmoticPressVo> listValue(Integer type) {
List<OsmoticPressVo> list = mapper.listValue(); List<OsmoticPressVo> list;
if(type == 1){
list = mapper.listValue();
}else {
list = mapper.flowListValue();
}
OsmoticQuerySo so = new OsmoticQuerySo(); OsmoticQuerySo so = new OsmoticQuerySo();
List<String> stationCodes = list.stream().map(OsmoticPressR::getStationCode).collect(Collectors.toList()); List<String> 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 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(); Date minTm = list.stream().filter(o->o.getTm() != null).min(Comparator.comparing(OsmoticPressVo::getTm)).get().getTm();
so.setStationCodes(stationCodes); so.setStationCodes(stationCodes);
@ -399,6 +406,39 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return list; return list;
} }
public List<OsmoticPressDetailVo> detailValue(OsmoticDetailQuerySo so) {
List<OsmoticPressDetailVo> list = mapper.detailValue(so);
OsmoticQuerySo osmoticQuerySo = new OsmoticQuerySo();
BeanUtils.copyProperties(so,osmoticQuerySo);
List<StRzVo> stRzVos = mapper.queryLineRz(osmoticQuerySo);
return bindPressDetail(list,stRzVos);
}
private List<OsmoticPressDetailVo> bindPressDetail(List<OsmoticPressDetailVo> list, List<StRzVo> stRzVos) {
HashSet<String> strings = new HashSet<>();
list.stream().forEach(v1 -> strings.add(v1.getTm()));
stRzVos.stream().forEach(v1 -> strings.add(v1.getTm()));
List<OsmoticPressDetailVo> result = new ArrayList<>();
strings.stream().forEach(v1 ->{
OsmoticPressDetailVo v = new OsmoticPressDetailVo();
v.setTm(v1);
result.add(v);
});
List<OsmoticPressDetailVo> 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());
}
} }