|
@@ -64,7 +64,7 @@ public class YohoNowDataSynService { |
|
@@ -64,7 +64,7 @@ public class YohoNowDataSynService { |
64
|
@Resource
|
64
|
@Resource
|
65
|
private ITblAttentionUserRepository tblAttentionUserRepository;
|
65
|
private ITblAttentionUserRepository tblAttentionUserRepository;
|
66
|
private final Logger logger = LoggerFactory.getLogger(YohoNowDataSynService.class);
|
66
|
private final Logger logger = LoggerFactory.getLogger(YohoNowDataSynService.class);
|
67
|
- @Resource(name = "entityManagerPrimary")
|
67
|
+ @Resource(name = "entityManagerSecondary")
|
68
|
private EntityManager publicEntityManager;
|
68
|
private EntityManager publicEntityManager;
|
69
|
public final int size=50;
|
69
|
public final int size=50;
|
70
|
private Boolean isStop =false;
|
70
|
private Boolean isStop =false;
|
|
@@ -345,7 +345,23 @@ public class YohoNowDataSynService { |
|
@@ -345,7 +345,23 @@ public class YohoNowDataSynService { |
345
|
List<PublicUserAttention> userAttentions = buildSynAttentionAuthor(fanUsersMap,filtedFanUids);
|
345
|
List<PublicUserAttention> userAttentions = buildSynAttentionAuthor(fanUsersMap,filtedFanUids);
|
346
|
logger.info("before synAttentionAuthorByArticle.size is {}",userAttentions.size());
|
346
|
logger.info("before synAttentionAuthorByArticle.size is {}",userAttentions.size());
|
347
|
if(!CollectionUtils.isEmpty(userAttentions)){
|
347
|
if(!CollectionUtils.isEmpty(userAttentions)){
|
348
|
- publicUserAttentionRepository.saveAll(userAttentions);
|
348
|
+ publicEntityManager.getTransaction().begin();
|
|
|
349
|
+ StringBuilder sb = null;
|
|
|
350
|
+ for(PublicUserAttention attention : userAttentions){
|
|
|
351
|
+ if(null == sb ){
|
|
|
352
|
+ sb = new StringBuilder("insert into public_user_attention(uid,target_id,attention_type,author_type,status,src_channel,create_time,update_time) values ");
|
|
|
353
|
+ }else {
|
|
|
354
|
+ sb.append(",");
|
|
|
355
|
+ }
|
|
|
356
|
+ sb.append("(").append(attention.getUid()).append(",").append(attention.getTargetId()).append(",").append(attention.getAttentionType()).append(",")
|
|
|
357
|
+ .append(attention.getAuthorType()).append(",").append(attention.getStatus()).append(",").
|
|
|
358
|
+ append(attention.getSrcChannel()).append(",").append(attention.getCreateTime()).append(",").append(attention.getUpdateTime()).append(")");
|
|
|
359
|
+ }
|
|
|
360
|
+ sb.append("ON DUPLICATE KEY UPDATE uid=values(uid),target_id=values(target_id),attention_type=values(attention_type),author_type=values(author_type),status=values(status),src_channel=values(src_channel),create_time=values(create_time),update_time=values(update_time)");
|
|
|
361
|
+ publicEntityManager.createNativeQuery(sb.toString()).executeUpdate();
|
|
|
362
|
+ publicEntityManager.flush();
|
|
|
363
|
+ publicEntityManager.getTransaction().commit();
|
|
|
364
|
+
|
349
|
try{
|
365
|
try{
|
350
|
Thread.sleep(500);
|
366
|
Thread.sleep(500);
|
351
|
}catch (Exception exp){
|
367
|
}catch (Exception exp){
|