tao.mo

API代码提交

mt
2021年8月4日13:39:17
...@@ -90,6 +90,13 @@ ...@@ -90,6 +90,13 @@
90 <artifactId>httpclientutil</artifactId> 90 <artifactId>httpclientutil</artifactId>
91 <version>1.0.4</version> 91 <version>1.0.4</version>
92 </dependency> 92 </dependency>
93 +
94 + <!--序列化-->
95 + <dependency>
96 + <groupId>com.alibaba</groupId>
97 + <artifactId>fastjson</artifactId>
98 + <version>1.2.38</version>
99 + </dependency>
93 </dependencies> 100 </dependencies>
94 101
95 <profiles> 102 <profiles>
......
1 +package com.erry.iclear.dateInterface.api.request;
2 +
3 +import io.swagger.annotations.ApiModel;
4 +import io.swagger.annotations.ApiModelProperty;
5 +import lombok.Data;
6 +import javax.persistence.*;
7 +import java.io.Serializable;
8 +
9 +@ApiModel(value = "receiptMessage", description = "海关回执")
10 +@Entity
11 +@Table(name = "T_RECEIPT_MESSAGE")
12 +@Data
13 +public class ReceiptMessage implements Serializable {
14 +
15 + private static final long serialVersionUID = 4293869083362084652L;
16 + /**
17 + * ID,自动增加
18 + */
19 + @Id
20 + @GeneratedValue
21 + @Column(name = "ID")
22 + private Long id;
23 +
24 + @ApiModelProperty(value = "客户端编号", name = "clientSeqNo", example = "773515164336")
25 + @Column(name = "CLIENTSEQ_NO")
26 + String clientSeqNo;
27 +
28 + @ApiModelProperty(value = "数据中心统一编号", name = "seqNo", example = "E20210000617922161")
29 + @Column(name = "SEQ_NO")
30 + String seqNo;
31 +
32 + @ApiModelProperty(value = "报关单编号", name = "entryId", example = "010120210000226020")
33 + @Column(name = "ENTRY_ID")
34 + String entryId;
35 +
36 + @ApiModelProperty(value = "回执时间", name = "noticeDate", example = "20210423T231152")
37 + @Column(name = "NOTICE_DATE")
38 + String noticeDate;
39 +
40 + @ApiModelProperty(value = "回执代码", name = "channel", example = "R")
41 + @Column(name = "CHANNEL")
42 + String channel;
43 +
44 + @ApiModelProperty(value = "回执说明", name = "note", example = "该单已结关")
45 + @Column(name = "NOTE")
46 + String note;
47 +
48 + @ApiModelProperty(value = "总单号_运单号", name = "billNo", example = "02355851832_773515164336")
49 + @Column(name = "BILL_NO")
50 + String billNo;
51 +}
1 +package com.erry.iclear.dateInterface.api.response;
2 +
3 +import lombok.AllArgsConstructor;
4 +import lombok.Data;
5 +
6 +@Data
7 +@AllArgsConstructor
8 +public class TokenDataResult {
9 + String expire_in;
10 + String token;
11 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.erry.iclear.dateInterface.api.response;
2 +
3 +import lombok.AllArgsConstructor;
4 +import lombok.Data;
5 +
6 +import java.io.Serializable;
7 +
8 +@Data
9 +@AllArgsConstructor
10 +public class TokenResult implements Serializable {
11 + TokenDataResult data;
12 + String errorcode;
13 + String errormessage;
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.erry.iclear.dateInterface.common;
2 +
3 +/**
4 + * 常量
5 + * mt
6 + * 2021年7月29日13:34:15
7 + */
8 +public interface Constants {
9 + /**
10 + * api响应码
11 + */
12 + public static interface ApiResponseKeys{
13 + //成功
14 + public static final String SUCCESS = "0";
15 + //用户或密码不正确
16 + public static final String KEY_10001 = "10001";
17 + //用户不存在
18 + public static final String KEY_10002 = "10002";
19 + //账号已过期
20 + public static final String KEY_10003 = "10003";
21 + //凭证已过期
22 + public static final String KEY_10004 = "10004";
23 + //账号已禁用
24 + public static final String KEY_10005 = "10005";
25 + //用户凭证无效
26 + public static final String KEY_10013 = "10013";
27 + }
28 +}
1 +package com.erry.iclear.dateInterface.entity;
2 +
3 +import lombok.Data;
4 +
5 +import javax.persistence.*;
6 +import java.io.Serializable;
7 +import java.math.BigDecimal;
8 +import java.util.Date;
9 +
10 +/**
11 + * @author Administrator
12 + */
13 +@Entity
14 +@Table(name = "T_DECLEAR_TASK")
15 +@Data
16 +public class DeclearTask implements Serializable {
17 + private static final long serialVersionUID = 1763766526675864727L;
18 +
19 + /**
20 + * 运单明细表ID,自动增加
21 + */
22 + @Id
23 + @GeneratedValue(strategy = GenerationType.IDENTITY)
24 + @Column(name = "ID")
25 + private Long id;
26 +
27 + @Column(name = "CHMSIGNMENT_ID")
28 + private BigDecimal chmsignmentId;
29 +
30 + @Column(name = "CHMSIGNMENT_CODE")
31 + private String chmsignmentCode;
32 +
33 + @Column(name = "CHMSIGNMENT_HEAD_CODE")
34 + private String chmsignmentHeadCode;
35 +
36 + @Column(name = "PORT_ID")
37 + private BigDecimal portId;
38 +
39 + @Column(name = "PORT_NAME")
40 + private String portName;
41 +
42 + @Column(name = "FILE_TYPE")
43 + private String fileType;
44 +
45 + @Column(name = "OPERATION_TIME")
46 + private Date operationTime;
47 +
48 + @Column(name = "OPERATION_NAME")
49 + private String operationName;
50 +
51 + @Column(name = "DATA_SOURCE")
52 + private String dataSource;
53 +
54 + @Column(name = "PUSH_NUMBER")
55 + private BigDecimal pushNumber;
56 +
57 + @Column(name = "PUSH_TIME")
58 + private Date pushTime;
59 +
60 + @Column(name = "RESPONSE_TIME")
61 + private Date responseTime;
62 +
63 + @Column(name = "RESPONSE_RESULTS")
64 + private String responseResults;
65 +
66 + @Column(name = "RESPONSE_CONTENT")
67 + private String responseContent;
68 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.erry.iclear.dateInterface.repository;
2 +
3 +import com.erry.iclear.dateInterface.api.request.ReceiptMessage;
4 +import com.erry.iclear.dateInterface.entity.DeclearTask;
5 +import com.erry.iclear.dateInterface.entity.OrigplacecodeMapping;
6 +import org.springframework.data.jpa.repository.JpaRepository;
7 +import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
8 +import org.springframework.data.jpa.repository.Modifying;
9 +import org.springframework.data.jpa.repository.Query;
10 +import org.springframework.data.repository.query.Param;
11 +import org.springframework.stereotype.Repository;
12 +
13 +import java.util.Date;
14 +import java.util.List;
15 +
16 +/**
17 + * 海关回执信息日志表
18 + * mt
19 + * 2021年7月29日15:36:29
20 + */
21 +@Repository
22 +public interface ReceiptMessageRepository extends JpaSpecificationExecutor<ReceiptMessage>, JpaRepository<ReceiptMessage, Long> {
23 + /**
24 + * 查找所有目的地
25 + *
26 + * @param
27 + * @return
28 + */
29 + @Query(nativeQuery = true, value = "SELECT TOP 1 RM.* FROM T_RECEIPT_MESSAGE RM INNER JOIN T_DECLEAR_TASK DT ON(RM.ID = DT.CHMSIGNMENT_ID) WHERE FILE_TYPE = 2 AND PUSH_NUMBER < 3 AND (RESPONSE_RESULTS IS NULL OR RESPONSE_RESULTS <> '0') ORDER BY RM.NOTICE_DATE ASC")
30 + public List<ReceiptMessage> findReceiptMessageList();
31 +
32 + @Modifying(clearAutomatically = false)
33 + @Query(nativeQuery = true,value = "UPDATE T_DECLEAR_TASK SET PUSH_TIME = ?1,PUSH_NUMBER = PUSH_NUMBER + 1,RESPONSE_TIME = ?2,RESPONSE_RESULTS = ?3,RESPONSE_CONTENT = ?4 WHERE FILE_TYPE = 2 AND CHMSIGNMENT_ID = ?5")
34 + void updateDeclearTaskStatus(Date pushTime, Date responseTime, String responseResults, String responseContent, Long chmsignmentId);
35 +
36 +
37 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.erry.iclear.dateInterface.service;
2 +
3 +import com.arronlong.httpclientutil.HttpClientUtil;
4 +import com.arronlong.httpclientutil.common.HttpConfig;
5 +import com.arronlong.httpclientutil.common.HttpHeader;
6 +import com.erry.iclear.dateInterface.api.request.ReceiptMessage;
7 +import com.erry.iclear.dateInterface.api.response.TokenResult;
8 +import com.erry.iclear.dateInterface.common.Constants;
9 +import com.erry.iclear.dateInterface.entity.DeclearTask;
10 +import com.erry.iclear.dateInterface.repository.ReceiptMessageRepository;
11 +import com.erry.iclear.dateInterface.util.JsonToJava;
12 +import lombok.extern.slf4j.Slf4j;
13 +import org.apache.http.Header;
14 +import org.springframework.beans.factory.annotation.Autowired;
15 +import org.springframework.beans.factory.annotation.Value;
16 +import org.springframework.stereotype.Service;
17 +
18 +import javax.transaction.Transactional;
19 +import java.math.BigDecimal;
20 +import java.util.*;
21 +
22 +/**
23 + * 调用API接口Service
24 + * mt
25 + * 2021年7月28日17:04:27
26 + */
27 +@Service
28 +@Slf4j
29 +@Transactional(rollbackOn = Exception.class)
30 +public class ApiService {
31 + @Value("${api.token-info.username}")
32 + String username;
33 + @Value("${api.token-info.password}")
34 + String password;
35 + @Value("${api.address.token-url}")
36 + String tokenUrl;
37 + @Value("${api.address.refresh-token-url}")
38 + String refreshTokenUrl;
39 + @Value("${api.address.customs-url}")
40 + String customsUrl;
41 + @Value("${api.address.complete-msg-url}")
42 + String completeMsgUrl;
43 +
44 + @Autowired
45 + ReceiptMessageRepository receiptMessageRepository;
46 +
47 + /**
48 + * 获取token信息
49 + * @return
50 + * @throws Exception
51 + */
52 + public TokenResult getToken() throws Exception{
53 + Map<String,Object> map = new HashMap<String,Object>();
54 + map.put("username", this.username);
55 + map.put("password", this.password);
56 + HttpConfig config = HttpConfig.custom()
57 + .url(tokenUrl)
58 + .map(map)
59 + .encoding("utf-8");
60 + String tokenJson = HttpClientUtil.post(config);
61 + TokenResult tokenResult = JsonToJava.parseJson(tokenJson,TokenResult.class);
62 + return tokenResult;
63 + }
64 +
65 + /**
66 + * 刷新token
67 + * @param token
68 + * @throws Exception
69 + */
70 + public void refreshToken(String token) throws Exception{
71 + Map<String,Object> map = new HashMap<String,Object>();
72 + map.put("token", token);
73 + HttpConfig config = HttpConfig.custom()
74 + .url(refreshTokenUrl)
75 + .map(map)
76 + .encoding("utf-8");
77 + HttpClientUtil.post(config);
78 + }
79 +
80 + /**
81 + * 传输海关回执数据
82 + * @param token
83 + * @throws Exception
84 + */
85 + public void pushCustoms(String token){
86 + Header[] headers = HttpHeader.custom()
87 + .other("Content-Type", "application/json")
88 + .other("Authorization", token)
89 + .build();
90 + //获取海关回执数据
91 + List<ReceiptMessage> receiptMessageList = receiptMessageRepository.findReceiptMessageList();
92 + List<DeclearTask> declearTaskList = new ArrayList<DeclearTask>();
93 + receiptMessageList.forEach(d->{
94 + DeclearTask declearTask = new DeclearTask();
95 + try {
96 + //设置ID
97 + declearTask.setChmsignmentId(BigDecimal.valueOf(d.getId()));
98 + //推送时间
99 + declearTask.setPushTime(new Date());
100 + String objJson = JsonToJava.toJson(d);
101 + //推送海关回执数据
102 + HttpConfig config = HttpConfig.custom()
103 + .headers(headers)
104 + .url(customsUrl)
105 + .encoding("utf-8")
106 + .json(objJson);
107 + String json = HttpClientUtil.post(config);
108 + //接口响应时间
109 + declearTask.setResponseTime(new Date());
110 + TokenResult tokenResult = JsonToJava.parseJson(json,TokenResult.class);
111 + if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){
112 + //推送成功,记录推送状态
113 + declearTask.setResponseResults(tokenResult.getErrorcode());
114 + declearTask.setResponseContent(tokenResult.getErrormessage());
115 + declearTaskList.add(declearTask);
116 + }else if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.KEY_10004)){
117 + //如果凭证失效,则刷新凭证
118 + refreshToken(token);
119 + }else{
120 + //推送失败,记录推送状态
121 + declearTask.setResponseResults(tokenResult.getErrorcode());
122 + declearTask.setResponseContent(tokenResult.getErrormessage());
123 + declearTaskList.add(declearTask);
124 + log.info("海关回执推送失败,推送相应码为:"+tokenResult.getErrorcode() + ",推送ID为:" + d.getId());
125 + }
126 + }catch(Exception ex){
127 + //接口响应时间
128 + declearTask.setResponseTime(new Date());
129 + declearTask.setResponseResults("接口调用失败!");
130 + declearTask.setResponseContent(ex.getMessage());
131 + declearTaskList.add(declearTask);
132 + ex.printStackTrace();
133 + }
134 + });
135 + declearTaskList.forEach(declearTask -> {
136 + //将已经推送完成的回执信息状态修改
137 + receiptMessageRepository.updateDeclearTaskStatus(declearTask.getPushTime(),
138 + declearTask.getResponseTime(),
139 + declearTask.getResponseResults(),
140 + declearTask.getResponseContent(),
141 + declearTask.getChmsignmentId().longValue());
142 + });
143 + }
144 +
145 + /**
146 + * 传输完整报文数据
147 + * @param token
148 + * @throws Exception
149 + */
150 + public void pushMawb(String token){
151 + Header[] headers = HttpHeader.custom()
152 + .other("Content-Type", "application/json")
153 + .other("Authorization", token)
154 + .build();
155 + //获取海关回执数据
156 +
157 + }
158 +}
1 package com.erry.iclear.dateInterface.task; 1 package com.erry.iclear.dateInterface.task;
2 2
3 +import com.erry.iclear.dateInterface.api.response.TokenResult;
4 +import com.erry.iclear.dateInterface.common.Constants;
5 +import com.erry.iclear.dateInterface.service.ApiService;
3 import lombok.extern.slf4j.Slf4j; 6 import lombok.extern.slf4j.Slf4j;
7 +import org.springframework.beans.factory.annotation.Autowired;
4 import org.springframework.scheduling.annotation.Scheduled; 8 import org.springframework.scheduling.annotation.Scheduled;
5 import org.springframework.stereotype.Component; 9 import org.springframework.stereotype.Component;
6 10
...@@ -10,18 +14,65 @@ import org.springframework.stereotype.Component; ...@@ -10,18 +14,65 @@ import org.springframework.stereotype.Component;
10 @Component 14 @Component
11 @Slf4j 15 @Slf4j
12 public class IClearApiTask { 16 public class IClearApiTask {
17 + @Autowired
18 + ApiService apiService;
19 + String token;
13 20
14 /** 21 /**
15 * TODO 定时任务:每分钟推送: 报关数据、回执 22 * TODO 定时任务:每分钟推送: 报关数据、回执
16 */ 23 */
17 - @Scheduled(cron = "${task.pushMawbToIClear}") 24 + @Scheduled(cron = "${task.pushCustomsTask}")
18 - public void pushMawbToIClear(){ 25 + public void pushCustomsTask(){
19 try{ 26 try{
20 - log.info("pushMawbToIClear start>>>>>>>>>>>>"); 27 + log.info("pushCustomsTask start>>>>>>>>>>>>");
28 + if(token == null){
29 + try {
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成功则进行海关回执推送
43 + apiService.pushCustoms(this.token);
44 + log.info("pushCustomsTask end>>>>>>>>>>>>");
45 + }catch (Exception e){
46 + log.error("pushCustomsTask() error:" +e.getMessage());
47 + }
48 + }
21 49
22 - log.info("pushMawbToIClear end>>>>>>>>>>>>"); 50 + /**
51 + * TODO 定时任务:每分钟推送: 完整报文
52 + */
53 + @Scheduled(cron = "${task.pushMawbTask}")
54 + public void pushMawbTask(){
55 + try{
56 + log.info("pushMawbTask start>>>>>>>>>>>>");
57 + if(token == null){
58 + try {
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成功则进行海关回执推送
72 + apiService.pushMawb(this.token);
73 + log.info("pushMawbTask end>>>>>>>>>>>>");
23 }catch (Exception e){ 74 }catch (Exception e){
24 - log.error("pushMawbToIClear() error:" +e.getMessage()); 75 + log.error("pushMawbTask() error:" +e.getMessage());
25 } 76 }
26 } 77 }
27 } 78 }
......
1 +package com.erry.iclear.dateInterface.util;
2 +
3 +import com.alibaba.fastjson.JSONObject;
4 +import com.alibaba.fastjson.serializer.SerializerFeature;
5 +
6 +import java.io.File;
7 +import java.io.FileOutputStream;
8 +import java.io.OutputStreamWriter;
9 +import java.io.Writer;
10 +
11 +/**
12 + * json字符串和java对象转换
13 + * mt
14 + * 2021年7月29日11:40:27
15 + */
16 +public class JsonToJava {
17 +
18 + /*
19 + Json字符串转Java对象
20 + */
21 + public static <T>T parseJson(String jsonStr, Class cla) {
22 + Object jsonRootBean = JSONObject.parseObject(jsonStr, cla);
23 + return (T)jsonRootBean;
24 + }
25 +
26 + /*
27 + 对象转Json串
28 + */
29 + public static String toJson(Object object) {
30 + String jsonString = JSONObject.toJSONString(object, SerializerFeature.WriteMapNullValue);
31 + return jsonString;
32 + }
33 +}
...@@ -6,9 +6,25 @@ spring: ...@@ -6,9 +6,25 @@ spring:
6 driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver 6 driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
7 type: com.alibaba.druid.pool.DruidDataSource 7 type: com.alibaba.druid.pool.DruidDataSource
8 8
9 -
10 -
11 task: 9 task:
12 - pushMawbToIClear: 0 0/1 * * * ? 10 + #推送海关回执
13 - 11 + pushCustomsTask: 0 0/1 * * * ?
12 + #推送完整报文
13 + pushMawbTask: 0 0/1 * * * ?
14 14
15 +#推送地址
16 +api:
17 + token-info:
18 + #获取token账号
19 + username: iclear_external_ctm
20 + #获取token密码
21 + password: toQu3arch6
22 + address:
23 + #获取token地址
24 + token-url: https://apiuat.iclrccd-fedex.com/login
25 + #刷新token地址
26 + refresh-token-url: https://apiuat.iclrccd-fedex.com/user/token/refresh
27 + #传输海关回执地址
28 + customs-url: https://apiuat.iclrccd-fedex.com/export/outbound/customs
29 + #推送完整报文地址
30 + complete-msg-url: https://apiuat.iclrccd-fedex.com/export/outbound/mawb
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -6,6 +6,25 @@ spring: ...@@ -6,6 +6,25 @@ spring:
6 driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver 6 driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
7 type: com.alibaba.druid.pool.DruidDataSource 7 type: com.alibaba.druid.pool.DruidDataSource
8 8
9 -
10 task: 9 task:
11 - pushMawbToIClear: 0 0/1 * * * ?
...\ No newline at end of file ...\ No newline at end of file
10 + #推送海关回执
11 + pushCustomsTask: 0 0/1 * * * ?
12 + #推送完整报文
13 + pushMawbTask: 0 0/1 * * * ?
14 +
15 +#推送地址
16 +api:
17 + token-info:
18 + #获取token账号
19 + username: iclear_external_ctm
20 + #获取token密码
21 + password: toQu3arch6
22 + address:
23 + #获取token地址
24 + token-url: https://api.iclrccd-fedex.com/export/login
25 + #刷新token地址
26 + refresh-token-url: https://api.iclrccd-fedex.com/export/admin/user/token/refresh
27 + #传输海关回执地址
28 + customs-url: https://api.iclrccd-fedex.com/export/outbound/customs
29 + #推送完整报文地址
30 + complete-msg-url: https://api.iclrccd-fedex.com/export/export/outbound/mawb
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -6,9 +6,25 @@ spring: ...@@ -6,9 +6,25 @@ spring:
6 driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver 6 driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
7 type: com.alibaba.druid.pool.DruidDataSource 7 type: com.alibaba.druid.pool.DruidDataSource
8 8
9 -
10 -
11 task: 9 task:
12 - pushMawbToIClear: 0 0/1 * * * ? 10 + #推送海关回执
13 - 11 + pushCustomsTask: 0 0/1 * * * ?
12 + #推送完整报文
13 + pushMawbTask: 0 0/1 * * * ?
14 14
15 +#推送地址
16 +api:
17 + token-info:
18 + #获取token账号
19 + username: iclear_external_ctm
20 + #获取token密码
21 + password: toQu3arch6
22 + address:
23 + #获取token地址
24 + token-url: https://apiuat.iclrccd-fedex.com/login
25 + #刷新token地址
26 + refresh-token-url: https://apiuat.iclrccd-fedex.com/user/token/refresh
27 + #传输海关回执地址
28 + customs-url: https://apiuat.iclrccd-fedex.com/export/outbound/customs
29 + #推送完整报文地址
30 + complete-msg-url: https://apiuat.iclrccd-fedex.com/export/outbound/mawb
...\ No newline at end of file ...\ No newline at end of file
......
1 +package com.erry.iclear.dateInterface;
2 +
3 +import com.arronlong.httpclientutil.HttpClientUtil;
4 +import com.arronlong.httpclientutil.common.HttpConfig;
5 +import com.arronlong.httpclientutil.common.HttpHeader;
6 +import com.erry.iclear.dateInterface.api.response.TokenResult;
7 +import com.erry.iclear.dateInterface.util.JsonToJava;
8 +import org.apache.http.Header;
9 +import org.junit.Test;
10 +import org.springframework.beans.factory.annotation.Value;
11 +
12 +import java.util.HashMap;
13 +import java.util.Map;
14 +
15 +public class TokenTest extends IClearApiApplicationTests {
16 + @Value("${api.token-info.username}")
17 + String username;
18 + @Value("${api.token-info.password}")
19 + String password;
20 + @Value("${api.address.token-url}")
21 + String tokenUrl;
22 + @Value("${api.address.refresh-token-url}")
23 + String refreshTokenUrl;
24 + @Value("${api.address.customs-url}")
25 + String customsUrl;
26 + @Value("${api.address.complete-msg-url}")
27 + String completeMsgUrl;
28 +
29 + @Test
30 + public void token() throws Exception{
31 + Map<String,Object> map = new HashMap<String,Object>();
32 + map.put("username", this.username);
33 + map.put("password", this.password);
34 + HttpConfig config = HttpConfig.custom()
35 + .url(tokenUrl)
36 + .map(map)
37 + .encoding("utf-8");
38 + String token = HttpClientUtil.post(config);
39 +
40 + TokenResult rss = JsonToJava.parseJson(token, TokenResult.class);
41 +
42 + System.out.println(token);
43 + System.out.println(refreshTokenUrl);
44 + token = "eyJhbGciOiJSUzI1NiJ9.eyJleHBpcmVBdCI6MTYyNzQ3MTkyNjIxMCwidXNlcklkIjoiaWNsZWFyX2V4dGVybmFsX2N0bSJ9.dGrNuB8yHkeDM2Cmxwa7tej30fxQ6BpKYieWYh2kaW_nx75Hit8wy3FiLZTEgfXqa4o2axJEslrPgzedle5j5PIlTl-vz1WcCKDvLAh0PNeCX6i7NmpMKwemPAJp8gdo1HYjMdJPn7cV7Cjc7rSS1zjS4NCu0Ob7Qjf_FKopBYYJUITGy79Y0XbDo9_tHxS-2_8ahU3q78l799amQughnnMU3srpD9PLyKNO8uz6l-eV6ShSfYNE0o2L1FSH8xgqpIKNrRsl-JKasHIQl-82CiX-2XEtFFU4JbxDp9t-7jo-UlEIIKWk1Gy10nVC9FSntFFIHgTJ2lMAxF7QqI3QlQ";
45 + Map<String,Object> map1 = new HashMap<String,Object>();
46 + map1.put("token", token);
47 + HttpConfig config1 = HttpConfig.custom()
48 + .url(refreshTokenUrl)
49 + .map(map1)
50 + .encoding("utf-8");
51 + String rs = HttpClientUtil.post(config1);
52 + System.out.println(rs);
53 + }
54 +}