Showing
1 changed file
with
29 additions
and
56 deletions
| ... | @@ -25,20 +25,8 @@ public class IClearApiTask { | ... | @@ -25,20 +25,8 @@ public class IClearApiTask { |
| 25 | public void pushCustomsTask(){ | 25 | public void pushCustomsTask(){ |
| 26 | try{ | 26 | try{ |
| 27 | log.info("pushCustomsTask start>>>>>>>>>>>>"); | 27 | log.info("pushCustomsTask start>>>>>>>>>>>>"); |
| 28 | - if(token == null){ | 28 | + //获取token |
| 29 | - try { | 29 | + getToken(); |
| 30 | - //获取token | ||
| 31 | - TokenResult tokenResult = apiService.getToken(); | ||
| 32 | - if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){ | ||
| 33 | - this.token = tokenResult.getData().getToken(); | ||
| 34 | - } | ||
| 35 | - }catch(Exception ex){ | ||
| 36 | - ex.printStackTrace(); | ||
| 37 | - } | ||
| 38 | - } | ||
| 39 | - if(this.token == null){ | ||
| 40 | - throw new Exception("获取token失败!"); | ||
| 41 | - } | ||
| 42 | //获取token成功则进行海关回执推送 | 30 | //获取token成功则进行海关回执推送 |
| 43 | apiService.pushCustoms(this.token); | 31 | apiService.pushCustoms(this.token); |
| 44 | log.info("pushCustomsTask end>>>>>>>>>>>>"); | 32 | log.info("pushCustomsTask end>>>>>>>>>>>>"); |
| ... | @@ -54,20 +42,8 @@ public class IClearApiTask { | ... | @@ -54,20 +42,8 @@ public class IClearApiTask { |
| 54 | public void pushMawbTask(){ | 42 | public void pushMawbTask(){ |
| 55 | try{ | 43 | try{ |
| 56 | log.info("pushMawbTask start>>>>>>>>>>>>"); | 44 | log.info("pushMawbTask start>>>>>>>>>>>>"); |
| 57 | - if(token == null){ | 45 | + //获取token |
| 58 | - try { | 46 | + getToken(); |
| 59 | - //获取token | ||
| 60 | - TokenResult tokenResult = apiService.getToken(); | ||
| 61 | - if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){ | ||
| 62 | - this.token = tokenResult.getData().getToken(); | ||
| 63 | - } | ||
| 64 | - }catch(Exception ex){ | ||
| 65 | - ex.printStackTrace(); | ||
| 66 | - } | ||
| 67 | - } | ||
| 68 | - if(this.token == null){ | ||
| 69 | - throw new Exception("获取token失败!"); | ||
| 70 | - } | ||
| 71 | //获取token成功则进行海关回执推送 | 47 | //获取token成功则进行海关回执推送 |
| 72 | apiService.pushMawb(this.token); | 48 | apiService.pushMawb(this.token); |
| 73 | log.info("pushMawbTask end>>>>>>>>>>>>"); | 49 | log.info("pushMawbTask end>>>>>>>>>>>>"); |
| ... | @@ -82,20 +58,8 @@ public class IClearApiTask { | ... | @@ -82,20 +58,8 @@ public class IClearApiTask { |
| 82 | public void pushErrorReturnDate(){ | 58 | public void pushErrorReturnDate(){ |
| 83 | try{ | 59 | try{ |
| 84 | log.info("pushErrorReturnDate start>>>>>>>>>>>>"); | 60 | log.info("pushErrorReturnDate start>>>>>>>>>>>>"); |
| 85 | - if(token == null){ | 61 | + //获取token |
| 86 | - try { | 62 | + getToken(); |
| 87 | - //获取token | ||
| 88 | - TokenResult tokenResult = apiService.getToken(); | ||
| 89 | - if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){ | ||
| 90 | - this.token = tokenResult.getData().getToken(); | ||
| 91 | - } | ||
| 92 | - }catch(Exception ex){ | ||
| 93 | - ex.printStackTrace(); | ||
| 94 | - } | ||
| 95 | - } | ||
| 96 | - if(this.token == null){ | ||
| 97 | - throw new Exception("获取token失败!"); | ||
| 98 | - } | ||
| 99 | //获取token成功则进行海关回执推送 | 63 | //获取token成功则进行海关回执推送 |
| 100 | apiService.pushErrorReturnDate(this.token); | 64 | apiService.pushErrorReturnDate(this.token); |
| 101 | log.info("pushErrorReturnDate end>>>>>>>>>>>>"); | 65 | log.info("pushErrorReturnDate end>>>>>>>>>>>>"); |
| ... | @@ -110,20 +74,8 @@ public class IClearApiTask { | ... | @@ -110,20 +74,8 @@ public class IClearApiTask { |
| 110 | public void pushErrorData(){ | 74 | public void pushErrorData(){ |
| 111 | try{ | 75 | try{ |
| 112 | log.info("pushErrorDeclareDate start>>>>>>>>>>>>"); | 76 | log.info("pushErrorDeclareDate start>>>>>>>>>>>>"); |
| 113 | - if(token == null){ | 77 | + //获取token |
| 114 | - try { | 78 | + getToken(); |
| 115 | - //获取token | ||
| 116 | - TokenResult tokenResult = apiService.getToken(); | ||
| 117 | - if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){ | ||
| 118 | - this.token = tokenResult.getData().getToken(); | ||
| 119 | - } | ||
| 120 | - }catch(Exception ex){ | ||
| 121 | - ex.printStackTrace(); | ||
| 122 | - } | ||
| 123 | - } | ||
| 124 | - if(this.token == null){ | ||
| 125 | - throw new Exception("获取token失败!"); | ||
| 126 | - } | ||
| 127 | //获取token成功则进行海关回执推送 | 79 | //获取token成功则进行海关回执推送 |
| 128 | apiService.pushErrorDeclareDate(this.token); | 80 | apiService.pushErrorDeclareDate(this.token); |
| 129 | log.info("pushErrorDeclareDate end>>>>>>>>>>>>"); | 81 | log.info("pushErrorDeclareDate end>>>>>>>>>>>>"); |
| ... | @@ -131,4 +83,25 @@ public class IClearApiTask { | ... | @@ -131,4 +83,25 @@ public class IClearApiTask { |
| 131 | log.error("pushErrorDeclareDate() error:" +e.getMessage()); | 83 | log.error("pushErrorDeclareDate() error:" +e.getMessage()); |
| 132 | } | 84 | } |
| 133 | } | 85 | } |
| 86 | + | ||
| 87 | + /** | ||
| 88 | + * 获取token | ||
| 89 | + * @throws Exception | ||
| 90 | + */ | ||
| 91 | + private void getToken() throws Exception{ | ||
| 92 | + if(token == null){ | ||
| 93 | + try { | ||
| 94 | + //获取token | ||
| 95 | + TokenResult tokenResult = apiService.getToken(); | ||
| 96 | + if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){ | ||
| 97 | + this.token = tokenResult.getData().getToken(); | ||
| 98 | + } | ||
| 99 | + }catch(Exception ex){ | ||
| 100 | + ex.printStackTrace(); | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + if(this.token == null){ | ||
| 104 | + throw new Exception("获取token失败!"); | ||
| 105 | + } | ||
| 106 | + } | ||
| 134 | } | 107 | } | ... | ... |
-
Please register or login to post a comment