Authored by 张帅

fix

... ... @@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
... ... @@ -81,18 +82,24 @@ public class GrassArticleDataCheckServiceImpl implements IGrassArticleDataCheckS
e.printStackTrace();
}
}
int publicCount = 0;
List<Integer> publicArticleIds = Lists.newArrayList();
if(!CollectionUtils.isEmpty(grassArticleIds)){
List<PublicArticle> publicArticleList = publicArticleRepository.findAllByRelateIdInAndArticleTypeIn(grassArticleIds, needSyncArticleType);
List<Integer> publicArticleIds = publicArticleList.stream().map(BaseEntity::getId).collect(Collectors.toList());
int publicCount = publicArticleList.size();
publicArticleIds = publicArticleList.stream().map(BaseEntity::getId).collect(Collectors.toList());
publicCount = publicArticleList.size();
}
logger.info("checkArticleData , get publicCount is {}", publicCount);
JSONObject result = new JSONObject();
JSONArray data = new JSONArray();
data.add(checkArticle(total, publicCount));
if(!CollectionUtils.isEmpty(publicArticleIds)){
data.add(checkArticleBlock(grassArticleIds, publicArticleIds));
data.add(checkArticleProduct(grassArticleIds, publicArticleIds));
data.add(checkArticleLabel(grassArticleIds, publicArticleIds));
}
result.put("data",data);
return result;
}
... ...
... ... @@ -156,7 +156,10 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
List<PublicArticle> nowPublicArticleList = publicArticleRepository.findAllByRelateIdInAndArticleTypeIn(nowArticleIds, Lists.newArrayList(5));
publicArticleId.addAll(nowPublicArticleList.stream().map(BaseEntity::getId).collect(Collectors.toList()));
}
int public_count = publicUserPraiseRepository.countByTargetIdInAndPraiseTypeIsAndSrcChannelIs(publicArticleId, UserPraiseConstant.ARTICLE_PRAISE , 1);
int public_count=0;
if(!CollectionUtils.isEmpty(publicArticleId)){
public_count = publicUserPraiseRepository.countByTargetIdInAndPraiseTypeIsAndSrcChannelIs(publicArticleId, UserPraiseConstant.ARTICLE_PRAISE , 1);
}
public_praise_count +=public_count;
grass_praise_count +=grass_count;
try {
... ... @@ -184,9 +187,15 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
logger.info("checkPraiseBySelf begin, startTime is {}, endTime is {}", startTime, endTime);
Long startTimeLong = (long)startTime * 1000;
Long endTimeLong = (long)endTime * 1000;
JSONObject result = new JSONObject();
List<GrassArticlePraise> grassArticlePraiseList = grassArticlePraiseRepository.findAllByCreateTimeBetween(
startTime, endTime);
if(grassArticlePraiseList.isEmpty()){
result.put("grass_praise_count", grassArticlePraiseList.size());
result.put("public_praise_count", 0 );
return result;
}
List<Integer> grassArticleIds = grassArticlePraiseList.stream().map(GrassArticlePraise::getArticleId).collect(Collectors.toList());
List<GrassArticle> grassArticleList = grassArticleRepository.findAllByIdIn(grassArticleIds);
List<Integer> nowArticleIds = grassArticleList.stream().filter(grassArticle -> grassArticle.getArticleType()==5).map(GrassArticle::getRelateId).collect(Collectors.toList());
... ... @@ -197,8 +206,11 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
List<PublicArticle> nowPublicArticleList = publicArticleRepository.findAllByRelateIdInAndArticleTypeIn(nowArticleIds, Lists.newArrayList(5));
publicArticleIds.addAll(nowPublicArticleList.stream().map(BaseEntity::getId).collect(Collectors.toList()));
}
int public_count = publicUserPraiseRepository.countByTargetIdInAndPraiseTypeIsAndSrcChannelIsAndCreateTimeBetween(publicArticleIds, UserPraiseConstant.ARTICLE_PRAISE , 1,startTimeLong, endTimeLong);
JSONObject result = new JSONObject();
int public_count=0;
if(!CollectionUtils.isEmpty(publicArticleIds)){
public_count = publicUserPraiseRepository.countByTargetIdInAndPraiseTypeIsAndSrcChannelIsAndCreateTimeBetween(publicArticleIds, UserPraiseConstant.ARTICLE_PRAISE , 1,startTimeLong, endTimeLong);
}
result.put("checkPraiseResult", grassArticlePraiseList.size() == public_count? CHECK_SUCCESS : CHECK_FAIL);
result.put("grass_praise_count", grassArticlePraiseList.size());
result.put("public_praise_count", public_count );
... ... @@ -236,7 +248,10 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
List<PublicArticle> nowPublicArticleList = publicArticleRepository.findAllByRelateIdInAndArticleTypeIn(nowArticleIds, Lists.newArrayList(5));
publicArticleId.addAll(nowPublicArticleList.stream().map(BaseEntity::getId).collect(Collectors.toList()));
}
int public_count = publicUserFavoriteRepository.countByTargetIdInAndFavoriteTypeIsAndSrcChannelIs(publicArticleId, 1 , 1);
int public_count=0;
if(!CollectionUtils.isEmpty(publicArticleId)){
public_count = publicUserFavoriteRepository.countByTargetIdInAndFavoriteTypeIsAndSrcChannelIs(publicArticleId, 1 , 1);
}
grass_favorite_count += grass_count;
public_favorite_count += public_count;
try {
... ... @@ -265,9 +280,16 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
logger.info("checkFavoriteBySelf begin, startTime is {}, endTime is {}", startTime, endTime);
Long startTimeLong = (long)startTime * 1000;
Long endTimeLong = (long)endTime * 1000;
JSONObject result = new JSONObject();
List<UserFavoriteArticle> userFavoriteArticleList = userFavoriteArticleRepository.findAllByCreateTimeBetween(
startTime, endTime);
if(userFavoriteArticleList.isEmpty()){
result.put("grass_favorite_count", userFavoriteArticleList.size());
result.put("public_favorite_count", 0 );
return result;
}
List<Integer> grassArticleIds = userFavoriteArticleList.stream().map(UserFavoriteArticle::getArticleId).collect(Collectors.toList());
List<GrassArticle> grassArticleList = grassArticleRepository.findAllByIdIn(grassArticleIds);
List<Integer> nowArticleIds = grassArticleList.stream().filter(grassArticle -> grassArticle.getArticleType()==5).map(GrassArticle::getRelateId).collect(Collectors.toList());
... ... @@ -278,8 +300,10 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
List<PublicArticle> nowPublicArticleList = publicArticleRepository.findAllByRelateIdInAndArticleTypeIn(nowArticleIds, Lists.newArrayList(5));
publicArticleIds.addAll(nowPublicArticleList.stream().map(BaseEntity::getId).collect(Collectors.toList()));
}
int public_count = publicUserFavoriteRepository.countByTargetIdInAndFavoriteTypeIsAndSrcChannelIsAndCreateTimeBetween(publicArticleIds, 1, 1,startTimeLong, endTimeLong);
JSONObject result = new JSONObject();
int public_count=0;
if(!CollectionUtils.isEmpty(publicArticleIds)){
public_count = publicUserFavoriteRepository.countByTargetIdInAndFavoriteTypeIsAndSrcChannelIsAndCreateTimeBetween(publicArticleIds, 1, 1,startTimeLong, endTimeLong);
}
result.put("checkFavoriteResult", userFavoriteArticleList.size() == public_count? CHECK_SUCCESS : CHECK_FAIL);
result.put("grass_favorite_count", userFavoriteArticleList.size());
result.put("public_favorite_count", public_count );
... ... @@ -298,11 +322,14 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
logger.info("syncUserAttention begin, startTime is {}, endTime is {}", startTime, endTime);
Long startTimeLong = (long)startTime * 1000;
Long endTimeLong = (long)endTime * 1000;
int public_count = 0;
List<GrassUserAttention> grassUserAttentionList = grassUserAttentionRepository.findAllByCreateTimeBetweenAndCreateTimeAfter(
startTime, endTime, DATA_BEGIN_TIME);
if(!grassUserAttentionList.isEmpty()){
List<Integer> uids = grassUserAttentionList.stream().map(GrassUserAttention::getUid).collect(Collectors.toList());
List<Integer> followIds = grassUserAttentionList.stream().map(GrassUserAttention::getFollowUid).collect(Collectors.toList());
int public_count = publicUserAttentionRepository.countByTargetIdInAndUidInAndAttentionTypeIsAndSrcChannelIsAndCreateTimeBetween(followIds, uids, 1,1,startTimeLong, endTimeLong);
public_count = publicUserAttentionRepository.countByTargetIdInAndUidInAndAttentionTypeIsAndSrcChannelIsAndCreateTimeBetween(followIds, uids, 1,1,startTimeLong, endTimeLong);
}
JSONObject result = new JSONObject();
result.put("checkUserAttentionResult", grassUserAttentionList.size() == public_count? CHECK_SUCCESS : CHECK_FAIL);
result.put("grass_userAttention_count", grassUserAttentionList.size());
... ... @@ -348,8 +375,10 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
List<PublicArticle> nowPublicArticleList = publicArticleRepository.findAllByRelateIdInAndArticleTypeIn(nowArticleIds, Lists.newArrayList(5));
publicArticleId.addAll(nowPublicArticleList.stream().map(BaseEntity::getId).collect(Collectors.toList()));
}
int public_count = publicUserCommentRepository.countByArticleIdInAndSrcChannelIs(publicArticleId, 1);
int public_count = 0;
if(!CollectionUtils.isEmpty(publicArticleId)){
public_count = publicUserCommentRepository.countByArticleIdInAndSrcChannelIs(publicArticleId, 1);
}
grass_comment_count += grass_count;
public_comment_count += public_count;
try {
... ... @@ -372,9 +401,17 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
logger.info("checkCommentsBySelf begin, startTime is {}, endTime is {}", startTime, endTime);
Long startTimeLong = (long)startTime * 1000;
Long endTimeLong = (long)endTime * 1000;
JSONObject result = new JSONObject();
List<GrassArticleComment> grassArticleComments = grassArticleCommentRepository.findAllByCreateTimeBetween(
startTime, endTime);
if(grassArticleComments.isEmpty()){
result.put("grass_comment_count", grassArticleComments.size());
result.put("public_comment_count", 0 );
return result;
}
List<Integer> grassArticleIds = grassArticleComments.stream().map(GrassArticleComment::getDestId).collect(Collectors.toList());
List<GrassArticle> grassArticleList = grassArticleRepository.findAllByIdIn(grassArticleIds);
List<Integer> nowArticleIds = grassArticleList.stream().filter(grassArticle -> grassArticle.getArticleType()==5).map(GrassArticle::getRelateId).collect(Collectors.toList());
... ... @@ -385,8 +422,11 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
List<PublicArticle> nowPublicArticleList = publicArticleRepository.findAllByRelateIdInAndArticleTypeIn(nowArticleIds, Lists.newArrayList(5));
publicArticleIds.addAll(nowPublicArticleList.stream().map(BaseEntity::getId).collect(Collectors.toList()));
}
int public_count = publicUserCommentRepository.countByArticleIdInAndSrcChannelIsAndCreateTimeBetween(publicArticleIds, 1,startTimeLong, endTimeLong);
JSONObject result = new JSONObject();
int public_count = 0;
if(!CollectionUtils.isEmpty(publicArticleIds)){
public_count = publicUserCommentRepository.countByArticleIdInAndSrcChannelIsAndCreateTimeBetween(publicArticleIds, 1,startTimeLong, endTimeLong);
}
result.put("checkCommentResult", grassArticleComments.size() == public_count? CHECK_SUCCESS : CHECK_FAIL);
result.put("grass_comment_count", grassArticleComments.size());
result.put("public_comment_count", public_count );
... ... @@ -419,8 +459,11 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
grass_count ++;
}
}
int public_count = 0;
if(!CollectionUtils.isEmpty(publicCommentIds)){
public_count = publicUserPraiseRepository.countByTargetIdInAndPraiseTypeIsAndSrcChannelIsAndCreateTimeBetween(publicCommentIds, 2, 1,startTimeLong,endTimeLong);
int public_count = publicUserPraiseRepository.countByTargetIdInAndPraiseTypeIsAndSrcChannelIsAndCreateTimeBetween(publicCommentIds, 2, 1,startTimeLong,endTimeLong);
}
JSONObject result = new JSONObject();
result.put("checkCommentPraiseResult", grass_count == public_count? CHECK_SUCCESS : CHECK_FAIL);
result.put("grass_count", grass_count);
... ...