|  |  |  | 
|---|
|  |  |  | import com.doumee.core.utils.HttpsUtil; | 
|---|
|  |  |  | import com.doumee.core.wx.WXConstant; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemDictData; | 
|---|
|  |  |  | import com.doumee.service.system.SystemDictDataService; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.http.client.methods.CloseableHttpResponse; | 
|---|
|  |  |  | import org.apache.http.client.methods.HttpGet; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.apache.http.impl.client.CloseableHttpClient; | 
|---|
|  |  |  | import org.apache.http.impl.client.HttpClients; | 
|---|
|  |  |  | import org.apache.http.util.EntityUtils; | 
|---|
|  |  |  | import org.apache.shiro.SecurityUtils; | 
|---|
|  |  |  | import org.apache.shiro.mgt.DefaultSecurityManager; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
|---|
|  |  |  | import org.springframework.scheduling.annotation.EnableScheduling; | 
|---|
|  |  |  | 
|---|
|  |  |  | * @date 2021-10-10 14:40:35 | 
|---|
|  |  |  | * https://www.bejson.com/othertools/cron/  cron 表达式生成地址 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Component | 
|---|
|  |  |  | @EnableScheduling | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | public class ScheduleTool { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemDictDataService systemDictDataService; | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 是否开发者 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Value("${timing}") | 
|---|
|  |  |  | @Value("${debug_model}") | 
|---|
|  |  |  | private Boolean timing; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Scheduled(fixedDelay=1000 * 60 * 90) | 
|---|
|  |  |  | public void updAccessToken(){ | 
|---|
|  |  |  | DefaultSecurityManager securityManager = new DefaultSecurityManager(); | 
|---|
|  |  |  | SecurityUtils.setSecurityManager(securityManager); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String appId = systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_APPID).getCode(); | 
|---|
|  |  |  | String appSecret = systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_SECRET).getCode(); | 
|---|
|  |  |  | //生成微信token | 
|---|
|  |  |  | 
|---|
|  |  |  | if(!Objects.isNull(systemDictData)){ | 
|---|
|  |  |  | systemDictData.setCode(json.getString("access_token")); | 
|---|
|  |  |  | systemDictData.setUpdateTime(new Date()); | 
|---|
|  |  |  | systemDictDataBiz.updateByIdNew(systemDictData); | 
|---|
|  |  |  | systemDictDataService.updateById(systemDictData); | 
|---|
|  |  |  | log.info(" 更新微信公众号 ACCESS_TOKEN =========> " + systemDictData.getCode() ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|