布置图-位移监测数据,按测点查询数据详情

master
wany 2024-07-16 14:32:24 +08:00
parent f29690ccd6
commit 8f363c7b46
9 changed files with 218 additions and 25 deletions

View File

@ -2,10 +2,10 @@ 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.*;
import com.gunshi.project.xyt.entity.vo.OsmoticShiftVo;
import com.gunshi.project.xyt.model.OsmoticShiftR; import com.gunshi.project.xyt.model.OsmoticShiftR;
import com.gunshi.project.xyt.service.OsmoticShiftRService; import com.gunshi.project.xyt.service.OsmoticShiftRService;
import com.gunshi.project.xyt.validate.markers.Insert; import com.gunshi.project.xyt.validate.markers.Insert;
@ -84,4 +84,16 @@ public class OsmoticShiftRController {
service.yearStatExport(osmoticQuerySo,response); service.yearStatExport(osmoticQuerySo,response);
} }
@Operation(summary = "布置图-位移监测")
@GetMapping("/list/value")
public R<List<OsmoticShiftListVo>> listValue() {
return R.ok(service.listValue());
}
@Operation(summary = "布置图-按测站查询位移监测数据")
@PostMapping("/detail/value")
public R<List<OsmoticShiftValueVo>> detailValue(@RequestBody @Validated OsmoticDetailQuerySo so) {
return R.ok(service.detailValue(so));
}
} }

View File

@ -3,9 +3,7 @@ package com.gunshi.project.xyt.entity.so;
import com.gunshi.db.dto.DateTimeRangeSo; import com.gunshi.db.dto.DateTimeRangeSo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
import org.hibernate.validator.constraints.Range;
/** /**
* Description: * Description:
@ -18,9 +16,7 @@ import org.hibernate.validator.constraints.Range;
@Schema(description = "布置图详细数据查询对象") @Schema(description = "布置图详细数据查询对象")
public class OsmoticDetailQuerySo { public class OsmoticDetailQuerySo {
@Schema(description = "类型1渗压 2渗流") @Schema(description = "类型2渗流 其他可不传)")
@NotNull(message = "类型不可为空")
@Range(min = 1,max = 2)
private Integer type = 1; private Integer type = 1;
@Schema(description = "时间") @Schema(description = "时间")

View File

@ -1,12 +1,9 @@
package com.gunshi.project.xyt.entity.vo; 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 io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
/** /**
* Description: * Description:
@ -25,8 +22,7 @@ public class OsmoticPressVo {
private String profileName; private String profileName;
@Schema(description="监测时间") @Schema(description="监测时间")
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8") private String tm;
private Date tm;
@Schema(description="监测值") @Schema(description="监测值")
private BigDecimal value; private BigDecimal value;

View File

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

View File

@ -45,4 +45,10 @@ public class OsmoticShiftValueVo {
@Schema(description="h方向") @Schema(description="h方向")
private BigDecimal h; private BigDecimal h;
/**
*
*/
@Schema(description="库水位")
private BigDecimal rz;
} }

View File

