四全-全天候-河道水情
parent
db3a093461
commit
029653630d
|
|
@ -1,13 +1,13 @@
|
|||
package com.gunshi.project.xyt.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.core.annotation.Get;
|
||||
import com.gunshi.core.annotation.Post;
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.db.dto.PageSo;
|
||||
import com.gunshi.project.xyt.entity.so.SoilMoisturePageSo;
|
||||
import com.gunshi.project.xyt.entity.vo.SoilMoistureVO;
|
||||
import com.gunshi.project.xyt.model.SafetyReinforcement;
|
||||
import com.gunshi.project.xyt.model.SoilMoistureData;
|
||||
import com.gunshi.project.xyt.model.SoilMoistureStation;
|
||||
import com.gunshi.project.xyt.service.SoilMoistureDataService;
|
||||
|
|
@ -23,6 +23,8 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 土壤墒情
|
||||
|
|
@ -40,7 +42,18 @@ public class SoilMoistureController {
|
|||
|
||||
@Get(path = "/stationList", summary = "站点列表")
|
||||
public R<List<SoilMoistureStation>> listStation() {
|
||||
return R.ok(soilMoistureStationService.list());
|
||||
List<SoilMoistureStation> list = soilMoistureStationService.list();
|
||||
if(CollectionUtil.isEmpty(list)){
|
||||
return R.ok(list);
|
||||
}
|
||||
List<SoilMoistureStation> collect = list.stream().peek(e -> {
|
||||
LambdaQueryWrapper<SoilMoistureData> qw = new LambdaQueryWrapper();
|
||||
qw.eq(SoilMoistureData::getStcd,e.getStcd()).orderByDesc(SoilMoistureData::getCreateTime).last(" limit 1");
|
||||
SoilMoistureData one = soilMoistureDataService.getOne(qw);
|
||||
e.setTm(one.getCreateTime());
|
||||
e.setVal(one.getVal());
|
||||
}).collect(Collectors.toList());
|
||||
return R.ok(collect);
|
||||
}
|
||||
|
||||
@Post(path = "/page", summary = "分页")
|
||||
|
|
|
|||
|
|
@ -26,20 +26,27 @@ public class SoilMoistureVO {
|
|||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
private BigDecimal nearWeekVal;
|
||||
private BigDecimal nearWeekValMax;
|
||||
private BigDecimal nearWeekValMin;
|
||||
|
||||
private BigDecimal nearMonthVal;
|
||||
private BigDecimal nearMonthValMax;
|
||||
private BigDecimal nearMonthValMin;
|
||||
|
||||
private BigDecimal nearThreeMonthVal;
|
||||
private BigDecimal nearThreeMonthValMax;
|
||||
private BigDecimal nearThreeMonthValMin;
|
||||
|
||||
private BigDecimal nearSixMonthVal;
|
||||
private BigDecimal nearSixMonthValMax;
|
||||
private BigDecimal nearSixMonthValMin;
|
||||
|
||||
private BigDecimal nearYearVal;
|
||||
private BigDecimal nearYearValMax;
|
||||
private BigDecimal nearYearValMin;
|
||||
|
||||
private BigDecimal currWeekVal;
|
||||
private BigDecimal currWeekValMax;
|
||||
private BigDecimal currWeekValMin;
|
||||
|
||||
private BigDecimal currMonthVal;
|
||||
|
||||
private BigDecimal currYearVal;
|
||||
private BigDecimal currMonthValMax;
|
||||
private BigDecimal currMonthValMin;
|
||||
|
||||
private BigDecimal currYearValMax;
|
||||
private BigDecimal currYearValMin;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public interface StStbprpBMapper extends BaseMapper<StStbprpB> {
|
|||
" AND a.moditime >= #{obj.dateSo.start} " +
|
||||
"</if> " +
|
||||
"<if test='obj.dateSo != null and obj.dateSo.end != null'> " +
|
||||
" AND a.moditime <= #{obj.dateSo.end} " +
|
||||
" AND a.moditime <= #{obj.dateSo.end} order by a.moditime desc" +
|
||||
"</if>" +
|
||||
"</script>")
|
||||
List<StZqrlBVo> flowList(@Param("obj") StZqrlBDto obj);
|
||||
|
|
|
|||
|
|
@ -47,4 +47,10 @@ public class SoilMoistureStation implements Serializable {
|
|||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private BigDecimal val;
|
||||
|
||||
@TableField(exist = false)
|
||||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
|
||||
private Date tm;
|
||||
}
|
||||
|
|
@ -4,19 +4,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
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.PageSo;
|
||||
import com.gunshi.project.xyt.entity.so.SoilMoisturePageSo;
|
||||
import com.gunshi.project.xyt.entity.vo.SoilMoistureVO;
|
||||
import com.gunshi.project.xyt.mapper.SoilMoistureDataMapper;
|
||||
import com.gunshi.project.xyt.mapper.SoilMoistureStationMapper;
|
||||
import com.gunshi.project.xyt.model.SoilMoistureData;
|
||||
import com.gunshi.project.xyt.model.SoilMoistureStation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
|
|
@ -38,10 +34,10 @@ public class SoilMoistureDataService extends ServiceImpl<SoilMoistureDataMapper,
|
|||
}
|
||||
if(Objects.nonNull(page.getDateRangeSo())){
|
||||
if(Objects.nonNull(page.getDateRangeSo().getStart())){
|
||||
|
||||
query.ge(SoilMoistureData::getCreateTime, page.getDateRangeSo().getStart());
|
||||
}
|
||||
if(Objects.nonNull(page.getDateRangeSo().getEnd())){
|
||||
|
||||
query.le(SoilMoistureData::getCreateTime, page.getDateRangeSo().getEnd());
|
||||
}
|
||||
}
|
||||
query.orderByDesc(SoilMoistureData::getCreateTime);
|
||||
|
|
@ -57,32 +53,49 @@ public class SoilMoistureDataService extends ServiceImpl<SoilMoistureDataMapper,
|
|||
LambdaQueryWrapper<SoilMoistureData> qw = new LambdaQueryWrapper();
|
||||
qw.eq(SoilMoistureData::getStcd,stcd).orderByDesc(SoilMoistureData::getCreateTime).last(" limit 1");
|
||||
SoilMoistureData max = baseMapper.selectOne(qw);
|
||||
SoilMoistureData min = new SoilMoistureData();
|
||||
vo.setCreateTime(max.getCreateTime());
|
||||
vo.setCurrVal(Objects.nonNull(max)? max.getVal(): null);
|
||||
|
||||
max = findMaxByRang(today, today.minusWeeks(1), stcd);
|
||||
vo.setNearWeekVal(Objects.nonNull(max)? max.getVal(): null);
|
||||
max = findMaxByRang(today, today.minusWeeks(1), stcd);
|
||||
min = findMinByRang(today, today.minusWeeks(1), stcd);
|
||||
vo.setNearWeekValMax(Objects.nonNull(max)? max.getVal(): null);
|
||||
vo.setNearWeekValMin(Objects.nonNull(min)? min.getVal(): null);
|
||||
|
||||
max = findMaxByRang(today, today.minusMonths(1), stcd);
|
||||
vo.setNearMonthVal(Objects.nonNull(max)? max.getVal(): null);
|
||||
min = findMinByRang(today, today.minusMonths(1), stcd);
|
||||
vo.setNearMonthValMax(Objects.nonNull(max)? max.getVal(): null);
|
||||
vo.setNearMonthValMin(Objects.nonNull(min)? min.getVal(): null);
|
||||
|
||||
max = findMaxByRang(today, today.minusMonths(3), stcd);
|
||||
vo.setNearThreeMonthVal(Objects.nonNull(max)? max.getVal(): null);
|
||||
min = findMinByRang(today, today.minusMonths(3), stcd);
|
||||
vo.setNearThreeMonthValMax(Objects.nonNull(max)? max.getVal(): null);
|
||||
vo.setNearThreeMonthValMin(Objects.nonNull(min)? min.getVal(): null);
|
||||
|
||||
max = findMaxByRang(today, today.minusMonths(6), stcd);
|
||||
vo.setNearSixMonthVal(Objects.nonNull(max)? max.getVal(): null);
|
||||
min = findMinByRang(today, today.minusMonths(6), stcd);
|
||||
vo.setNearSixMonthValMax(Objects.nonNull(max)? max.getVal(): null);
|
||||
vo.setNearSixMonthValMin(Objects.nonNull(min)? min.getVal(): null);
|
||||
|
||||
max = findMaxByRang(today, today.minusYears(1), stcd);
|
||||
vo.setNearYearVal(Objects.nonNull(max)? max.getVal(): null);
|
||||
min = findMinByRang(today, today.minusYears(1), stcd);
|
||||
vo.setNearYearValMax(Objects.nonNull(max)? max.getVal(): null);
|
||||
vo.setNearYearValMin(Objects.nonNull(min)? min.getVal(): null);
|
||||
|
||||
max = findMaxByRang(today, today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)), stcd);
|
||||
vo.setCurrWeekVal(Objects.nonNull(max)? max.getVal(): null);
|
||||
min = findMinByRang(today, today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)), stcd);
|
||||
vo.setCurrWeekValMax(Objects.nonNull(max)? max.getVal(): null);
|
||||
vo.setCurrWeekValMin(Objects.nonNull(min)? min.getVal(): null);
|
||||
|
||||
max = findMaxByRang(today, today.withDayOfMonth(1), stcd);
|
||||
vo.setCurrMonthVal(Objects.nonNull(max)? max.getVal(): null);
|
||||
min = findMinByRang(today, today.withDayOfMonth(1), stcd);
|
||||
vo.setCurrMonthValMax(Objects.nonNull(max)? max.getVal(): null);
|
||||
vo.setCurrMonthValMin(Objects.nonNull(min)? min.getVal(): null);
|
||||
|
||||
max = findMaxByRang(today, today.withDayOfYear(1), stcd);
|
||||
vo.setCurrYearVal(Objects.nonNull(max)? max.getVal(): null);
|
||||
min = findMinByRang(today, today.withDayOfYear(1), stcd);
|
||||
vo.setCurrYearValMax(Objects.nonNull(max)? max.getVal(): null);
|
||||
vo.setCurrYearValMin(Objects.nonNull(min)? min.getVal(): null);
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
|
@ -93,6 +106,14 @@ public class SoilMoistureDataService extends ServiceImpl<SoilMoistureDataMapper,
|
|||
qw.ge(SoilMoistureData::getCreateTime,startDate).orderByDesc(SoilMoistureData::getVal).last(" limit 1");
|
||||
return baseMapper.selectOne(qw);
|
||||
}
|
||||
|
||||
public SoilMoistureData findMinByRang(LocalDate now, LocalDate startDate, String stcd){
|
||||
LambdaQueryWrapper<SoilMoistureData> qw = new LambdaQueryWrapper();
|
||||
qw.eq(SoilMoistureData::getStcd,stcd);
|
||||
qw.le(SoilMoistureData::getCreateTime,now);
|
||||
qw.ge(SoilMoistureData::getCreateTime,startDate).orderByAsc(SoilMoistureData::getVal).last(" limit 1");
|
||||
return baseMapper.selectOne(qw);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue