yujian
2019-12-19 626d711cb15896055c13fe344eb7fcc824589715
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.yeshi.fanli.job;
 
import javax.annotation.Resource;
 
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
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;
        
        long totalPage = (count / 100) + 1;
        for (long page = 0; page < totalPage; page++) {
            try {
                brandInfoService.addShopAndGoods(page * 100, 100);
            } catch (Exception e) {
               LogHelper.errorDetailInfo(e);
            }
        }
    }
    
}