chore(瘦身): 摘 13 处零引用私有方法(160 行)与 mapstruct 死依赖
判死的尺子比「生产没调用」更严:private + 无注解 + 非 get/set/is 形态 + 名字在本文件只出现 1 次 + 在全仓 2,074 个跟踪文件(含 tests、mapper XML、两个前端 src)里也只出现 1 次。 tests 里有 57 处 getDeclaredMethod,反射是按名字取方法的,只看调用图会误杀。 同族审计给的是 40 支/450 行,差额那些名字会出现在别处的字符串或日志里,按这个口径不可证死, 所以只搬能证死的 13 处:AppearancePatentTaskService 37、DeleteBrandRunService 31、 QueryAsinTaskService 27、ZiniaoClientImpl 21、PublishWorkbookService 16、 ShopDataCrawlTaskService 9、PatrolDeleteTaskService 9、DedupeTotalDataService 6、 ShopMatchTaskService 4。 mapstruct 判死锚的是包名而不是注解名:本仓的 @Mapper 是 MyBatis-Plus 的 org.apache.ibatis.annotations.Mapper,按注解名判会误杀。依据是 import org.mapstruct 在 main+test 双口径 0,且 target 里没有 *MapperImpl*、generated-sources 0 文件。 验证走独立工作树(与主树同 HEAD 69d2ebb0):改前 mvn -o -q -DskipTests test-compile 出 MVN_RC=0,改后同命令再 0,才按字节搬回;搬回后 git diff --numstat 全是 0 加 / N 删。 主树这些路径在搬之前 0 脏、HEAD 与校验树同点,两条都设了断言。
This commit is contained in:
@@ -19,7 +19,6 @@
|
|||||||
<java.version>21</java.version>
|
<java.version>21</java.version>
|
||||||
<knife4j.version>4.5.0</knife4j.version>
|
<knife4j.version>4.5.0</knife4j.version>
|
||||||
<mybatis-plus.version>3.5.7</mybatis-plus.version>
|
<mybatis-plus.version>3.5.7</mybatis-plus.version>
|
||||||
<mapstruct.version>1.5.5.Final</mapstruct.version>
|
|
||||||
<easyexcel.version>4.0.3</easyexcel.version>
|
<easyexcel.version>4.0.3</easyexcel.version>
|
||||||
<hutool.version>5.8.36</hutool.version>
|
<hutool.version>5.8.36</hutool.version>
|
||||||
<rocketmq-spring.version>2.3.5</rocketmq-spring.version>
|
<rocketmq-spring.version>2.3.5</rocketmq-spring.version>
|
||||||
@@ -135,11 +134,6 @@
|
|||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.mapstruct</groupId>
|
|
||||||
<artifactId>mapstruct</artifactId>
|
|
||||||
<version>${mapstruct.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
@@ -177,11 +171,6 @@
|
|||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.18.36</version>
|
<version>1.18.36</version>
|
||||||
</path>
|
</path>
|
||||||
<path>
|
|
||||||
<groupId>org.mapstruct</groupId>
|
|
||||||
<artifactId>mapstruct-processor</artifactId>
|
|
||||||
<version>${mapstruct.version}</version>
|
|
||||||
</path>
|
|
||||||
</annotationProcessorPaths>
|
</annotationProcessorPaths>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|||||||
-37
@@ -2561,11 +2561,6 @@ public class AppearancePatentTaskService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, AppearancePatentResultRowDto> loadPersistedResultRowsForResultRows(
|
|
||||||
Long taskId, List<AppearancePatentResultRowDto> requestedRows) {
|
|
||||||
Set<String> requestedKeys = resultLookupKeysForResultRows(requestedRows);
|
|
||||||
return loadPersistedResultRowsForKeys(taskId, requestedKeys);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, AppearancePatentResultRowDto> loadPersistedResultRowsForKeys(
|
private Map<String, AppearancePatentResultRowDto> loadPersistedResultRowsForKeys(
|
||||||
Long taskId, Set<String> requestedKeys) {
|
Long taskId, Set<String> requestedKeys) {
|
||||||
@@ -2651,15 +2646,6 @@ public class AppearancePatentTaskService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private AppearancePatentResultRowDto findPersistedResultRow(
|
|
||||||
AppearancePatentResultRowDto row,
|
|
||||||
Map<String, AppearancePatentResultRowDto> resultMap) {
|
|
||||||
if (row == null || resultMap == null || resultMap.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
AppearancePatentResultRowDto result = resultMap.get(rowKey(row));
|
|
||||||
return result == null ? resultMap.get(legacyRowKey(row)) : result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sleepBeforeResultRowsRetry(int attempt) {
|
private void sleepBeforeResultRowsRetry(int attempt) {
|
||||||
try {
|
try {
|
||||||
@@ -2683,25 +2669,6 @@ public class AppearancePatentTaskService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private AppearancePatentResultRowDto findResultRowByAsin(String asin, Map<String, AppearancePatentResultRowDto> resultMap) {
|
|
||||||
String normalizedAsin = normalize(asin).toUpperCase(Locale.ROOT);
|
|
||||||
if (normalizedAsin.isBlank() || resultMap == null || resultMap.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
AppearancePatentResultRowDto fallback = null;
|
|
||||||
for (AppearancePatentResultRowDto row : resultMap.values()) {
|
|
||||||
if (row == null || !normalizedAsin.equals(normalize(row.getAsin()).toUpperCase(Locale.ROOT))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (hasResolvedLlmFields(row) || hasReasonFields(row)) {
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
if (fallback == null) {
|
|
||||||
fallback = row;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasReasonFields(AppearancePatentResultRowDto row) {
|
private boolean hasReasonFields(AppearancePatentResultRowDto row) {
|
||||||
if (row == null) {
|
if (row == null) {
|
||||||
@@ -3124,10 +3091,6 @@ public class AppearancePatentTaskService {
|
|||||||
return transientPayloadStorageService.storeChunkPayloadVersioned(MODULE_TYPE, taskId, scopeHash, chunkIndex, payloadJson);
|
return transientPayloadStorageService.storeChunkPayloadVersioned(MODULE_TYPE, taskId, scopeHash, chunkIndex, payloadJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String storeSharedLlmBatchPayload(Long taskId, String scopeHash, String payloadJson) {
|
|
||||||
requireSharedTransientPayloadStorage("llm batch payload");
|
|
||||||
return transientPayloadStorageService.storeParsedPayloadFast(MODULE_TYPE, taskId, scopeHash, payloadJson, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void requireSharedTransientPayloadStorage(String payloadType) {
|
private void requireSharedTransientPayloadStorage(String payloadType) {
|
||||||
if (!transientPayloadStorageService.isSharedWriteEnabled()) {
|
if (!transientPayloadStorageService.isSharedWriteEnabled()) {
|
||||||
|
|||||||
-6
@@ -1201,12 +1201,6 @@ public class DedupeTotalDataService {
|
|||||||
return dedupeTotalDataMapper.selectOne(query) != null;
|
return dedupeTotalDataMapper.selectOne(query) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int deleteByDataValue(String dataValue, AccessScope scope, Long groupId) {
|
|
||||||
LambdaQueryWrapper<DedupeTotalDataEntity> query = new LambdaQueryWrapper<DedupeTotalDataEntity>()
|
|
||||||
.eq(DedupeTotalDataEntity::getDataValue, dataValue);
|
|
||||||
applyGroupScope(query, scope, groupId);
|
|
||||||
return dedupeTotalDataMapper.delete(query);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 批量删除大小:单事务 IN 删除的阈值,兼顾锁窗口与事务日志。 */
|
/** 批量删除大小:单事务 IN 删除的阈值,兼顾锁窗口与事务日志。 */
|
||||||
private static final int DELETE_BATCH_SIZE = 500;
|
private static final int DELETE_BATCH_SIZE = 500;
|
||||||
|
|||||||
-31
@@ -2094,37 +2094,6 @@ public class DeleteBrandRunService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private File buildResultWorkbook(Long taskId,
|
|
||||||
DeleteBrandParsedFileCacheDto parsedFile,
|
|
||||||
MergedDeleteBrandFile mergedFile) {
|
|
||||||
File outputDir = FileUtil.mkdir(FileUtil.file(System.getProperty("java.io.tmpdir"), "delete-brand-result", String.valueOf(taskId)));
|
|
||||||
File outputFile = buildNamedOutputFile(outputDir, blankToDefault(parsedFile.getSourceFilename(), "delete-brand-result.xlsx"));
|
|
||||||
|
|
||||||
try (SXSSFWorkbook workbook = new SXSSFWorkbook(200);
|
|
||||||
FileOutputStream outputStream = new FileOutputStream(outputFile)) {
|
|
||||||
workbook.setCompressTempFiles(true);
|
|
||||||
Sheet sheet = workbook.createSheet("删除品牌结果");
|
|
||||||
Row headerRow = sheet.createRow(0);
|
|
||||||
headerRow.createCell(0).setCellValue("国家");
|
|
||||||
headerRow.createCell(1).setCellValue("删除ASIN");
|
|
||||||
headerRow.createCell(2).setCellValue("状态");
|
|
||||||
|
|
||||||
int rowIndex = 1;
|
|
||||||
for (DeleteBrandProcessedCountryDto country : mergedFile.countries()) {
|
|
||||||
for (DeleteBrandCountryResultItemDto item : country.getItems()) {
|
|
||||||
Row row = sheet.createRow(rowIndex++);
|
|
||||||
createTextCell(row, 0, country.getCountry());
|
|
||||||
createTextCell(row, 1, item.getAsin());
|
|
||||||
createTextCell(row, 2, item.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
applyDeleteBrandColumnWidths(sheet, 3);
|
|
||||||
workbook.write(outputStream);
|
|
||||||
return outputFile;
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw new BusinessException("生成删除品牌结果文件失败: " + parsedFile.getSourceFilename());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private File buildResultWorkbookPreserveLayout(Long taskId,
|
private File buildResultWorkbookPreserveLayout(Long taskId,
|
||||||
DeleteBrandParsedFileCacheDto parsedFile,
|
DeleteBrandParsedFileCacheDto parsedFile,
|
||||||
|
|||||||
-9
@@ -521,11 +521,6 @@ public class PatrolDeleteTaskService {
|
|||||||
taskCacheService.saveTaskCache(task);
|
taskCacheService.saveTaskCache(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanupTaskAuxiliaryData(Long taskId) {
|
|
||||||
taskResultItemService.deleteTaskItems(taskId, MODULE_TYPE);
|
|
||||||
taskProgressSnapshotService.delete(taskId, MODULE_TYPE);
|
|
||||||
taskFileJobService.deleteTaskJobs(taskId, MODULE_TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cleanupTaskAuxiliaryDataFast(Long taskId) {
|
private void cleanupTaskAuxiliaryDataFast(Long taskId) {
|
||||||
taskResultItemService.deleteTaskItemsRowsOnly(taskId, MODULE_TYPE);
|
taskResultItemService.deleteTaskItemsRowsOnly(taskId, MODULE_TYPE);
|
||||||
@@ -534,10 +529,6 @@ public class PatrolDeleteTaskService {
|
|||||||
taskFileJobService.deleteTaskJobs(taskId, MODULE_TYPE);
|
taskFileJobService.deleteTaskJobs(taskId, MODULE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanupResultAuxiliaryData(Long taskId, Long resultId) {
|
|
||||||
taskResultItemService.deleteResultItem(taskId, MODULE_TYPE, resultId);
|
|
||||||
taskFileJobService.deleteResultJobs(taskId, MODULE_TYPE, resultId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cleanupResultAuxiliaryDataFast(Long taskId, Long resultId) {
|
private void cleanupResultAuxiliaryDataFast(Long taskId, Long resultId) {
|
||||||
taskResultItemService.deleteResultItemRowsOnly(taskId, MODULE_TYPE, resultId);
|
taskResultItemService.deleteResultItemRowsOnly(taskId, MODULE_TYPE, resultId);
|
||||||
|
|||||||
-16
@@ -175,22 +175,6 @@ public class PublishWorkbookService {
|
|||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, List<PublishRowDto>> groupByCountry(List<PublishRowDto> rows) {
|
|
||||||
Map<String, List<PublishRowDto>> grouped = new LinkedHashMap<>();
|
|
||||||
if (rows != null) {
|
|
||||||
for (PublishRowDto row : rows) {
|
|
||||||
if (row == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String country = countrySheetName(row.getCountry());
|
|
||||||
grouped.computeIfAbsent(country, ignored -> new ArrayList<>()).add(row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (grouped.isEmpty()) {
|
|
||||||
grouped.put("空数据", List.of());
|
|
||||||
}
|
|
||||||
return grouped;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeSheet(Sheet sheet,
|
private void writeSheet(Sheet sheet,
|
||||||
List<PublishRowDto> rows,
|
List<PublishRowDto> rows,
|
||||||
|
|||||||
-27
@@ -880,33 +880,6 @@ public class QueryAsinTaskService {
|
|||||||
return new ArrayList<>(map.values());
|
return new ArrayList<>(map.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<QueryAsinCountryAsinsDto> mergeCountryAsins(List<QueryAsinCountryAsinsDto> base, List<QueryAsinCountryAsinsDto> incoming) {
|
|
||||||
Map<String, QueryAsinCountryAsinsDto> map = new LinkedHashMap<>();
|
|
||||||
for (QueryAsinCountryAsinsDto item : copyCountryAsins(base)) {
|
|
||||||
map.put(item.getCountry(), item);
|
|
||||||
}
|
|
||||||
for (QueryAsinCountryAsinsDto item : copyCountryAsins(incoming)) {
|
|
||||||
String country = normalizeCountry(item.getCountry());
|
|
||||||
if (blank(country)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
item.setCountry(country);
|
|
||||||
QueryAsinCountryAsinsDto existing = map.get(country);
|
|
||||||
if (existing == null) {
|
|
||||||
map.put(country, item);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
List<String> merged = new ArrayList<>(existing.getAsins() == null ? List.of() : existing.getAsins());
|
|
||||||
for (String asin : item.getAsins() == null ? List.<String>of() : item.getAsins()) {
|
|
||||||
String normalized = normalizeAsin(asin);
|
|
||||||
if (!normalized.isEmpty() && !merged.contains(normalized)) {
|
|
||||||
merged.add(normalized);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
existing.setAsins(merged);
|
|
||||||
}
|
|
||||||
return new ArrayList<>(map.values());
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasAnyPayloadData(QueryAsinShopPayloadDto payload) {
|
private boolean hasAnyPayloadData(QueryAsinShopPayloadDto payload) {
|
||||||
if (payload == null) {
|
if (payload == null) {
|
||||||
|
|||||||
-9
@@ -2419,15 +2419,6 @@ public class ShopDataCrawlTaskService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean sameDailyFileState(ShopDataCrawlDailyFileEntity expected,
|
|
||||||
ShopDataCrawlDailyFileEntity actual) {
|
|
||||||
if (expected == null || actual == null) {
|
|
||||||
return expected == actual;
|
|
||||||
}
|
|
||||||
return Objects.equals(expected.getId(), actual.getId())
|
|
||||||
&& Objects.equals(expected.getVersion(), actual.getVersion())
|
|
||||||
&& Objects.equals(expected.getResultFileUrl(), actual.getResultFileUrl());
|
|
||||||
}
|
|
||||||
|
|
||||||
private ShopDataCrawlDailyFileEntity findExistingDailyMembership(Long resultId) {
|
private ShopDataCrawlDailyFileEntity findExistingDailyMembership(Long resultId) {
|
||||||
List<ShopDataCrawlDailyMemberEntity> members = dailyFileService.findMembersByResultId(resultId);
|
List<ShopDataCrawlDailyMemberEntity> members = dailyFileService.findMembersByResultId(resultId);
|
||||||
|
|||||||
-4
@@ -1241,10 +1241,6 @@ public class ShopMatchTaskService {
|
|||||||
return stages;
|
return stages;
|
||||||
}
|
}
|
||||||
|
|
||||||
private LocalDateTime loadScheduledAt(Long taskId) {
|
|
||||||
FileTaskEntity task = loadTaskForExecution(taskId);
|
|
||||||
return task == null ? null : task.getScheduledAt();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void mergeQueueFieldsFromRequest(ProductRiskResultItemVo vo, Long taskId) {
|
private void mergeQueueFieldsFromRequest(ProductRiskResultItemVo vo, Long taskId) {
|
||||||
FileTaskEntity task = loadTaskForExecution(taskId);
|
FileTaskEntity task = loadTaskForExecution(taskId);
|
||||||
|
|||||||
-21
@@ -210,27 +210,6 @@ public class ZiniaoClientImpl implements ZiniaoClient {
|
|||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String postWithAuthorization(String path, String authorization, Map<String, Object> body, String action) {
|
|
||||||
String token = requireText(authorization, "紫鸟授权 token 未配置");
|
|
||||||
RestClient.RequestBodySpec request = getRestClient().post()
|
|
||||||
.uri(joinUrl(ziniaoProperties.getBaseUrl(), path))
|
|
||||||
.headers(headers -> {
|
|
||||||
if (token.regionMatches(true, 0, "Bearer ", 0, 7)) {
|
|
||||||
headers.set("Authorization", token);
|
|
||||||
} else {
|
|
||||||
headers.setBearerAuth(token);
|
|
||||||
}
|
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
});
|
|
||||||
if (body != null) {
|
|
||||||
request.body(body);
|
|
||||||
}
|
|
||||||
String raw = request
|
|
||||||
.retrieve()
|
|
||||||
.body(String.class);
|
|
||||||
validateSuccess(raw, action, path);
|
|
||||||
return raw;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void applyAuthorization(org.springframework.http.HttpHeaders headers, String apiKey) {
|
private void applyAuthorization(org.springframework.http.HttpHeaders headers, String apiKey) {
|
||||||
String token = requireText(apiKey, "紫鸟 apiKey 未配置");
|
String token = requireText(apiKey, "紫鸟 apiKey 未配置");
|
||||||
|
|||||||
Reference in New Issue
Block a user