fix: 优化逻辑
This commit is contained in:
parent
83a18a31a1
commit
817c3ba49d
@ -75,16 +75,16 @@ public class JobRunner implements ApplicationRunner {
|
|||||||
ao.setStartTime(DateUtil.beginOfYear(DateUtil.offset(ao.getEndTime(), DateField.YEAR,-1)));
|
ao.setStartTime(DateUtil.beginOfYear(DateUtil.offset(ao.getEndTime(), DateField.YEAR,-1)));
|
||||||
}
|
}
|
||||||
envWqDataService.wqLastData(ao);
|
envWqDataService.wqLastData(ao);
|
||||||
log.info("--------------------wq最新一条数据---------------------");
|
// log.info("--------------------wq最新一条数据---------------------");
|
||||||
eqJobService.eqAnchorPointLastDate(ao);
|
// eqJobService.eqAnchorPointLastDate(ao);
|
||||||
log.info("--------------------eq最新一条数据---------------------");
|
// log.info("--------------------eq最新一条数据---------------------");
|
||||||
eqJobService.eqAnchorPointLastDate(ao);
|
// eqJobService.eqAnchorPointLastDate(ao);
|
||||||
log.info("--------------------eq最新一条数据---------------------");
|
// log.info("--------------------eq最新一条数据---------------------");
|
||||||
dwJobService.wtLastData(ao);
|
// dwJobService.wtLastData(ao);
|
||||||
log.info("--------------------wt最新一条数据---------------------");
|
// log.info("--------------------wt最新一条数据---------------------");
|
||||||
dwJobService.wtvtPointData(ao);
|
// dwJobService.wtvtPointData(ao);
|
||||||
log.info("--------------------wt最新一条数据---------------------");
|
// log.info("--------------------wt最新一条数据---------------------");
|
||||||
fhJobService.zqLastData(ao);
|
// fhJobService.zqLastData(ao);
|
||||||
log.info("--------------------fh最新一条数据---------------------");
|
// log.info("--------------------fh最新一条数据---------------------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import com.yfd.platform.utils.ExportZipUtil;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -362,8 +363,26 @@ public class QgcExportServiceImpl implements IQgcExportService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rstcdToStcd.isEmpty()) {
|
if (rstcdToStcd.isEmpty()) {
|
||||||
log.warn("指标 {} 未找到 STTP={} 的测站数据", processor.getFieldName(), sttp);
|
// 无对应测站时仍生成 Sheet,仅保留日期列(无电站列),避免整表缺失
|
||||||
return null;
|
log.warn("指标 {} 未找到 STTP={} 的测站数据,生成空 Sheet(仅日期列)", processor.getFieldName(), sttp);
|
||||||
|
List<List<Object>> emptyRows = new ArrayList<>();
|
||||||
|
int daysInMonth = getDaysInMonth(mr);
|
||||||
|
for (int d = 1; d <= daysInMonth; d++) {
|
||||||
|
List<Object> row = new ArrayList<>();
|
||||||
|
row.add(String.format("%02d", d));
|
||||||
|
emptyRows.add(row);
|
||||||
|
}
|
||||||
|
List<String> emptyLabels = processor.isVariation()
|
||||||
|
? VARIATION_LABELS
|
||||||
|
: (processor.hasComplianceRate()
|
||||||
|
? List.of("日均最低", "日均最高", "月内最低", "月内最低时间", "月内最高", "月内最高时间", "月均", LABEL_COMPLIANCE)
|
||||||
|
: BASE_LABELS);
|
||||||
|
for (String label : emptyLabels) {
|
||||||
|
List<Object> row = new ArrayList<>();
|
||||||
|
row.add(label);
|
||||||
|
emptyRows.add(row);
|
||||||
|
}
|
||||||
|
return emptyRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> uniqueStcds = rstcdToStcd.values().stream().distinct().toList();
|
List<String> uniqueStcds = rstcdToStcd.values().stream().distinct().toList();
|
||||||
@ -466,8 +485,16 @@ public class QgcExportServiceImpl implements IQgcExportService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rstcdToStcd.isEmpty()) {
|
if (rstcdToStcd.isEmpty()) {
|
||||||
log.warn("生态流量未找到 STTP=ENG 的测站数据");
|
// 未找到电站时仍生成 Sheet,仅保留子标题行(无电站数据行)
|
||||||
return null;
|
log.warn("生态流量未找到 STTP=ENG 的测站数据,生成空 Sheet");
|
||||||
|
List<String> subHeaders = Arrays.asList("电站名称", "所属水电基地", "生态流量限值", "日达标率", "小时达标率", "备注");
|
||||||
|
List<Object> subRow = new ArrayList<>();
|
||||||
|
subRow.addAll(subHeaders);
|
||||||
|
subRow.addAll(subHeaders);
|
||||||
|
subRow.addAll(subHeaders);
|
||||||
|
List<List<Object>> rows = new ArrayList<>();
|
||||||
|
rows.add(subRow);
|
||||||
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> uniqueStcds = rstcdToStcd.values().stream().distinct().toList();
|
List<String> uniqueStcds = rstcdToStcd.values().stream().distinct().toList();
|
||||||
@ -773,8 +800,20 @@ public class QgcExportServiceImpl implements IQgcExportService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rstcdToStcd.isEmpty()) {
|
if (rstcdToStcd.isEmpty()) {
|
||||||
log.warn("水质达标率未找到 STTP=WQ 的测站数据");
|
// 未找到测站时仍生成 Sheet,仅保留子标题行(无电站数据行)
|
||||||
return null;
|
log.warn("水质达标率未找到 STTP=WQ 的测站数据,生成空 Sheet");
|
||||||
|
List<Object> subRow = new ArrayList<>();
|
||||||
|
subRow.add("");
|
||||||
|
subRow.add("达标数");
|
||||||
|
subRow.add("总数");
|
||||||
|
subRow.add("达标率(%)");
|
||||||
|
subRow.add("达标数");
|
||||||
|
subRow.add("总数");
|
||||||
|
subRow.add("达标率(%)");
|
||||||
|
subRow.add("");
|
||||||
|
List<List<Object>> rows = new ArrayList<>();
|
||||||
|
rows.add(subRow);
|
||||||
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> uniqueStcds = rstcdToStcd.values().stream().distinct().toList();
|
List<String> uniqueStcds = rstcdToStcd.values().stream().distinct().toList();
|
||||||
@ -1007,13 +1046,13 @@ public class QgcExportServiceImpl implements IQgcExportService {
|
|||||||
private StationResolution resolveStations(List<String> rstcds, Set<String> sttpTypes) {
|
private StationResolution resolveStations(List<String> rstcds, Set<String> sttpTypes) {
|
||||||
StationResolution result = new StationResolution();
|
StationResolution result = new StationResolution();
|
||||||
if (rstcds == null || rstcds.isEmpty()) return result;
|
if (rstcds == null || rstcds.isEmpty()) return result;
|
||||||
|
LambdaQueryWrapper<StationMapping> wrapper = new LambdaQueryWrapper<>();
|
||||||
List<StationMapping> mappings = stationMappingMapper.selectList(
|
wrapper.and(w -> {
|
||||||
new LambdaQueryWrapper<StationMapping>()
|
if (CollectionUtils.isNotEmpty(rstcds)) {
|
||||||
.in(StationMapping::getRstcd, rstcds)
|
w.in(StationMapping::getRstcd, rstcds).or().in(StationMapping::getStcd, rstcds);
|
||||||
.or()
|
}
|
||||||
.in(StationMapping::getStcd, rstcds)
|
});
|
||||||
);
|
List<StationMapping> mappings = stationMappingMapper.selectList(wrapper);
|
||||||
|
|
||||||
// 添加逻辑:如果 sttp 是 "ENG",则 rstcd 赋值为 stcd
|
// 添加逻辑:如果 sttp 是 "ENG",则 rstcd 赋值为 stcd
|
||||||
mappings.forEach(mapping -> {
|
mappings.forEach(mapping -> {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user