wangwei il y a 7 ans
Parent
commit
64bb014f05

+ 2 - 1
examcloud-exchange-outer-api-provider/src/main/java/cn/com/qmth/examcloud/exchange/outer/api/provider/FaceppController.java

@@ -208,7 +208,8 @@ public class FaceppController extends ControllerSupport {
 							StudentFaceInfo studentFaceInfo = studentFaceInfoResponseEntity
 									.getBody();
 							// 获取faceSet,并将faceToken添加进facesetToken
-							String facesetToken = studentFaceInfoClient.getFaceSet();
+							String facesetToken = studentFaceInfoClient
+									.getFaceSet(accessUser.getUserToken());
 							if (faceppService.addFace(faceToken, facesetToken)) {
 								String photoMD5 = fileName + "." + suffix;
 								faceppService.saveStudentFaceInfo(studentFaceInfo, photoMD5,

+ 270 - 301
examcloud-exchange-outer-service/src/main/java/cn/com/qmth/examcloud/exchange/outer/service/FaceppService.java

@@ -1,23 +1,13 @@
 package cn.com.qmth.examcloud.exchange.outer.service;
 
-import cn.com.qmth.examcloud.common.dto.core.Student;
-import cn.com.qmth.examcloud.common.dto.core.StudentFaceInfo;
-import cn.com.qmth.examcloud.common.dto.em.ExamStudent;
-import cn.com.qmth.examcloud.commons.web.security.bean.User;
-import cn.com.qmth.examcloud.commons.web.security.entity.AccessUser;
-import cn.com.qmth.examcloud.exchange.base.exception.DetectNoFaceException;
-import cn.com.qmth.examcloud.exchange.base.exception.ExamStudentNotExistException;
-import cn.com.qmth.examcloud.exchange.base.exception.FaceppException;
-import cn.com.qmth.examcloud.exchange.base.exception.InvalidJpgException;
-import cn.com.qmth.examcloud.exchange.base.exception.UpYunException;
-import cn.com.qmth.examcloud.exchange.dao.bean.FaceDetectResponse;
-import cn.com.qmth.examcloud.exchange.outer.service.client.ExamStudentClient;
-import cn.com.qmth.examcloud.exchange.outer.service.client.StudentFaceInfoClient;
-import cn.com.qmth.examcloud.exchange.outer.service.impl.UpyunServiceImpl;
-import cn.com.qmth.examcloud.commons.base.util.GsonUtil;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Date;
+import java.util.List;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpEntity;
@@ -35,18 +25,23 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
 
-
-
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.security.NoSuchAlgorithmException;
-import java.util.Date;
-import java.util.List;
+import cn.com.qmth.examcloud.common.dto.core.Student;
+import cn.com.qmth.examcloud.common.dto.core.StudentFaceInfo;
+import cn.com.qmth.examcloud.common.dto.em.ExamStudent;
+import cn.com.qmth.examcloud.commons.base.util.GsonUtil;
+import cn.com.qmth.examcloud.commons.web.security.bean.User;
+import cn.com.qmth.examcloud.exchange.base.exception.DetectNoFaceException;
+import cn.com.qmth.examcloud.exchange.base.exception.ExamStudentNotExistException;
+import cn.com.qmth.examcloud.exchange.base.exception.FaceppException;
+import cn.com.qmth.examcloud.exchange.base.exception.InvalidJpgException;
+import cn.com.qmth.examcloud.exchange.base.exception.UpYunException;
+import cn.com.qmth.examcloud.exchange.dao.bean.FaceDetectResponse;
+import cn.com.qmth.examcloud.exchange.outer.service.client.ExamStudentClient;
+import cn.com.qmth.examcloud.exchange.outer.service.client.StudentFaceInfoClient;
+import cn.com.qmth.examcloud.exchange.outer.service.impl.UpyunServiceImpl;
 
 /**
  * Created by yuanpan on 2017/5/15.
@@ -55,289 +50,263 @@ import java.util.List;
 public class FaceppService {
 	private static final Logger LOG = LoggerFactory.getLogger(FaceppService.class);
 
-    @Value("${app.facepp.api_key}")
-    private String apiKey;
+	@Value("${app.facepp.api_key}")
+	private String apiKey;
 
-    @Value("${app.facepp.api_secret}")
-    private String apiSecret;
-    
-    @Autowired
-    ExamStudentClient examStudentClient;
+	@Value("${app.facepp.api_secret}")
+	private String apiSecret;
 
-    @Autowired
-    UpyunServiceImpl upyunService;
+	@Autowired
+	ExamStudentClient examStudentClient;
 
-    @Autowired
-    StudentFaceInfoClient studentFaceInfoClient;
+	@Autowired
+	UpyunServiceImpl upyunService;
 
-    private void closeResponse(CloseableHttpResponse httpResponse) {
-        if (httpResponse != null) {
-            try {
-                httpResponse.close();
-            } catch (IOException e) {
-                e.printStackTrace();
-            } finally {
-                httpResponse = null;
-            }
-        }
-    }
+	@Autowired
+	StudentFaceInfoClient studentFaceInfoClient;
 
-    /**
-     * 检测人脸
-     *
-     * @param imageUrl
-     * @return 检测到的人脸的face_token
-     * @throws URISyntaxException
-     * @throws DetectNoFaceException
-     */
-    public String detectSingleFace(String imageUrl) throws URISyntaxException, DetectNoFaceException {
-        int time = 3;//重新检测次数为3次
-        String faceToken = "";
-        while (time > 0) {
-            //调用人脸识别接口
-            CloseableHttpClient httpClient = HttpClients.createDefault();
-            URI uri = new URIBuilder()
-                    .setScheme("https")
-                    .setHost("api-cn.faceplusplus.com")
-                    .setPath("/facepp/v3/detect")
-                    .setParameter("api_key", apiKey)
-                    .setParameter("api_secret", apiSecret)
-                    .setParameter("image_url", imageUrl)
-                    .build();
+	private void closeResponse(CloseableHttpResponse httpResponse) {
+		if (httpResponse != null) {
+			try {
+				httpResponse.close();
+			} catch (IOException e) {
+				e.printStackTrace();
+			} finally {
+				httpResponse = null;
+			}
+		}
+	}
 
-            HttpPost httpPost = new HttpPost(uri);
-            CloseableHttpResponse httpResponse = null;
-            try {
-            	httpResponse = httpClient.execute(httpPost);
-                HttpEntity responseEntity = httpResponse.getEntity();
-                int statusCode = httpResponse.getStatusLine().getStatusCode();
-                BufferedReader reader = new BufferedReader(new InputStreamReader(responseEntity.getContent()));
-                if (statusCode == 200) {
-                	Gson gson = new GsonBuilder().create();
-                    FaceDetectResponse faceDetectResponse = gson.fromJson(reader, FaceDetectResponse.class);
-                    if (faceDetectResponse.getFaces() != null && faceDetectResponse.getFaces().size() > 0) {
-                        faceToken = faceDetectResponse.getFaces().get(0).getFace_token();
-                        break;
-                    } else {
-                        throw new DetectNoFaceException();
-                    }
-                } else {
-                     StringBuffer buffer = new StringBuffer();
-                     String str = "";
-                     while(StringUtils.isNoneBlank((str = reader.readLine()))) {
-                         buffer.append(str);
-                     }
-                     String result = buffer.toString();
-                     LOG.info("获取token失败:"+result);
-                     time--;
-                }
-                httpClient.close();
-            } catch (IOException e) {
-                //重试
-                LOG.error("检测人脸失败,剩余次数:" + (time - 1), e);
-                time--;
-                if (time < 1) {
-                    throw new DetectNoFaceException();
-                }
-            }finally{
-            	closeResponse(httpResponse);
-            }
-        }
-        LOG.info("检测到人脸token:" + faceToken);
-        return faceToken;
-    }
+	/**
+	 * 检测人脸
+	 *
+	 * @param imageUrl
+	 * @return 检测到的人脸的face_token
+	 * @throws URISyntaxException
+	 * @throws DetectNoFaceException
+	 */
+	public String detectSingleFace(String imageUrl)
+			throws URISyntaxException, DetectNoFaceException {
+		int time = 3;// 重新检测次数为3次
+		String faceToken = "";
+		while (time > 0) {
+			// 调用人脸识别接口
+			CloseableHttpClient httpClient = HttpClients.createDefault();
+			URI uri = new URIBuilder().setScheme("https").setHost("api-cn.faceplusplus.com")
+					.setPath("/facepp/v3/detect").setParameter("api_key", apiKey)
+					.setParameter("api_secret", apiSecret).setParameter("image_url", imageUrl)
+					.build();
 
-    /**
-     * 将人脸加入到人脸集合
-     *
-     * @param faceToken
-     * @param facesetToken
-     * @throws URISyntaxException
-     */
-    public boolean addFace(String faceToken, String facesetToken) throws URISyntaxException {
-        boolean success = false;
-        int time = 3;//重新检测次数为3次
-        while (time > 0) {
-            //调用人脸识别接口
-            CloseableHttpClient httpClient = HttpClients.createDefault();
-            URI uri = new URIBuilder()
-                    .setScheme("https")
-                    .setHost("api-cn.faceplusplus.com")
-                    .setPath("/facepp/v3/faceset/addface")
-                    .setParameter("api_key", apiKey)
-                    .setParameter("api_secret", apiSecret)
-                    .setParameter("faceset_token", facesetToken)
-                    .setParameter("face_tokens", faceToken)
-                    .build();
+			HttpPost httpPost = new HttpPost(uri);
+			CloseableHttpResponse httpResponse = null;
+			try {
+				httpResponse = httpClient.execute(httpPost);
+				HttpEntity responseEntity = httpResponse.getEntity();
+				int statusCode = httpResponse.getStatusLine().getStatusCode();
+				BufferedReader reader = new BufferedReader(
+						new InputStreamReader(responseEntity.getContent()));
+				if (statusCode == 200) {
+					Gson gson = new GsonBuilder().create();
+					FaceDetectResponse faceDetectResponse = gson.fromJson(reader,
+							FaceDetectResponse.class);
+					if (faceDetectResponse.getFaces() != null
+							&& faceDetectResponse.getFaces().size() > 0) {
+						faceToken = faceDetectResponse.getFaces().get(0).getFace_token();
+						break;
+					} else {
+						throw new DetectNoFaceException();
+					}
+				} else {
+					StringBuffer buffer = new StringBuffer();
+					String str = "";
+					while (StringUtils.isNoneBlank((str = reader.readLine()))) {
+						buffer.append(str);
+					}
+					String result = buffer.toString();
+					LOG.info("获取token失败:" + result);
+					time--;
+				}
+				httpClient.close();
+			} catch (IOException e) {
+				// 重试
+				LOG.error("检测人脸失败,剩余次数:" + (time - 1), e);
+				time--;
+				if (time < 1) {
+					throw new DetectNoFaceException();
+				}
+			} finally {
+				closeResponse(httpResponse);
+			}
+		}
+		LOG.info("检测到人脸token:" + faceToken);
+		return faceToken;
+	}
 
-            HttpPost httpPost = new HttpPost(uri);
-            CloseableHttpResponse httpResponse = null;
-            try {
-                httpResponse = httpClient.execute(httpPost);
-                StatusLine statusLine = httpResponse.getStatusLine();
-                //不能这么打印,会导致流关闭,从而造成异常。除非下面到代码不需要从流读取响应内容,则这里可以打印
-                LOG.info("添加人脸到集合响应:" + EntityUtils.toString(httpResponse.getEntity()));
-                if (statusLine.getStatusCode() == 200) {
-                    success = true;
-                    //加入成功
-                    break;
-                } else {
-                    time--;
-                }
-            } catch (IOException e) {
-                LOG.error("添加人脸失败,剩余次数:" + (time - 1), e);
-                time--;
-            } finally {
-                closeResponse(httpResponse);
-            }
-        }
-        return success;
-    }
-    
-    
-    /**
-     * 添加人脸到人脸集合
-     * @param faceToken
-     * @return 添加成功则返回faceset_token,否则返回null
-     * @throws URISyntaxException
-     */
-/*    public String createFaceset(String faceToken) throws URISyntaxException {
-        int time = 3;//重新检测次数为3次
-        while (time > 0) {
+	/**
+	 * 将人脸加入到人脸集合
+	 *
+	 * @param faceToken
+	 * @param facesetToken
+	 * @throws URISyntaxException
+	 */
+	public boolean addFace(String faceToken, String facesetToken) throws URISyntaxException {
+		boolean success = false;
+		int time = 3;// 重新检测次数为3次
+		while (time > 0) {
+			// 调用人脸识别接口
+			CloseableHttpClient httpClient = HttpClients.createDefault();
+			URI uri = new URIBuilder().setScheme("https").setHost("api-cn.faceplusplus.com")
+					.setPath("/facepp/v3/faceset/addface").setParameter("api_key", apiKey)
+					.setParameter("api_secret", apiSecret)
+					.setParameter("faceset_token", facesetToken)
+					.setParameter("face_tokens", faceToken).build();
 
+			HttpPost httpPost = new HttpPost(uri);
+			CloseableHttpResponse httpResponse = null;
+			try {
+				httpResponse = httpClient.execute(httpPost);
+				StatusLine statusLine = httpResponse.getStatusLine();
+				// 不能这么打印,会导致流关闭,从而造成异常。除非下面到代码不需要从流读取响应内容,则这里可以打印
+				LOG.info("添加人脸到集合响应:" + EntityUtils.toString(httpResponse.getEntity()));
+				if (statusLine.getStatusCode() == 200) {
+					success = true;
+					// 加入成功
+					break;
+				} else {
+					time--;
+				}
+			} catch (IOException e) {
+				LOG.error("添加人脸失败,剩余次数:" + (time - 1), e);
+				time--;
+			} finally {
+				closeResponse(httpResponse);
+			}
+		}
+		return success;
+	}
 
-            //调用人脸识别接口
-            CloseableHttpClient httpClient = HttpClients.createDefault();
-            URI uri = new URIBuilder()
-                    .setScheme("https")
-                    .setHost("api-cn.faceplusplus.com")
-                    .setPath("/facepp/v3/faceset/create")
-                    .setParameter("api_key", apiKey)
-                    .setParameter("api_secret", apiSecret)
-                    .setParameter("face_tokens", faceToken)
-                    .build();
+	/**
+	 * 添加人脸到人脸集合
+	 * 
+	 * @param faceToken
+	 * @return 添加成功则返回faceset_token,否则返回null
+	 * @throws URISyntaxException
+	 */
+	/*
+	 * public String createFaceset(String faceToken) throws URISyntaxException {
+	 * int time = 3;//重新检测次数为3次 while (time > 0) {
+	 * 
+	 * 
+	 * //调用人脸识别接口 CloseableHttpClient httpClient = HttpClients.createDefault();
+	 * URI uri = new URIBuilder() .setScheme("https")
+	 * .setHost("api-cn.faceplusplus.com") .setPath("/facepp/v3/faceset/create")
+	 * .setParameter("api_key", apiKey) .setParameter("api_secret", apiSecret)
+	 * .setParameter("face_tokens", faceToken) .build();
+	 * 
+	 * HttpPost httpPost = new HttpPost(uri); CloseableHttpResponse httpResponse
+	 * = null; try { httpResponse = httpClient.execute(httpPost); StatusLine
+	 * statusLine = httpResponse.getStatusLine(); if (statusLine.getStatusCode()
+	 * == 200) { HttpEntity httpEntity = httpResponse.getEntity(); Gson gson =
+	 * new GsonBuilder().create(); Reader reader = new
+	 * InputStreamReader(httpEntity.getContent()); CreateFacesetResponse
+	 * faceDetectResponse = gson.fromJson(reader, CreateFacesetResponse.class);
+	 * if (!StringUtils.isEmpty(faceDetectResponse.getFaceset_token())) { return
+	 * faceDetectResponse.getFaceset_token(); } } //准备重试 time--; } catch
+	 * (IOException e) { //重试 LOG.error("保存人脸失败,剩余次数:" + (time - 1), e); time--;
+	 * } finally { closeResponse(httpResponse); } } return null; }
+	 */
 
-            HttpPost httpPost = new HttpPost(uri);
-            CloseableHttpResponse httpResponse = null;
-            try {
-                httpResponse = httpClient.execute(httpPost);
-                StatusLine statusLine = httpResponse.getStatusLine();
-                if (statusLine.getStatusCode() == 200) {
-                    HttpEntity httpEntity = httpResponse.getEntity();
-                    Gson gson = new GsonBuilder().create();
-                    Reader reader = new InputStreamReader(httpEntity.getContent());
-                    CreateFacesetResponse faceDetectResponse = gson.fromJson(reader, CreateFacesetResponse.class);
-                    if (!StringUtils.isEmpty(faceDetectResponse.getFaceset_token())) {
-                        return faceDetectResponse.getFaceset_token();
-                    }
-                }
-                //准备重试
-                time--;
-            } catch (IOException e) {
-                //重试
-                LOG.error("保存人脸失败,剩余次数:" + (time - 1), e);
-                time--;
-            } finally {
-                closeResponse(httpResponse);
-            }
-        }
-        return null;
-    }*/
+	public void processOne(User accessUser, String fileName, byte[] dataBytes, Long rootOrgId)
+			throws InvalidJpgException, ExamStudentNotExistException, NoSuchAlgorithmException,
+			DetectNoFaceException, URISyntaxException, FaceppException, UpYunException {
+		String userToken = accessUser.getUserToken();
+		String[] nameAndSuffix = fileName.split("\\.");
+		if (nameAndSuffix.length < 2) {
+			throw new InvalidJpgException(fileName + "不是一个照片文件");
+		}
+		String identityNumber = (nameAndSuffix[0].startsWith("/")
+				|| nameAndSuffix[0].startsWith("\\"))
+						? nameAndSuffix[0].substring(1)
+						: nameAndSuffix[0];
+		String suffix = nameAndSuffix[1];
+		LOG.info("文件名为 :" + identityNumber + ",后缀名为:" + suffix);
+		// 根据身份证号码,查询考生是否存在
+		LOG.info("查询身份证号码为 :" + identityNumber + "的学生");
+		String json = examStudentClient.getExamStudentByIdentityNumber(userToken, identityNumber);
+		// LOG.info("查询结果为 :" + json);
+		if (StringUtils.isEmpty(json)) {
+			LOG.error("身份证号为:" + identityNumber + "的考生不存在");
+			throw new ExamStudentNotExistException();
+		} else {
+			List<ExamStudent> examStudentList = GsonUtil.jsonToArrayList(json, ExamStudent.class);
 
-    public void processOne(User accessUser, String fileName, byte[] dataBytes, Long rootOrgId) throws
-            InvalidJpgException, ExamStudentNotExistException, NoSuchAlgorithmException,
-            DetectNoFaceException, URISyntaxException, FaceppException, UpYunException {
-    	String userToken = accessUser.getUserToken();
-        String[] nameAndSuffix = fileName.split("\\.");
-        if (nameAndSuffix.length < 2) {
-            throw new InvalidJpgException(fileName + "不是一个照片文件");
-        }
-        String identityNumber = (nameAndSuffix[0].startsWith("/") || nameAndSuffix[0].startsWith("\\")) ? nameAndSuffix[0].substring(1) : nameAndSuffix[0];
-        String suffix = nameAndSuffix[1];
-        LOG.info("文件名为 :" + identityNumber + ",后缀名为:" + suffix);
-        //根据身份证号码,查询考生是否存在
-        LOG.info("查询身份证号码为 :" + identityNumber + "的学生");
-        String json = examStudentClient.getExamStudentByIdentityNumber(userToken, identityNumber);
-        //LOG.info("查询结果为 :" + json);
-        if (StringUtils.isEmpty(json)) {
-            LOG.error("身份证号为:" + identityNumber + "的考生不存在");
-            throw new ExamStudentNotExistException();
-        } else {
-            List<ExamStudent> examStudentList = GsonUtil.jsonToArrayList(json, ExamStudent.class);
+			if (examStudentList.size() < 1) {
+				LOG.error("身份证号为:" + identityNumber + "的考生不存在");
+				throw new ExamStudentNotExistException();
+			}
+			ExamStudent examStudent = examStudentList.get(0);
+			// 保存学生照片到又拍云
+			String upyunFileName = upyunService.getMd5(dataBytes);
+			try {
+				if (upyunService.saveStudentPhoto(identityNumber, dataBytes, upyunFileName,
+						"." + suffix)) {
+					// 调用人脸识别接口
+					String faceToken = detectSingleFace(upyunService.getDownloadUrl(identityNumber,
+							upyunFileName, "." + suffix));
+					if (StringUtils.isBlank(faceToken)) {
+						throw new FaceppException(identityNumber + "获取token失败");
+					}
+					String facesetToken = studentFaceInfoClient.getFaceSet(userToken);
+					ResponseEntity<StudentFaceInfo> studentFaceInfoResponseEntity = studentFaceInfoClient
+							.getByIdentityNumber(userToken, identityNumber, rootOrgId);
+					StudentFaceInfo studentFaceInfo = studentFaceInfoResponseEntity.getBody();
+					if (addFace(faceToken, facesetToken)) {
+						String photoMD5 = upyunFileName + "." + suffix;
+						saveStudentFaceInfo(studentFaceInfo, photoMD5, faceToken, facesetToken,
+								examStudent.getStudentId(), accessUser.getDisplayName(),
+								"INTERFACE_ADD", userToken);
+					} else {
+						throw new FaceppException(identityNumber + "保存当前faceToken到人脸集合(faceSet)失败");
+					}
+				} else {
+					throw new UpYunException("身份证号为:" + identityNumber + "的考生照片保存到又拍云失败");
+				}
+			} catch (IOException e) {
+				throw new RuntimeException("身份证号为:" + identityNumber + "的考生照片保存失败", e);
+			}
+		}
+	}
 
-            if (examStudentList.size() < 1) {
-                LOG.error("身份证号为:" + identityNumber + "的考生不存在");
-                throw new ExamStudentNotExistException();
-            }
-            ExamStudent examStudent = examStudentList.get(0);
-            //保存学生照片到又拍云
-            String upyunFileName = upyunService.getMd5(dataBytes);
-            try {
-                if (upyunService.saveStudentPhoto(identityNumber, dataBytes, upyunFileName, "." + suffix)) {
-                    //调用人脸识别接口
-                    String faceToken = detectSingleFace(upyunService.getDownloadUrl(identityNumber, upyunFileName, "." + suffix));
-                    if(StringUtils.isBlank(faceToken)){
-                    	 throw new FaceppException(identityNumber+"获取token失败");
-                    }
-                    String facesetToken = studentFaceInfoClient.getFaceSet();
-                    ResponseEntity<StudentFaceInfo> studentFaceInfoResponseEntity = studentFaceInfoClient.getByIdentityNumber(userToken, identityNumber, rootOrgId);
-                    StudentFaceInfo studentFaceInfo = studentFaceInfoResponseEntity.getBody();
-                    if (addFace(faceToken,facesetToken)){
-                    	String photoMD5 = upyunFileName+"."+suffix;
-                    	saveStudentFaceInfo(studentFaceInfo,
-                    					    photoMD5,	
-			                    			faceToken,
-			                    			facesetToken,
-			                    			examStudent.getStudentId(),
-			                    			accessUser.getDisplayName(),
-			                    			"INTERFACE_ADD",
-			                    			userToken);
-                    } else {
-                        throw new FaceppException(identityNumber + "保存当前faceToken到人脸集合(faceSet)失败");
-                    }
-                } else {
-                    throw new UpYunException("身份证号为:" + identityNumber + "的考生照片保存到又拍云失败");
-                }
-            } catch (IOException e) {
-                throw new RuntimeException("身份证号为:" + identityNumber + "的考生照片保存失败", e);
-            }
-        }
-    }
-    
-    /**
-     * 保存studentFaceInfo
-     * @param studentFaceInfo
-     * @param photoMD5
-     * @param faceToken
-     * @param facesetToken
-     * @param studentId
-     * @param accessUserName
-     * @param createType
-     * @param userToken
-     */
-    public void saveStudentFaceInfo(StudentFaceInfo studentFaceInfo,
-						    		String photoMD5,
-						    		String faceToken,
-						    		String facesetToken,
-						    		Long studentId,
-						    		String accessUserName,
-						    		String createType,
-						    		String userToken){
-    	if (studentFaceInfo == null) {
-            studentFaceInfo = new StudentFaceInfo();
-            Student student = new Student();
-            student.setId(studentId);
-            studentFaceInfo.setStudent(student);
-            studentFaceInfo.setCreateUser(accessUserName);
-            studentFaceInfo.setCreateTime(new Date());
-        } else {
-            studentFaceInfo.setUpdateUser(accessUserName);
-            studentFaceInfo.setUpdateTime(new Date());
-        }
-        studentFaceInfo.setFaceToken(faceToken);
-        studentFaceInfo.setFaceSetToken(facesetToken);
-        studentFaceInfo.setPhotoMD5(photoMD5);
-        studentFaceInfo.setCreateType(createType);
-    	studentFaceInfoClient.save(userToken, studentFaceInfo);
-    }
+	/**
+	 * 保存studentFaceInfo
+	 * 
+	 * @param studentFaceInfo
+	 * @param photoMD5
+	 * @param faceToken
+	 * @param facesetToken
+	 * @param studentId
+	 * @param accessUserName
+	 * @param createType
+	 * @param userToken
+	 */
+	public void saveStudentFaceInfo(StudentFaceInfo studentFaceInfo, String photoMD5,
+			String faceToken, String facesetToken, Long studentId, String accessUserName,
+			String createType, String userToken) {
+		if (studentFaceInfo == null) {
+			studentFaceInfo = new StudentFaceInfo();
+			Student student = new Student();
+			student.setId(studentId);
+			studentFaceInfo.setStudent(student);
+			studentFaceInfo.setCreateUser(accessUserName);
+			studentFaceInfo.setCreateTime(new Date());
+		} else {
+			studentFaceInfo.setUpdateUser(accessUserName);
+			studentFaceInfo.setUpdateTime(new Date());
+		}
+		studentFaceInfo.setFaceToken(faceToken);
+		studentFaceInfo.setFaceSetToken(facesetToken);
+		studentFaceInfo.setPhotoMD5(photoMD5);
+		studentFaceInfo.setCreateType(createType);
+		studentFaceInfoClient.save(userToken, studentFaceInfo);
+	}
 }

