Authored by 张帅

检查接口分页

... ... @@ -12,6 +12,8 @@ import com.yoho.datasync.fullsync.service.IGrassArticleDataCheckService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 java.util.*;
... ... @@ -62,11 +64,23 @@ public class GrassArticleDataCheckServiceImpl implements IGrassArticleDataCheckS
@Override
public JSONObject checkArticleData(Long startTime, Long endTime) {
int grassArticleTotal = grassArticleRepository.countByCreateTimeAfterAndCreateTimeBeforeAndArticleTypeInAndAuthStatusIn(startTime, endTime,needSyncArticleType,needSyncArticleStatus);
logger.info("checkArticleData , get grassArticleTotal is {}", grassArticleTotal);
List<GrassArticle> grassArticleList = grassArticleRepository.findAllByCreateTimeAfterAndCreateTimeBeforeAndArticleTypeInAndAuthStatusIn(
startTime, endTime,needSyncArticleType,needSyncArticleStatus);
List<Integer> grassArticleIds = grassArticleList.stream().map(BaseEntity::getId).collect(Collectors.toList());
int total = grassArticleRepository.countByCreateTimeAfterAndCreateTimeBeforeAndArticleTypeInAndAuthStatusIn(startTime, endTime, needSyncArticleType, needSyncArticleStatus);
int pageSize = 100;
int totalPage = total % pageSize ==0 ? total / pageSize : (total / pageSize)+1;
logger.info("checkArticleData , get grassArticleTotal is {}", total);
List<Integer> grassArticleIds = Lists.newArrayList();
for (int i = 0; i < totalPage; i++) {
Pageable pageReq = PageRequest.of(i, pageSize);
List<GrassArticle> grassArticleList = grassArticleRepository.findAllByCreateTimeAfterAndCreateTimeBeforeAndArticleTypeInAndAuthStatusIn(
startTime, endTime,needSyncArticleType,needSyncArticleStatus,pageReq);
List<Integer> grassArticleId = grassArticleList.stream().map(BaseEntity::getId).collect(Collectors.toList());
grassArticleIds.addAll(grassArticleId);
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
List<PublicArticle> publicArticleList = publicArticleRepository.findAllByRelateIdInAndArticleTypeIn(grassArticleIds, needSyncArticleType);
List<Integer> publicArticleIds = publicArticleList.stream().map(BaseEntity::getId).collect(Collectors.toList());
... ... @@ -75,7 +89,7 @@ public class GrassArticleDataCheckServiceImpl implements IGrassArticleDataCheckS
JSONObject result = new JSONObject();
JSONArray data = new JSONArray();
data.add(checkArticle(grassArticleTotal, publicCount));
data.add(checkArticle(total, publicCount));
data.add(checkArticleBlock(grassArticleIds, publicArticleIds));
data.add(checkArticleProduct(grassArticleIds, publicArticleIds));
data.add(checkArticleLabel(grassArticleIds, publicArticleIds));
... ...
... ... @@ -142,7 +142,7 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
int pageSize = 100;
int totalPage = total % pageSize ==0 ? total / pageSize : (total / pageSize)+1;
int grass_praise_count=0;
List<Integer> publicArticleIds = Lists.newArrayList();
int public_praise_count=0;
for (int i = 0; i < totalPage; i++) {
Pageable pageReq = PageRequest.of(i, pageSize);
List<GrassArticle> grassArticleList = grassArticleRepository.findAllByCreateTimeAfterAndCreateTimeBeforeAndArticleTypeInAndAuthStatusIn(
... ... @@ -156,7 +156,8 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
List<PublicArticle> nowPublicArticleList = publicArticleRepository.findAllByRelateIdInAndArticleTypeIn(nowArticleIds, Lists.newArrayList(5));
publicArticleId.addAll(nowPublicArticleList.stream().map(BaseEntity::getId).collect(Collectors.toList()));
}
publicArticleIds.addAll(publicArticleId);
int public_count = publicUserPraiseRepository.countByTargetIdInAndPraiseTypeIsAndSrcChannelIs(publicArticleId, UserPraiseConstant.ARTICLE_PRAISE , 1);
public_praise_count +=public_count;
grass_praise_count +=grass_count;
try {
Thread.sleep(200);
... ... @@ -167,11 +168,10 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
int public_count = publicUserPraiseRepository.countByTargetIdInAndPraiseTypeIsAndSrcChannelIs(publicArticleIds, UserPraiseConstant.ARTICLE_PRAISE , 1);
JSONObject result = new JSONObject();
result.put("checkPraiseResult", grass_praise_count == public_count? CHECK_SUCCESS : CHECK_FAIL);
result.put("checkPraiseResult", grass_praise_count == public_praise_count? CHECK_SUCCESS : CHECK_FAIL);
result.put("grass_praise_count", grass_praise_count );
result.put("public_praise_count", public_count );
result.put("public_praise_count", public_praise_count );
return result;
}
... ... @@ -219,7 +219,7 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
int pageSize = 100;
int totalPage = total % pageSize ==0 ? total / pageSize : (total / pageSize)+1;
int grass_favorite_count = 0;
List<Integer> publicArticleIds = Lists.newArrayList();
int public_favorite_count = 0;
for (int i = 0; i < totalPage; i++) {
Pageable pageReq = PageRequest.of(i, pageSize);
... ... @@ -236,16 +236,21 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
List<PublicArticle> nowPublicArticleList = publicArticleRepository.findAllByRelateIdInAndArticleTypeIn(nowArticleIds, Lists.newArrayList(5));
publicArticleId.addAll(nowPublicArticleList.stream().map(BaseEntity::getId).collect(Collectors.toList()));
}
publicArticleIds.addAll(publicArticleId);
int public_count = publicUserFavoriteRepository.countByTargetIdInAndFavoriteTypeIsAndSrcChannelIs(publicArticleId, 1 , 1);
grass_favorite_count += grass_count;
public_favorite_count += public_count;
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
int public_count = publicUserFavoriteRepository.countByTargetIdInAndFavoriteTypeIsAndSrcChannelIs(publicArticleIds, 1 , 1);
JSONObject result = new JSONObject();
result.put("checkFavoriteResult", grass_favorite_count == public_count? CHECK_SUCCESS : CHECK_FAIL);
result.put("checkFavoriteResult", grass_favorite_count == public_favorite_count? CHECK_SUCCESS : CHECK_FAIL);
result.put("grass_favorite_count", grass_favorite_count );
result.put("public_favorite_count", public_count );
result.put("public_favorite_count", public_favorite_count );
return result;
}
... ... @@ -324,7 +329,7 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
int total = grassArticleRepository.countByCreateTimeAfterAndCreateTimeBeforeAndArticleTypeInAndAuthStatusIn(startTimeLong, endTimeLong,needSyncArticleType,needSyncArticleStatus);
int totalPage = total % pageSize ==0 ? total / pageSize : (total / pageSize)+1;
int grass_comment_count = 0;
List<Integer> publicArticleIds = Lists.newArrayList();
int public_comment_count = 0;
for (int i = 0; i < totalPage; i++) {
Pageable pageReq = PageRequest.of(i, pageSize);
... ... @@ -343,16 +348,22 @@ public class GrassInteractiveDataCheckServiceImpl implements IGrassInteractiveDa
List<PublicArticle> nowPublicArticleList = publicArticleRepository.findAllByRelateIdInAndArticleTypeIn(nowArticleIds, Lists.newArrayList(5));
publicArticleId.addAll(nowPublicArticleList.stream().map(BaseEntity::getId).collect(Collectors.toList()));
}
publicArticleIds.addAll(publicArticleId);
int public_count = publicUserCommentRepository.countByArticleIdInAndSrcChannelIs(publicArticleId, 1);
grass_comment_count += grass_count;
public_comment_count += public_count;
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
int public_count = publicUserCommentRepository.countByArticleIdInAndSrcChannelIs(publicArticleIds, 1);
JSONObject result = new JSONObject();
result.put("checkCommentResult", grass_comment_count == public_count? CHECK_SUCCESS : CHECK_FAIL);
result.put("checkCommentResult", grass_comment_count == public_comment_count? CHECK_SUCCESS : CHECK_FAIL);
result.put("grass_comment_count", grass_comment_count);
result.put("public_comment_count", public_count );
result.put("public_comment_count", public_comment_count );
return result;
}
... ...