find bug of schedule

This commit is contained in:
chen 2022-05-07 18:22:23 +09:00
parent e9b10304c7
commit efa1628019
4 changed files with 25 additions and 5 deletions

View File

@ -47,6 +47,9 @@ public class DailyIncomeStaSchedule {
//获取昨天的结束时间 //获取昨天的结束时间
Date endTime = DateUtil.getDateEndTime(yesterday); Date endTime = DateUtil.getDateEndTime(yesterday);
//每次查询作家的最后一个主键id
long lastAuthorId = -1;
//每次查询的作家数量 //每次查询的作家数量
int needAuthorNumber = 10; int needAuthorNumber = 10;
//查询出来的真实作家数量 //查询出来的真实作家数量
@ -55,8 +58,15 @@ public class DailyIncomeStaSchedule {
Date maxAuthorCreateTime = new Date(); Date maxAuthorCreateTime = new Date();
do { do {
//1.查询作家列表 //1.查询作家列表
List<Author> authors = authorService.queryAuthorList(needAuthorNumber, maxAuthorCreateTime); List<Author> authors = authorService.queryAuthorList(needAuthorNumber, maxAuthorCreateTime, lastAuthorId);
//本次查询到的真实作者数量
realAuthorNumber = authors.size(); realAuthorNumber = authors.size();
//本次查询到的作者最后一个id用于下次查询传入
if(realAuthorNumber != 0){
Author author = authors.get(realAuthorNumber - 1);
lastAuthorId = author.getId();
}
for (Author author : authors) { for (Author author : authors) {
maxAuthorCreateTime = author.getCreateTime(); maxAuthorCreateTime = author.getCreateTime();
Long authorId = author.getId(); Long authorId = author.getId();

View File

@ -41,6 +41,9 @@ public class MonthIncomeStaSchedule {
Date startTime = DateUtil.getLastMonthStartTime(); Date startTime = DateUtil.getLastMonthStartTime();
Date endTime = DateUtil.getLastMonthEndTime(); Date endTime = DateUtil.getLastMonthEndTime();
//每次查询作家的最后一个主键id
long lastAuthorId = -1;
//每次查询的作家数量 //每次查询的作家数量
int needAuthorNumber = 10; int needAuthorNumber = 10;
//查询出来的真实作家数量 //查询出来的真实作家数量
@ -49,8 +52,14 @@ public class MonthIncomeStaSchedule {
Date maxAuthorCreateTime = new Date(); Date maxAuthorCreateTime = new Date();
do { do {
//1.查询作家列表 //1.查询作家列表
List<Author> authors = authorService.queryAuthorList(needAuthorNumber, maxAuthorCreateTime); List<Author> authors = authorService.queryAuthorList(needAuthorNumber, maxAuthorCreateTime, lastAuthorId);
//本次查询到的真实作者数量
realAuthorNumber = authors.size(); realAuthorNumber = authors.size();
//本次查询到的作者最后一个id用于下次查询传入
if(realAuthorNumber != 0){
Author author = authors.get(realAuthorNumber - 1);
lastAuthorId = author.getId();
}
for (Author author : authors) { for (Author author : authors) {
maxAuthorCreateTime = author.getCreateTime(); maxAuthorCreateTime = author.getCreateTime();
Long authorId = author.getId(); Long authorId = author.getId();

View File

@ -48,8 +48,9 @@ public interface AuthorService {
* @return 作家列表 * @return 作家列表
* @param limit 查询条数 * @param limit 查询条数
* @param maxAuthorCreateTime 最大申请时间 * @param maxAuthorCreateTime 最大申请时间
* @param fromAuthorId 从第几个id开始查询不包含此id
*/ */
List<Author> queryAuthorList(int limit, Date maxAuthorCreateTime); List<Author> queryAuthorList(int limit, Date maxAuthorCreateTime, long fromAuthorId);
/** /**
* 查询收入日统计是否入库 * 查询收入日统计是否入库

View File

@ -101,11 +101,11 @@ public class AuthorServiceImpl implements AuthorService {
} }
@Override @Override
public List<Author> queryAuthorList(int needAuthorNumber, Date maxAuthorCreateTime) { public List<Author> queryAuthorList(int needAuthorNumber, Date maxAuthorCreateTime, long lastAuthorId) {
return authorMapper.selectMany(select(AuthorDynamicSqlSupport.id, AuthorDynamicSqlSupport.userId) return authorMapper.selectMany(select(AuthorDynamicSqlSupport.id, AuthorDynamicSqlSupport.userId)
.from(AuthorDynamicSqlSupport.author) .from(AuthorDynamicSqlSupport.author)
.where(AuthorDynamicSqlSupport.id, isGreaterThan(lastAuthorId))
.where(AuthorDynamicSqlSupport.createTime, isLessThan(maxAuthorCreateTime)) .where(AuthorDynamicSqlSupport.createTime, isLessThan(maxAuthorCreateTime))
.orderBy(AuthorDynamicSqlSupport.createTime.descending())
.limit(needAuthorNumber) .limit(needAuthorNumber)
.build() .build()
.render(RenderingStrategies.MYBATIS3)); .render(RenderingStrategies.MYBATIS3));