+ 20 - 11
examcloud-exchange-outer-service/src/main/java/cn/com/qmth/examcloud/exchange/outer/service/client/StudentFaceInfoClient.java

@@ -2,7 +2,11 @@ package cn.com.qmth.examcloud.exchange.outer.service.client;
 
 import org.springframework.cloud.netflix.feign.FeignClient;
 import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
 
 import cn.com.qmth.examcloud.common.dto.core.StudentFaceInfo;
 
@@ -11,15 +15,20 @@ import cn.com.qmth.examcloud.common.dto.core.StudentFaceInfo;
  */
 @FeignClient(value = "ExamCloud-service-core")
 public interface StudentFaceInfoClient {
-    @RequestMapping(method = RequestMethod.POST, value = "${$rmp.ctr.basic}/studentFaceInfo")
-    ResponseEntity<StudentFaceInfo> save(@RequestHeader("user_token") String token, @RequestBody StudentFaceInfo studentFaceInfo);
+	@RequestMapping(method = RequestMethod.POST, value = "${$rmp.ctr.basic}/studentFaceInfo")
+	ResponseEntity<StudentFaceInfo> save(@RequestHeader("user_token") String token,
+			@RequestBody StudentFaceInfo studentFaceInfo);
 
-    @RequestMapping(method = RequestMethod.GET, value = "${$rmp.ctr.basic}/studentFaceInfo/identityNumber")
-    ResponseEntity<StudentFaceInfo> getByIdentityNumber(@RequestHeader("user_token") String token, @RequestParam("identityNumber") String identityNumber, @RequestParam("orgId") Long orgId);
-    /**
-     * 获取faceSetToken(人脸集合)
-     * @return
-     */
-    @RequestMapping(method = RequestMethod.GET, value = "${$rmp.ctr.basic}/faceSet/enableFaceSet")
-    String getFaceSet();
+	@RequestMapping(method = RequestMethod.GET, value = "${$rmp.ctr.basic}/studentFaceInfo/identityNumber")
+	ResponseEntity<StudentFaceInfo> getByIdentityNumber(@RequestHeader("user_token") String token,
+			@RequestParam("identityNumber") String identityNumber,
+			@RequestParam("orgId") Long orgId);
+
+	/**
+	 * 获取faceSetToken(人脸集合)
+	 * 
+	 * @return
+	 */
+	@RequestMapping(method = RequestMethod.GET, value = "${$rmp.ctr.basic}/faceSet/enableFaceSet")
+	String getFaceSet(@RequestHeader("user_token") String token);
 }