package com.yeshi.fanli.job;
|
|
import javax.annotation.Resource;
|
|
import org.springframework.stereotype.Component;
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
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 * * ? ")
|
@XxlJob("brandGoodsUpdateHandler")
|
public ReturnT<String> demoJobHandler(String param) throws Exception {
|
updateGoods();
|
return ReturnT.SUCCESS;
|
}
|
|
public void updateGoods() {
|
System.out.println("品牌商品更新执行");
|
if (!Constant.IS_TASK)
|
return;
|
long startTime = java.lang.System.currentTimeMillis();
|
LogHelper.test("开始执行品牌更新---updateGoods" + startTime);
|
long count = brandInfoService.countValidByCid(null);
|
if (count == 0)
|
return;
|
|
long totalPage = (count / 100) + 1;
|
for (long page = 0; page < totalPage; page++) {
|
try {
|
brandInfoService.addShopAndGoods(page * 100, 100);
|
} catch (Exception e) {
|
LogHelper.errorDetailInfo(e);
|
}
|
}
|
long endTime = java.lang.System.currentTimeMillis();
|
LogHelper.test("结束执行品牌更新---updateGoods" + endTime + ",总耗时:" + (endTime - startTime) / 1000);
|
}
|
|
}
|