|
@@ -125,6 +125,7 @@ public class GzhReplyVideoRefreshJob {
|
|
|
.map(Map.Entry::getValue)
|
|
.map(Map.Entry::getValue)
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
List<VideoDetail> searchVideos = new ArrayList<>();
|
|
List<VideoDetail> searchVideos = new ArrayList<>();
|
|
|
|
|
+ List<String> existTitles = new ArrayList<>();
|
|
|
for (JSONObject obj : sortedList) {
|
|
for (JSONObject obj : sortedList) {
|
|
|
String text = obj.getString("title");
|
|
String text = obj.getString("title");
|
|
|
// 提取关键词
|
|
// 提取关键词
|
|
@@ -159,8 +160,10 @@ public class GzhReplyVideoRefreshJob {
|
|
|
if (aiResult.isSuccess()) {
|
|
if (aiResult.isSuccess()) {
|
|
|
List<String> keywords = JSONObject.parseArray(aiResult.getResponse().getChoices().get(0).getMessage().getContent(), String.class);
|
|
List<String> keywords = JSONObject.parseArray(aiResult.getResponse().getChoices().get(0).getMessage().getContent(), String.class);
|
|
|
log.info("GzhReplyVideoRefreshJob accountName:{} text:{} keywords:{}", accountName, text, keywords);
|
|
log.info("GzhReplyVideoRefreshJob accountName:{} text:{} keywords:{}", accountName, text, keywords);
|
|
|
- VideoDetail videoDetail = searchVideoByKeyword(keywords, searchVideos);
|
|
|
|
|
|
|
+ VideoDetail videoDetail = searchVideoByKeyword(keywords, searchVideos, existTitles);
|
|
|
if (videoDetail != null) {
|
|
if (videoDetail != null) {
|
|
|
|
|
+ existTitles.add(videoDetail.getTitle());
|
|
|
|
|
+ existTitles.add(text);
|
|
|
videoDetail.setTitle(text);
|
|
videoDetail.setTitle(text);
|
|
|
videoDetail.setCover(obj.getString("coverImgUrl"));
|
|
videoDetail.setCover(obj.getString("coverImgUrl"));
|
|
|
searchVideos.add(videoDetail);
|
|
searchVideos.add(videoDetail);
|
|
@@ -214,7 +217,7 @@ public class GzhReplyVideoRefreshJob {
|
|
|
return creativeIdTextMap;
|
|
return creativeIdTextMap;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private VideoDetail searchVideoByKeyword(List<String> keywords, List<VideoDetail> searchVideos) {
|
|
|
|
|
|
|
+ private VideoDetail searchVideoByKeyword(List<String> keywords, List<VideoDetail> searchVideos, List<String> existTitles) {
|
|
|
if (CollectionUtils.isNotEmpty(keywords)) {
|
|
if (CollectionUtils.isNotEmpty(keywords)) {
|
|
|
String searchVideoSql = "SELECT v.id, v.title, v.cover_img_path\n" +
|
|
String searchVideoSql = "SELECT v.id, v.title, v.cover_img_path\n" +
|
|
|
"FROM videoods.wx_video v\n" +
|
|
"FROM videoods.wx_video v\n" +
|
|
@@ -229,11 +232,20 @@ public class GzhReplyVideoRefreshJob {
|
|
|
// 过滤重复视频
|
|
// 过滤重复视频
|
|
|
boolean filter = false;
|
|
boolean filter = false;
|
|
|
for (VideoDetail searchVideo : searchVideos) {
|
|
for (VideoDetail searchVideo : searchVideos) {
|
|
|
- if (searchVideo.getId().equals(videoId) || TitleSimilarCheckUtil.isSimilar(title, searchVideo.getTitle(), TitleSimilarCheckUtil.SIMILARITY_THRESHOLD)) {
|
|
|
|
|
|
|
+ if (searchVideo.getId().equals(videoId)) {
|
|
|
filter = true;
|
|
filter = true;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ // 过滤重复标题
|
|
|
|
|
+ if (!filter && CollectionUtils.isNotEmpty(existTitles)) {
|
|
|
|
|
+ for (String existTitle : existTitles) {
|
|
|
|
|
+ if (TitleSimilarCheckUtil.isSimilar(title, existTitle, TitleSimilarCheckUtil.SIMILARITY_THRESHOLD)) {
|
|
|
|
|
+ filter = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
if (filter) {
|
|
if (filter) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|