1
This commit is contained in:
@@ -124,16 +124,32 @@ public class BatchPublishServiceImpl implements IBatchPublishService
|
|||||||
Set<String> processedSkuids = new HashSet<>();
|
Set<String> processedSkuids = new HashSet<>();
|
||||||
|
|
||||||
// 优先处理URL(更准确)
|
// 优先处理URL(更准确)
|
||||||
for (String url : urls) {
|
for (int i = 0; i < urls.size(); i++) {
|
||||||
|
String url = urls.get(i);
|
||||||
try {
|
try {
|
||||||
|
log.info("正在处理第 {}/{} 个URL: {}", i + 1, urls.size(), url);
|
||||||
Map<String, Object> productInfo = queryProductInfo(url);
|
Map<String, Object> productInfo = queryProductInfo(url);
|
||||||
if (productInfo != null) {
|
|
||||||
|
if (productInfo == null) {
|
||||||
|
log.warn("URL解析返回空结果: {}", url);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
String skuid = (String) productInfo.get("skuid");
|
String skuid = (String) productInfo.get("skuid");
|
||||||
if (skuid != null && !processedSkuids.contains(skuid)) {
|
if (skuid == null || skuid.trim().isEmpty()) {
|
||||||
|
log.warn("商品SKUID为空,URL: {}, 返回数据: {}", url, productInfo);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (processedSkuids.contains(skuid)) {
|
||||||
|
log.info("SKUID已存在,跳过: {}", skuid);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
products.add(productInfo);
|
products.add(productInfo);
|
||||||
processedSkuids.add(skuid);
|
processedSkuids.add(skuid);
|
||||||
}
|
log.info("成功添加商品: SKUID={}, 名称={}", skuid, productInfo.get("productName"));
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("查询商品信息失败,URL: {}", url, e);
|
log.error("查询商品信息失败,URL: {}", url, e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import java.util.regex.Pattern;
|
|||||||
*/
|
*/
|
||||||
public class LineReportParser {
|
public class LineReportParser {
|
||||||
|
|
||||||
// 京东链接正则表达式
|
// 京东链接正则表达式(贪婪匹配,捕获完整URL)
|
||||||
private static final Pattern JD_URL_PATTERN = Pattern.compile("https?://[^\\s]*?jd\\.com[^\\s]*");
|
private static final Pattern JD_URL_PATTERN = Pattern.compile("https?://[^\\s]*jd\\.com[^\\s]*");
|
||||||
|
|
||||||
// SKUID正则表达式(10-13位数字)
|
// SKUID正则表达式(10-13位数字)
|
||||||
private static final Pattern SKUID_PATTERN = Pattern.compile("\\b(\\d{10,13})\\b");
|
private static final Pattern SKUID_PATTERN = Pattern.compile("\\b(\\d{10,13})\\b");
|
||||||
|
|||||||
Reference in New Issue
Block a user