提交更改
This commit is contained in:
+13
-5
@@ -1264,25 +1264,33 @@ public class SimilarAsinCozeClient {
|
||||
|
||||
private Object cozePrice(Object value) {
|
||||
if (value == null) {
|
||||
return "";
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
if (value instanceof BigDecimal decimal) {
|
||||
return decimal.stripTrailingZeros();
|
||||
return normalizeCozeDecimal(decimal);
|
||||
}
|
||||
if (value instanceof Number number) {
|
||||
return new BigDecimal(number.toString()).stripTrailingZeros();
|
||||
return normalizeCozeDecimal(new BigDecimal(number.toString()));
|
||||
}
|
||||
String text = safeText(String.valueOf(value));
|
||||
if (text.isBlank()) {
|
||||
return "";
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
try {
|
||||
return new BigDecimal(text).stripTrailingZeros();
|
||||
return normalizeCozeDecimal(new BigDecimal(text));
|
||||
} catch (NumberFormatException ex) {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
private BigDecimal normalizeCozeDecimal(BigDecimal value) {
|
||||
BigDecimal normalized = value.stripTrailingZeros();
|
||||
if (normalized.scale() < 0) {
|
||||
return normalized.setScale(0);
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
private boolean isBlankPrice(Object value) {
|
||||
return value == null || value instanceof String text && text.isBlank();
|
||||
}
|
||||
|
||||
+65
-14
@@ -606,13 +606,7 @@ public class SimilarAsinTaskService {
|
||||
}
|
||||
|
||||
public void submitResult(Long taskId, SimilarAsinSubmitResultRequest request) {
|
||||
TaskDistributedLockService.LockHandle lockHandle = acquireTaskLock(taskId, TASK_LOCK_WAIT_MILLIS);
|
||||
if (lockHandle == null) {
|
||||
throw new BusinessException(40902, "任务正在处理上一批结果,请稍后重试");
|
||||
}
|
||||
try (lockHandle) {
|
||||
submitResultLocked(taskId, request);
|
||||
}
|
||||
submitResultLocked(taskId, request);
|
||||
}
|
||||
|
||||
private void submitResultLocked(Long taskId, SimilarAsinSubmitResultRequest request) {
|
||||
@@ -4532,12 +4526,20 @@ public class SimilarAsinTaskService {
|
||||
row.createCell(col++).setCellValue(firstNonBlank(parsedRow.getCountry(), ""));
|
||||
row.createCell(col++).setCellValue(readValueByHeader(parsedRow, "卖家名称", "卖家名", "卖家", "店铺名称", "店铺名", "seller name", "seller_name", "seller-name", "sellername", "store name", "shop name"));
|
||||
row.createCell(col++).setCellValue(readValueByHeader(parsedRow, "品牌", "brand"));
|
||||
row.createCell(col++).setCellValue(resultRow == null ? "" : userFacingCozeCellValue(resultRow, resultRow.getIsStock()));
|
||||
row.createCell(col++).setCellValue(resultRow == null ? "" : userFacingCozeCellValue(resultRow, resultRow.getSimilarity()));
|
||||
row.createCell(col++).setCellValue(resultRow == null ? "" : userFacingCozeCellValue(resultRow, resultRow.getIsConform()));
|
||||
row.createCell(col++).setCellValue(resultRow == null ? "" : userFacingCozeCellValue(resultRow, resultRow.getReason()));
|
||||
row.createCell(col++).setCellValue(resultRow == null ? "" : userFacingCozeCellValue(resultRow, resultRow.getCategory()));
|
||||
row.createCell(col).setCellValue(resultRow == null ? "" : firstNonBlank(resultRow.getStatus(), ""));
|
||||
String isStock = resultRow == null ? "" : userFacingCozeCellValue(resultRow, resultRow.getIsStock());
|
||||
String similarity = resultRow == null ? "" : userFacingCozeCellValue(resultRow, resultRow.getSimilarity());
|
||||
String isConform = resultRow == null ? "" : userFacingCozeCellValue(resultRow, resultRow.getIsConform());
|
||||
String reason = resultRow == null ? "" : userFacingCozeCellValue(resultRow, resultRow.getReason());
|
||||
String category = resultRow == null ? "" : userFacingCozeCellValue(resultRow, resultRow.getCategory());
|
||||
String status = resultRow == null || isSilentOutputFailure(resultRow)
|
||||
? ""
|
||||
: resolveResultStatus(resultRow, isStock, similarity, isConform, reason, category);
|
||||
row.createCell(col++).setCellValue(isStock);
|
||||
row.createCell(col++).setCellValue(similarity);
|
||||
row.createCell(col++).setCellValue(isConform);
|
||||
row.createCell(col++).setCellValue(reason);
|
||||
row.createCell(col++).setCellValue(category);
|
||||
row.createCell(col).setCellValue(status);
|
||||
if (resultRow != null) {
|
||||
// 行高固定到 IMAGE_ROW_HEIGHT_POINTS(Excel 上限 409pt):
|
||||
row.setHeightInPoints(SimilarAsinImageEmbedder.IMAGE_ROW_HEIGHT_POINTS);
|
||||
@@ -4733,6 +4735,39 @@ public class SimilarAsinTaskService {
|
||||
|| hasUsableCozeField(row.getStatus());
|
||||
}
|
||||
|
||||
static String resolveResultStatus(SimilarAsinResultRowDto row, String... visibleResultValues) {
|
||||
if (row == null) {
|
||||
return "\u5931\u8d25";
|
||||
}
|
||||
if (hasText(row.getMainUrl()) || hasText(row.getPuzzleImg1()) || hasText(row.getPuzzleImg2())) {
|
||||
return "\u6210\u529f";
|
||||
}
|
||||
String rawStatus = row.getStatus() == null ? "" : row.getStatus().trim();
|
||||
if (!rawStatus.isBlank()) {
|
||||
return isFailedStatus(rawStatus) ? "\u5931\u8d25" : "\u6210\u529f";
|
||||
}
|
||||
if (visibleResultValues != null) {
|
||||
for (String value : visibleResultValues) {
|
||||
if (hasText(value)) {
|
||||
return "\u6210\u529f";
|
||||
}
|
||||
}
|
||||
}
|
||||
return hasText(row.getConclusion()) ? "\u6210\u529f" : "\u5931\u8d25";
|
||||
}
|
||||
|
||||
private static boolean isFailedStatus(String status) {
|
||||
String normalized = status == null ? "" : status.trim().toLowerCase(Locale.ROOT);
|
||||
return normalized.contains("fail")
|
||||
|| normalized.contains("error")
|
||||
|| normalized.contains("\u5931\u8d25")
|
||||
|| normalized.contains("\u9519\u8bef");
|
||||
}
|
||||
|
||||
private static boolean hasText(String value) {
|
||||
return value != null && !value.trim().isBlank();
|
||||
}
|
||||
|
||||
private boolean isExportableResultRow(SimilarAsinResultRowDto row) {
|
||||
if (row == null) {
|
||||
return false;
|
||||
@@ -4902,7 +4937,7 @@ public class SimilarAsinTaskService {
|
||||
.eq(FileTaskEntity::getUserId, userId)
|
||||
.eq(FileTaskEntity::getStatus, STATUS_RUNNING)
|
||||
.inSql(FileTaskEntity::getId,
|
||||
"select distinct task_id from file_result " +
|
||||
"select distinct task_id from biz_file_result " +
|
||||
"where module_type = '" + MODULE_TYPE + "' " +
|
||||
"and user_id = " + userId + " " +
|
||||
"and result_file_url is not null and result_file_url <> ''"));
|
||||
@@ -5665,6 +5700,9 @@ public class SimilarAsinTaskService {
|
||||
|
||||
private String userFacingCozeCellValue(SimilarAsinResultRowDto row, String value) {
|
||||
String normalizedValue = normalize(value);
|
||||
if (isSilentOutputFailure(row) || isSilentOutputFailure(normalizedValue)) {
|
||||
return "";
|
||||
}
|
||||
if (!normalizedValue.isBlank() && !isTechnicalCozeFailure(normalizedValue)) {
|
||||
return value;
|
||||
}
|
||||
@@ -5690,6 +5728,19 @@ public class SimilarAsinTaskService {
|
||||
return firstNonBlank(row.getConclusion(), "");
|
||||
}
|
||||
|
||||
private boolean isSilentOutputFailure(SimilarAsinResultRowDto row) {
|
||||
return row != null
|
||||
&& (isSilentOutputFailure(row.getError())
|
||||
|| isSilentOutputFailure(row.getReason())
|
||||
|| isSilentOutputFailure(row.getConclusion()));
|
||||
}
|
||||
|
||||
private boolean isSilentOutputFailure(String value) {
|
||||
String normalized = normalize(value).toLowerCase(Locale.ROOT);
|
||||
return normalized.contains("required field missing")
|
||||
&& normalized.contains("skip coze");
|
||||
}
|
||||
|
||||
private boolean isTechnicalCozeFailure(String value) {
|
||||
String normalized = normalize(value).toLowerCase(Locale.ROOT);
|
||||
if (normalized.isBlank()) {
|
||||
|
||||
Reference in New Issue
Block a user