Authored by wangnan

商品人气值获取方式修改 fix

... ... @@ -2,7 +2,7 @@ package com.yoho.search.consumer.job;
import com.yoho.search.base.utils.DateStyle;
import com.yoho.search.base.utils.DateUtil;
import com.yoho.search.dal.ProductHeatValueMapper;
import com.yoho.search.dal.ProductHeatValuesMapper;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -21,40 +21,41 @@ public class ProductHeatValueJob {
private static final Logger logger = LoggerFactory.getLogger(ProductHeatValueJob.class);
@Autowired
private ProductHeatValueMapper productHeatValueMapper;
private ProductHeatValuesMapper productHeatValuesMapper;
private static final int CLEAN_BATCH_COUNT = 1000;
// /**
// * 每隔半个小时,更新一次数据到索引中
// */
// @Scheduled(cron = "0 0/30 * * * ?")
// public void doUpdateProductIndexHeatValue() {
// long begin = System.currentTimeMillis();
// logger.info("ProductHeatValueJob.doUpdateProductIndexHeatValue start----[begin={}]", begin);
// RetryBusinessFlowExecutor flowExecutor = new RetryBusinessFlowExecutor(productIndexHeatValueUpdateFlow, ISearchConstants.SEARCH_INDEX_BATCH_MAX_THREAD_SIZE, ISearchConstants.SEARCH_INDEX_BATCH_LIMIT);
// boolean result = flowExecutor.execute();
// logger.info("ProductHeatValueJob.doUpdateProductIndexHeatValue end----[result={}][cost={}]", result, System.currentTimeMillis() - begin);
// }
/**
* 每天1点,删除三天前那天的数据
*/
@Scheduled(cron = "0 0 1 * * ?")
public void clean() {
long begin = System.currentTimeMillis();
logger.info("ProductHeatValueJob.clean start----[begin={}]", begin);
logger.info("ProductHeatValuesJob.clean start----[begin={}]", begin);
// 默认取前三天
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH, -3);
calendar.set(Calendar.HOUR_OF_DAY, 0);
String generateDateStr = DateUtil.DateToString(calendar.getTime(), DateStyle.YYYYMMDD);
List<Long> sknList = productHeatValueMapper.selectSknByDate(generateDateStr, CLEAN_BATCH_COUNT);
List<Long> sknList = productHeatValuesMapper.selectSknByDate(generateDateStr, CLEAN_BATCH_COUNT);
while (CollectionUtils.isNotEmpty(sknList)) {
productHeatValueMapper.deleteBatch(sknList,generateDateStr);
sknList = productHeatValueMapper.selectSknByDate(generateDateStr, CLEAN_BATCH_COUNT);
productHeatValuesMapper.deleteBatch(sknList, generateDateStr);
sknList = productHeatValuesMapper.selectSknByDate(generateDateStr, CLEAN_BATCH_COUNT);
}
logger.info("ProductHeatValueJob.clean end----[clearDateStr={}][cost={}]", generateDateStr, System.currentTimeMillis() - begin);
logger.info("ProductHeatValueJobs.clean end----[clearDateStr={}][cost={}]", generateDateStr, System.currentTimeMillis() - begin);
}
// /**
// * 每隔半个小时,更新一次数据到索引中
// */
// @Scheduled(cron = "0 0/30 * * * ?")
// public void doUpdateProductIndexHeatValue() {
// long begin = System.currentTimeMillis();
// logger.info("ProductHeatValueJob.doUpdateProductIndexHeatValue start----[begin={}]", begin);
// RetryBusinessFlowExecutor flowExecutor = new RetryBusinessFlowExecutor(productIndexHeatValueUpdateFlow, ISearchConstants.SEARCH_INDEX_BATCH_MAX_THREAD_SIZE, ISearchConstants.SEARCH_INDEX_BATCH_LIMIT);
// boolean result = flowExecutor.execute();
// logger.info("ProductHeatValueJob.doUpdateProductIndexHeatValue end----[result={}][cost={}]", result, System.currentTimeMillis() - begin);
// }
}
... ...