2024-07-08 17:47:02 +08:00
|
|
|
|
package com.gunshi.project.xyt.service;
|
|
|
|
|
|
|
2024-07-11 10:58:35 +08:00
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
2024-07-10 09:27:20 +08:00
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
2024-07-08 17:47:02 +08:00
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
2024-07-11 10:58:35 +08:00
|
|
|
|
import com.gunshi.project.xyt.entity.so.InfiltraLineSo;
|
2024-07-10 09:27:20 +08:00
|
|
|
|
import com.gunshi.project.xyt.entity.so.OsmoticQueryPageSo;
|
2024-07-10 16:28:20 +08:00
|
|
|
|
import com.gunshi.project.xyt.entity.so.OsmoticQuerySo;
|
|
|
|
|
|
import com.gunshi.project.xyt.entity.vo.*;
|
2024-07-08 17:47:02 +08:00
|
|
|
|
import com.gunshi.project.xyt.mapper.OsmoticPressRMapper;
|
2024-07-11 10:58:35 +08:00
|
|
|
|
import com.gunshi.project.xyt.model.OsmoticPressDevice;
|
|
|
|
|
|
import com.gunshi.project.xyt.model.OsmoticPressDeviceAutoDao;
|
2024-07-08 17:47:02 +08:00
|
|
|
|
import com.gunshi.project.xyt.model.OsmoticPressR;
|
2024-07-10 16:28:20 +08:00
|
|
|
|
import com.gunshi.project.xyt.util.DateUtil;
|
|
|
|
|
|
import com.gunshi.project.xyt.util.MyBeanUtil;
|
2024-07-10 09:27:20 +08:00
|
|
|
|
import jakarta.annotation.Resource;
|
2024-07-08 17:47:02 +08:00
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
2024-07-10 16:28:20 +08:00
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
2024-07-08 17:47:02 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 描述: 渗压监测记录表
|
|
|
|
|
|
* author: xusan
|
|
|
|
|
|
* date: 2024-07-08 17:30:37
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Service
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
|
public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, OsmoticPressR>
|
|
|
|
|
|
{
|
2024-07-10 09:27:20 +08:00
|
|
|
|
@Resource
|
|
|
|
|
|
private OsmoticPressRMapper mapper;
|
2024-07-08 17:47:02 +08:00
|
|
|
|
|
2024-07-11 10:58:35 +08:00
|
|
|
|
@Resource
|
|
|
|
|
|
private OsmoticPressDeviceAutoDao pressDeviceAutoDao;
|
|
|
|
|
|
|
2024-07-10 09:27:20 +08:00
|
|
|
|
public Page<OsmoticPressR> queryPage(OsmoticQueryPageSo osmoticQueryPageSo) {
|
|
|
|
|
|
return mapper.queryPage(osmoticQueryPageSo.getPageSo().toPage(),osmoticQueryPageSo);
|
|
|
|
|
|
}
|
2024-07-10 16:28:20 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 测值查询,管水位和库水位数据固定查询每日早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());
|
|
|
|
|
|
}
|
2024-07-11 10:58:35 +08:00
|
|
|
|
|
|
|
|
|
|
public List<OsmoticStationVo> infiltraLine(InfiltraLineSo infiltraLineSo) {
|
|
|
|
|
|
List<OsmoticStationVo> resList = new ArrayList<>();
|
|
|
|
|
|
String profileCode = infiltraLineSo.getProfileCode();
|
|
|
|
|
|
//通过断面查询渗压
|
|
|
|
|
|
List<OsmoticPressDevice> pressList = pressDeviceAutoDao.list(new QueryWrapper<OsmoticPressDevice>().eq("profile_code", profileCode));
|
|
|
|
|
|
if(CollectionUtils.isEmpty(pressList)){
|
|
|
|
|
|
return resList;
|
|
|
|
|
|
}
|
|
|
|
|
|
List<String> stationCodes = pressList.stream().map(OsmoticPressDevice::getStationCode).collect(Collectors.toList());
|
|
|
|
|
|
//查询库水位
|
|
|
|
|
|
List<StRzVo> list = mapper.queryLineRz(infiltraLineSo);
|
|
|
|
|
|
Map<String, BigDecimal> rzMap = list.stream().collect(Collectors.toMap(StRzVo::getTm, StRzVo::getRz));
|
|
|
|
|
|
//查询测站管水位
|
|
|
|
|
|
List<OsmoticValueVo> valueList = mapper.queryLineValue(infiltraLineSo,stationCodes);
|
|
|
|
|
|
//查询测站预警信息
|
|
|
|
|
|
List<OsmoticValueVo> warnList = mapper.queryWarn(infiltraLineSo,stationCodes);
|
|
|
|
|
|
valueList.stream().map(vo->{
|
|
|
|
|
|
Boolean b = warnList.stream().filter(o->o.getStationCode().equals(vo.getStationCode()) && o.getTm().equals(vo.getTm())).findAny().isPresent();
|
|
|
|
|
|
if(b){
|
|
|
|
|
|
vo.setStatus(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
return vo;
|
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
HashSet<String> dateList = new HashSet<>();
|
|
|
|
|
|
list.stream().forEach(v1 -> dateList.add(v1.getTm()));
|
|
|
|
|
|
valueList.stream().forEach(v1 -> dateList.add(v1.getTm()));
|
|
|
|
|
|
for(String str : dateList){
|
|
|
|
|
|
OsmoticStationVo vo = new OsmoticStationVo();
|
|
|
|
|
|
vo.setTm(str);
|
|
|
|
|
|
vo.setRz(rzMap.get(str));
|
|
|
|
|
|
List<OsmoticValueVo> newList = valueList.stream().filter(o->str.equals(o.getTm())).collect(Collectors.toList());
|
|
|
|
|
|
vo.setList(newList);
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(newList) && newList.stream().filter(o->o.getStatus() == 0).findAny().isPresent()){
|
|
|
|
|
|
vo.setStatus(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
resList.add(vo);
|
|
|
|
|
|
}
|
|
|
|
|
|
return resList;
|
|
|
|
|
|
}
|
2024-07-08 17:47:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|