|
@@ -14,6 +14,8 @@ import org.apache.http.client.utils.URIBuilder;
|
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -26,8 +28,6 @@ import com.google.common.collect.Maps;
|
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.UserType;
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
-import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
|
|
|
-import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
|
|
|
import cn.com.qmth.examcloud.commons.util.HttpClientUtil;
|
|
|
import cn.com.qmth.examcloud.commons.util.JsonUtil;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.FaceCloudService;
|
|
@@ -60,13 +60,7 @@ import cn.com.qmth.examcloud.web.upyun.UpyunService;
|
|
|
@Service
|
|
|
public class FaceServiceImpl implements FaceService {
|
|
|
|
|
|
- protected ExamCloudLog log = ExamCloudLogFactory.getLog(this.getClass());
|
|
|
-
|
|
|
- /**
|
|
|
- * 接口日志
|
|
|
- */
|
|
|
- private static final ExamCloudLog INTERFACE_LOG = ExamCloudLogFactory
|
|
|
- .getLog("INTERFACE_LOGGER");
|
|
|
+ private static final Logger LOG = LoggerFactory.getLogger(FaceServiceImpl.class);
|
|
|
|
|
|
@Autowired
|
|
|
StudentCloudService studentCloudService;
|
|
@@ -154,7 +148,7 @@ public class FaceServiceImpl implements FaceService {
|
|
|
info.put("facesetToken", facesetToken);
|
|
|
|
|
|
if (times > 5) {
|
|
|
- log.error("添加faceToken至faceSet失败. info=" + JsonUtil.toJson(info));
|
|
|
+ LOG.error("添加faceToken至faceSet失败. info=" + JsonUtil.toJson(info));
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -167,7 +161,7 @@ public class FaceServiceImpl implements FaceService {
|
|
|
.setParameter("faceset_token", facesetToken)
|
|
|
.setParameter("face_tokens", faceToken).build();
|
|
|
|
|
|
- INTERFACE_LOG.info("[Face++ Rquest]. url=" + uri.toString());
|
|
|
+ LOG.info("[Face++ Rquest]. url=" + uri.toString());
|
|
|
|
|
|
HttpPost httpPost = new HttpPost(uri);
|
|
|
|
|
@@ -176,7 +170,7 @@ public class FaceServiceImpl implements FaceService {
|
|
|
int statusCode = httpResponse.getStatusLine().getStatusCode();
|
|
|
String respBody = EntityUtils.toString(entity, "UTF-8");
|
|
|
|
|
|
- INTERFACE_LOG.info(
|
|
|
+ LOG.info(
|
|
|
"[Face++ Response]. statusCode=" + statusCode + "; respBody=" + respBody);
|
|
|
|
|
|
if (respBody.contains("QUOTA_EXCEEDED")) {
|
|
@@ -202,7 +196,7 @@ public class FaceServiceImpl implements FaceService {
|
|
|
times++;
|
|
|
continue;
|
|
|
} catch (Exception e) {
|
|
|
- log.error("调用addface接口异常. info=" + JsonUtil.toJson(info), e);
|
|
|
+ LOG.error("调用addface接口异常. info=" + JsonUtil.toJson(info), e);
|
|
|
times++;
|
|
|
continue;
|
|
|
} finally {
|
|
@@ -256,7 +250,7 @@ public class FaceServiceImpl implements FaceService {
|
|
|
.setParameter("api_secret", apiSecret).setParameter("image_url", photoUrl)
|
|
|
.build();
|
|
|
|
|
|
- INTERFACE_LOG
|
|
|
+ LOG
|
|
|
.info("[Face++ Rquest]. url=" + uri.toString() + "; photoUrl=" + photoUrl);
|
|
|
|
|
|
HttpPost httpPost = new HttpPost(uri);
|
|
@@ -266,7 +260,7 @@ public class FaceServiceImpl implements FaceService {
|
|
|
int statusCode = httpResponse.getStatusLine().getStatusCode();
|
|
|
String respBody = EntityUtils.toString(entity, "UTF-8");
|
|
|
|
|
|
- INTERFACE_LOG.info(
|
|
|
+ LOG.info(
|
|
|
"[Face++ Response]. statusCode=" + statusCode + "; respBody=" + respBody);
|
|
|
|
|
|
if (statusCode == HttpStatus.SC_OK) {
|
|
@@ -288,7 +282,7 @@ public class FaceServiceImpl implements FaceService {
|
|
|
times++;
|
|
|
continue;
|
|
|
} catch (Exception e) {
|
|
|
- log.error("调用detect接口异常. photoUrl=" + photoUrl, e);
|
|
|
+ LOG.error("调用detect接口异常. photoUrl=" + photoUrl, e);
|
|
|
times++;
|
|
|
continue;
|
|
|
} finally {
|