1
This commit is contained in:
@@ -1735,9 +1735,9 @@ public class TencentDocController extends BaseController {
|
|||||||
Integer startRow = params.get("startRow") != null ?
|
Integer startRow = params.get("startRow") != null ?
|
||||||
Integer.valueOf(params.get("startRow").toString()) : 850;
|
Integer.valueOf(params.get("startRow").toString()) : 850;
|
||||||
|
|
||||||
// 结束行,默认读取200行
|
// 结束行,默认到2500行
|
||||||
Integer endRow = params.get("endRow") != null ?
|
Integer endRow = params.get("endRow") != null ?
|
||||||
Integer.valueOf(params.get("endRow").toString()) : (startRow + 199);
|
Integer.valueOf(params.get("endRow").toString()) : 2500;
|
||||||
|
|
||||||
if (accessToken == null || fileId == null || sheetId == null) {
|
if (accessToken == null || fileId == null || sheetId == null) {
|
||||||
return AjaxResult.error("文档配置不完整,请先配置 fileId 和 sheetId");
|
return AjaxResult.error("文档配置不完整,请先配置 fileId 和 sheetId");
|
||||||
@@ -1838,8 +1838,8 @@ public class TencentDocController extends BaseController {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清理物流链接(去除空格等)
|
// 清理物流链接(去除空格、换行符、中文等)
|
||||||
logisticsLink = logisticsLink.trim();
|
logisticsLink = cleanLogisticsLink(logisticsLink);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 通过物流链接查找订单
|
// 通过物流链接查找订单
|
||||||
@@ -1927,5 +1927,45 @@ public class TencentDocController extends BaseController {
|
|||||||
return AjaxResult.error("反向同步失败: " + e.getMessage());
|
return AjaxResult.error("反向同步失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理物流链接
|
||||||
|
* 去除空格、换行符、制表符、中文等特殊字符,只保留URL有效字符
|
||||||
|
*
|
||||||
|
* @param logisticsLink 原始物流链接
|
||||||
|
* @return 清理后的物流链接
|
||||||
|
*/
|
||||||
|
private String cleanLogisticsLink(String logisticsLink) {
|
||||||
|
if (logisticsLink == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 去除首尾空格
|
||||||
|
String cleaned = logisticsLink.trim();
|
||||||
|
|
||||||
|
// 去除换行符、制表符等空白字符
|
||||||
|
cleaned = cleaned.replaceAll("[\\r\\n\\t]", "");
|
||||||
|
|
||||||
|
// 去除所有空格
|
||||||
|
cleaned = cleaned.replaceAll("\\s+", "");
|
||||||
|
|
||||||
|
// 提取URL(如果包含中文或其他非URL字符,尝试提取URL部分)
|
||||||
|
// 匹配 http:// 或 https:// 开头的URL
|
||||||
|
java.util.regex.Pattern urlPattern = java.util.regex.Pattern.compile("https?://[^\\s\\u4e00-\\u9fa5]+");
|
||||||
|
java.util.regex.Matcher matcher = urlPattern.matcher(cleaned);
|
||||||
|
|
||||||
|
if (matcher.find()) {
|
||||||
|
cleaned = matcher.group();
|
||||||
|
} else {
|
||||||
|
// 如果没有找到完整URL,尝试提取 3.cn 相关的链接
|
||||||
|
java.util.regex.Pattern shortUrlPattern = java.util.regex.Pattern.compile("https?://3\\.cn/[^\\s\\u4e00-\\u9fa5]+");
|
||||||
|
java.util.regex.Matcher shortMatcher = shortUrlPattern.matcher(cleaned);
|
||||||
|
if (shortMatcher.find()) {
|
||||||
|
cleaned = shortMatcher.group();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cleaned.trim();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user