年度渗流统计查询及导出

master
wany 2024-07-12 14:32:30 +08:00
parent b2627616ff
commit 81fc1f5d05
4 changed files with 53 additions and 18 deletions

View File

@ -91,19 +91,19 @@ public class OsmoticPressRController {
service.export(osmoticQuerySo,response); service.export(osmoticQuerySo,response);
} }
@Operation(summary = "年度渗压统计(表格)") @Operation(summary = "年度渗压/渗流统计(表格)")
@PostMapping("/year/stat") @PostMapping("/year/stat")
public R<List<OsmoticStationVo>> yearStat(@RequestBody OsmoticQuerySo osmoticQuerySo) { public R<List<OsmoticStationVo>> yearStat(@RequestBody OsmoticQuerySo osmoticQuerySo) {
return R.ok(service.yearStat(osmoticQuerySo)); return R.ok(service.yearStat(osmoticQuerySo));
} }
@Operation(summary = "年度渗压统计(全年度特征值统计)") @Operation(summary = "年度渗压/渗流统计(全年度特征值统计)")
@PostMapping("/year/stat/value") @PostMapping("/year/stat/value")
public R<List<OsmoticChartVo>> yearStatValue(@RequestBody OsmoticQuerySo osmoticQuerySo) { public R<List<OsmoticChartVo>> yearStatValue(@RequestBody OsmoticQuerySo osmoticQuerySo) {
return R.ok(service.yearStatValue(osmoticQuerySo)); return R.ok(service.yearStatValue(osmoticQuerySo));
} }
@Operation(summary = "年度渗压统计导出") @Operation(summary = "年度渗压/渗流统计导出")
@PostMapping( "/year/stat/export") @PostMapping( "/year/stat/export")
public void yearStatExport(@RequestBody OsmoticQuerySo osmoticQuerySo, HttpServletResponse response) { public void yearStatExport(@RequestBody OsmoticQuerySo osmoticQuerySo, HttpServletResponse response) {
service.yearStatExport(osmoticQuerySo,response); service.yearStatExport(osmoticQuerySo,response);

View File

@ -2,6 +2,7 @@ package com.gunshi.project.xyt.entity.so;
import com.gunshi.db.dto.DateTimeRangeSo; import com.gunshi.db.dto.DateTimeRangeSo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
@ -17,6 +18,10 @@ import java.util.List;
@Schema(description = "测值查询对象") @Schema(description = "测值查询对象")
public class OsmoticQuerySo { public class OsmoticQuerySo {
@Schema(description = "类型1渗压 2渗流")
@NotNull(message = "类型不可为空")
private Integer type = 1;
@Schema(description = "年度") @Schema(description = "年度")
private Integer year; private Integer year;

View File

@ -64,8 +64,13 @@ public interface OsmoticPressRMapper extends BaseMapper<OsmoticPressR> {
@Select(""" @Select("""
<script> <script>
select t.station_code as stationCode,to_char(t.tm,'YYYY-MM-DD') as tm,t.value select t.station_code as stationCode,to_char(t.tm,'YYYY-MM-DD') as tm,
from public.osmotic_press_r t <if test = "obj.type == 1">
t.value from public.osmotic_press_r t
</if>
<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 station_code in
<foreach collection="obj.stationCodes" item="code" separator="," open="(" close=")"> <foreach collection="obj.stationCodes" item="code" separator="," open="(" close=")">
#{code} #{code}

View File

@ -11,6 +11,7 @@ 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.*; import com.gunshi.project.xyt.model.*;
import com.gunshi.project.xyt.model.AttDamProfileAutoDao; 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.OsmoticPressDeviceAutoDao;
import com.gunshi.project.xyt.util.DateUtil; import com.gunshi.project.xyt.util.DateUtil;
import com.gunshi.project.xyt.util.ExcelUtil; import com.gunshi.project.xyt.util.ExcelUtil;
@ -44,6 +45,9 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
@Resource @Resource
private OsmoticPressDeviceAutoDao pressDeviceAutoDao; private OsmoticPressDeviceAutoDao pressDeviceAutoDao;
@Resource
private OsmoticFlowDeviceAutoDao flowDeviceAutoDao;
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);
} }
@ -67,7 +71,7 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
//查询库水位 //查询库水位
List<StRzVo> list = mapper.queryRz(osmoticQuerySo); List<StRzVo> list = mapper.queryRz(osmoticQuerySo);
Map<String, BigDecimal> rzMap = list.stream().collect(Collectors.toMap(StRzVo::getTm, StRzVo::getRz)); Map<String, BigDecimal> rzMap = list.stream().collect(Collectors.toMap(StRzVo::getTm, StRzVo::getRz));
//查询测站管水位 //查询测站管水位/渗流量
List<OsmoticValueVo> valueList = mapper.queryValue(osmoticQuerySo); List<OsmoticValueVo> valueList = mapper.queryValue(osmoticQuerySo);
//数据处理 //数据处理
for(String str : dateList){ for(String str : dateList){
@ -90,7 +94,7 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
//查询库水位 //查询库水位
List<StRzVo> list = mapper.queryRz(osmoticQuerySo); List<StRzVo> list = mapper.queryRz(osmoticQuerySo);
//查询测站降雨量 //查询测站降雨量
List<StRzVo> drpList = new ArrayList<>(); List<StRzVo> drpList;
if(year != null){ if(year != null){
drpList = mapper.queryDrp(year); drpList = mapper.queryDrp(year);
OsmoticChartVo chartVo = new OsmoticChartVo(); OsmoticChartVo chartVo = new OsmoticChartVo();
@ -218,6 +222,11 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
return pressList.stream().map(OsmoticPressDevice::getStationCode).collect(Collectors.toList()); 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) { public void export(OsmoticQuerySo osmoticQuerySo, HttpServletResponse response) {
//通过断面查询渗压设备 //通过断面查询渗压设备
List<String> stationCodes = queryPressList(osmoticQuerySo.getProfileCode()); List<String> stationCodes = queryPressList(osmoticQuerySo.getProfileCode());
@ -241,7 +250,7 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
for(int i = 0;i < stationCodes.size();i++){ for(int i = 0;i < stationCodes.size();i++){
String code = stationCodes.get(i); String code = stationCodes.get(i);
OsmoticValueVo valueVo = vo.getList().stream().filter(o->code.equals(o.getStationCode())).findFirst().orElse(null); OsmoticValueVo valueVo = vo.getList().stream().filter(o->code.equals(o.getStationCode())).findFirst().orElse(null);
test.put(code,valueVo != null ? valueVo.getValue() : "-"); test.put(code,valueVo != null ? valueVo.getValue() : "");
} }
test.put("t4", vo.getStatus() == 0 ? "异常":"正常"); test.put("t4", vo.getStatus() == 0 ? "异常":"正常");
list.add(test); list.add(test);
@ -254,9 +263,15 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
} }
private OsmoticQuerySo commonQueryHandle(OsmoticQuerySo osmoticQuerySo){ private OsmoticQuerySo commonQueryHandle(OsmoticQuerySo osmoticQuerySo){
String profileCode = osmoticQuerySo.getProfileCode(); List<String> stationCodes;
//通过断面查询渗压设备 if(osmoticQuerySo.getType() == 2){
List<String> stationCodes = queryPressList(profileCode); //查询所有的渗流设备
stationCodes = queryFlowList();
}else{
String profileCode = osmoticQuerySo.getProfileCode();
//通过断面查询渗压设备
stationCodes = queryPressList(profileCode);
}
osmoticQuerySo.setStationCodes(stationCodes); osmoticQuerySo.setStationCodes(stationCodes);
Integer year = osmoticQuerySo.getYear(); Integer year = osmoticQuerySo.getYear();
Date start = DateUtil.convertStringToDate(year + "-01-01 00:00:00"); Date start = DateUtil.convertStringToDate(year + "-01-01 00:00:00");
@ -279,12 +294,22 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
} }
public void yearStatExport(OsmoticQuerySo osmoticQuerySo, HttpServletResponse response) { public void yearStatExport(OsmoticQuerySo osmoticQuerySo, HttpServletResponse response) {
String profileName = ""; String headName = "断面测压管水位(m)";
//断面名称 String fileName = "断面年度渗压统计";
AttDamProfile damProfile = profileAutoDao.getById(osmoticQuerySo.getProfileCode()); String sheetName = "年度渗压统计";
if(damProfile != null){ if(osmoticQuerySo.getType() == 1){
profileName = damProfile.getProfileName(); //断面名称
AttDamProfile damProfile = profileAutoDao.getById(osmoticQuerySo.getProfileCode());
if(damProfile != null){
headName = damProfile.getProfileName() + headName;
fileName = damProfile.getProfileName() + fileName;
}
}else {
headName = "渗流量(L/s)";
fileName = "年度渗流统计";
sheetName = "年度渗流统计";
} }
//上方表格数据 //上方表格数据
List<OsmoticStationVo> resList = yearStat(osmoticQuerySo); List<OsmoticStationVo> resList = yearStat(osmoticQuerySo);
//下方特征值数据 //下方特征值数据
@ -304,7 +329,7 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
for(String code : stationCodes){ for(String code : stationCodes){
List<String> heads = new ArrayList<>(); List<String> heads = new ArrayList<>();
heads.add(profileName + "断面测压管水位(m)"); heads.add(headName);
heads.add(code); heads.add(code);
headList.add(heads); headList.add(heads);
} }
@ -390,7 +415,7 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
diff.put("t3", chartList.stream().filter(o->"drp".equals(o.getStationCode())).findFirst().get().getDiff()); diff.put("t3", chartList.stream().filter(o->"drp".equals(o.getStationCode())).findFirst().get().getDiff());
list.add(diff); list.add(diff);
ExcelUtil.exportExcel(headList,tableData(list),2,new int[]{0},profileName+"断面年度渗压统计",response,"年度渗压统计"); ExcelUtil.exportExcel(headList,tableData(list),2,new int[]{0},fileName,response,sheetName);
} }
private List<List> tableData( List<Map<String, Object>> list){ private List<List> tableData( List<Map<String, Object>> list){