|
|
@ -54,6 +54,8 @@ public class SyncReportJob {
|
|
|
|
private LarkTableHelper larkTableHelper;
|
|
|
|
private LarkTableHelper larkTableHelper;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private LarkRobotHelper larkRobotHelper;
|
|
|
|
private LarkRobotHelper larkRobotHelper;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private RefreshTokenJob refreshTokenJob;
|
|
|
|
@Value("${lark.robot.group}")
|
|
|
|
@Value("${lark.robot.group}")
|
|
|
|
private String ROBOT_GROUP;
|
|
|
|
private String ROBOT_GROUP;
|
|
|
|
@Value("${sync.flag}")
|
|
|
|
@Value("${sync.flag}")
|
|
|
@ -94,7 +96,7 @@ public class SyncReportJob {
|
|
|
|
//初始化飞书信息及相关配置
|
|
|
|
//初始化飞书信息及相关配置
|
|
|
|
initLarkInfo(context);
|
|
|
|
initLarkInfo(context);
|
|
|
|
//重置ticket
|
|
|
|
//重置ticket
|
|
|
|
resetTicket(context);
|
|
|
|
// resetTicket(context);
|
|
|
|
// preSync(context);
|
|
|
|
// preSync(context);
|
|
|
|
cleanTableDate(context);
|
|
|
|
cleanTableDate(context);
|
|
|
|
//执行分页同步
|
|
|
|
//执行分页同步
|
|
|
@ -382,31 +384,44 @@ public class SyncReportJob {
|
|
|
|
context.setTicket(ticket);
|
|
|
|
context.setTicket(ticket);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 生成调用接口的token信息
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String generateToken(CJTJobContext context) {
|
|
|
|
private String generateToken(CJTJobContext context) {
|
|
|
|
String tokenCacheKey = buildCacheUniqueKey(RedisConstants.CJT_TOKEN_CACHE_KEY, context.getAppKey());
|
|
|
|
String tokenCacheKey = buildCacheUniqueKey(RedisConstants.CJT_TOKEN_CACHE_KEY, context.getAppKey());
|
|
|
|
String openToken = (String) redisCache.getCacheObject(tokenCacheKey);
|
|
|
|
String openToken = (String) redisCache.getCacheObject(tokenCacheKey);
|
|
|
|
if (StringUtils.isBlank(openToken)) {
|
|
|
|
if (org.springframework.util.StringUtils.isEmpty(openToken)) {
|
|
|
|
CJTRequest cjtRequest = new CJTRequest(REQUEST_GENERATE_TOKEN_PATH
|
|
|
|
CjtAccountEnum cjtAccountEnum = cjtAccount(context.getCjt());
|
|
|
|
, context.getAppKey()
|
|
|
|
refreshTokenJob.waitForToken(cjtAccountEnum);
|
|
|
|
, context.getAppSecret()
|
|
|
|
return refreshTokenJob.getToken(cjtAccountEnum);
|
|
|
|
, context.getTicket()
|
|
|
|
|
|
|
|
, context.getCertificate());
|
|
|
|
|
|
|
|
cjtRequest.buildGenerateBody();
|
|
|
|
|
|
|
|
JSONObject body = JSONObject.parseObject(post(cjtRequest));
|
|
|
|
|
|
|
|
JSONObject value = body.getJSONObject("value");
|
|
|
|
|
|
|
|
String token = value.getString("accessToken");
|
|
|
|
|
|
|
|
context.setOpenToken(token);
|
|
|
|
|
|
|
|
redisCache.setCacheObject(tokenCacheKey, token, 5, TimeUnit.MINUTES);
|
|
|
|
|
|
|
|
return token;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
context.setOpenToken(openToken);
|
|
|
|
context.setOpenToken(openToken);
|
|
|
|
return openToken;
|
|
|
|
return openToken;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 生成调用接口的token信息
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
// private String generateToken(CJTJobContext context) {
|
|
|
|
|
|
|
|
// String tokenCacheKey = buildCacheUniqueKey(RedisConstants.CJT_TOKEN_CACHE_KEY, context.getAppKey());
|
|
|
|
|
|
|
|
// String openToken = (String) redisCache.getCacheObject(tokenCacheKey);
|
|
|
|
|
|
|
|
// if (StringUtils.isBlank(openToken)) {
|
|
|
|
|
|
|
|
// CJTRequest cjtRequest = new CJTRequest(REQUEST_GENERATE_TOKEN_PATH
|
|
|
|
|
|
|
|
// , context.getAppKey()
|
|
|
|
|
|
|
|
// , context.getAppSecret()
|
|
|
|
|
|
|
|
// , context.getTicket()
|
|
|
|
|
|
|
|
// , context.getCertificate());
|
|
|
|
|
|
|
|
// cjtRequest.buildGenerateBody();
|
|
|
|
|
|
|
|
// JSONObject body = JSONObject.parseObject(post(cjtRequest));
|
|
|
|
|
|
|
|
// JSONObject value = body.getJSONObject("value");
|
|
|
|
|
|
|
|
// String token = value.getString("accessToken");
|
|
|
|
|
|
|
|
// context.setOpenToken(token);
|
|
|
|
|
|
|
|
// redisCache.setCacheObject(tokenCacheKey, token, 5, TimeUnit.MINUTES);
|
|
|
|
|
|
|
|
// return token;
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// context.setOpenToken(openToken);
|
|
|
|
|
|
|
|
// return openToken;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 生成调用接口的token信息
|
|
|
|
* 生成调用接口的token信息
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|