deason 2 anos atrás
pai
commit
e2236751da

+ 11 - 12
examcloud-exchange-outer-service/src/main/java/cn/com/qmth/examcloud/exchange/outer/service/impl/FaceServiceImpl.java

@@ -147,8 +147,8 @@ public class FaceServiceImpl implements FaceService {
 			String facesetToken = getFacesetToken(rootOrgId);
 			info.put("facesetToken", facesetToken);
 
-			if (times > 5) {
-				LOG.error("添加faceToken至faceSet失败. info=" + JsonUtil.toJson(info));
+			if (times > 3) {
+				LOG.error("添加faceToken至faceSet失败. info:{}", JsonUtil.toJson(info));
 				return null;
 			}
 
@@ -170,8 +170,7 @@ public class FaceServiceImpl implements FaceService {
 				int statusCode = httpResponse.getStatusLine().getStatusCode();
 				String respBody = EntityUtils.toString(entity, "UTF-8");
 
-				LOG.info(
-						"[Face++ Response]. statusCode=" + statusCode + "; respBody=" + respBody);
+				LOG.info("[Face++ Response]. statusCode=" + statusCode + "; respBody=" + respBody);
 
 				if (respBody.contains("QUOTA_EXCEEDED")) {
 					throw new StatusException("620006", "faceset is full");
@@ -196,7 +195,7 @@ public class FaceServiceImpl implements FaceService {
 				times++;
 				continue;
 			} catch (Exception e) {
-				LOG.error("调用addface接口异常. info=" + JsonUtil.toJson(info), e);
+				LOG.error("添加faceToken接口异常. info:{} errCount:{} err:{}" + JsonUtil.toJson(info), times, e.getMessage());
 				times++;
 				continue;
 			} finally {
@@ -239,9 +238,11 @@ public class FaceServiceImpl implements FaceService {
 		int times = 0;
 		String faceToken = null;
 		while (true) {
-			if (times > 5) {
+			if (times > 3) {
+				LOG.error("人脸检测失败. photoUrl:{}", photoUrl);
 				throw new StatusException("620005", "人脸检测失败");
 			}
+
 			CloseableHttpClient httpClient = HttpClients.createDefault();
 			CloseableHttpResponse httpResponse = null;
 			try {
@@ -250,8 +251,7 @@ public class FaceServiceImpl implements FaceService {
 						.setParameter("api_secret", apiSecret).setParameter("image_url", photoUrl)
 						.build();
 
-				LOG
-						.info("[Face++ Rquest]. url=" + uri.toString() + "; photoUrl=" + photoUrl);
+				LOG.info("[Face++ Rquest]. url=" + uri.toString() + "; photoUrl=" + photoUrl);
 
 				HttpPost httpPost = new HttpPost(uri);
 
@@ -260,14 +260,13 @@ public class FaceServiceImpl implements FaceService {
 				int statusCode = httpResponse.getStatusLine().getStatusCode();
 				String respBody = EntityUtils.toString(entity, "UTF-8");
 
-				LOG.info(
-						"[Face++ Response]. statusCode=" + statusCode + "; respBody=" + respBody);
+				LOG.info("[Face++ Response]. statusCode=" + statusCode + "; respBody=" + respBody);
 
 				if (statusCode == HttpStatus.SC_OK) {
 					JSONObject jsonObject = JSON.parseObject(respBody);
 					JSONArray faces = jsonObject.getJSONArray("faces");
 					if (1 != faces.size()) {
-						throw new StatusException("620009", "检测到多张人脸. photoUrl=" + photoUrl);
+						throw new StatusException("620009", "检测人脸数量不正确. photoUrl=" + photoUrl);
 					}
 
 					JSONObject face = faces.getJSONObject(0);
@@ -282,7 +281,7 @@ public class FaceServiceImpl implements FaceService {
 				times++;
 				continue;
 			} catch (Exception e) {
-				LOG.error("调用detect接口异常. photoUrl=" + photoUrl, e);
+				LOG.error("人脸检测接口异常. photoUrl:{} errCount:{} err:{}", photoUrl, times, e.getMessage());
 				times++;
 				continue;
 			} finally {