年度位移统计导出
parent
8c70e5ef0e
commit
e79dd9ce45
|
|
@ -13,6 +13,7 @@ import com.gunshi.project.xyt.validate.markers.Update;
|
|||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -77,6 +78,10 @@ public class OsmoticShiftRController {
|
|||
return R.ok(service.yearStatValue(osmoticQuerySo));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "年度位移统计导出")
|
||||
@PostMapping( "/year/stat/export")
|
||||
public void yearStatExport(@RequestBody @Validated OsmoticQuerySo osmoticQuerySo, HttpServletResponse response) {
|
||||
service.yearStatExport(osmoticQuerySo,response);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -21,11 +21,12 @@ 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
|
||||
from public.osmotic_shift_r t
|
||||
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>
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ 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.OsmoticPressR;
|
||||
import com.gunshi.project.xyt.util.DataHandleUtil;
|
||||
import com.gunshi.project.xyt.util.DateUtil;
|
||||
import com.gunshi.project.xyt.util.ExcelUtil;
|
||||
import com.gunshi.project.xyt.util.MyBeanUtil;
|
||||
|
|
@ -230,7 +231,7 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
|
|||
for (String s : heads) {
|
||||
hs.add(Arrays.asList(s));
|
||||
}
|
||||
ExcelUtil.exportExcel(hs, tableData(list), "浸润线", response, "浸润线");
|
||||
ExcelUtil.exportExcel(hs, DataHandleUtil.tableData(list), "浸润线", response, "浸润线");
|
||||
}
|
||||
|
||||
private OsmoticQuerySo commonQueryHandle(OsmoticQuerySo osmoticQuerySo){
|
||||
|
|
@ -340,7 +341,7 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
|
|||
|
||||
Map<String, Object> min = new LinkedHashMap<>();
|
||||
min.put("t0","全年度特征值统计");
|
||||
min.put("t1", "最大值");
|
||||
min.put("t1", "最小值");
|
||||
for(int i = 0;i < stationCodes.size();i++){
|
||||
String code = stationCodes.get(i);
|
||||
min.put(code,chartList.stream().filter(o->code.equals(o.getStationCode())).findFirst().get().getMinValue());
|
||||
|
|
@ -371,22 +372,9 @@ public class OsmoticPressRService extends ServiceImpl<OsmoticPressRMapper, Osmot
|
|||
diff.put("t3", chartList.stream().filter(o->"drp".equals(o.getStationCode())).findFirst().get().getDiff());
|
||||
list.add(diff);
|
||||
|
||||
ExcelUtil.exportExcel(headList,tableData(list),2,new int[]{0},fileName,response,sheetName);
|
||||
ExcelUtil.exportExcel(headList, DataHandleUtil.tableData(list),2,new int[]{0},fileName,response,sheetName);
|
||||
}
|
||||
|
||||
private List<List> tableData( List<Map<String, Object>> list){
|
||||
List<List> list2 = new ArrayList<>();
|
||||
Collection values;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
values = list.get(i).values();
|
||||
List objects = new ArrayList<>();
|
||||
for (Object value : values) {
|
||||
objects.add(value == null ? "" : value.toString());
|
||||
}
|
||||
list2.add(objects);
|
||||
}
|
||||
return list2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,12 @@ 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.DataHandleUtil;
|
||||
import com.gunshi.project.xyt.util.DateUtil;
|
||||
import com.gunshi.project.xyt.util.ExcelUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -36,8 +38,9 @@ public class OsmoticShiftRService extends ServiceImpl<OsmoticShiftRMapper, Osmot
|
|||
@Resource
|
||||
private OsmoticShiftRMapper mapper;
|
||||
|
||||
@Resource
|
||||
private OsmoticShiftDeviceAutoDao shiftDeviceAutoDao;
|
||||
private static final String X_PREFIX = "/X";
|
||||
private static final String Y_PREFIX = "/Y";
|
||||
private static final String H_PREFIX = "/H";
|
||||
|
||||
public Page<OsmoticShiftR> queryPage(OsmoticQueryPageSo osmoticQueryPageSo) {
|
||||
LambdaQueryWrapper<OsmoticShiftR> wrapper = Wrappers.lambdaQuery();
|
||||
|
|
@ -96,7 +99,7 @@ public class OsmoticShiftRService extends ServiceImpl<OsmoticShiftRMapper, Osmot
|
|||
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.setStationCode(key + X_PREFIX);
|
||||
xVo.setMaxValue(xMax.getX());
|
||||
xVo.setMaxTm(xMax.getTm());
|
||||
xVo.setMinValue(xMin.getX());
|
||||
|
|
@ -107,7 +110,7 @@ public class OsmoticShiftRService extends ServiceImpl<OsmoticShiftRMapper, Osmot
|
|||
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.setStationCode(key + Y_PREFIX);
|
||||
yVo.setMaxValue(yMax.getY());
|
||||
yVo.setMaxTm(yMax.getTm());
|
||||
yVo.setMinValue(yMin.getY());
|
||||
|
|
@ -118,7 +121,7 @@ public class OsmoticShiftRService extends ServiceImpl<OsmoticShiftRMapper, Osmot
|
|||
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.setStationCode(key + H_PREFIX);
|
||||
hVo.setMaxValue(hMax.getH());
|
||||
hVo.setMaxTm(hMax.getTm());
|
||||
hVo.setMinValue(hMin.getH());
|
||||
|
|
@ -129,6 +132,118 @@ public class OsmoticShiftRService extends ServiceImpl<OsmoticShiftRMapper, Osmot
|
|||
});
|
||||
return resList;
|
||||
}
|
||||
|
||||
public void yearStatExport(OsmoticQuerySo osmoticQuerySo, HttpServletResponse response) {
|
||||
String fileName = "年度位移统计";
|
||||
String sheetName = "年度位移统计";
|
||||
|
||||
//上方表格数据
|
||||
List<OsmoticShiftVo> resList = yearStat(osmoticQuerySo);
|
||||
//下方特征值数据
|
||||
List<OsmoticChartVo> chartList = yearStatValue(osmoticQuerySo);
|
||||
List<String> stationCodes = osmoticQuerySo.getStationCodes();
|
||||
//表头信息
|
||||
List<List<String>> headList = new ArrayList<>();
|
||||
List<String> heads1 = new ArrayList<>();
|
||||
heads1.add("序号");
|
||||
heads1.add("序号");
|
||||
headList.add(heads1);
|
||||
|
||||
List<String> heads2 = new ArrayList<>();
|
||||
heads2.add("监测日期");
|
||||
heads2.add("监测日期");
|
||||
headList.add(heads2);
|
||||
|
||||
for(String code : stationCodes){
|
||||
List<String> headsX = new ArrayList<>();
|
||||
headsX.add(code);
|
||||
headsX.add("X");
|
||||
headList.add(headsX);
|
||||
|
||||
List<String> headsY = new ArrayList<>();
|
||||
headsY.add(code);
|
||||
headsY.add("Y");
|
||||
headList.add(headsY);
|
||||
|
||||
List<String> headsH = new ArrayList<>();
|
||||
headsH.add(code);
|
||||
headsH.add("H");
|
||||
headList.add(headsH);
|
||||
}
|
||||
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (int j = 0;j < resList.size(); j++) {
|
||||
OsmoticShiftVo vo = resList.get(j);
|
||||
Map<String, Object> test = new LinkedHashMap<>();
|
||||
test.put("t0",j+1);
|
||||
test.put("t1", vo.getTm());
|
||||
for(int i = 0;i < stationCodes.size();i++){
|
||||
String code = stationCodes.get(i);
|
||||
OsmoticShiftValueVo valueVo = vo.getList().stream().filter(o->code.equals(o.getStationCode())).findFirst().orElse(null);
|
||||
test.put(code + X_PREFIX,valueVo != null ? valueVo.getX() : "");
|
||||
test.put(code + Y_PREFIX,valueVo != null ? valueVo.getY() : "");
|
||||
test.put(code + H_PREFIX,valueVo != null ? valueVo.getH() : "");
|
||||
}
|
||||
list.add(test);
|
||||
}
|
||||
|
||||
Map<String, Object> max = new LinkedHashMap<>();
|
||||
max.put("t0","全年度特征值统计");
|
||||
max.put("t1", "最大值");
|
||||
for(int i = 0;i < stationCodes.size();i++){
|
||||
String code = stationCodes.get(i);
|
||||
max.put(code+X_PREFIX,chartList.stream().filter(o->(code+X_PREFIX).equals(o.getStationCode())).findFirst().get().getMaxValue());
|
||||
max.put(code+Y_PREFIX,chartList.stream().filter(o->(code+Y_PREFIX).equals(o.getStationCode())).findFirst().get().getMaxValue());
|
||||
max.put(code+H_PREFIX,chartList.stream().filter(o->(code+H_PREFIX).equals(o.getStationCode())).findFirst().get().getMaxValue());
|
||||
}
|
||||
list.add(max);
|
||||
|
||||
Map<String, Object> maxTm = new LinkedHashMap<>();
|
||||
maxTm.put("t0","全年度特征值统计");
|
||||
maxTm.put("t1", "日期");
|
||||
for(int i = 0;i < stationCodes.size();i++){
|
||||
String code = stationCodes.get(i);
|
||||
maxTm.put(code+X_PREFIX,chartList.stream().filter(o->(code+X_PREFIX).equals(o.getStationCode())).findFirst().get().getMaxTm());
|
||||
maxTm.put(code+Y_PREFIX,chartList.stream().filter(o->(code+Y_PREFIX).equals(o.getStationCode())).findFirst().get().getMaxTm());
|
||||
maxTm.put(code+H_PREFIX,chartList.stream().filter(o->(code+H_PREFIX).equals(o.getStationCode())).findFirst().get().getMaxTm());
|
||||
}
|
||||
list.add(maxTm);
|
||||
|
||||
Map<String, Object> min = new LinkedHashMap<>();
|
||||
min.put("t0","全年度特征值统计");
|
||||
min.put("t1", "最小值");
|
||||
for(int i = 0;i < stationCodes.size();i++){
|
||||
String code = stationCodes.get(i);
|
||||
min.put(code+X_PREFIX,chartList.stream().filter(o->(code+X_PREFIX).equals(o.getStationCode())).findFirst().get().getMinValue());
|
||||
min.put(code+Y_PREFIX,chartList.stream().filter(o->(code+Y_PREFIX).equals(o.getStationCode())).findFirst().get().getMinValue());
|
||||
min.put(code+H_PREFIX,chartList.stream().filter(o->(code+H_PREFIX).equals(o.getStationCode())).findFirst().get().getMinValue());
|
||||
}
|
||||
list.add(min);
|
||||
|
||||
Map<String, Object> minTm = new LinkedHashMap<>();
|
||||
minTm.put("t0","全年度特征值统计");
|
||||
minTm.put("t1", "日期");
|
||||
for(int i = 0;i < stationCodes.size();i++){
|
||||
String code = stationCodes.get(i);
|
||||
minTm.put(code+X_PREFIX,chartList.stream().filter(o->(code+X_PREFIX).equals(o.getStationCode())).findFirst().get().getMinTm());
|
||||
minTm.put(code+Y_PREFIX,chartList.stream().filter(o->(code+Y_PREFIX).equals(o.getStationCode())).findFirst().get().getMinTm());
|
||||
minTm.put(code+H_PREFIX,chartList.stream().filter(o->(code+H_PREFIX).equals(o.getStationCode())).findFirst().get().getMinTm());
|
||||
}
|
||||
list.add(minTm);
|
||||
|
||||
Map<String, Object> diff = new LinkedHashMap<>();
|
||||
diff.put("t0","全年度特征值统计");
|
||||
diff.put("t1", "年变幅");
|
||||
for(int i = 0;i < stationCodes.size();i++){
|
||||
String code = stationCodes.get(i);
|
||||
diff.put(code+X_PREFIX,chartList.stream().filter(o->(code+X_PREFIX).equals(o.getStationCode())).findFirst().get().getDiff());
|
||||
diff.put(code+Y_PREFIX,chartList.stream().filter(o->(code+Y_PREFIX).equals(o.getStationCode())).findFirst().get().getDiff());
|
||||
diff.put(code+H_PREFIX,chartList.stream().filter(o->(code+H_PREFIX).equals(o.getStationCode())).findFirst().get().getDiff());
|
||||
}
|
||||
list.add(diff);
|
||||
|
||||
ExcelUtil.exportExcel(headList, DataHandleUtil.tableData(list),2,new int[]{0},fileName,response,sheetName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.gunshi.project.xyt.util;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -33,5 +35,19 @@ public class DataHandleUtil {
|
|||
return lowerW.add(diff.multiply(upperW.subtract(lowerW)).divide(upperRz.subtract(lowerRz),2,RoundingMode.UP));
|
||||
}
|
||||
|
||||
public static List<List> tableData( List<Map<String, Object>> list){
|
||||
List<List> list2 = new ArrayList<>();
|
||||
Collection values;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
values = list.get(i).values();
|
||||
List objects = new ArrayList<>();
|
||||
for (Object value : values) {
|
||||
objects.add(value == null ? "" : value.toString());
|
||||
}
|
||||
list2.add(objects);
|
||||
}
|
||||
return list2;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue