|
@@ -6,6 +6,8 @@ import com.fs.erp.dto.GetInitTokenResponseDTO;
|
|
|
import com.fs.erp.dto.RefreshTokenRequestDTO;
|
|
|
import com.fs.erp.http.JstErpHttpService;
|
|
|
import com.fs.erp.utils.SignUtil;
|
|
|
+import com.fs.his.config.FsSysConfig;
|
|
|
+import com.fs.his.utils.ConfigUtil;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -40,6 +42,9 @@ public class JstTokenService {
|
|
|
@Autowired
|
|
|
private StringRedisTemplate redisTemplate;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ConfigUtil configUtil;
|
|
|
+
|
|
|
/**
|
|
|
* 获取访问令牌,如果缓存中存在有效令牌则直接返回,否则重新获取
|
|
|
* @return 有效的访问令牌
|
|
@@ -159,13 +164,20 @@ public class JstTokenService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 定时任务,每20天刷新一次令牌
|
|
|
+ * 定时任务,每28天凌晨3点刷新一次令牌
|
|
|
* 根据文档说明,刷新token必须在有效期小于15天时进行,所以这里设置20天刷新一次
|
|
|
*/
|
|
|
// @Scheduled(fixedRate = 20 * 24 * 60 * 60 * 1000)
|
|
|
+ @Scheduled(cron = "0 0 3 */28 * ?")
|
|
|
public void scheduleTokenRefresh() {
|
|
|
log.info("定时任务:刷新聚水潭API令牌");
|
|
|
try {
|
|
|
+ //判断是否开启erp
|
|
|
+ FsSysConfig sysConfig = configUtil.getSysConfig();
|
|
|
+ Integer erpOpen = sysConfig.getErpOpen();
|
|
|
+ if (erpOpen == null || erpOpen == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
refreshAccessToken();
|
|
|
} catch (Exception e) {
|
|
|
log.error("定时刷新令牌失败", e);
|