年度位移统计查询,年度渗压统计查询联调修改
parent
81fc1f5d05
commit
8c70e5ef0e
|
|
@ -69,43 +69,43 @@ public class OsmoticPressRController {
|
|||
|
||||
@Operation(summary = "测值查询(数据表)")
|
||||
@PostMapping("/query/value")
|
||||
public R<List<OsmoticStationVo>> queryValue(@RequestBody OsmoticQuerySo osmoticQuerySo) {
|
||||
public R<List<OsmoticStationVo>> queryValue(@RequestBody @Validated OsmoticQuerySo osmoticQuerySo) {
|
||||
return R.ok(service.queryValue(osmoticQuerySo,null));
|
||||
}
|
||||
|
||||
@Operation(summary = "测值查询(多图单表)")
|
||||
@PostMapping("/query/chart")
|
||||
public R<List<OsmoticChartVo>> queryChart(@RequestBody OsmoticQuerySo osmoticQuerySo) {
|
||||
public R<List<OsmoticChartVo>> queryChart(@RequestBody @Validated OsmoticQuerySo osmoticQuerySo) {
|
||||
return R.ok(service.queryChart(osmoticQuerySo,null));
|
||||
}
|
||||
|
||||
@Operation(summary = "浸润线查询")
|
||||
@PostMapping("/infiltra/line")
|
||||
public R<List<OsmoticStationVo>> infiltraLine(@RequestBody OsmoticQuerySo osmoticQuerySo) {
|
||||
public R<List<OsmoticStationVo>> infiltraLine(@RequestBody @Validated OsmoticQuerySo osmoticQuerySo) {
|
||||
return R.ok(service.infiltraLine(osmoticQuerySo));
|
||||
}
|
||||
|
||||
@Operation(summary = "浸润线导出")
|
||||
@PostMapping( "/export")
|
||||
public void export(@RequestBody OsmoticQuerySo osmoticQuerySo, HttpServletResponse response) {
|
||||
public void export(@RequestBody @Validated OsmoticQuerySo osmoticQuerySo, HttpServletResponse response) {
|
||||
service.export(osmoticQuerySo,response);
|
||||
}
|
||||
|
||||
@Operation(summary = "年度渗压/渗流统计(表格)")
|
||||
@PostMapping("/year/stat")
|
||||
public R<List<OsmoticStationVo>> yearStat(@RequestBody OsmoticQuerySo osmoticQuerySo) {
|
||||
public R<List<OsmoticStationVo>> yearStat(@RequestBody @Validated OsmoticQuerySo osmoticQuerySo) {
|
||||
return R.ok(service.yearStat(osmoticQuerySo));
|
||||
}
|
||||
|
||||
@Operation(summary = "年度渗压/渗流统计(全年度特征值统计)")
|
||||
@PostMapping("/year/stat/value")
|
||||
public R<List<OsmoticChartVo>> yearStatValue(@RequestBody OsmoticQuerySo osmoticQuerySo) {
|
||||
public R<List<OsmoticChartVo>> yearStatValue(@RequestBody @Validated OsmoticQuerySo osmoticQuerySo) {
|
||||
return R.ok(service.yearStatValue(osmoticQuerySo));
|
||||
}
|
||||
|
||||
@Operation(summary = "年度渗压/渗流统计导出")
|
||||
@PostMapping( "/year/stat/export")
|
||||
public void yearStatExport(@RequestBody OsmoticQuerySo osmoticQuerySo, HttpServletResponse response) {
|
||||
public void yearStatExport(@RequestBody @Validated OsmoticQuerySo osmoticQuerySo, HttpServletResponse response) {
|
||||
service.yearStatExport(osmoticQuerySo,response);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ 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.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.model.OsmoticShiftR;
|
||||
import com.gunshi.project.xyt.service.OsmoticShiftRService;
|
||||
import com.gunshi.project.xyt.validate.markers.Insert;
|
||||
|
|
@ -62,4 +65,18 @@ public class OsmoticShiftRController {
|
|||
return R.ok(service.queryPage(osmoticQueryPageSo));
|
||||
}
|
||||
|
||||
@Operation(summary = "年度位移统计(表格)")
|
||||
@PostMapping("/year/stat")
|
||||
public R<List<OsmoticShiftVo>> yearStat(@RequestBody @Validated OsmoticQuerySo osmoticQuerySo) {
|
||||
return R.ok(service.yearStat(osmoticQuerySo));
|
||||
}
|
||||
|
||||
@Operation(summary = "年度位移统计(全年度特征值统计)")
|
||||
@PostMapping("/year/stat/value")
|
||||
public R<List<OsmoticChartVo>> yearStatValue(@RequestBody @Validated OsmoticQuerySo osmoticQuerySo) {
|
||||
return R.ok(service.yearStatValue(osmoticQuerySo));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,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.NotNull;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -19,7 +19,6 @@ import java.util.List;
|
|||
public class OsmoticQuerySo {
|
||||
|
||||
@Schema(description = "类型(1渗压 2渗流)")
|
||||
@NotNull(message = "类型不可为空")
|
||||
private Integer type = 1;
|
||||
|
||||
@Schema(description = "年度")
|
||||
|
|
@ -28,9 +27,9 @@ public class OsmoticQuerySo {
|
|||
@Schema(description = "时间")
|
||||
private DateTimeRangeSo dateTimeRangeSo;
|
||||
|
||||
@Schema(description = "监测断面")
|
||||
private String profileCode;
|
||||
@Schema(description = "监测断面名称(只有导出时传)")
|
||||
private String profileName;
|
||||
|
||||
@Schema(description = "测点编号")
|
||||
private List<String> stationCodes;
|
||||
private List<@NotEmpty String> stationCodes;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
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 OsmoticShiftValueVo {
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
@Schema(description="时间")
|
||||
private String tm;
|
||||
|
||||
/**
|
||||
* 测点编号
|
||||
*/
|
||||
@Schema(description="测点编号")
|
||||
private String stationCode;
|
||||
|
||||
/**
|
||||
* x方向
|
||||
*/
|
||||
@Schema(description="x方向")
|
||||
private BigDecimal x;
|
||||
|
||||
/**
|
||||
* y方向
|
||||
*/
|
||||
@Schema(description="y方向")
|
||||
private BigDecimal y;
|
||||
|
||||
/**
|
||||
* h方向
|
||||
*/
|
||||
@Schema(description="h方向")
|
||||
private BigDecimal h;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
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 OsmoticShiftVo{
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
@Schema(description="时间")
|
||||
private String tm;
|
||||
|
||||
@Schema(description="测值")
|
||||
private List<OsmoticShiftValueVo> list;
|
||||
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ public interface OsmoticPressRMapper extends BaseMapper<OsmoticPressR> {
|
|||
<if test = "obj.type == 2">
|
||||
t.q as value from public.osmotic_flow_r t
|
||||
</if>
|
||||
where to_char(t.tm, 'HH24:MI:SS') = '08:00:00' and station_code in
|
||||
where to_char(t.tm, 'HH24:MI:SS') = '08:00:00' and t.station_code in
|
||||
<foreach collection="obj.stationCodes" item="code" separator="," open="(" close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,14 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.entity.so.OsmoticQuerySo;
|
||||
import com.gunshi.project.xyt.entity.vo.OsmoticShiftValueVo;
|
||||
import com.gunshi.project.xyt.model.OsmoticShiftR;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: 位移监测记录表
|
||||
|
|
@ -12,4 +18,22 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
@Mapper
|
||||
public interface OsmoticShiftRMapper extends BaseMapper<OsmoticShiftR> {
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
select t.station_code as stationCode,to_char(t.tm,'YYYY-MM-DD') as tm,t.x,t.y,t.h
|
||||
from public.osmotic_shift_r t and t.station_code in
|
||||
<foreach collection="obj.stationCodes" item="code" separator="," open="(" close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
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<OsmoticShiftValueVo> queryValue(@Param("obj") OsmoticQuerySo osmoticQuerySo);
|
||||
}
|
||||
|
|
@ -1,11 +1,17 @@
|
|||
package com.gunshi.project.xyt.model;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 描述: 位移设备表
|
||||
|
|
@ -19,4 +25,50 @@ public class OsmoticShiftDevice implements Serializable {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 测点编号
|
||||
*/
|
||||
@TableId(value="station_code", type= IdType.AUTO)
|
||||
@Schema(description="测点编号")
|
||||
@Size(max = 50,message = "测点编号最大长度要小于 50")
|
||||
@NotBlank(message = "测点编号不能为空")
|
||||
private String stationCode;
|
||||
|
||||
/**
|
||||
* 仪器编号
|
||||
*/
|
||||
@TableField(value="device_code")
|
||||
@Schema(description="仪器编号")
|
||||
@Size(max = 50,message = "仪器编号最大长度要小于 50")
|
||||
private String deviceCode;
|
||||
|
||||
/**
|
||||
* 仪器名称
|
||||
*/
|
||||
@TableField(value="device_name")
|
||||
@Schema(description="仪器名称")
|
||||
@Size(max = 50,message = "仪器名称最大长度要小于 50")
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 仪器型号
|
||||
*/
|
||||
@TableField(value="model")
|
||||
@Schema(description="仪器型号")
|
||||
@Size(max = 50,message = "仪器型号最大长度要小于 50")
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
@TableField(value="lgtd")
|
||||
@Schema(description="经度")
|
||||
private BigDecimal lgtd;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
@TableField(value="lttd")
|
||||
@Schema(description="纬度")
|
||||
private BigDecimal lttd;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.gunshi.project.xyt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
|
@ -9,10 +8,7 @@ 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.model.*;
|
||||
import com.gunshi.project.xyt.model.AttDamProfileAutoDao;
|
||||
import com.gunshi.project.xyt.model.OsmoticFlowDeviceAutoDao;
|
||||
import com.gunshi.project.xyt.model.OsmoticPressDeviceAutoDao;
|
||||
import com.gunshi.project.xyt.model.OsmoticPressR;
|
||||
import com.gunshi.project.xyt.util.DateUtil;
|
||||
import com.gunshi.project.xyt.util.ExcelUtil;
|
||||
import com.gunshi.project.xyt.util.MyBeanUtil;
|
||||
|
|
@ -39,15 +35,6 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
|
|||
@Resource
|
||||
private OsmoticPressRMapper mapper;
|
||||
|
||||
@Resource
|
||||
private AttDamProfileAutoDao profileAutoDao;
|
||||
|
||||
@Resource
|
||||
private OsmoticPressDeviceAutoDao pressDeviceAutoDao;
|
||||
|
||||
@Resource
|
||||
private OsmoticFlowDeviceAutoDao flowDeviceAutoDao;
|
||||
|
||||
public Page<OsmoticPressR> queryPage(OsmoticQueryPageSo osmoticQueryPageSo) {
|
||||
return mapper.queryPage(osmoticQueryPageSo.getPageSo().toPage(),osmoticQueryPageSo);
|
||||
}
|
||||
|
|
@ -93,6 +80,29 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
|
|||
List<String> stationCodes = osmoticQuerySo.getStationCodes();
|
||||
//查询库水位
|
||||
List<StRzVo> list = mapper.queryRz(osmoticQuerySo);
|
||||
//查询测站管水位
|
||||
List<OsmoticValueVo> valueList = mapper.queryValue(osmoticQuerySo);
|
||||
//按测站分组
|
||||
Map<String, List<OsmoticValueVo>> map = valueList.stream().collect(Collectors.groupingBy(OsmoticValueVo::getStationCode));
|
||||
for(String code : stationCodes){
|
||||
OsmoticChartVo vo = new OsmoticChartVo();
|
||||
vo.setStationCode(code);
|
||||
if(map.containsKey(code)){
|
||||
List<OsmoticValueVo> voList = map.get(code);
|
||||
OsmoticValueVo max = voList.stream().max(Comparator.comparing(OsmoticValueVo::getValue)).get();
|
||||
OsmoticValueVo min = voList.stream().min(Comparator.comparing(OsmoticValueVo::getValue)).get();
|
||||
vo.setStationCode(code);
|
||||
vo.setMaxValue(max.getValue());
|
||||
vo.setMaxTm(max.getTm());
|
||||
vo.setMinValue(min.getValue());
|
||||
vo.setMinTm(min.getTm());
|
||||
vo.setDiff(max.getValue().subtract(min.getValue()));
|
||||
if(year == null){
|
||||
vo.setDetailVos(bindData(MyBeanUtil.collectionCopy(list,OsmoticChartDetailVo.class),MyBeanUtil.collectionCopy(voList,OsmoticChartDetailVo.class)));
|
||||
}
|
||||
}
|
||||
resList.add(vo);
|
||||
}
|
||||
//查询测站降雨量
|
||||
List<StRzVo> drpList;
|
||||
if(year != null){
|
||||
|
|
@ -123,29 +133,6 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
|
|||
resList.add(drpVo);
|
||||
}
|
||||
}
|
||||
//查询测站管水位
|
||||
List<OsmoticValueVo> valueList = mapper.queryValue(osmoticQuerySo);
|
||||
//按测站分组
|
||||
Map<String, List<OsmoticValueVo>> map = valueList.stream().collect(Collectors.groupingBy(OsmoticValueVo::getStationCode));
|
||||
for(String code : stationCodes){
|
||||
OsmoticChartVo vo = new OsmoticChartVo();
|
||||
vo.setStationCode(code);
|
||||
if(map.containsKey(code)){
|
||||
List<OsmoticValueVo> voList = map.get(code);
|
||||
OsmoticValueVo max = voList.stream().max(Comparator.comparing(OsmoticValueVo::getValue)).get();
|
||||
OsmoticValueVo min = voList.stream().min(Comparator.comparing(OsmoticValueVo::getValue)).get();
|
||||
vo.setStationCode(code);
|
||||
vo.setMaxValue(max.getValue());
|
||||
vo.setMaxTm(max.getTm());
|
||||
vo.setMinValue(min.getValue());
|
||||
vo.setMinTm(min.getTm());
|
||||
vo.setDiff(max.getValue().subtract(min.getValue()));
|
||||
if(year == null){
|
||||
vo.setDetailVos(bindData(MyBeanUtil.collectionCopy(list,OsmoticChartDetailVo.class),MyBeanUtil.collectionCopy(voList,OsmoticChartDetailVo.class)));
|
||||
}
|
||||
}
|
||||
resList.add(vo);
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
|
|
@ -179,13 +166,6 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
|
|||
|
||||
public List<OsmoticStationVo> infiltraLine(OsmoticQuerySo osmoticQuerySo) {
|
||||
List<OsmoticStationVo> resList = new ArrayList<>();
|
||||
String profileCode = osmoticQuerySo.getProfileCode();
|
||||
//通过断面查询渗压设备
|
||||
List<String> stationCodes = queryPressList(profileCode);
|
||||
if(CollectionUtils.isEmpty(stationCodes)){
|
||||
return resList;
|
||||
}
|
||||
osmoticQuerySo.setStationCodes(stationCodes);
|
||||
//查询库水位
|
||||
List<StRzVo> list = mapper.queryLineRz(osmoticQuerySo);
|
||||
Map<String, BigDecimal> rzMap = list.stream().collect(Collectors.toMap(StRzVo::getTm, StRzVo::getRz));
|
||||
|
|
@ -217,19 +197,10 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
|
|||
return resList;
|
||||
}
|
||||
|
||||
private List<String> queryPressList(String profileCode){
|
||||
List<OsmoticPressDevice> pressList = pressDeviceAutoDao.list(new QueryWrapper<OsmoticPressDevice>().eq("profile_code", profileCode));
|
||||
return pressList.stream().map(OsmoticPressDevice::getStationCode).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<String> queryFlowList(){
|
||||
List<OsmoticFlowDevice> flowList = flowDeviceAutoDao.list();
|
||||
return flowList.stream().map(OsmoticFlowDevice::getStationCode).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void export(OsmoticQuerySo osmoticQuerySo, HttpServletResponse response) {
|
||||
//通过断面查询渗压设备
|
||||
List<String> stationCodes = queryPressList(osmoticQuerySo.getProfileCode());
|
||||
List<String> stationCodes = osmoticQuerySo.getStationCodes();
|
||||
//表头信息
|
||||
List<String> heads = new ArrayList<>();
|
||||
heads.add("序号");
|
||||
|
|
@ -263,16 +234,6 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
|
|||
}
|
||||
|
||||
private OsmoticQuerySo commonQueryHandle(OsmoticQuerySo osmoticQuerySo){
|
||||
List<String> stationCodes;
|
||||
if(osmoticQuerySo.getType() == 2){
|
||||
//查询所有的渗流设备
|
||||
stationCodes = queryFlowList();
|
||||
}else{
|
||||
String profileCode = osmoticQuerySo.getProfileCode();
|
||||
//通过断面查询渗压设备
|
||||
stationCodes = queryPressList(profileCode);
|
||||
}
|
||||
osmoticQuerySo.setStationCodes(stationCodes);
|
||||
Integer year = osmoticQuerySo.getYear();
|
||||
Date start = DateUtil.convertStringToDate(year + "-01-01 00:00:00");
|
||||
Date end = DateUtil.convertStringToDate(year + "-12-31 00:00:00");
|
||||
|
|
@ -294,16 +255,11 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
|
|||
}
|
||||
|
||||
public void yearStatExport(OsmoticQuerySo osmoticQuerySo, HttpServletResponse response) {
|
||||
String headName = "断面测压管水位(m)";
|
||||
String headName = osmoticQuerySo.getProfileName() + "断面测压管水位(m)";
|
||||
String fileName = "断面年度渗压统计";
|
||||
String sheetName = "年度渗压统计";
|
||||
if(osmoticQuerySo.getType() == 1){
|
||||
//断面名称
|
||||
AttDamProfile damProfile = profileAutoDao.getById(osmoticQuerySo.getProfileCode());
|
||||
if(damProfile != null){
|
||||
headName = damProfile.getProfileName() + headName;
|
||||
fileName = damProfile.getProfileName() + fileName;
|
||||
}
|
||||
fileName = osmoticQuerySo.getProfileName() + fileName;
|
||||
}else {
|
||||
headName = "渗流量(L/s)";
|
||||
fileName = "年度渗流统计";
|
||||
|
|
|
|||
|
|
@ -5,13 +5,24 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|||
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.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.mapper.OsmoticShiftRMapper;
|
||||
import com.gunshi.project.xyt.model.OsmoticShiftDeviceAutoDao;
|
||||
import com.gunshi.project.xyt.model.OsmoticShiftR;
|
||||
import com.gunshi.project.xyt.util.DateUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 描述: 位移监测记录表
|
||||
* author: xusan
|
||||
|
|
@ -22,6 +33,11 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public class OsmoticShiftRService extends ServiceImpl<OsmoticShiftRMapper, OsmoticShiftR>
|
||||
{
|
||||
@Resource
|
||||
private OsmoticShiftRMapper mapper;
|
||||
|
||||
@Resource
|
||||
private OsmoticShiftDeviceAutoDao shiftDeviceAutoDao;
|
||||
|
||||
public Page<OsmoticShiftR> queryPage(OsmoticQueryPageSo osmoticQueryPageSo) {
|
||||
LambdaQueryWrapper<OsmoticShiftR> wrapper = Wrappers.lambdaQuery();
|
||||
|
|
@ -37,6 +53,82 @@ public class OsmoticShiftRService extends ServiceImpl<OsmoticShiftRMapper, Osmot
|
|||
wrapper.orderByDesc(OsmoticShiftR::getTm);
|
||||
return this.page(osmoticQueryPageSo.getPageSo().toPage(),wrapper);
|
||||
}
|
||||
|
||||
public List<OsmoticShiftVo> yearStat(OsmoticQuerySo osmoticQuerySo) {
|
||||
List<OsmoticShiftVo> resList = new ArrayList<>();
|
||||
commonQueryHandle(osmoticQuerySo);
|
||||
//查询位移监测记录
|
||||
List<OsmoticShiftValueVo> valueList = mapper.queryValue(osmoticQuerySo);
|
||||
List<String> dateList = DateUtil.getDatesBetween(osmoticQuerySo.getDateTimeRangeSo().getStart(), osmoticQuerySo.getDateTimeRangeSo().getEnd(), false);
|
||||
//数据处理
|
||||
for(String str : dateList){
|
||||
OsmoticShiftVo vo = new OsmoticShiftVo();
|
||||
vo.setTm(str);
|
||||
vo.setList(valueList.stream().filter(o->str.equals(o.getTm())).collect(Collectors.toList()));
|
||||
resList.add(vo);
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
private OsmoticQuerySo commonQueryHandle(OsmoticQuerySo osmoticQuerySo){
|
||||
Integer year = osmoticQuerySo.getYear();
|
||||
Date start = DateUtil.convertStringToDate(year + "-01-01 00:00:00");
|
||||
Date end = DateUtil.convertStringToDate(year + "-12-31 00:00:00");
|
||||
DateTimeRangeSo so = new DateTimeRangeSo();
|
||||
so.setStart(start);
|
||||
so.setEnd(end);
|
||||
osmoticQuerySo.setDateTimeRangeSo(so);
|
||||
return osmoticQuerySo;
|
||||
}
|
||||
|
||||
|
||||
public List<OsmoticChartVo> yearStatValue(OsmoticQuerySo osmoticQuerySo) {
|
||||
List<OsmoticChartVo> resList = new ArrayList<>();
|
||||
commonQueryHandle(osmoticQuerySo);
|
||||
//查询位移监测记录
|
||||
List<OsmoticShiftValueVo> valueList = mapper.queryValue(osmoticQuerySo);
|
||||
//按测站分组
|
||||
Map<String, List<OsmoticShiftValueVo>> map = valueList.stream().collect(Collectors.groupingBy(OsmoticShiftValueVo::getStationCode));
|
||||
map.entrySet().forEach(o->{
|
||||
String key = o.getKey();
|
||||
List<OsmoticShiftValueVo> value = o.getValue();
|
||||
|
||||
OsmoticChartVo xVo = new OsmoticChartVo();
|
||||
OsmoticShiftValueVo xMax = value.stream().max(Comparator.comparing(OsmoticShiftValueVo::getX)).get();
|
||||
OsmoticShiftValueVo xMin = value.stream().min(Comparator.comparing(OsmoticShiftValueVo::getX)).get();
|
||||
xVo.setStationCode(key + "/X");
|
||||
xVo.setMaxValue(xMax.getX());
|
||||
xVo.setMaxTm(xMax.getTm());
|
||||
xVo.setMinValue(xMin.getX());
|
||||
xVo.setMinTm(xMin.getTm());
|
||||
xVo.setDiff(xMax.getX().subtract(xMin.getX()));
|
||||
resList.add(xVo);
|
||||
|
||||
OsmoticChartVo yVo = new OsmoticChartVo();
|
||||
OsmoticShiftValueVo yMax = value.stream().max(Comparator.comparing(OsmoticShiftValueVo::getY)).get();
|
||||
OsmoticShiftValueVo yMin = value.stream().min(Comparator.comparing(OsmoticShiftValueVo::getY)).get();
|
||||
yVo.setStationCode(key + "/Y");
|
||||
yVo.setMaxValue(yMax.getY());
|
||||
yVo.setMaxTm(yMax.getTm());
|
||||
yVo.setMinValue(yMin.getY());
|
||||
yVo.setMinTm(yMin.getTm());
|
||||
yVo.setDiff(yMax.getY().subtract(yMin.getY()));
|
||||
resList.add(yVo);
|
||||
|
||||
OsmoticChartVo hVo = new OsmoticChartVo();
|
||||
OsmoticShiftValueVo hMax = value.stream().max(Comparator.comparing(OsmoticShiftValueVo::getH)).get();
|
||||
OsmoticShiftValueVo hMin = value.stream().min(Comparator.comparing(OsmoticShiftValueVo::getH)).get();
|
||||
hVo.setStationCode(key + "/H");
|
||||
hVo.setMaxValue(hMax.getH());
|
||||
hVo.setMaxTm(hMax.getTm());
|
||||
hVo.setMinValue(hMin.getH());
|
||||
hVo.setMinTm(hMin.getTm());
|
||||
hVo.setDiff(hMax.getH().subtract(hMin.getH()));
|
||||
resList.add(hVo);
|
||||
|
||||
});
|
||||
return resList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue