...
|
...
|
@@ -12,6 +12,8 @@ import com.yoho.datasync.fullsync.dal.repository.yhcms.model.TblAttentionUser; |
|
|
import com.yoho.datasync.fullsync.dal.repository.yhcms.model.TblCommentInfo;
|
|
|
import com.yoho.datasync.fullsync.dal.repository.yhsocial.*;
|
|
|
import com.yoho.datasync.fullsync.dal.repository.yhsocial.model.*;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
...
|
...
|
@@ -61,9 +63,11 @@ public class YohoNowDataSynService { |
|
|
private PublicUserAttentionRepository publicUserAttentionRepository;
|
|
|
@Resource
|
|
|
private ITblAttentionUserRepository tblAttentionUserRepository;
|
|
|
private final Logger logger = LoggerFactory.getLogger(YohoNowDataSynService.class);
|
|
|
@Resource(name = "entityManagerPrimary")
|
|
|
private EntityManager publicEntityManager;
|
|
|
public final int size=50;
|
|
|
private Boolean isStop =false;
|
|
|
|
|
|
public String synArticle(long begTime, long endTime) {
|
|
|
int total = postsRepository.selectTotal(begTime,endTime);
|
...
|
...
|
@@ -74,10 +78,11 @@ public class YohoNowDataSynService { |
|
|
}
|
|
|
List<Integer> postIds = postsList.stream().map(Posts::getId).collect(Collectors.toList());
|
|
|
List<PostsPraiseTotal> praiseTotals = postsPraiseRepository.selectTotal(postIds);
|
|
|
List<PostsBlock> postsBlocks = postsBlockRepository.selectTotal(postIds);
|
|
|
List<PostsBlock> postsBlocks = postsBlockRepository.selectByPostIds(postIds);
|
|
|
Map<Integer,List<PostsBlock>> postsBlockMap = BeanConvertUtils.listToListMap(postsBlocks,Integer.class,"postsId");
|
|
|
Map<Integer,PostsPraiseTotal> postsPraiseTotalMap = BeanConvertUtils.listToMap(praiseTotals,Integer.class,"postsId");
|
|
|
List<PublicArticle> pArticles = buildPublicArticles(postsList,postsBlockMap,postsPraiseTotalMap);
|
|
|
logger.info("before synArticle.size is {}",pArticles.size());
|
|
|
publicArticleRepository.saveAll(pArticles);
|
|
|
//文章审核表同步
|
|
|
synArticleAudit(pArticles,postsList);
|
...
|
...
|
@@ -122,6 +127,7 @@ public class YohoNowDataSynService { |
|
|
audit.setAuditStatus(2);//审核都是通过的
|
|
|
auditList.add(audit);
|
|
|
}
|
|
|
logger.info("before synArticleAudit.size is {}",auditList.size());
|
|
|
if(!auditList.isEmpty()){
|
|
|
publicArticleAuditRepository.saveAll(auditList);
|
|
|
}
|
...
|
...
|
@@ -173,6 +179,7 @@ public class YohoNowDataSynService { |
|
|
needSyncList.add(articleLabel);
|
|
|
});
|
|
|
}
|
|
|
logger.info("before synArticleLabel.size is {}",needSyncList.size());
|
|
|
if(!CollectionUtils.isEmpty(needSyncList)){
|
|
|
publicArticleLabelRepository.saveAll(needSyncList);
|
|
|
}
|
...
|
...
|
@@ -219,6 +226,7 @@ public class YohoNowDataSynService { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
logger.info("before synArticleBlock.size is {}",pBlocks.size());
|
|
|
if(!pBlocks.isEmpty()){
|
|
|
publicArticleBlockRepository.saveAll(pBlocks);
|
|
|
}
|
...
|
...
|
@@ -276,7 +284,7 @@ public class YohoNowDataSynService { |
|
|
// article.setFavoriteNum();//favoriteCount TODO
|
|
|
article.setStatus(1);//auth_status
|
|
|
article.setAuditStatus(2);//auth_status 与审核相关
|
|
|
article.setPublishTime(posts.getCreateTime());//create_time
|
|
|
article.setPublishTime(posts.getRevieweTime());//create_time
|
|
|
article.setCreateTime(posts.getCreateTime());//create_time
|
|
|
article.setUpdateTime(posts.getUpdateTime());//update_time
|
|
|
//设置封面
|
...
|
...
|
@@ -335,6 +343,7 @@ public class YohoNowDataSynService { |
|
|
List<Integer> fanUids = fanUsersMap.keySet().stream().collect(Collectors.toList());
|
|
|
List<Integer> filtedFanUids = communityUserRepository.selectRealUids(fanUids);
|
|
|
List<PublicUserAttention> userAttentions = buildSynAttentionAuthor(fanUsersMap,filtedFanUids);
|
|
|
logger.info("before synAttentionAuthorByArticle.size is {}",userAttentions.size());
|
|
|
if(!CollectionUtils.isEmpty(userAttentions)){
|
|
|
publicUserAttentionRepository.saveAll(userAttentions);
|
|
|
try{
|
...
|
...
|
@@ -358,6 +367,7 @@ public class YohoNowDataSynService { |
|
|
List<Integer> fanUids = fanUsersMap.keySet().stream().collect(Collectors.toList());
|
|
|
List<Integer> filtedFanUids = communityUserRepository.selectRealUids(fanUids);
|
|
|
List<PublicUserAttention> userAttentions = buildSynAttentionAuthor(fanUsersMap,filtedFanUids);
|
|
|
logger.info("before synAttentionAuthorByTime.size is {}",userAttentions.size());
|
|
|
if(!CollectionUtils.isEmpty(userAttentions)){
|
|
|
publicUserAttentionRepository.saveAll(userAttentions);
|
|
|
try{
|
...
|
...
|
@@ -416,6 +426,7 @@ public class YohoNowDataSynService { |
|
|
List<PostsPraise> praiseList = postsPraiseRepository.selectByPostIds(relateIds,i,size);
|
|
|
//将点赞数据同步到表grass_article_praise
|
|
|
List<PublicUserPraise> articlePraises = buildSynArticlePraises(articleMap,praiseList);
|
|
|
logger.info("before synPraiseDataByArticle.size is {}",articlePraises.size());
|
|
|
if(!articlePraises.isEmpty()){
|
|
|
publicUserPraiseRepository.saveAll(articlePraises);
|
|
|
try{
|
...
|
...
|
@@ -442,6 +453,7 @@ public class YohoNowDataSynService { |
|
|
|
|
|
//将点赞数据同步到表grass_article_praise
|
|
|
List<PublicUserPraise> articlePraises = buildSynArticlePraises(articleMap,praiseList);
|
|
|
logger.info("before synPraiseDataByTime.size is {}",articlePraises.size());
|
|
|
if(!articlePraises.isEmpty()){
|
|
|
publicUserPraiseRepository.saveAll(articlePraises);
|
|
|
try{
|
...
|
...
|
@@ -482,6 +494,7 @@ public class YohoNowDataSynService { |
|
|
if(CollectionUtils.isEmpty(rootComments)){
|
|
|
break;
|
|
|
}
|
|
|
logger.info("before synCommentDataByArticle.size is {}",rootComments.size());
|
|
|
List<PublicUserComment> parentArticleComments = batchSaveNewComment(articleMap,rootComments,null);
|
|
|
if(!CollectionUtils.isEmpty(parentArticleComments)){
|
|
|
List<Integer> parentIds = parentArticleComments.stream().map(comm->comm.getRelateId()).collect(Collectors.toList());
|
...
|
...
|
@@ -510,7 +523,7 @@ public class YohoNowDataSynService { |
|
|
List<Integer> articleRelateIds = rootComments.stream().map(TblCommentInfo::getContentId).collect(Collectors.toList());
|
|
|
List<PublicArticle> articleList = publicArticleRepository.selectByRelateIds(articleRelateIds);
|
|
|
Map<Integer,PublicArticle> articleMap = BeanConvertUtils.listToMap(articleList,Integer.class,"relateId");
|
|
|
|
|
|
logger.info("before synCommentDataByTime.size is {}",rootComments.size());
|
|
|
List<PublicUserComment> parentArticleComments = batchSaveNewComment(articleMap,rootComments,null);
|
|
|
if(!CollectionUtils.isEmpty(parentArticleComments)){
|
|
|
List<Integer> parentIds = parentArticleComments.stream().map(comm->comm.getRelateId()).collect(Collectors.toList());
|
...
|
...
|
@@ -615,4 +628,12 @@ public class YohoNowDataSynService { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public Boolean getStop() {
|
|
|
return isStop;
|
|
|
}
|
|
|
|
|
|
public void setStop(Boolean stop) {
|
|
|
isStop = stop;
|
|
|
}
|
|
|
} |
...
|
...
|
|