admin
2021-01-04 aa6ef62aef83e277d4171df1d9f0803f91738216
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
package com.newvideo.job;
 
import com.newvideo.domain.Config;
import com.newvideo.service.imp.ConfigService;
import com.newvideo.service.imp.StatisticsService;
import com.newvideo.util.Constant;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.yeshi.utils.AppMarketUtil;
import org.yeshi.utils.StringUtil;
 
import javax.annotation.Resource;
 
/**
 * @author Administrator
 */
@Component
public class AdJob {
 
    @Resource
    private ConfigService configService;
 
    @Scheduled(cron = "0 0/20 * * * ? ")
    public void checkHuaWeiOnLine() {
        try {
            Config config = configService.getConfigByKey("huawei_online_version_name");
            if (config != null) {
                //应用市场的版本
                String appId = "10458566";
                String onLineVersion = AppMarketUtil.getHWLatestVersion(appId);
                if (StringUtil.isNullOrEmpty(onLineVersion)) {
                    throw new Exception("应用市场版本获取失败:" + appId);
                }
                String onLiningVersionName = config.getValue();
                if (Integer.parseInt(onLineVersion.replace(".", "")) >= Integer.parseInt(onLiningVersionName.replace(".", ""))) {
                    //升一个版本
                    Config versionConfig = configService.getConfigByKey("huawei_online_version");
                    versionConfig.setValue((Integer.parseInt(versionConfig.getValue()) + 1) + "");
                    configService.updateConfig(versionConfig);
                }
            }
        } catch (Exception e) {
 
        }
 
 
    }
}