Authored by Zhao

rebuildjob添加历史价格的逻辑

package com.yoho.search.consumer.job;
import com.yoho.search.dal.ProductPriceHistoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class HistoryPriceJob {
@Autowired
private ProductPriceHistoryMapper productPriceHistoryMapper;
@Scheduled(cron = "0 30 2 * * ?")
public void updateHistoryPriceTask () {
productPriceHistoryMapper.backupHistoryPrice();
productPriceHistoryMapper.updateCurrentPrice();
}
}
package com.yoho.search.consumer.job;
import com.yoho.search.consumer.service.base.ProductPriceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -22,6 +23,8 @@ public class IndexRebuildJob implements ApplicationEventPublisherAware {
private IYohoIndexService yohoIndexService;
@Autowired
private RebuildFlagService rebuildFlagService;
@Autowired
private ProductPriceService productPriceService;
private static final Logger logger = LoggerFactory.getLogger(IndexRebuildJob.class);
... ... @@ -33,6 +36,11 @@ public class IndexRebuildJob implements ApplicationEventPublisherAware {
}
@Scheduled(cron = "0 0 3 * * ?")
public void rebuildIndexTask() {
productPriceService.batchUpdateHistoryPrice();
execute();
}
public void execute() {
long begin = System.currentTimeMillis();
logger.info("indexRebuildJob execute start----[begin={}]", begin);
... ...
... ... @@ -76,4 +76,10 @@ public class ProductPriceService {
public List<ProductPriceHistory> selectProductPriceHistorys(List<Integer> sknList) {
return productPriceHistoryMapper.selectByPrimaryKeyList(sknList);
}
public void batchUpdateHistoryPrice () {
productPriceHistoryMapper.backupHistoryPrice();
productPriceHistoryMapper.updateCurrentPrice();
}
}
... ...