@ -156,21 +156,21 @@ public interface OsmoticPressRMapper extends BaseMapper<OsmoticPressR> {
@Select(""" @Select("""
<script> <script>
SELECT st.station_code,r.value,r.tm,m.profile_name FROM osmotic_press_device st SELECT st.station_code,r.value, to_char(r.tm,'YYYY-MM-DD HH24:MI:SS') as tm,m.profile_name FROM osmotic_press_device st
LEFT JOIN (SELECT station_code,MAX(tm) tm FROM osmotic_press_r GROUP BY station_code) maxr ON st.station_code = maxr.station_code LEFT JOIN (SELECT station_code,MAX(tm) tm FROM osmotic_press_r GROUP BY station_code) maxr ON st.station_code = maxr.station_code
LEFT JOIN osmotic_press_r r ON maxr.station_code = r.station_code AND maxr.tm = r.tm LEFT JOIN osmotic_press_r r ON maxr.station_code = r.station_code AND maxr.tm = r.tm
LEFT JOIN att_dam_profile m ON st.profile_code = m.profile_code LEFT JOIN att_dam_profile m ON st.profile_code = m.profile_code
ORDER BY st.profile_code,st.station_code ORDER BY m.profile_name asc,st.station_code asc,r.tm desc
</script> </script>
""") """)
List<OsmoticPressVo> listValue(); List<OsmoticPressVo> listValue();
@Select(""" @Select("""
<script> <script>
SELECT st.station_code,r.q as value,r.tm FROM osmotic_flow_device st SELECT st.station_code,r.q as value, to_char(r.tm,'YYYY-MM-DD HH24:MI:SS') as 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 (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 LEFT JOIN osmotic_flow_r r ON maxr.station_code = r.station_code AND maxr.tm = r.tm
ORDER BY st.station_code ORDER BY st.station_code asc,r.tm desc
</script> </script>
""") """)
List<OsmoticPressVo> flowListValue(); List<OsmoticPressVo> flowListValue();

View File

@ -1,7 +1,9 @@
package com.gunshi.project.xyt.mapper; package com.gunshi.project.xyt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; 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.so.OsmoticQuerySo;
import com.gunshi.project.xyt.entity.vo.OsmoticShiftListVo;
import com.gunshi.project.xyt.entity.vo.OsmoticShiftValueVo; import com.gunshi.project.xyt.entity.vo.OsmoticShiftValueVo;
import com.gunshi.project.xyt.model.OsmoticShiftR; import com.gunshi.project.xyt.model.OsmoticShiftR;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -37,4 +39,49 @@ public interface OsmoticShiftRMapper extends BaseMapper<OsmoticShiftR> {
</script> </script>
""") """)
List<OsmoticShiftValueVo> queryValue(@Param("obj") OsmoticQuerySo osmoticQuerySo); List<OsmoticShiftValueVo> queryValue(@Param("obj") OsmoticQuerySo osmoticQuerySo);
@Select("""
<script>
SELECT st.station_code,r.x,r.y,r.h,to_char(r.tm,'YYYY-MM-DD HH24:MI:SS') as tm FROM osmotic_shift_device st
LEFT JOIN (SELECT station_code,MAX(tm) tm FROM osmotic_shift_r GROUP BY station_code) maxr ON st.station_code = maxr.station_code
LEFT JOIN osmotic_shift_r r ON maxr.station_code = r.station_code AND maxr.tm = r.tm
ORDER BY st.station_code asc,r.tm desc
</script>
""")
List<OsmoticShiftListVo> listValue();
@Select("""
<script>
select t.station_code as stationCode,to_char(t.tm,'YYYY-MM-DD HH24:MI:SS') as tm,s.direction
from public.osmotic_warn_r t
left join public.osmotic_warn_rule s on t.rule_id = s.id
where t.station_code in
<foreach collection="obj.stationCodes" item="code" separator="," open="(" close=")">
#{code}
</foreach>
<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<OsmoticShiftListVo> queryWarn(@Param("obj") OsmoticQuerySo so);
@Select("""
<script>
select to_char(t.tm,'YYYY-MM-DD HH24:MI:SS') as tm,t.x,t.y,t.h from public.osmotic_shift_r t
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<OsmoticShiftValueVo> detailValue(@Param("obj") OsmoticDetailQuerySo so);
} }

View File

@ -386,19 +386,19 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
} }
OsmoticQuerySo so = new OsmoticQuerySo(); OsmoticQuerySo so = new OsmoticQuerySo();
List<String> stationCodes = list.stream().map(OsmoticPressVo::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(); String 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 minTm = list.stream().filter(o->o.getTm() != null).min(Comparator.comparing(OsmoticPressVo::getTm)).get().getTm();
so.setStationCodes(stationCodes); so.setStationCodes(stationCodes);
DateTimeRangeSo dateTimeRangeSo = new DateTimeRangeSo(); DateTimeRangeSo dateTimeRangeSo = new DateTimeRangeSo();
dateTimeRangeSo.setStart(minTm); dateTimeRangeSo.setStart(DateUtil.convertStringToDate(minTm));
dateTimeRangeSo.setEnd(maxTm); dateTimeRangeSo.setEnd(DateUtil.convertStringToDate(maxTm));
so.setDateTimeRangeSo(dateTimeRangeSo); so.setDateTimeRangeSo(dateTimeRangeSo);
List<OsmoticValueVo> warnList = mapper.queryWarn(so); List<OsmoticValueVo> warnList = mapper.queryWarn(so);
list.stream().map(o->{ 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); 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){ if(b){
o.setStatus(1); o.setStatus(1);
} }

View File

@ -6,11 +6,11 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
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.OsmoticChartVo; import com.gunshi.project.xyt.entity.vo.*;
import com.gunshi.project.xyt.entity.vo.OsmoticShiftValueVo; import com.gunshi.project.xyt.mapper.OsmoticPressRMapper;
import com.gunshi.project.xyt.entity.vo.OsmoticShiftVo;
import com.gunshi.project.xyt.mapper.OsmoticShiftRMapper; import com.gunshi.project.xyt.mapper.OsmoticShiftRMapper;
import com.gunshi.project.xyt.model.OsmoticShiftR; import com.gunshi.project.xyt.model.OsmoticShiftR;
import com.gunshi.project.xyt.util.DataHandleUtil; import com.gunshi.project.xyt.util.DataHandleUtil;
@ -19,6 +19,7 @@ import com.gunshi.project.xyt.util.ExcelUtil;
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;
@ -38,6 +39,9 @@ public class OsmoticShiftRService extends ServiceImpl<OsmoticShiftRMapper, Osmot
@Resource @Resource
private OsmoticShiftRMapper mapper; private OsmoticShiftRMapper mapper;
@Resource
private OsmoticPressRMapper pressRMapper;
private static final String X_PREFIX = "/X"; private static final String X_PREFIX = "/X";
private static final String Y_PREFIX = "/Y"; private static final String Y_PREFIX = "/Y";
private static final String H_PREFIX = "/H"; private static final String H_PREFIX = "/H";
@ -244,6 +248,74 @@ public class OsmoticShiftRService extends ServiceImpl<OsmoticShiftRMapper, 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<OsmoticShiftListVo> listValue() {
List<OsmoticShiftListVo> list = mapper.listValue();
OsmoticQuerySo so = new OsmoticQuerySo();
List<String> 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<OsmoticShiftListVo> 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<OsmoticShiftValueVo> detailValue(OsmoticDetailQuerySo so) {
List<OsmoticShiftValueVo> list = mapper.detailValue(so);
OsmoticQuerySo osmoticQuerySo = new OsmoticQuerySo();
BeanUtils.copyProperties(so,osmoticQuerySo);
List<StRzVo> stRzVos = pressRMapper.queryLineRz(osmoticQuerySo);
return bindShiftDetail(list,stRzVos);
}
private List<OsmoticShiftValueVo> bindShiftDetail(List<OsmoticShiftValueVo> 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<OsmoticShiftValueVo> result = new ArrayList<>();
strings.stream().forEach(v1 ->{
OsmoticShiftValueVo v = new OsmoticShiftValueVo();
v.setTm(v1);
result.add(v);
});
List<OsmoticShiftValueVo> 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());
}
} }