package com.yeshi.fanli.job;
|
|
import java.util.Date;
|
|
import javax.annotation.Resource;
|
|
import org.springframework.stereotype.Component;
|
import org.yeshi.utils.DateUtil;
|
|
import com.yeshi.fanli.log.LogHelper;
|
import com.yeshi.fanli.service.inter.brand.BrandInfoService;
|
import com.yeshi.fanli.util.Constant;
|
|
/**
|
* 品牌信息更新
|
*
|
* @author Administrator
|
*
|
*/
|
@Component
|
public class BrandInfoJob {
|
|
@Resource
|
private BrandInfoService brandInfoService;
|
|
/**
|
* 每两个小时进行更新品牌商品信息
|
*/
|
// @Scheduled(cron = "0 0 1/2 * * ? ")
|
public void updateGoods() {
|
if (!Constant.IS_TASK)
|
return;
|
|
long count = brandInfoService.countValidByCid(null);
|
if (count == 0)
|
return;
|
|
for (int page = 1; page < (count / 100) + 1; page++) {
|
brandInfoService.addShopAndGoods((page - 1) * 100, 100);
|
}
|
}
|
|
/**
|
* 清理前一天的
|
*/
|
// @Scheduled(cron = "0 30 0 * * ? ")
|
public void removeAgoByDate() {
|
if (!Constant.IS_TASK)
|
return;
|
|
try {
|
brandInfoService.removeAgoByDate(DateUtil.reduceDay(1, new Date()));
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
|
}
|