...
|
...
|
@@ -17,6 +17,7 @@ import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.persistence.EntityManager;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.regex.Matcher;
|
...
|
...
|
@@ -60,7 +61,8 @@ public class YohoNowDataSynService { |
|
|
private IPublicUserAttentionRepository publicUserAttentionRepository;
|
|
|
@Resource
|
|
|
private ITblAttentionUserRepository tblAttentionUserRepository;
|
|
|
|
|
|
@Resource(name = "entityManagerPrimary")
|
|
|
private EntityManager publicEntityManager;
|
|
|
public final int size=50;
|
|
|
|
|
|
public String synArticle(long begTime, long endTime) {
|
...
|
...
|
@@ -92,6 +94,22 @@ public class YohoNowDataSynService { |
|
|
return "success";
|
|
|
}
|
|
|
|
|
|
private void synArticles(List<PublicArticle> pArticles){
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
for(PublicArticle article : pArticles){
|
|
|
if(sb.length()==0){
|
|
|
sb.append("insert into public_article(cover_img,article_type ,relate_id ,author_uid,praise_num," +
|
|
|
"status,audit_status,publish_time,create_time,update_time) values");
|
|
|
}else{
|
|
|
sb.append(",");
|
|
|
}
|
|
|
sb.append("(").append(article.getCoverImg()).append(article.getArticleType()).append(article.getRelateId()).
|
|
|
append(article.getAuthorUid()).append(article.getPraiseNum()).append(article.getStatus()).
|
|
|
append(article.getAuditStatus()).append(article.getPublishTime()).append(article.getCreateTime())
|
|
|
.append(article.getUpdateTime());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void synArticleAudit(List<PublicArticle> pArticles, List<Posts> postsList) {
|
|
|
List<PublicArticleAudit> auditList = new ArrayList<>();
|
|
|
Map<Integer,Posts> postsMap = BeanConvertUtils.listToMap(postsList,Integer.class,"id");
|
...
|
...
|
@@ -118,23 +136,17 @@ public class YohoNowDataSynService { |
|
|
List<Integer> postIds = pArticleList.stream().map(PublicArticle::getRelateId).collect(Collectors.toList());
|
|
|
Map<Integer,Integer> articleIdAndPostIdMap = pArticleList.stream().
|
|
|
collect(Collectors.toMap(PublicArticle::getRelateId, PublicArticle::getId,(k1, k2)->k1));
|
|
|
//获取在grass 模块已存在的uid, 并排除
|
|
|
List<TopicPost> topicPosts = topicPostRepository.selectByPostIds(postIds);
|
|
|
//同步标签
|
|
|
List<Integer> topicIds = topicPosts.stream().map(TopicPost::getTopicId).distinct().collect(Collectors.toList());
|
|
|
List<PublicLabel> needSyncLabelList = new ArrayList<>();
|
|
|
if(!CollectionUtils.isEmpty(topicIds)){
|
|
|
//排除已经同步过来的标签
|
|
|
List<PublicLabel> existLabel = publicLabelRepository.selectByIds(topicIds);
|
|
|
List<Integer> existLabelIds = existLabel.stream().map(PublicLabel::getId).collect(Collectors.toList());
|
|
|
List<Integer> needSyncIds = topicIds.stream().filter(integer -> !existLabelIds.contains(integer)).collect(Collectors.toList());
|
|
|
if(!CollectionUtils.isEmpty(needSyncIds)){
|
|
|
List<Topic> topicList = topicRepository.selectByIds(needSyncIds);
|
|
|
if(!CollectionUtils.isEmpty(topicIds)){
|
|
|
List<Topic> topicList = topicRepository.selectByIds(topicIds);
|
|
|
if(!CollectionUtils.isEmpty(topicList)){
|
|
|
long now = System.currentTimeMillis();
|
|
|
topicList.forEach(x -> {
|
|
|
PublicLabel grassLabel = new PublicLabel();
|
|
|
grassLabel.setId(x.getId());
|
|
|
grassLabel.setLabelName(x.getTopicName().replace("#",""));
|
|
|
grassLabel.setStatus(1);
|
|
|
grassLabel.setCreateTime(now);
|
...
|
...
|
|