|
@@ -30,11 +30,10 @@ import java.util.Map;
|
|
|
*/
|
|
|
@Component
|
|
|
public class AttendanceAssessmentSdk {
|
|
|
-
|
|
|
-
|
|
|
public static final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
public static final String REDIS_KEY_NAME = "attendance_assessment_token";
|
|
|
public static final int TOKEN_EXPIRED_SECONDS = 1700;
|
|
|
+ public static final String GSLB = "KC";
|
|
|
private static final Logger logger = LoggerFactory.getLogger(AttendanceAssessmentSdk.class);
|
|
|
// 客户端ID
|
|
|
private String appId;
|
|
@@ -46,7 +45,8 @@ public class AttendanceAssessmentSdk {
|
|
|
private String clientIp;
|
|
|
// token的虚拟目录
|
|
|
private String tokenVirtualDirectory;
|
|
|
- private Map<String, String> businessDataMap = new HashMap<>(2);
|
|
|
+
|
|
|
+ private Map<String, Object> businessDataMap = new HashMap<>(2);
|
|
|
// api路由
|
|
|
private Map<String, String> apiVirtualDirectoryMap = null;
|
|
|
@Autowired
|
|
@@ -78,25 +78,36 @@ public class AttendanceAssessmentSdk {
|
|
|
}
|
|
|
|
|
|
public ApiReturnDto apiCall(ApiCallDto paramVo) {
|
|
|
- logger.info("接口调用开始:", paramVo.getApiCode());
|
|
|
+ logger.info("接口调用开始:{}", paramVo.getApiCode());
|
|
|
// 请求地址
|
|
|
String url = this.clientIp + this.apiVirtualDirectoryMap.get(paramVo.getApiCode());
|
|
|
logger.info("api地址:{}", url);
|
|
|
+
|
|
|
+
|
|
|
+ ApiReturnDto apiReturnDto = null;
|
|
|
+ String apiResult = null;
|
|
|
+
|
|
|
+ /**********************组装请求参数**************************************/
|
|
|
+ Map<String, Map<String, Object>> postData = new HashMap<>(2);
|
|
|
+ Map<String, Object> requestData = getRequestData();
|
|
|
+ requestData.put("TOKEN", getToken());
|
|
|
+ requestData.put("GSLB", GSLB);
|
|
|
+ Map<String, Object> businessMap = (Map<String, Object>) paramVo.getData();
|
|
|
+ postData.put("STANDARD_DATA", requestData);
|
|
|
+ postData.put("BUSINESS_DATA", businessMap);
|
|
|
JSONConfig config = new JSONConfig();
|
|
|
config.setIgnoreNullValue(false);
|
|
|
- String jsonStr = JSONUtil.toJsonStr(paramVo.getData(), config);
|
|
|
+ String jsonStr = JSONUtil.toJsonStr(postData, config);
|
|
|
logger.info("入参:{}", jsonStr);
|
|
|
- ApiReturnDto apiReturnDto = null;
|
|
|
- String apiResult=null;
|
|
|
try {
|
|
|
- apiResult = HttpRequest.post(url).headerMap(setHeadMap(), true).body(jsonStr).execute().body();
|
|
|
+ apiResult = HttpRequest.post(url).body(jsonStr).execute().body();
|
|
|
logger.info("接口返回报文:{}", apiResult);
|
|
|
- apiReturnDto= JSONUtil.toBean(apiResult, ApiReturnDto.class);
|
|
|
- }catch (Exception e){
|
|
|
+ apiReturnDto = JSONUtil.toBean(apiResult, ApiReturnDto.class);
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- logger.error("接口调用异常",e.getMessage());
|
|
|
- apiResult="接口调用异常:"+e.getMessage();
|
|
|
- }finally {
|
|
|
+ logger.error("接口调用异常", e.getMessage());
|
|
|
+ apiResult = "接口调用异常:" + e.getMessage();
|
|
|
+ } finally {
|
|
|
// 接口调用结束后续逻辑处理
|
|
|
String finalApiResult = apiResult;
|
|
|
Thread td = new Thread(() -> afterAll(paramVo, jsonStr, finalApiResult));
|
|
@@ -113,10 +124,9 @@ public class AttendanceAssessmentSdk {
|
|
|
}
|
|
|
String url = this.clientIp + this.tokenVirtualDirectory;
|
|
|
/**********************组装请求参数**************************************/
|
|
|
- Map<String, Map<String, String>> postData = new HashMap<>(2);
|
|
|
+ Map<String, Map<String, Object>> postData = new HashMap<>(2);
|
|
|
postData.put("STANDARD_DATA", getRequestData());
|
|
|
postData.put("BUSINESS_DATA", this.businessDataMap);
|
|
|
-
|
|
|
logger.info("请求url: {}", url);
|
|
|
String body = HttpRequest.post(url).body(postData.toString()).execute().body();
|
|
|
logger.info("接口返回: {}", body);
|
|
@@ -167,8 +177,8 @@ public class AttendanceAssessmentSdk {
|
|
|
return sdf.format(new Date());
|
|
|
}
|
|
|
|
|
|
- private Map<String, String> getRequestData() {
|
|
|
- Map<String, String> standardDataMap = new HashMap<>(3);
|
|
|
+ private Map<String, Object> getRequestData() {
|
|
|
+ Map<String, Object> standardDataMap = new HashMap<>(3);
|
|
|
standardDataMap.put("ZINSTID", SecurityUtil.getUUID());
|
|
|
standardDataMap.put("ZZREQTIME", getRequestTime());
|
|
|
standardDataMap.put("ORGCODE", this.orgCode);
|