|
@@ -47,8 +47,8 @@ public class StatisticsTask {
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.setTime(new Date());
|
|
|
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
- Date countTime = calendar.getTime();
|
|
|
- String dateStr = new SimpleDateFormat("yyyyMMdd").format(countTime);
|
|
|
+ Date viewTime = calendar.getTime();
|
|
|
+ String dateStr = new SimpleDateFormat("yyyyMMdd").format(viewTime);
|
|
|
log.info(">>>>>>>>>>>【定时任务】统计前一天商品详情访问量,统计日期(前一天):" + dateStr);
|
|
|
// 获取Redis的Key: @Statistics(prefix = "statistics_details", field = "productId")
|
|
|
String redisKey = "statistics_details:productId:" + dateStr;
|
|
@@ -62,10 +62,11 @@ public class StatisticsTask {
|
|
|
if (null != entry && StringUtils.isNotEmpty(entry.getKey()) && StringUtils.isNotEmpty(entry.getValue())) {
|
|
|
Integer productId = Integer.parseInt(entry.getKey());
|
|
|
Integer views = Integer.parseInt(entry.getValue());
|
|
|
- baseMapper.insertProductViews(productId, views, countTime);
|
|
|
+ baseMapper.insertProductViews(productId, views, viewTime);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ log.info(">>>>>>>>>>>【定时任务】统计前一天商品详情访问量,统计成功:" + result);
|
|
|
} catch (Exception e) {
|
|
|
log.error(">>>>>>>>>>>【定时任务】统计前一天商品详情访问量失败:",e);
|
|
|
}
|