fix: 优化综合导出限值和备注返回
This commit is contained in:
parent
73ae21a62b
commit
94fde50aad
@ -71,7 +71,7 @@ public class SecurityConfig {
|
||||
// .requestMatchers("/system/**").permitAll()
|
||||
.requestMatchers("/qgcExport/**").permitAll()
|
||||
// .requestMatchers("/eng/**").permitAll()
|
||||
// .requestMatchers("/eq/**").permitAll()
|
||||
.requestMatchers("/eq/**").permitAll()
|
||||
// .requestMatchers("/env/**").permitAll()
|
||||
// .requestMatchers("/warn/**").permitAll()
|
||||
// .requestMatchers("/threedroamb/**").permitAll()
|
||||
|
||||
@ -24,6 +24,7 @@ import com.yfd.platform.qgc_eng.eq.entity.vo.StcdInfoVo;
|
||||
import com.yfd.platform.qgc_eng.eq.entity.vo.WbsbVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface EngEqDataService {
|
||||
|
||||
@ -53,6 +54,26 @@ public interface EngEqDataService {
|
||||
|
||||
EngEqRuleVo getEngLimit(DataSourceRequest dataSourceRequest);
|
||||
|
||||
/**
|
||||
* 根据测站编码和时间范围查询生态流量限值及来源
|
||||
*
|
||||
* @param stcd 测站编码
|
||||
* @param startTime 开始时间 yyyy-MM-dd HH:mm:ss
|
||||
* @param endTime 结束时间 yyyy-MM-dd HH:mm:ss
|
||||
* @return 生态流量限值信息(含环保部/水利部限值及来源、多年平均流量及来源)
|
||||
*/
|
||||
EngEqRuleVo getEngLimitByTime(String stcd, String startTime, String endTime);
|
||||
|
||||
/**
|
||||
* 批量查询生态流量限值及来源
|
||||
*
|
||||
* @param stcdList 测站编码列表
|
||||
* @param startTime 开始时间 yyyy-MM-dd HH:mm:ss
|
||||
* @param endTime 结束时间 yyyy-MM-dd HH:mm:ss
|
||||
* @return STCD → 生态流量限值信息
|
||||
*/
|
||||
Map<String, EngEqRuleVo> getEngLimitByTimeBatch(List<String> stcdList, String startTime, String endTime);
|
||||
|
||||
QgcQecStaticVo getQgcStaticData(DataSourceRequest dataSourceRequest, String type);
|
||||
|
||||
DataSourceResult<WbsbVo> getWbsbList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
@ -47,9 +47,11 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
@ -57,6 +59,7 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class EngEqDataServiceImpl implements EngEqDataService {
|
||||
@ -978,6 +981,143 @@ public class EngEqDataServiceImpl implements EngEqDataService {
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EngEqRuleVo getEngLimitByTime(String stcd, String startTime, String endTime) {
|
||||
EngEqRuleVo vo = new EngEqRuleVo().setStcd(stcd);
|
||||
|
||||
// 1. 查询电站信息(多年平均流量)
|
||||
Map<String, Object> stationParamMap = new HashMap<>();
|
||||
stationParamMap.put("stcd", stcd);
|
||||
List<Map<String, Object>> stationList = microservicDynamicSQLMapper.pageAllList(
|
||||
null,
|
||||
"SELECT STCD, ENNM AS STNM, AVQ, AVQ_SRC FROM SD_ENGINFO_B_H " +
|
||||
"WHERE STCD = #{map.stcd} AND NVL(IS_DELETED, 0) = 0",
|
||||
stationParamMap
|
||||
);
|
||||
if (CollUtil.isNotEmpty(stationList)) {
|
||||
Map<String, Object> station = stationList.get(0);
|
||||
vo.setStnm(asString(station.get("STNM")));
|
||||
BigDecimal avq = toBigDecimal(station.get("AVQ"));
|
||||
if (avq != null) {
|
||||
vo.setAvqStr(stripTrailingZeros(avq));
|
||||
}
|
||||
String avqSrc = asString(station.get("AVQ_SRC"));
|
||||
if (StrUtil.isNotBlank(avqSrc)) {
|
||||
vo.setAvqVlsr(avqSrc);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 查询环保部限值规则
|
||||
List<Map<String, Object>> eqmnList = queryEngLimitRuleDetails(stcd, startTime, endTime, "EQMN");
|
||||
vo.setEqmnStr(buildEngLimitValue(eqmnList));
|
||||
vo.setVlsr(buildEngLimitVlsr(eqmnList));
|
||||
|
||||
// 3. 查询水利部限值规则
|
||||
List<Map<String, Object>> eqmnMwrList = queryEngLimitRuleDetails(stcd, startTime, endTime, "EQMNMWR");
|
||||
vo.setEqmnmwrStr(buildEngLimitValue(eqmnMwrList));
|
||||
vo.setMwrVlsr(buildEngLimitVlsr(eqmnMwrList));
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, EngEqRuleVo> getEngLimitByTimeBatch(List<String> stcdList, String startTime, String endTime) {
|
||||
Map<String, EngEqRuleVo> result = new LinkedHashMap<>();
|
||||
if (CollUtil.isEmpty(stcdList)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 把列表转为 ('A','B','C') 格式的字符串
|
||||
String stcdStr = stcdList.stream()
|
||||
.map(s -> "'" + s + "'") // 手动加单引号
|
||||
.collect(Collectors.joining(","));
|
||||
|
||||
String sql = "SELECT STCD, ENNM AS STNM, AVQ, AVQ_SRC FROM SD_ENGINFO_B_H " +
|
||||
"WHERE STCD IN (" + stcdStr + ") " +
|
||||
"AND NVL(IS_DELETED, 0) = 0";
|
||||
|
||||
// 此时 paramMap 甚至可以传空,因为值已经写死在 SQL 里了
|
||||
List<Map<String, Object>> stationList = microservicDynamicSQLMapper.pageAllList(null, sql, new HashMap<>());
|
||||
Map<String, Map<String, Object>> stationMap = new LinkedHashMap<>();
|
||||
if (CollUtil.isNotEmpty(stationList)) {
|
||||
for (Map<String, Object> row : stationList) {
|
||||
stationMap.put(asString(row.get("STCD")), row);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 逐个查询限值规则并组装结果
|
||||
for (String stcd : stcdList) {
|
||||
EngEqRuleVo vo = new EngEqRuleVo().setStcd(stcd);
|
||||
|
||||
Map<String, Object> station = stationMap.get(stcd);
|
||||
if (station != null) {
|
||||
vo.setStnm(asString(station.get("STNM")));
|
||||
BigDecimal avq = toBigDecimal(station.get("AVQ"));
|
||||
if (avq != null) {
|
||||
vo.setAvqStr(stripTrailingZeros(avq));
|
||||
}
|
||||
String avqSrc = asString(station.get("AVQ_SRC"));
|
||||
if (StrUtil.isNotBlank(avqSrc)) {
|
||||
vo.setAvqVlsr(avqSrc);
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, Object>> eqmnList = queryEngLimitRuleDetails(stcd, startTime, endTime, "EQMN");
|
||||
vo.setEqmnStr(buildEngLimitValue(eqmnList));
|
||||
vo.setVlsr(buildEngLimitVlsr(eqmnList));
|
||||
|
||||
List<Map<String, Object>> eqmnMwrList = queryEngLimitRuleDetails(stcd, startTime, endTime, "EQMNMWR");
|
||||
vo.setEqmnmwrStr(buildEngLimitValue(eqmnMwrList));
|
||||
vo.setMwrVlsr(buildEngLimitVlsr(eqmnMwrList));
|
||||
|
||||
result.put(stcd, vo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建生态流量限值展示(不含前缀,仅时间段和限值)
|
||||
*/
|
||||
private String buildEngLimitValue(List<Map<String, Object>> detailList) {
|
||||
if (CollUtil.isEmpty(detailList)) {
|
||||
return "无限值要求";
|
||||
}
|
||||
List<String> parts = new ArrayList<>();
|
||||
for (Map<String, Object> row : detailList) {
|
||||
String beginTime = asString(row.get("BEGIN_TIME"));
|
||||
String endTime = asString(row.get("END_TIME"));
|
||||
BigDecimal minVal = toBigDecimal(row.get("MIN_VAL"));
|
||||
if (StrUtil.length(beginTime) != 4 || StrUtil.length(endTime) != 4 || minVal == null) {
|
||||
continue;
|
||||
}
|
||||
parts.add(String.format("%s月%s日~%s月%s日限值为:%s",
|
||||
beginTime.substring(0, 2), beginTime.substring(2, 4),
|
||||
endTime.substring(0, 2), endTime.substring(2, 4),
|
||||
stripTrailingZeros(minVal)));
|
||||
}
|
||||
if (parts.isEmpty()) {
|
||||
return "无限值要求";
|
||||
}
|
||||
return String.join(";", parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取限值来源(VLSR),去重后用逗号拼接
|
||||
*/
|
||||
private String buildEngLimitVlsr(List<Map<String, Object>> detailList) {
|
||||
if (CollUtil.isEmpty(detailList)) {
|
||||
return "";
|
||||
}
|
||||
Set<String> vlsrSet = new LinkedHashSet<>();
|
||||
for (Map<String, Object> row : detailList) {
|
||||
String vlsr = asString(row.get("VLSR"));
|
||||
if (StrUtil.isNotBlank(vlsr)) {
|
||||
vlsrSet.add(vlsr);
|
||||
}
|
||||
}
|
||||
return vlsrSet.isEmpty() ? "" : String.join(",", vlsrSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceResult<String> getFidKendoListCust(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||
|
||||
@ -15,6 +15,8 @@ import com.yfd.platform.qgc_export.mapper.SdQecdaySMapper;
|
||||
import com.yfd.platform.qgc_export.mapper.StationMappingMapper;
|
||||
import com.yfd.platform.qgc_export.processor.*;
|
||||
import com.yfd.platform.qgc_export.service.IQgcExportService;
|
||||
import com.yfd.platform.qgc_eng.eq.entity.vo.EngEqRuleVo;
|
||||
import com.yfd.platform.qgc_eng.eq.service.EngEqDataService;
|
||||
import com.yfd.platform.utils.ExportZipUtil;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -137,6 +139,9 @@ public class QgcExportServiceImpl implements IQgcExportService {
|
||||
@Resource
|
||||
private QecProcessor qecProcessor;
|
||||
|
||||
@Resource
|
||||
private EngEqDataService engEqDataService;
|
||||
|
||||
private static final SimpleDateFormat SDF_TIME = new SimpleDateFormat("dd日 HH时");
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@ -418,34 +423,38 @@ public class QgcExportServiceImpl implements IQgcExportService {
|
||||
List<List<Object>> rows = new ArrayList<>();
|
||||
rows.add(subRow); // 子标题作为第一行
|
||||
|
||||
// 批量查询各测站的生态流量限值
|
||||
Map<String, EngEqRuleVo> limitMap = engEqDataService.getEngLimitByTimeBatch(uniqueStcds, startStr, endStr);
|
||||
|
||||
for (String rstcd : stationOrder) {
|
||||
String stcd = rstcdToStcd.get(rstcd);
|
||||
String displayName = stationRes.getDisplayName(rstcd, sttp);
|
||||
String baseName = stationRes.getBaseName(rstcd, sttp);
|
||||
ComplianceStats s = stcd != null ? statsByStcd.get(stcd) : null;
|
||||
EngEqRuleVo rule = stcd != null ? limitMap.get(stcd) : null;
|
||||
|
||||
List<Object> row = new ArrayList<>();
|
||||
// 环保部
|
||||
row.add(displayName != null ? displayName : rstcd);
|
||||
row.add(baseName);
|
||||
row.add(""); // 生态流量限值(暂空)
|
||||
row.add(rule != null && rule.getEqmnStr() != null ? rule.getEqmnStr() : "");
|
||||
row.add(s != null ? s.dailyHb : "");
|
||||
row.add(s != null ? s.hourlyHb : "");
|
||||
row.add(""); // 备注(暂空)
|
||||
row.add(rule != null && rule.getVlsr() != null ? rule.getVlsr() : "");
|
||||
// 水利部
|
||||
row.add(displayName != null ? displayName : rstcd);
|
||||
row.add(baseName);
|
||||
row.add("");
|
||||
row.add(rule != null && rule.getEqmnmwrStr() != null ? rule.getEqmnmwrStr() : "");
|
||||
row.add(s != null ? s.dailySl : "");
|
||||
row.add(s != null ? s.hourlySl : "");
|
||||
row.add("");
|
||||
row.add(rule != null && rule.getMwrVlsr() != null ? rule.getMwrVlsr() : "");
|
||||
// 多年平均
|
||||
row.add(displayName != null ? displayName : rstcd);
|
||||
row.add(baseName);
|
||||
row.add("");
|
||||
row.add(rule != null && rule.getAvqStr() != null ? rule.getAvqStr() : "");
|
||||
row.add(s != null ? s.dailyDn : "");
|
||||
row.add(s != null ? s.hourlyDn : "");
|
||||
row.add("");
|
||||
row.add(rule != null && rule.getAvqVlsr() != null ? rule.getAvqVlsr() : "");
|
||||
|
||||
rows.add(row);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user