2024-07-08 17:47:02 +08:00
|
|
|
package com.gunshi.project.xyt.service;
|
|
|
|
|
|
2024-07-10 09:27:20 +08:00
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
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-12 17:12:05 +08:00
|
|
|
import com.gunshi.db.dto.DateTimeRangeSo;
|
2024-07-10 09:27:20 +08:00
|
|
|
import com.gunshi.project.xyt.entity.so.OsmoticQueryPageSo;
|
2024-07-12 17:12:05 +08:00
|
|
|
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;
|
2024-07-08 17:47:02 +08:00
|
|
|
import com.gunshi.project.xyt.mapper.OsmoticShiftRMapper;
|
2024-07-12 17:12:05 +08:00
|
|
|
import com.gunshi.project.xyt.model.OsmoticShiftDeviceAutoDao;
|
2024-07-08 17:47:02 +08:00
|
|
|
import com.gunshi.project.xyt.model.OsmoticShiftR;
|
2024-07-12 17:12:05 +08:00
|
|
|
import com.gunshi.project.xyt.util.DateUtil;
|
|
|
|
|
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-12 17:12:05 +08:00
|
|
|
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 OsmoticShiftRService extends ServiceImpl<OsmoticShiftRMapper, OsmoticShiftR>
|
|
|
|
|
{
|
2024-07-12 17:12:05 +08:00
|
|
|
@Resource
|
|
|
|
|
private OsmoticShiftRMapper mapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private OsmoticShiftDeviceAutoDao shiftDeviceAutoDao;
|
2024-07-08 17:47:02 +08:00
|
|
|
|
2024-07-10 09:27:20 +08:00
|
|
|
public Page<OsmoticShiftR> queryPage(OsmoticQueryPageSo osmoticQueryPageSo) {
|
|
|
|
|
LambdaQueryWrapper<OsmoticShiftR> wrapper = Wrappers.lambdaQuery();
|
|
|
|
|
if(osmoticQueryPageSo.getDateTimeRangeSo() != null && osmoticQueryPageSo.getDateTimeRangeSo().getStart() != null){
|
|
|
|
|
wrapper.ge(OsmoticShiftR::getTm,osmoticQueryPageSo.getDateTimeRangeSo().getStart());
|
|
|
|
|
}
|
|
|
|
|
if(osmoticQueryPageSo.getDateTimeRangeSo() != null && osmoticQueryPageSo.getDateTimeRangeSo().getEnd() != null){
|
|
|
|
|
wrapper.le(OsmoticShiftR::getTm,osmoticQueryPageSo.getDateTimeRangeSo().getEnd());
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isNotEmpty(osmoticQueryPageSo.getStationCode())){
|
|
|
|
|
wrapper.eq(OsmoticShiftR::getStationCode,osmoticQueryPageSo.getStationCode());
|
|
|
|
|
}
|
|
|
|
|
wrapper.orderByDesc(OsmoticShiftR::getTm);
|
|
|
|
|
return this.page(osmoticQueryPageSo.getPageSo().toPage(),wrapper);
|
|
|
|
|
}
|
2024-07-12 17:12:05 +08:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2024-07-08 17:47:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|