去重导出列固定顺序为 id/ASIN/国家/价格/品牌;QueryAsin 按店铺加载数据并修正前端回退逻辑
This commit is contained in:
+33
-3
@@ -47,6 +47,7 @@ public class DedupeRunService {
|
||||
|
||||
private static final String HEADER_SPLIT_MARKER = "idASIN国家状态价格变体数量";
|
||||
private static final String HEADER_STOP_COLUMN = "缩略图地址8";
|
||||
private static final List<String> EXPORT_COLUMN_PRIORITY = List.of("id", "ASIN", "国家", "价格", "品牌");
|
||||
|
||||
private final FileTaskMapper fileTaskMapper;
|
||||
private final FileResultMapper fileResultMapper;
|
||||
@@ -254,6 +255,7 @@ public class DedupeRunService {
|
||||
private void cleanExcelByLegacyRules(File inputFile, File outputFile, List<String> selectedColumns,
|
||||
boolean keepIntegerIds, boolean keepUnderscoreIds,
|
||||
boolean keepIntegerMainIdsWhenNoSubIds) throws Exception {
|
||||
selectedColumns = reorderExportColumns(selectedColumns);
|
||||
long readStartNs = System.nanoTime();
|
||||
DedupeReadResult readResult = readDedupeRows(
|
||||
inputFile,
|
||||
@@ -310,13 +312,14 @@ public class DedupeRunService {
|
||||
}
|
||||
long writeNs = elapsedNs(writeStartNs);
|
||||
log.info(
|
||||
"dedupe clean stages file={} scannedRows={} keptRows={} uniqueAsins={} matchedAsins={} outputRows={} readFilterMs={} dbMs={} writeMs={} totalCleanMs={}",
|
||||
"dedupe clean stages file={} scannedRows={} keptRows={} uniqueAsins={} matchedAsins={} outputRows={} filteredFbaRows={} readFilterMs={} dbMs={} writeMs={} totalCleanMs={}",
|
||||
inputFile.getName(),
|
||||
readResult.scannedRows(),
|
||||
readResult.rows().size(),
|
||||
candidateAsinValues.size(),
|
||||
matchedAsinValues.size(),
|
||||
outputRows,
|
||||
readResult.filteredFbaRows(),
|
||||
toMs(readNs),
|
||||
toMs(dbNs),
|
||||
toMs(writeNs),
|
||||
@@ -324,6 +327,24 @@ public class DedupeRunService {
|
||||
);
|
||||
}
|
||||
|
||||
private List<String> reorderExportColumns(List<String> selectedColumns) {
|
||||
if (selectedColumns == null || selectedColumns.isEmpty()) {
|
||||
return selectedColumns;
|
||||
}
|
||||
List<String> ordered = new ArrayList<>(selectedColumns.size() + EXPORT_COLUMN_PRIORITY.size());
|
||||
for (String priority : EXPORT_COLUMN_PRIORITY) {
|
||||
if (selectedColumns.contains(priority)) {
|
||||
ordered.add(priority);
|
||||
}
|
||||
}
|
||||
for (String column : selectedColumns) {
|
||||
if (!ordered.contains(column)) {
|
||||
ordered.add(column);
|
||||
}
|
||||
}
|
||||
return ordered;
|
||||
}
|
||||
|
||||
private DedupeReadResult readDedupeRows(File inputFile, List<String> selectedColumns,
|
||||
boolean keepIntegerIds, boolean keepUnderscoreIds,
|
||||
boolean keepIntegerMainIdsWhenNoSubIds) throws Exception {
|
||||
@@ -356,14 +377,23 @@ public class DedupeRunService {
|
||||
}
|
||||
Integer idColumnIndex = headerMap.get("id");
|
||||
Integer asinColumnIndex = headerMap.get("ASIN");
|
||||
Integer shippingTypeColumnIndex = headerMap.get("发货类型");
|
||||
|
||||
int scannedRows = 0;
|
||||
int filteredFbaRows = 0;
|
||||
for (int rowNum = 1; rowNum <= sheet.getLastRowNum(); rowNum++) {
|
||||
Row row = sheet.getRow(rowNum);
|
||||
if (row == null) {
|
||||
continue;
|
||||
}
|
||||
scannedRows++;
|
||||
if (shippingTypeColumnIndex != null) {
|
||||
String shippingType = normalizeCellText(formatter.formatCellValue(row.getCell(shippingTypeColumnIndex)));
|
||||
if ("FBA".equalsIgnoreCase(shippingType)) {
|
||||
filteredFbaRows++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (idColumnIndex == null) {
|
||||
rows.add(buildCandidateRow(row, selectedIndexes, asinColumnIndex, formatter));
|
||||
continue;
|
||||
@@ -383,7 +413,7 @@ public class DedupeRunService {
|
||||
}
|
||||
|
||||
pendingMainIdGroup.flush(rows);
|
||||
return new DedupeReadResult(sheet.getSheetName(), rows, scannedRows);
|
||||
return new DedupeReadResult(sheet.getSheetName(), rows, scannedRows, filteredFbaRows);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -641,7 +671,7 @@ public class DedupeRunService {
|
||||
return nanos / 1_000_000L;
|
||||
}
|
||||
|
||||
private record DedupeReadResult(String sheetName, List<DedupeCandidateRow> rows, int scannedRows) {
|
||||
private record DedupeReadResult(String sheetName, List<DedupeCandidateRow> rows, int scannedRows, int filteredFbaRows) {
|
||||
}
|
||||
|
||||
private record DedupeCandidateRow(List<String> selectedValues, String asinValue) {
|
||||
|
||||
Reference in New Issue
Block a user