|
@@ -1,6 +1,8 @@
|
|
package cn.com.qmth.examcloud.exchange.outer.service.impl;
|
|
package cn.com.qmth.examcloud.exchange.outer.service.impl;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
+import java.io.FileInputStream;
|
|
|
|
+import java.io.InputStream;
|
|
import java.net.URI;
|
|
import java.net.URI;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -14,6 +16,7 @@ import org.apache.http.client.utils.URIBuilder;
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
import org.apache.http.impl.client.HttpClients;
|
|
import org.apache.http.impl.client.HttpClients;
|
|
import org.apache.http.util.EntityUtils;
|
|
import org.apache.http.util.EntityUtils;
|
|
|
|
+import org.apache.poi.util.IOUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -23,6 +26,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.base.exception.ExamCloudRuntimeException;
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLog;
|
|
import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLog;
|
|
import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLogFactory;
|
|
import cn.com.qmth.examcloud.commons.base.logging.ExamCloudLogFactory;
|
|
@@ -38,6 +42,7 @@ import cn.com.qmth.examcloud.core.basic.api.request.SaveStudentFaceReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetStudentResp;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetStudentResp;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetUsableFacesetListResp;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetUsableFacesetListResp;
|
|
import cn.com.qmth.examcloud.exchange.inner.service.UpyunService;
|
|
import cn.com.qmth.examcloud.exchange.inner.service.UpyunService;
|
|
|
|
+import cn.com.qmth.examcloud.exchange.inner.service.bean.UpyunPathEnvironmentInfo;
|
|
import cn.com.qmth.examcloud.exchange.outer.service.FaceService;
|
|
import cn.com.qmth.examcloud.exchange.outer.service.FaceService;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -85,8 +90,24 @@ public class FaceServiceImpl implements FaceService {
|
|
GetStudentResp resp = studentCloudService.getStudent(req);
|
|
GetStudentResp resp = studentCloudService.getStudent(req);
|
|
StudentBean student = resp.getStudentInfo();
|
|
StudentBean student = resp.getStudentInfo();
|
|
identityNumber = student.getIdentityNumber();
|
|
identityNumber = student.getIdentityNumber();
|
|
-
|
|
|
|
- String photoUrl = upyunService.writeFile(rootOrgId, identityNumber, photoName, file);
|
|
|
|
|
|
+ Long id = student.getId();
|
|
|
|
+
|
|
|
|
+ UpyunPathEnvironmentInfo env = new UpyunPathEnvironmentInfo();
|
|
|
|
+ env.setFileSuffix(fileSuffix);
|
|
|
|
+ env.setRootOrgId(rootOrgId);
|
|
|
|
+ env.setUserId(id);
|
|
|
|
+ InputStream in = null;
|
|
|
|
+ String photoUrl = null;
|
|
|
|
+ try {
|
|
|
|
+ in = new FileInputStream(file);
|
|
|
|
+ photoUrl = upyunService.writeFile("studentBasePhoto", env, in);
|
|
|
|
+ } catch (StatusException e) {
|
|
|
|
+ throw e;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new ExamCloudRuntimeException(e);
|
|
|
|
+ } finally {
|
|
|
|
+ IOUtils.closeQuietly(in);
|
|
|
|
+ }
|
|
|
|
|
|
String faceToken = detect(photoUrl);
|
|
String faceToken = detect(photoUrl);
|
|
|
|
|