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) { } } }