tao.mo

任务后取token调整

mt
2021年9月1日15:35:49
......@@ -25,20 +25,8 @@ public class IClearApiTask {
public void pushCustomsTask(){
try{
log.info("pushCustomsTask start>>>>>>>>>>>>");
if(token == null){
try {
//获取token
TokenResult tokenResult = apiService.getToken();
if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){
this.token = tokenResult.getData().getToken();
}
}catch(Exception ex){
ex.printStackTrace();
}
}
if(this.token == null){
throw new Exception("获取token失败!");
}
//获取token
getToken();
//获取token成功则进行海关回执推送
apiService.pushCustoms(this.token);
log.info("pushCustomsTask end>>>>>>>>>>>>");
......@@ -54,20 +42,8 @@ public class IClearApiTask {
public void pushMawbTask(){
try{
log.info("pushMawbTask start>>>>>>>>>>>>");
if(token == null){
try {
//获取token
TokenResult tokenResult = apiService.getToken();
if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){
this.token = tokenResult.getData().getToken();
}
}catch(Exception ex){
ex.printStackTrace();
}
}
if(this.token == null){
throw new Exception("获取token失败!");
}
//获取token
getToken();
//获取token成功则进行海关回执推送
apiService.pushMawb(this.token);
log.info("pushMawbTask end>>>>>>>>>>>>");
......@@ -82,20 +58,8 @@ public class IClearApiTask {
public void pushErrorReturnDate(){
try{
log.info("pushErrorReturnDate start>>>>>>>>>>>>");
if(token == null){
try {
//获取token
TokenResult tokenResult = apiService.getToken();
if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){
this.token = tokenResult.getData().getToken();
}
}catch(Exception ex){
ex.printStackTrace();
}
}
if(this.token == null){
throw new Exception("获取token失败!");
}
//获取token
getToken();
//获取token成功则进行海关回执推送
apiService.pushErrorReturnDate(this.token);
log.info("pushErrorReturnDate end>>>>>>>>>>>>");
......@@ -110,20 +74,8 @@ public class IClearApiTask {
public void pushErrorData(){
try{
log.info("pushErrorDeclareDate start>>>>>>>>>>>>");
if(token == null){
try {
//获取token
TokenResult tokenResult = apiService.getToken();
if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){
this.token = tokenResult.getData().getToken();
}
}catch(Exception ex){
ex.printStackTrace();
}
}
if(this.token == null){
throw new Exception("获取token失败!");
}
//获取token
getToken();
//获取token成功则进行海关回执推送
apiService.pushErrorDeclareDate(this.token);
log.info("pushErrorDeclareDate end>>>>>>>>>>>>");
......@@ -131,4 +83,25 @@ public class IClearApiTask {
log.error("pushErrorDeclareDate() error:" +e.getMessage());
}
}
/**
* 获取token
* @throws Exception
*/
private void getToken() throws Exception{
if(token == null){
try {
//获取token
TokenResult tokenResult = apiService.getToken();
if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){
this.token = tokenResult.getData().getToken();
}
}catch(Exception ex){
ex.printStackTrace();
}
}
if(this.token == null){
throw new Exception("获取token失败!");
}
}
}
......