Authored by 张帅

Merge branch 'test6.8.9'

@@ -89,6 +89,7 @@ public class GrassArticleSyncServiceImpl implements IGrassArticleSyncService { @@ -89,6 +89,7 @@ public class GrassArticleSyncServiceImpl implements IGrassArticleSyncService {
89 int indexPage = index; 89 int indexPage = index;
90 es.execute(() -> { 90 es.execute(() -> {
91 syncArticle(startTime, endTime, indexPage, pageSize); 91 syncArticle(startTime, endTime, indexPage, pageSize);
  92 +
92 }); 93 });
93 } 94 }
94 }finally { 95 }finally {
@@ -107,6 +108,13 @@ public class GrassArticleSyncServiceImpl implements IGrassArticleSyncService { @@ -107,6 +108,13 @@ public class GrassArticleSyncServiceImpl implements IGrassArticleSyncService {
107 syncArticleProduct(publicArticleList); 108 syncArticleProduct(publicArticleList);
108 //同步label 和 article_label表 109 //同步label 和 article_label表
109 syncArticleLabel(publicArticleList); 110 syncArticleLabel(publicArticleList);
  111 +
  112 + try {
  113 + Thread.sleep(200);
  114 + } catch (InterruptedException e) {
  115 + logger.warn("syncArticle syncArticle error !error{}", e);
  116 + }
  117 +
110 } 118 }
111 119
112 120
@@ -217,9 +225,8 @@ public class GrassArticleSyncServiceImpl implements IGrassArticleSyncService { @@ -217,9 +225,8 @@ public class GrassArticleSyncServiceImpl implements IGrassArticleSyncService {
217 for (GrassArticleBlock grassArticleBlock:grassArticleBlocks) { 225 for (GrassArticleBlock grassArticleBlock:grassArticleBlocks) {
218 //第一个image为默认封面图 226 //第一个image为默认封面图
219 if("image".equals(grassArticleBlock.getTemplateKey())){ 227 if("image".equals(grassArticleBlock.getTemplateKey())){
220 - String dataString = JSONObject.parseObject(grassArticleBlock.getContentData()).getString("data");  
221 - JSONObject block = JSONObject.parseObject(dataString);  
222 - return block.getString("src"); 228 + String dataString = getBlock(grassArticleBlock.getTemplateKey(),grassArticleBlock.getContentData(),true);
  229 + return dataString;
223 } 230 }
224 231
225 } 232 }
@@ -157,7 +157,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -157,7 +157,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
157 */ 157 */
158 private void syncPraiseByArticle(Integer startTime, Integer endTime){ 158 private void syncPraiseByArticle(Integer startTime, Integer endTime){
159 logger.info("syncPraiseByArticle begin, startTime is {}, endTime is {}", startTime, endTime); 159 logger.info("syncPraiseByArticle begin, startTime is {}, endTime is {}", startTime, endTime);
160 - ExecutorService es = Executors.newSingleThreadExecutor(); 160 + ExecutorService es = Executors.newFixedThreadPool(2);
161 int pageSize = 100; 161 int pageSize = 100;
162 Long startTimeLong = (long)startTime * 1000; 162 Long startTimeLong = (long)startTime * 1000;
163 Long endTimeLong = (long)endTime * 1000; 163 Long endTimeLong = (long)endTime * 1000;
@@ -170,6 +170,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -170,6 +170,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
170 int indexPage = index; 170 int indexPage = index;
171 es.execute(() -> { 171 es.execute(() -> {
172 syncPraiseByArticlePage(startTimeLong, endTimeLong, indexPage, pageSize); 172 syncPraiseByArticlePage(startTimeLong, endTimeLong, indexPage, pageSize);
  173 +
173 }); 174 });
174 } 175 }
175 }finally { 176 }finally {
@@ -191,6 +192,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -191,6 +192,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
191 logger.info("syncPraiseByArticlePage find grassArticlePraise num is {}", grassArticlePraiseList.size()); 192 logger.info("syncPraiseByArticlePage find grassArticlePraise num is {}", grassArticlePraiseList.size());
192 List<PublicUserPraise> needSyncData = buildPublicUserPraise(publicArticleIdAndGrassIdMap, nowArticleIdAndpublicArticleIdMap,grassArticlePraiseList); 193 List<PublicUserPraise> needSyncData = buildPublicUserPraise(publicArticleIdAndGrassIdMap, nowArticleIdAndpublicArticleIdMap,grassArticlePraiseList);
193 publicUserPraiseRepository.saveAll(needSyncData); 194 publicUserPraiseRepository.saveAll(needSyncData);
  195 + try {
  196 + Thread.sleep(200);
  197 + } catch (InterruptedException e) {
  198 + logger.warn(" sync error{}", e);
  199 + }
194 } 200 }
195 201
196 private List<PublicUserPraise> buildPublicUserPraise(Map<Integer, Integer> publicArticleIdAndGrassIdMap,Map<Integer, Integer> nowArticleIdAndpublicArticleIdMap, List<GrassArticlePraise> grassArticlePraiseList){ 202 private List<PublicUserPraise> buildPublicUserPraise(Map<Integer, Integer> publicArticleIdAndGrassIdMap,Map<Integer, Integer> nowArticleIdAndpublicArticleIdMap, List<GrassArticlePraise> grassArticlePraiseList){
@@ -238,7 +244,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -238,7 +244,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
238 */ 244 */
239 private void syncPraiseBySelf(Integer startTime, Integer endTime){ 245 private void syncPraiseBySelf(Integer startTime, Integer endTime){
240 logger.info("syncPraiseBySelf begin, startTime is {}, endTime is {}", startTime, endTime); 246 logger.info("syncPraiseBySelf begin, startTime is {}, endTime is {}", startTime, endTime);
241 - ExecutorService es = Executors.newSingleThreadExecutor(); 247 + ExecutorService es = Executors.newFixedThreadPool(2);
242 int pageSize = 100; 248 int pageSize = 100;
243 int total = grassArticlePraiseRepository.countByCreateTimeBetween(startTime, endTime); 249 int total = grassArticlePraiseRepository.countByCreateTimeBetween(startTime, endTime);
244 logger.info("syncPraiseBySelf get grassArticlePraise count is {}", total); 250 logger.info("syncPraiseBySelf get grassArticlePraise count is {}", total);
@@ -249,6 +255,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -249,6 +255,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
249 int indexPage = index; 255 int indexPage = index;
250 es.execute(() -> { 256 es.execute(() -> {
251 syncPraiseBySelfPage(startTime, endTime, indexPage, pageSize); 257 syncPraiseBySelfPage(startTime, endTime, indexPage, pageSize);
  258 +
252 }); 259 });
253 } 260 }
254 }finally { 261 }finally {
@@ -270,6 +277,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -270,6 +277,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
270 277
271 List<PublicUserPraise> needSyncData = buildPublicUserPraise(publicArticleIdAndGrassIdMap,nowArticleIdAndpublicArticleIdMap, grassArticlePraiseList); 278 List<PublicUserPraise> needSyncData = buildPublicUserPraise(publicArticleIdAndGrassIdMap,nowArticleIdAndpublicArticleIdMap, grassArticlePraiseList);
272 publicUserPraiseRepository.saveAll(needSyncData); 279 publicUserPraiseRepository.saveAll(needSyncData);
  280 + try {
  281 + Thread.sleep(200);
  282 + } catch (InterruptedException e) {
  283 + logger.warn("sync error{}", e);
  284 + }
273 } 285 }
274 286
275 287
@@ -280,7 +292,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -280,7 +292,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
280 */ 292 */
281 private void syncFavoriteByArticle(Integer startTime, Integer endTime){ 293 private void syncFavoriteByArticle(Integer startTime, Integer endTime){
282 logger.info("syncFavoriteByArticle begin, startTime is {}, endTime is {}", startTime, endTime); 294 logger.info("syncFavoriteByArticle begin, startTime is {}, endTime is {}", startTime, endTime);
283 - ExecutorService es = Executors.newSingleThreadExecutor(); 295 + ExecutorService es = Executors.newFixedThreadPool(2);
284 Long startTimeLong = (long)startTime * 1000; 296 Long startTimeLong = (long)startTime * 1000;
285 Long endTimeLong = (long)endTime * 1000; 297 Long endTimeLong = (long)endTime * 1000;
286 int pageSize = 100; 298 int pageSize = 100;
@@ -293,6 +305,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -293,6 +305,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
293 int indexPage = index; 305 int indexPage = index;
294 es.execute(() -> { 306 es.execute(() -> {
295 syncFavoriteByArticlePage(startTimeLong, endTimeLong, indexPage, pageSize); 307 syncFavoriteByArticlePage(startTimeLong, endTimeLong, indexPage, pageSize);
  308 +
296 }); 309 });
297 } 310 }
298 }finally { 311 }finally {
@@ -315,6 +328,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -315,6 +328,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
315 logger.info("syncFavoriteByArticlePage find userFavoriteArticle num is {}", userFavoriteArticleList.size()); 328 logger.info("syncFavoriteByArticlePage find userFavoriteArticle num is {}", userFavoriteArticleList.size());
316 List<PublicUserFavorite> needSyncData = buildPublicUserFavorite(publicArticleIdAndGrassIdMap,nowArticleIdAndpublicArticleIdMap, userFavoriteArticleList); 329 List<PublicUserFavorite> needSyncData = buildPublicUserFavorite(publicArticleIdAndGrassIdMap,nowArticleIdAndpublicArticleIdMap, userFavoriteArticleList);
317 publicUserFavoriteRepository.saveAll(needSyncData); 330 publicUserFavoriteRepository.saveAll(needSyncData);
  331 + try {
  332 + Thread.sleep(200);
  333 + } catch (InterruptedException e) {
  334 + logger.warn("sync error{}", e);
  335 + }
318 } 336 }
319 337
320 338
@@ -353,7 +371,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -353,7 +371,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
353 */ 371 */
354 private void syncFavoriteBySelf(Integer startTime, Integer endTime){ 372 private void syncFavoriteBySelf(Integer startTime, Integer endTime){
355 logger.info("syncFavoriteBySelf begin, startTime is {}, endTime is {}", startTime, endTime); 373 logger.info("syncFavoriteBySelf begin, startTime is {}, endTime is {}", startTime, endTime);
356 - ExecutorService es = Executors.newSingleThreadExecutor(); 374 + ExecutorService es = Executors.newFixedThreadPool(2);
357 int pageSize = 100; 375 int pageSize = 100;
358 int total = userFavoriteArticleRepository.countByCreateTimeBetween(startTime, endTime); 376 int total = userFavoriteArticleRepository.countByCreateTimeBetween(startTime, endTime);
359 logger.info("syncFavoriteBySelf get grassArticlePraise count is {}", total); 377 logger.info("syncFavoriteBySelf get grassArticlePraise count is {}", total);
@@ -364,6 +382,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -364,6 +382,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
364 int indexPage = index; 382 int indexPage = index;
365 es.execute(() -> { 383 es.execute(() -> {
366 syncFavoriteBySelfPage(startTime, endTime, indexPage, pageSize); 384 syncFavoriteBySelfPage(startTime, endTime, indexPage, pageSize);
  385 +
367 }); 386 });
368 } 387 }
369 }finally { 388 }finally {
@@ -385,6 +404,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -385,6 +404,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
385 404
386 List<PublicUserFavorite> needSyncData = buildPublicUserFavorite(publicArticleIdAndGrassIdMap,nowArticleIdAndpublicArticleIdMap, userFavoriteArticleList); 405 List<PublicUserFavorite> needSyncData = buildPublicUserFavorite(publicArticleIdAndGrassIdMap,nowArticleIdAndpublicArticleIdMap, userFavoriteArticleList);
387 publicUserFavoriteRepository.saveAll(needSyncData); 406 publicUserFavoriteRepository.saveAll(needSyncData);
  407 + try {
  408 + Thread.sleep(200);
  409 + } catch (InterruptedException e) {
  410 + logger.warn("sync error{}", e);
  411 + }
388 } 412 }
389 413
390 414
@@ -395,7 +419,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -395,7 +419,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
395 */ 419 */
396 private void syncUserAttention(Integer startTime, Integer endTime){ 420 private void syncUserAttention(Integer startTime, Integer endTime){
397 logger.info("syncUserAttention begin, startTime is {}, endTime is {}", startTime, endTime); 421 logger.info("syncUserAttention begin, startTime is {}, endTime is {}", startTime, endTime);
398 - ExecutorService es = Executors.newSingleThreadExecutor(); 422 + ExecutorService es = Executors.newFixedThreadPool(2);
399 int pageSize = 100; 423 int pageSize = 100;
400 int total = grassUserAttentionRepository.countByCreateTimeBetween(startTime, endTime); 424 int total = grassUserAttentionRepository.countByCreateTimeBetween(startTime, endTime);
401 logger.info("syncUserAttention get attention count is {}", total); 425 logger.info("syncUserAttention get attention count is {}", total);
@@ -406,6 +430,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -406,6 +430,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
406 int indexPage = index; 430 int indexPage = index;
407 es.execute(() -> { 431 es.execute(() -> {
408 syncUserAttentionPage(startTime, endTime, indexPage, pageSize); 432 syncUserAttentionPage(startTime, endTime, indexPage, pageSize);
  433 +
409 }); 434 });
410 } 435 }
411 }finally { 436 }finally {
@@ -420,6 +445,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -420,6 +445,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
420 445
421 List<PublicUserAttention> needSyncData = buildPublicUserAttention(grassUserAttentionList); 446 List<PublicUserAttention> needSyncData = buildPublicUserAttention(grassUserAttentionList);
422 publicUserAttentionRepository.saveAll(needSyncData); 447 publicUserAttentionRepository.saveAll(needSyncData);
  448 + try {
  449 + Thread.sleep(200);
  450 + } catch (InterruptedException e) {
  451 + logger.warn("sync error{}", e);
  452 + }
423 } 453 }
424 454
425 private List<PublicUserAttention> buildPublicUserAttention( List<GrassUserAttention> grassUserAttentionList){ 455 private List<PublicUserAttention> buildPublicUserAttention( List<GrassUserAttention> grassUserAttentionList){
@@ -465,7 +495,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -465,7 +495,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
465 */ 495 */
466 private void syncCommentsByArticle(Integer startTime, Integer endTime){ 496 private void syncCommentsByArticle(Integer startTime, Integer endTime){
467 logger.info("syncCommentsByArticle begin, startTime is {}, endTime is {}", startTime, endTime); 497 logger.info("syncCommentsByArticle begin, startTime is {}, endTime is {}", startTime, endTime);
468 - ExecutorService es = Executors.newSingleThreadExecutor(); 498 + ExecutorService es = Executors.newFixedThreadPool(2);
469 int pageSize = 100; 499 int pageSize = 100;
470 Long startTimeLong = (long)startTime * 1000; 500 Long startTimeLong = (long)startTime * 1000;
471 Long endTimeLong = (long)endTime * 1000; 501 Long endTimeLong = (long)endTime * 1000;
@@ -495,7 +525,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -495,7 +525,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
495 */ 525 */
496 private void syncCommentsBySelf(Integer startTime, Integer endTime){ 526 private void syncCommentsBySelf(Integer startTime, Integer endTime){
497 logger.info("syncCommentsBySelf begin, startTime is {}, endTime is {}", startTime, endTime); 527 logger.info("syncCommentsBySelf begin, startTime is {}, endTime is {}", startTime, endTime);
498 - ExecutorService es = Executors.newSingleThreadExecutor(); 528 + ExecutorService es = Executors.newFixedThreadPool(2);
499 int pageSize = 100; 529 int pageSize = 100;
500 int total = grassArticleCommentRepository.countByCreateTimeBetween(startTime, endTime); 530 int total = grassArticleCommentRepository.countByCreateTimeBetween(startTime, endTime);
501 logger.info("syncCommentsBySelf get grassArticlePraise count is {}", total); 531 logger.info("syncCommentsBySelf get grassArticlePraise count is {}", total);
@@ -554,6 +584,12 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -554,6 +584,12 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
554 584
555 buildAndSaveChildrenCommentBySelf(publicArticleIdAndGrassIdMap, grassChildrenArticleComments, relateIdMap); 585 buildAndSaveChildrenCommentBySelf(publicArticleIdAndGrassIdMap, grassChildrenArticleComments, relateIdMap);
556 586
  587 + try {
  588 + Thread.sleep(200);
  589 + } catch (InterruptedException e) {
  590 + logger.warn("sync error{}", e);
  591 + }
  592 +
557 } 593 }
558 594
559 /** 595 /**
@@ -587,6 +623,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -587,6 +623,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
587 623
588 //同步所有层级的子评论 624 //同步所有层级的子评论
589 buildAndSaveChildrenComment(publicArticleIdAndGrassIdMap,rootPublicComments, childrenComments, rootIdMap); 625 buildAndSaveChildrenComment(publicArticleIdAndGrassIdMap,rootPublicComments, childrenComments, rootIdMap);
  626 + try {
  627 + Thread.sleep(200);
  628 + } catch (InterruptedException e) {
  629 + logger.warn("sync error{}", e);
  630 + }
590 631
591 } 632 }
592 633
@@ -784,7 +825,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -784,7 +825,7 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
784 */ 825 */
785 private void syncCommentPraise(Integer startTime, Integer endTime){ 826 private void syncCommentPraise(Integer startTime, Integer endTime){
786 logger.info("syncCommentPraise begin, startTime is {}, endTime is {}", startTime, endTime); 827 logger.info("syncCommentPraise begin, startTime is {}, endTime is {}", startTime, endTime);
787 - ExecutorService es = Executors.newSingleThreadExecutor(); 828 + ExecutorService es = Executors.newFixedThreadPool(2);
788 int pageSize = 100; 829 int pageSize = 100;
789 int total = grassCommentPraiseRepository.countByCreateTimeBetween(startTime, endTime); 830 int total = grassCommentPraiseRepository.countByCreateTimeBetween(startTime, endTime);
790 logger.info("syncCommentPraise get commentPraise count is {}", total); 831 logger.info("syncCommentPraise get commentPraise count is {}", total);
@@ -820,6 +861,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat @@ -820,6 +861,11 @@ public class GrassInteractiveDataSyncServiceImpl implements IGrassInteractiveDat
820 861
821 List<PublicUserPraise> needSyncData = buildPublicUserPraise(relateIdMap, grassCommentPraiseList); 862 List<PublicUserPraise> needSyncData = buildPublicUserPraise(relateIdMap, grassCommentPraiseList);
822 publicUserPraiseRepository.saveAll(needSyncData); 863 publicUserPraiseRepository.saveAll(needSyncData);
  864 + try {
  865 + Thread.sleep(200);
  866 + } catch (InterruptedException e) {
  867 + logger.warn("sync error{}", e);
  868 + }
823 } 869 }
824 870
825 private List<PublicUserPraise> buildPublicUserPraise(Map<Integer, Integer> relateIdMap, List<GrassCommentPraise> grassCommentPraiseList){ 871 private List<PublicUserPraise> buildPublicUserPraise(Map<Integer, Integer> relateIdMap, List<GrassCommentPraise> grassCommentPraiseList){
@@ -60,7 +60,7 @@ public class GrassUserDataSyncServiceImpl implements IGrassUserDataSyncService { @@ -60,7 +60,7 @@ public class GrassUserDataSyncServiceImpl implements IGrassUserDataSyncService {
60 60
61 private void syncUserAchieveData(Integer startTime, Integer endTime){ 61 private void syncUserAchieveData(Integer startTime, Integer endTime){
62 logger.info("syncUserAchieveData begin, startTime is {}, endTime is {}", startTime, endTime); 62 logger.info("syncUserAchieveData begin, startTime is {}, endTime is {}", startTime, endTime);
63 - ExecutorService es = Executors.newSingleThreadExecutor(); 63 + ExecutorService es = Executors.newFixedThreadPool(2);
64 int total = grassUserAchieveRepository.countByCreateTimeBetween(startTime, endTime); 64 int total = grassUserAchieveRepository.countByCreateTimeBetween(startTime, endTime);
65 logger.info("syncUserAchieveData get grassArticlePraise count is {}", total); 65 logger.info("syncUserAchieveData get grassArticlePraise count is {}", total);
66 int totalPage = total % pageSize ==0 ? total / pageSize : (total / pageSize)+1; 66 int totalPage = total % pageSize ==0 ? total / pageSize : (total / pageSize)+1;
@@ -83,6 +83,11 @@ public class GrassUserDataSyncServiceImpl implements IGrassUserDataSyncService { @@ -83,6 +83,11 @@ public class GrassUserDataSyncServiceImpl implements IGrassUserDataSyncService {
83 List<PublicUserHomePage> needSyncData = buildPublicUserHomePage(grassUserAchieveList); 83 List<PublicUserHomePage> needSyncData = buildPublicUserHomePage(grassUserAchieveList);
84 logger.info("syncUserAchieveDataPage need sync data count is {}", needSyncData.size()); 84 logger.info("syncUserAchieveDataPage need sync data count is {}", needSyncData.size());
85 publicUserHomePageRepository.saveAll(needSyncData); 85 publicUserHomePageRepository.saveAll(needSyncData);
  86 + try {
  87 + Thread.sleep(200);
  88 + } catch (InterruptedException e) {
  89 + logger.warn("sync error{}", e);
  90 + }
86 } 91 }
87 92
88 private List<PublicUserHomePage> buildPublicUserHomePage( List<GrassUserAchieve> grassUserAchieveList ){ 93 private List<PublicUserHomePage> buildPublicUserHomePage( List<GrassUserAchieve> grassUserAchieveList ){
@@ -107,7 +112,7 @@ public class GrassUserDataSyncServiceImpl implements IGrassUserDataSyncService { @@ -107,7 +112,7 @@ public class GrassUserDataSyncServiceImpl implements IGrassUserDataSyncService {
107 112
108 private void syncVirtualUserData(Integer startTime, Integer endTime){ 113 private void syncVirtualUserData(Integer startTime, Integer endTime){
109 logger.info("syncVirtualUserData begin, startTime is {}, endTime is {}", startTime, endTime); 114 logger.info("syncVirtualUserData begin, startTime is {}, endTime is {}", startTime, endTime);
110 - ExecutorService es = Executors.newSingleThreadExecutor(); 115 + ExecutorService es = Executors.newFixedThreadPool(2);
111 int total = grassVirtualUserRepository.countByCreateTimeBetween(startTime, endTime); 116 int total = grassVirtualUserRepository.countByCreateTimeBetween(startTime, endTime);
112 logger.info("syncVirtualUserData get grassArticlePraise count is {}", total); 117 logger.info("syncVirtualUserData get grassArticlePraise count is {}", total);
113 int totalPage = total % pageSize ==0 ? total / pageSize : (total / pageSize)+1; 118 int totalPage = total % pageSize ==0 ? total / pageSize : (total / pageSize)+1;
@@ -130,6 +135,11 @@ public class GrassUserDataSyncServiceImpl implements IGrassUserDataSyncService { @@ -130,6 +135,11 @@ public class GrassUserDataSyncServiceImpl implements IGrassUserDataSyncService {
130 List<PublicVirtualUser> needSyncData = buildPublicVirtualUserPage(grassUserAchieveList); 135 List<PublicVirtualUser> needSyncData = buildPublicVirtualUserPage(grassUserAchieveList);
131 logger.info("syncUserAchieveDataPage need sync data count is {}", needSyncData.size()); 136 logger.info("syncUserAchieveDataPage need sync data count is {}", needSyncData.size());
132 publicVirtualUserRepository.saveAll(needSyncData); 137 publicVirtualUserRepository.saveAll(needSyncData);
  138 + try {
  139 + Thread.sleep(200);
  140 + } catch (InterruptedException e) {
  141 + logger.warn("sync error{}", e);
  142 + }
133 } 143 }
134 144
135 145