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

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

@@ -42,6 +42,7 @@ import com.njcn.gather.storage.pojo.po.SimAndDigHarmonicResult;
import com.njcn.gather.storage.pojo.po.SimAndDigNonHarmonicResult;
import com.njcn.gather.storage.service.DetectionDataDealService;
import com.njcn.gather.storage.service.SimAndDigHarmonicService;
import com.njcn.gather.storage.service.TableGenService;
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.service.IDictDataService;
@@ -82,6 +83,7 @@ public class SocketDevResponseService {
private final IDictDataService dictDataService;
private final IPqSourceService pqSourceService;
private final IResultService resultService;
private final TableGenService tableGenService;
@Value("${dataCheck.enable}")
private Boolean dataCheck;
@@ -1178,6 +1180,7 @@ public class SocketDevResponseService {
sourceIssues = groupedIssues.values().stream().flatMap(List::stream).collect(Collectors.toList());
if (!param.isResumeFormal() && CollUtil.isNotEmpty(sourceIssues)) {
iPqDevService.clearFormalProgressForNewRun(param.getDevIds());
tableGenService.clearAdData(param.getCode());
}
SocketManager.addSourceList(sourceIssues);
Map<String, Long> sourceIssueMap = sourceIssues.stream()

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();