use of mingzuozhibi.persist.disc.Disc in project mzzb-server by mingzuozhibi.
the class HourlyMission method recordDiscsRankAndComputePt.
public void recordDiscsRankAndComputePt() {
// +9 timezone and prev hour, so +1h -1h = +0h
LocalDateTime recordTime = LocalDateTime.now();
LocalDate date = recordTime.toLocalDate();
int hour = recordTime.getHour();
dao.execute(session -> {
@SuppressWarnings("unchecked") List<Sakura> sakuras = session.createCriteria(Sakura.class).add(Restrictions.ne("key", "9999-99")).add(Restrictions.eq("enabled", true)).list();
Set<Disc> discs = new LinkedHashSet<>();
sakuras.forEach(sakura -> {
sakura.getDiscs().stream().filter(disc -> disc.getUpdateType() != UpdateType.None).filter(SakuraHelper::noExpiredDisc).forEach(discs::add);
});
LOGGER.info("[定时任务][记录碟片排名][碟片数量为:{}]", discs.size());
discs.forEach(disc -> {
Record record = getOrCreateRecord(dao, disc, date);
record.setRank(hour, disc.getThisRank());
record.setTotalPt(disc.getTotalPt());
});
LOGGER.info("[定时任务][计算碟片PT][碟片数量为:{}]", discs.size());
discs.forEach(disc -> {
if (disc.getUpdateType() != UpdateType.Sakura) {
computeAndUpdateAmazonPt(dao, disc);
} else {
computeAndUpdateSakuraPt(dao, disc);
}
});
});
}
Aggregations