|  |  | 
 |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
 |  |  | import com.doumee.core.utils.Constants; | 
 |  |  | 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; | 
 |  |  | 
 |  |  |     @Value("${debug_model}") | 
 |  |  |     private Boolean timing; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 更新微信公众号 ACCESS_TOKEN | 
 |  |  |      * @throws Exception | 
 |  |  |      */ | 
 |  |  |     @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 | 
 |  |  |         String url = WXConstant.GET_ACCESS_TOKEN_URL.replace("APPID",appId).replace("APPSECRET",appSecret); | 
 |  |  |         String response = HttpsUtil.get(url,false); | 
 |  |  |         JSONObject json = JSONObject.parseObject(response); | 
 |  |  |         System.out.println(json); | 
 |  |  |         SystemDictData systemDictData =  systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN); | 
 |  |  |         if(!Objects.isNull(systemDictData)){ | 
 |  |  |             systemDictData.setCode(json.getString("access_token")); | 
 |  |  |             systemDictData.setUpdateTime(new Date()); | 
 |  |  |             systemDictDataService.updateById(systemDictData); | 
 |  |  |             log.info(" 更新微信公众号 ACCESS_TOKEN =========> " + systemDictData.getCode() ); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  |