111
This commit is contained in:
1 parent
d1884d813f
commit
f8f938b04c
1 file changed
+11
-5
+11
-5
@@ -213,25 +213,31 @@ public class ThirdDoorApiServiceImpl implements ThirdDoorApiService {
|
||||
DoorBaseVo doorBaseVo = new DoorBaseVo();
|
||||
DoorApi.Api api = DoorApi.OPEN.setBaseUrl(doorConfig.getBaseUrl());
|
||||
ThirdDoorLogEntity logEntity = api.getInitLogEntity();
|
||||
String requestUrl = api.getBaseUrl() + api.getUrl();
|
||||
String body = null;
|
||||
Map<String, List<String>> requestHeaders = null;
|
||||
try {
|
||||
dto.setLockNotifyUrl(doorConfig.getCallbackBaseUrl() + doorConfig.getCallbackLockUrl());
|
||||
dto.setVideoNotifyUrl(doorConfig.getCallbackBaseUrl() + doorConfig.getCallbackVideoUrl());
|
||||
logEntity.setReq(JSONUtil.toJsonStr(dto));
|
||||
String body = JSONUtil.toJsonStr(dto);
|
||||
String res = api.getHttpRequest().header(apiCountersign(body)).body(body).execute().body();
|
||||
body = JSONUtil.toJsonStr(dto);
|
||||
requestHeaders = apiCountersign(body);
|
||||
String res = api.getHttpRequest().header(requestHeaders).body(body).execute().body();
|
||||
if (ObjectUtil.isEmpty(res)) throw new RuntimeException("response响应为空");
|
||||
logEntity.setRes(res);
|
||||
doorBaseVo = JSONUtil.toBean(res, DoorBaseVo.class);
|
||||
if (!doorBaseVo.isSuccess()) {
|
||||
String errorLog = String.format("请求错误res|%s|url|%s|body|%s|", res, api, body);
|
||||
String errorLog = String.format("|%s||open|请求错误|url|%s|headers|%s|body|%s|res|%s|", TAG, requestUrl, JSONUtil.toJsonStr(requestHeaders), body, res);
|
||||
log.error(errorLog);
|
||||
logEntity.setError(errorLog);
|
||||
DoorOpenVo errorVo = new DoorOpenVo();
|
||||
errorVo.setMessage(doorBaseVo.getMessage());
|
||||
return errorVo;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String error = String.format("|%s||volume|意外的错误error|%s|stack|%s|", TAG, e.getMessage(), Arrays.toString(e.getStackTrace()));
|
||||
log.error(error);
|
||||
String error = String.format("|%s||open|意外错误|url|%s|headers|%s|body|%s|exception|%s|message|%s|",
|
||||
TAG, requestUrl, JSONUtil.toJsonStr(requestHeaders), body, e.getClass().getName(), e.getMessage());
|
||||
log.error(error, e);
|
||||
logEntity.setError(error);
|
||||
} finally {
|
||||
logEntity.setTimeConsuming(Long.toString(System.currentTimeMillis() - startTime));
|
||||
|
||||
Reference in new issue
Block a user