不续检时清空原始数据和结果数据

This commit is contained in:
caozehui
2026-07-22 09:12:44 +08:00
parent e84a2a0860
commit c1c2b94469
3 changed files with 26 additions and 0 deletions

View File

@@ -7,6 +7,8 @@ public interface TableGenService {
void genTable(String code, boolean isContrast);
void clearAdData(String code);
/**
* 批量删除表 (包括谐波表、谐波结果表、非谐波表、非谐波结果表)
*

View File

@@ -13,6 +13,13 @@ public class TableGenServiceImpl implements TableGenService {
private final TableGenMapper tableGenMapper;
private static final String[] AD_TABLE_PREFIXES = {
"ad_non_harmonic_result_",
"ad_harmonic_result_",
"ad_non_harmonic_",
"ad_harmonic_"
};
@Override
public void genTable(String code, boolean isContrast) {
@@ -94,6 +101,20 @@ public class TableGenServiceImpl implements TableGenService {
tableGenMapper.genAdHarmonicTable("CREATE INDEX idx_ad_harmonic_result_" + code + "_dev_monitor_id" + " ON ad_harmonic_result_" + code + " (Dev_Monitor_Id);");
}
@Override
public void clearAdData(String code) {
checkTableSuffix(code);
for (String prefix : AD_TABLE_PREFIXES) {
tableGenMapper.genAdHarmonicTable("DELETE FROM " + prefix + code);
}
}
private void checkTableSuffix(String code) {
if (code == null || !code.matches("[A-Za-z0-9_]+")) {
throw new IllegalArgumentException("Invalid table suffix: " + code);
}
}
@Override
public void deleteTable(List<String> codeList) {
StringBuilder sb = new StringBuilder();