nidapeng
2024-04-29 61e4855523392fc3f84e3d8745320c10d29bed4f
server/visits/admin_timer/src/main/java/com/doumee/api/WxTokenTimerController.java
ÎļþÃû´Ó server/visits/dmvisit_web/src/main/java/com/doumee/api/ScheduleTool.java ÐÞ¸Ä
@@ -1,45 +1,37 @@
package com.doumee.api;
import com.alibaba.fastjson.JSONObject;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.model.ApiResponse;
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.business.impl.hksync.HkSyncVisitServiceImpl;
import com.doumee.service.business.impl.hksync.fhk.HkSyncVisitFromHKServiceImpl;
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.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.net.URI;
import java.util.Date;
import java.util.Map;
import java.util.Objects;
/**
 * å®šæ—¶ä»»åŠ¡
 * @author jiangping
 * @date 2021-10-10 14:40:35
 * https://www.bejson.com/othertools/cron/  cron è¡¨è¾¾å¼ç”Ÿæˆåœ°å€
 * @author æ±Ÿè¹„蹄
 * @date 2023/11/30 15:33
 */
//@Component
//@EnableScheduling
@Slf4j
public class ScheduleTool {
@Api(tags = "微信token定时器接口")
@RestController
@RequestMapping("/timer/wxtoken")
public class WxTokenTimerController extends BaseController {
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
@@ -50,13 +42,9 @@
     */
    @Value("${debug_model}")
    private Boolean timing;
    /**
     * æ›´æ–°å¾®ä¿¡å…¬ä¼—号 ACCESS_TOKEN
     * @throws Exception
     */
    @Scheduled(fixedDelay=1000 * 60 * 90)
    public void updAccessToken(){
    @ApiOperation("开启定时更新微信公众号accesstoken")
    @GetMapping("/updateWxAccessToken")
    public ApiResponse updateWxAccessToken() {
        DefaultSecurityManager securityManager = new DefaultSecurityManager();
        SecurityUtils.setSecurityManager(securityManager);
@@ -72,8 +60,8 @@
            systemDictData.setCode(json.getString("access_token"));
            systemDictData.setUpdateTime(new Date());
            systemDictDataService.updateById(systemDictData);
            log.info(" æ›´æ–°å¾®ä¿¡å…¬ä¼—号 ACCESS_TOKEN =========> " + systemDictData.getCode() );
        }
        return ApiResponse.success("开启定时更新微信公众号accesstoken成功");
    }