parent
83eeaca4ac
commit
83f993304a
|
@ -182,9 +182,7 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
|||
ProtocolRespDTO<PengXinStartTaskRsp> rspInfo = restfulInterface.startDisposeTask(url, token, reqItems);
|
||||
|
||||
// 判断是否token过期
|
||||
if (rspInfo != null && rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
|
||||
// 重新登录获取 token
|
||||
upgradeToken();
|
||||
if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getItems().get(0).getStatus())) {
|
||||
rspInfo = restfulInterface.startDisposeTask(url, token, reqItems);
|
||||
}
|
||||
|
||||
|
@ -250,9 +248,7 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
|||
new String[]{taskId});
|
||||
|
||||
// 判断是否token过期
|
||||
if (rspInfo != null && rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
|
||||
// 重新登录获取 token
|
||||
upgradeToken();
|
||||
if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getItems().get(0).getStatus())) {
|
||||
rspInfo = restfulInterface.stopDisposeTask(url, token, new String[]{taskId});
|
||||
}
|
||||
|
||||
|
@ -372,13 +368,12 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
|||
ProtocolRespDTO<PengXinDisposeAbilityRsp> rspInfo = restfulInterface.getDeviceDisposeAbility(url, token);
|
||||
|
||||
// 判断是否token过期
|
||||
if (rspInfo != null && rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
|
||||
// 重新登录获取 token
|
||||
upgradeToken();
|
||||
if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getStatus())) {
|
||||
rspInfo = restfulInterface.getDeviceDisposeAbility(url, token);
|
||||
}
|
||||
|
||||
if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()) {
|
||||
if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()
|
||||
&& rspInfo.getMsgContent().getStatus() == ErrorCode.ERR_OK.getCode()) {
|
||||
|
||||
rspInfo.getMsgContent().getCapacity().forEach(v -> {
|
||||
if (v.getObjectType().equals(DisposeObjectType.DOMAIN.getValue())) {
|
||||
|
@ -467,15 +462,14 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
|||
new String[]{taskId});
|
||||
|
||||
// 判断是否token过期
|
||||
if (rspInfo != null && rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
|
||||
// 重新登录获取 token
|
||||
upgradeToken();
|
||||
if (rspInfo != null && reLogin(rspInfo, rspInfo.getMsgContent().getItems().get(0).getStatus())) {
|
||||
rspInfo = restfulInterface.getDeviceTaskStatus(url, token, new String[]{taskId});
|
||||
}
|
||||
|
||||
if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()) {
|
||||
|
||||
if (rspInfo.getMsgContent().getItems().size() == 0) {
|
||||
int errCode = rspInfo.getMsgContent().getItems().get(0).getStatus();
|
||||
if (rspInfo.getMsgContent().getItems().size() == 0 || errCode != ErrorCode.ERR_OK.getCode()) {
|
||||
return new MulReturnType<>(ErrorCode.ERR_NOSUCHTASK, -1L);
|
||||
}
|
||||
|
||||
|
@ -504,6 +498,30 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* reLogin.
|
||||
*/
|
||||
private <T> boolean reLogin(ProtocolRespDTO<T> rspInfo, int status) {
|
||||
try {
|
||||
// 判断是否token过期
|
||||
if (rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
|
||||
// 重新登录获取 token
|
||||
upgradeToken();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (rspInfo.getCode() == HttpServletResponse.SC_OK &&
|
||||
(status == ErrorCode.ERR_LOGOUT.getCode() || status == ErrorCode.ERR_TOKENTIMEOUT.getCode() ||
|
||||
status == ErrorCode.ERR_TOKENNOTFOUND.getCode())){
|
||||
upgradeToken();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (Exception ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Period task runtime.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue