测值查询
parent
3a1f393d57
commit
20119ee039
|
|
@ -3,6 +3,9 @@ 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.OsmoticQueryPageSo;
|
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.OsmoticStationVo;
|
||||||
import com.gunshi.project.xyt.model.OsmoticPressR;
|
import com.gunshi.project.xyt.model.OsmoticPressR;
|
||||||
import com.gunshi.project.xyt.service.OsmoticPressRService;
|
import com.gunshi.project.xyt.service.OsmoticPressRService;
|
||||||
import com.gunshi.project.xyt.validate.markers.Insert;
|
import com.gunshi.project.xyt.validate.markers.Insert;
|
||||||
|
|
@ -62,4 +65,16 @@ public class OsmoticPressRController {
|
||||||
return R.ok(service.queryPage(osmoticQueryPageSo));
|
return R.ok(service.queryPage(osmoticQueryPageSo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "测值查询(数据表)")
|
||||||
|
@PostMapping("/query/value")
|
||||||
|
public R<List<OsmoticStationVo>> queryValue(@RequestBody OsmoticQuerySo osmoticQuerySo) {
|
||||||
|
return R.ok(service.queryValue(osmoticQuerySo));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "测值查询(多图单表)")
|
||||||
|
@PostMapping("/query/chart")
|
||||||
|
public R<List<OsmoticChartVo>> queryChart(@RequestBody OsmoticQuerySo osmoticQuerySo) {
|
||||||
|
return R.ok(service.queryChart(osmoticQuerySo));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.gunshi.project.xyt.entity.so;
|
||||||
|
|
||||||
|
import com.gunshi.db.dto.DateTimeRangeSo;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description:
|
||||||
|
* Created by wanyan on 2024/3/19
|
||||||
|
*
|
||||||
|
* @author wanyan
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "测值查询对象")
|
||||||
|
public class OsmoticQuerySo {
|
||||||
|
|
||||||
|
@Schema(description = "时间")
|
||||||
|
private DateTimeRangeSo dateTimeRangeSo;
|
||||||
|
|
||||||
|
|
||||||
|
@Schema(description = "测点编号")
|
||||||
|
private List<String> stationCodes;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.gunshi.project.xyt.entity.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Created by wanyan on 2024/3/13
|
||||||
|
*
|
||||||
|
* @author wanyan
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OsmoticChartDetailVo {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间
|
||||||
|
*/
|
||||||
|
@Schema(description="时间")
|
||||||
|
private String tm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库水位
|
||||||
|
*/
|
||||||
|
@Schema(description="库水位")
|
||||||
|
private BigDecimal rz;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管水位
|
||||||
|
*/
|
||||||
|
@Schema(description="管水位")
|
||||||
|
private BigDecimal value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.gunshi.project.xyt.entity.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description:
|
||||||
|
* Created by wanyan on 2024/7/9
|
||||||
|
*
|
||||||
|
* @author wanyan
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OsmoticChartVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测点编号
|
||||||
|
*/
|
||||||
|
@Schema(description="测点编号")
|
||||||
|
private String stationCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最大值
|
||||||
|
*/
|
||||||
|
@Schema(description="最大值")
|
||||||
|
private BigDecimal maxValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最大值时间
|
||||||
|
*/
|
||||||
|
@Schema(description="最大值时间")
|
||||||
|
private String maxTm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最小值
|
||||||
|
*/
|
||||||
|
@Schema(description="最小值")
|
||||||
|
private BigDecimal minValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最小值时间
|
||||||
|
*/
|
||||||
|
@Schema(description="最小值时间")
|
||||||
|
private String minTm;
|
||||||
|
|
||||||
|
@Schema(description = "数据")
|
||||||
|
private List<OsmoticChartDetailVo> detailVos;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.gunshi.project.xyt.entity.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description:
|
||||||
|
* Created by wanyan on 2024/7/9
|
||||||
|
*
|
||||||
|
* @author wanyan
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OsmoticStationVo extends StRzVo{
|
||||||
|
|
||||||
|
@Schema(description="测值")
|
||||||
|
private List<OsmoticValueVo> list;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.gunshi.project.xyt.entity.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Created by wanyan on 2024/3/13
|
||||||
|
*
|
||||||
|
* @author wanyan
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OsmoticValueVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间
|
||||||
|
*/
|
||||||
|
@Schema(description="时间")
|
||||||
|
private String tm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测点编号
|
||||||
|
*/
|
||||||
|
@Schema(description="测点编号")
|
||||||
|
private String stationCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管水位
|
||||||
|
*/
|
||||||
|
@Schema(description="管水位")
|
||||||
|
private BigDecimal value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.gunshi.project.xyt.entity.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 水库水情
|
||||||
|
* Created by wanyan on 2024/2/20
|
||||||
|
*
|
||||||
|
* @author wanyan
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class StRzVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间
|
||||||
|
*/
|
||||||
|
@Schema(description="时间")
|
||||||
|
private String tm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库水位
|
||||||
|
*/
|
||||||
|
@Schema(description="库水位")
|
||||||
|
private BigDecimal rz;
|
||||||
|
}
|
||||||
|
|
@ -3,11 +3,16 @@ 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.OsmoticQueryPageSo;
|
import com.gunshi.project.xyt.entity.so.OsmoticQueryPageSo;
|
||||||
|
import com.gunshi.project.xyt.entity.so.OsmoticQuerySo;
|
||||||
|
import com.gunshi.project.xyt.entity.vo.OsmoticValueVo;
|
||||||
|
import com.gunshi.project.xyt.entity.vo.StRzVo;
|
||||||
import com.gunshi.project.xyt.model.OsmoticPressR;
|
import com.gunshi.project.xyt.model.OsmoticPressR;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述: 渗压监测记录表
|
* 描述: 渗压监测记录表
|
||||||
* author: xusan
|
* author: xusan
|
||||||
|
|
@ -40,4 +45,40 @@ public interface OsmoticPressRMapper extends BaseMapper<OsmoticPressR> {
|
||||||
</script>
|
</script>
|
||||||
""")
|
""")
|
||||||
Page<OsmoticPressR> queryPage(Page<OsmoticPressR> page,@Param("obj") OsmoticQueryPageSo osmoticQueryPageSo);
|
Page<OsmoticPressR> queryPage(Page<OsmoticPressR> page,@Param("obj") OsmoticQueryPageSo osmoticQueryPageSo);
|
||||||
|
|
||||||
|
@Select("""
|
||||||
|
<script>
|
||||||
|
select to_char(t.tm,'YYYY-MM-DD') as tm,t.rz
|
||||||
|
from public.st_rsvr_r t
|
||||||
|
where to_char(t.tm, 'HH24:MI:SS') = '08:00:00'
|
||||||
|
<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<StRzVo> queryRz(@Param("obj") OsmoticQuerySo osmoticQuerySo);
|
||||||
|
|
||||||
|
@Select("""
|
||||||
|
<script>
|
||||||
|
select t.station_code as stationCode,to_char(t.tm,'YYYY-MM-DD') as tm,t.value
|
||||||
|
from public.osmotic_press_r t
|
||||||
|
where to_char(t.tm, 'HH24:MI:SS') = '08:00:00' and 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<OsmoticValueVo> queryValue(@Param("obj") OsmoticQuerySo osmoticQuerySo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -3,13 +3,21 @@ package com.gunshi.project.xyt.service;
|
||||||
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.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.vo.*;
|
||||||
import com.gunshi.project.xyt.mapper.OsmoticPressRMapper;
|
import com.gunshi.project.xyt.mapper.OsmoticPressRMapper;
|
||||||
import com.gunshi.project.xyt.model.OsmoticPressR;
|
import com.gunshi.project.xyt.model.OsmoticPressR;
|
||||||
|
import com.gunshi.project.xyt.util.DateUtil;
|
||||||
|
import com.gunshi.project.xyt.util.MyBeanUtil;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述: 渗压监测记录表
|
* 描述: 渗压监测记录表
|
||||||
* author: xusan
|
* author: xusan
|
||||||
|
|
@ -26,6 +34,80 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
|
||||||
public Page<OsmoticPressR> queryPage(OsmoticQueryPageSo osmoticQueryPageSo) {
|
public Page<OsmoticPressR> queryPage(OsmoticQueryPageSo osmoticQueryPageSo) {
|
||||||
return mapper.queryPage(osmoticQueryPageSo.getPageSo().toPage(),osmoticQueryPageSo);
|
return mapper.queryPage(osmoticQueryPageSo.getPageSo().toPage(),osmoticQueryPageSo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测值查询,管水位和库水位数据固定查询每日早8点
|
||||||
|
* @param osmoticQuerySo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<OsmoticStationVo> queryValue(OsmoticQuerySo osmoticQuerySo) {
|
||||||
|
List<String> dateList = DateUtil.getDatesBetween(osmoticQuerySo.getDateTimeRangeSo().getStart(), osmoticQuerySo.getDateTimeRangeSo().getEnd());
|
||||||
|
List<OsmoticStationVo> resList = new ArrayList<>();
|
||||||
|
//查询库水位
|
||||||
|
List<StRzVo> list = mapper.queryRz(osmoticQuerySo);
|
||||||
|
Map<String, BigDecimal> rzMap = list.stream().collect(Collectors.toMap(StRzVo::getTm, StRzVo::getRz));
|
||||||
|
//查询测站管水位
|
||||||
|
List<OsmoticValueVo> valueList = mapper.queryValue(osmoticQuerySo);
|
||||||
|
//数据处理
|
||||||
|
for(String str : dateList){
|
||||||
|
OsmoticStationVo vo = new OsmoticStationVo();
|
||||||
|
vo.setTm(str);
|
||||||
|
vo.setRz(rzMap.get(str));
|
||||||
|
vo.setList(valueList.stream().filter(o->str.equals(o.getTm())).collect(Collectors.toList()));
|
||||||
|
resList.add(vo);
|
||||||
|
}
|
||||||
|
return resList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OsmoticChartVo> queryChart(OsmoticQuerySo osmoticQuerySo) {
|
||||||
|
List<OsmoticChartVo> resList = new ArrayList<>();
|
||||||
|
//查询库水位
|
||||||
|
List<StRzVo> list = mapper.queryRz(osmoticQuerySo);
|
||||||
|
//查询测站管水位
|
||||||
|
List<OsmoticValueVo> valueList = mapper.queryValue(osmoticQuerySo);
|
||||||
|
//按测站分组
|
||||||
|
Map<String, List<OsmoticValueVo>> map = valueList.stream().collect(Collectors.groupingBy(OsmoticValueVo::getStationCode));
|
||||||
|
map.entrySet().forEach(o->{
|
||||||
|
OsmoticChartVo vo = new OsmoticChartVo();
|
||||||
|
List<OsmoticValueVo> voList = o.getValue();
|
||||||
|
OsmoticValueVo max = voList.stream().max(Comparator.comparing(OsmoticValueVo::getValue)).get();
|
||||||
|
OsmoticValueVo min = voList.stream().min(Comparator.comparing(OsmoticValueVo::getValue)).get();
|
||||||
|
vo.setStationCode(o.getKey());
|
||||||
|
vo.setMaxValue(max.getValue());
|
||||||
|
vo.setMaxTm(max.getTm());
|
||||||
|
vo.setMinValue(min.getValue());
|
||||||
|
vo.setMinTm(min.getTm());
|
||||||
|
vo.setDetailVos(bindData(MyBeanUtil.collectionCopy(list,OsmoticChartDetailVo.class),MyBeanUtil.collectionCopy(voList,OsmoticChartDetailVo.class)));
|
||||||
|
resList.add(vo);
|
||||||
|
});
|
||||||
|
return resList;
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据监测时间合并管水位和库水位数据
|
||||||
|
private List<OsmoticChartDetailVo> bindData(List<OsmoticChartDetailVo> tmRzList, List<OsmoticChartDetailVo> voList) {
|
||||||
|
HashSet<String> strings = new HashSet<>();
|
||||||
|
tmRzList.stream().forEach(v1 -> strings.add(v1.getTm()));
|
||||||
|
voList.stream().forEach(v1 -> strings.add(v1.getTm()));
|
||||||
|
|
||||||
|
List<OsmoticChartDetailVo> result = new ArrayList<>();
|
||||||
|
strings.stream().forEach(v1 ->{
|
||||||
|
OsmoticChartDetailVo v = new OsmoticChartDetailVo();
|
||||||
|
v.setTm(v1);
|
||||||
|
result.add(v);
|
||||||
|
});
|
||||||
|
|
||||||
|
List<OsmoticChartDetailVo> list = result.stream().map(v1 -> {
|
||||||
|
tmRzList.stream().filter(v2 -> v1.getTm().equals(v2.getTm())).forEach(v2 -> {
|
||||||
|
v1.setRz(v2.getRz());
|
||||||
|
});
|
||||||
|
|
||||||
|
voList.stream().filter(v2 -> v1.getTm().equals(v2.getTm())).forEach(v2 -> {
|
||||||
|
v1.setValue(v2.getValue());
|
||||||
|
});
|
||||||
|
return v1;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return list.stream().sorted(Comparator.comparing(OsmoticChartDetailVo::getTm)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,7 @@ import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description:
|
* Description:
|
||||||
|
|
@ -142,5 +141,17 @@ public class DateUtil {
|
||||||
return now.format(ym);
|
return now.format(ym);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<String> getDatesBetween(Date startDate, Date endDate) {
|
||||||
|
List<String> dates = new ArrayList<>();
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(startDate);
|
||||||
|
|
||||||
|
while (calendar.getTime().before(endDate)) {
|
||||||
|
dates.add(convertDateToString(calendar.getTime()));
|
||||||
|
calendar.add(Calendar.DATE, 1);
|
||||||
|
}
|
||||||
|
return dates.reversed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue