admin
2019-05-22 6eee4b9602f02664bfc4c55ae36583a1f419f73b
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package com.yeshi.fanli.job;
 
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import com.yeshi.fanli.entity.bus.lable.BoutiqueAutoRule;
import com.yeshi.fanli.entity.bus.lable.QualityFactory;
import com.yeshi.fanli.entity.common.AdminUser;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
 
/**
 * 更新大淘客数据
 */
 
@Component
public class UpdateDaTaoKeJob {
 
    @Resource
    private QualityFactoryService qualityFactoryService;
 
    @Resource
    private DaTaoKeGoodsDetailService daTaoKeGoodsService;
 
    // 两小时执行一次 对商品信息进行更新
    @Scheduled(cron = "0 0 0/2 * * ?")
    public void doUpdateJob() {
 
        if (!Constant.IS_TASK)
            return;
 
        List<TaoBaoGoodsBrief> listgoods = DaTaoKeUtil.getDingDongQiang();
        if (listgoods == null || listgoods.size() == 0) {
            return;
        }
 
        try {
            /* 操作人: 开发账号 */
            AdminUser admin = new AdminUser(2L);
            BoutiqueAutoRule autoRule = new BoutiqueAutoRule();
            autoRule.setAdminUser(admin);
            autoRule.setCalss9k9(false);
            autoRule.setFlashSale(true);
            autoRule.setStartWeight(1);
            autoRule.setEndWeight(3000);
            autoRule.setGoodsSource(QualityFactory.SOURCE_TAOBAO_DATAOKE);
            qualityFactoryService.autoInsertOrUpadateStorage(listgoods, null, autoRule);
 
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
 
    }
 
    // 20分钟更新一次
    @Scheduled(cron = "0 0/20 * * * ? ")
    public void doSyncJob() {
        if (!Constant.IS_TASK)
            return;
        try {
            new Thread(new Runnable() {
 
                @Override
                public void run() {
                    daTaoKeGoodsService.startSyncGoods();
                }
            }).start();
 
        } catch (Exception e) {
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
 
}