use of com.ibeiliao.deployment.admin.po.stat.LowQualityRankPO in project Corgi by kevinYin.
the class LowQualityRankDaoTest method testBatchInsertAndQuery.
@Test
public void testBatchInsertAndQuery() {
Date today = new Date();
int module1Id = 6;
List<LowQualityRankPO> list = new ArrayList<>();
list.add(create(today, module1Id));
list.add(create(today, 2));
list.add(create(today, 3));
list.add(create(today, 4));
lowQualityRankDao.batchInsertOrUpdate(list);
Date startDate = DateUtil.currentStartDate();
Date endDate = DateUtil.currentEndDate();
List<LowQualityRankPO> queryResult = lowQualityRankDao.queryByDate(startDate, endDate);
assertNotNull(queryResult);
assertTrue(queryResult.size() == 1);
// 检查 on duplicate
list = new ArrayList<>();
LowQualityRankPO module1 = create(today, module1Id);
list.add(module1);
list.add(create(today, 2));
lowQualityRankDao.batchInsertOrUpdate(list);
queryResult = lowQualityRankDao.queryByDate(startDate, endDate);
boolean found = false;
for (LowQualityRankPO tmp : queryResult) {
if (tmp.getModuleId() == module1Id) {
assertTrue(tmp.getDeployTimes() == module1.getDeployTimes());
found = true;
break;
}
}
assertTrue(found);
}
use of com.ibeiliao.deployment.admin.po.stat.LowQualityRankPO in project Corgi by kevinYin.
the class StatServiceImpl method statLowQualityModule.
private void statLowQualityModule(Date startTime, Date endTime) {
List<LowQualityRank> lowQualityRanks = deployHistoryService.statLowQualityModule(startTime, endTime);
if (lowQualityRanks.isEmpty()) {
logger.warn("没有发布数据");
return;
}
List<LowQualityRankPO> list = new ArrayList<>(lowQualityRanks.size());
for (LowQualityRank rank : lowQualityRanks) {
LowQualityRankPO po = new LowQualityRankPO();
po.setModuleId(rank.getModuleId());
po.setDeployTimes(rank.getDeployTimes());
po.setStatDate(startTime);
}
lowQualityRankDao.deleteByDate(startTime);
lowQualityRankDao.batchInsertOrUpdate(list);
}
use of com.ibeiliao.deployment.admin.po.stat.LowQualityRankPO in project Corgi by kevinYin.
the class LowQualityRankDaoTest method create.
private LowQualityRankPO create(Date date, int moduleId) {
LowQualityRankPO po = new LowQualityRankPO();
po.setStatDate(date);
po.setDeployTimes(random.nextInt(1000000));
po.setModuleId(moduleId);
return po;
}
Aggregations