|
@@ -12,15 +12,24 @@ import com.tencentcloudapi.faceid.v20180301.models.DetectAuthRequest;
|
|
|
import com.tencentcloudapi.faceid.v20180301.models.DetectAuthResponse;
|
|
import com.tencentcloudapi.faceid.v20180301.models.DetectAuthResponse;
|
|
|
import com.tencentcloudapi.faceid.v20180301.models.GetDetectInfoRequest;
|
|
import com.tencentcloudapi.faceid.v20180301.models.GetDetectInfoRequest;
|
|
|
import com.tencentcloudapi.faceid.v20180301.models.GetDetectInfoResponse;
|
|
import com.tencentcloudapi.faceid.v20180301.models.GetDetectInfoResponse;
|
|
|
|
|
+import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.modules.alioss.service.OssService;
|
|
import com.zhongzheng.modules.alioss.service.OssService;
|
|
|
import com.zhongzheng.modules.course.mapper.CourseMapper;
|
|
import com.zhongzheng.modules.course.mapper.CourseMapper;
|
|
|
import com.zhongzheng.modules.exam.domain.ExamArrangementGuide;
|
|
import com.zhongzheng.modules.exam.domain.ExamArrangementGuide;
|
|
|
import com.zhongzheng.modules.face.bo.FaceVo;
|
|
import com.zhongzheng.modules.face.bo.FaceVo;
|
|
|
import com.zhongzheng.modules.face.service.IFaceService;
|
|
import com.zhongzheng.modules.face.service.IFaceService;
|
|
|
|
|
+import com.zhongzheng.modules.user.bo.UserEditBo;
|
|
|
|
|
+import com.zhongzheng.modules.user.bo.UserOcrAddBo;
|
|
|
|
|
+import com.zhongzheng.modules.user.domain.User;
|
|
|
|
|
+import com.zhongzheng.modules.user.mapper.UserMapper;
|
|
|
|
|
+import com.zhongzheng.modules.user.service.IUserOcrService;
|
|
|
|
|
+import com.zhongzheng.modules.user.service.IUserService;
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
@Service
|
|
@Service
|
|
|
public class FaceServiceImpl implements IFaceService {
|
|
public class FaceServiceImpl implements IFaceService {
|
|
|
|
|
|
|
@@ -33,6 +42,12 @@ public class FaceServiceImpl implements IFaceService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private OssService ossService;
|
|
private OssService ossService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IUserOcrService iUserOcrService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private UserMapper userMapper;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public FaceVo getFaceDetectAuth() {
|
|
public FaceVo getFaceDetectAuth() {
|
|
|
try{
|
|
try{
|
|
@@ -57,7 +72,7 @@ public class FaceServiceImpl implements IFaceService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void getDetectInfo(String bizToken) {
|
|
|
|
|
|
|
+ public void getDetectInfo(String bizToken,Long userId) {
|
|
|
try{
|
|
try{
|
|
|
Credential cred = new Credential(SecretId, SecretKey);
|
|
Credential cred = new Credential(SecretId, SecretKey);
|
|
|
|
|
|
|
@@ -73,8 +88,48 @@ public class FaceServiceImpl implements IFaceService {
|
|
|
req.setBizToken(bizToken);
|
|
req.setBizToken(bizToken);
|
|
|
req.setRuleId("0");
|
|
req.setRuleId("0");
|
|
|
GetDetectInfoResponse resp = client.GetDetectInfo(req);
|
|
GetDetectInfoResponse resp = client.GetDetectInfo(req);
|
|
|
- JSONObject resultObject = JSONObject.parseObject(GetDetectInfoResponse.toJsonString(resp));
|
|
|
|
|
- System.out.println(GetDetectInfoResponse.toJsonString(resp));
|
|
|
|
|
|
|
+ JSONObject resultObject = JSONObject.parseObject(resp.getDetectInfo());
|
|
|
|
|
+ if (resultObject.containsKey("Text")){
|
|
|
|
|
+ Map entry = (Map)resultObject.get("Text");
|
|
|
|
|
+ int ErrCode = ((Integer)entry.get("ErrCode"));
|
|
|
|
|
+ if(ErrCode==0){ //0为成功
|
|
|
|
|
+ String IdCard = ((String)entry.get("IdCard"));
|
|
|
|
|
+ String Name = ((String)entry.get("Name"));
|
|
|
|
|
+ //照片
|
|
|
|
|
+ Map IdCardData = (Map)resultObject.get("IdCardData");
|
|
|
|
|
+ String OcrFront = ((String)IdCardData.get("OcrFront"));
|
|
|
|
|
+ String OcrFrontFileName = ossService.uploadBase64(OcrFront);
|
|
|
|
|
+ String OcrBack = ((String)IdCardData.get("OcrBack"));
|
|
|
|
|
+ String OcrBackFileName = ossService.uploadBase64(OcrBack);
|
|
|
|
|
+ //视频最佳帧截图
|
|
|
|
|
+ Map BestFrame = (Map)resultObject.get("BestFrame");
|
|
|
|
|
+ String imgBestFrame = ((String)BestFrame.get("BestFrame"));
|
|
|
|
|
+ String imgBestFrameFileName = ossService.uploadBase64(imgBestFrame);
|
|
|
|
|
+
|
|
|
|
|
+ User user = new User();
|
|
|
|
|
+ user.setUserId(userId);
|
|
|
|
|
+ user.setIdCardImg1(OcrFrontFileName);
|
|
|
|
|
+ user.setIdCardImg2(OcrBackFileName);
|
|
|
|
|
+ user.setRealname(Name);
|
|
|
|
|
+ user.setIdCard(IdCard);
|
|
|
|
|
+ user.setCertified(1);
|
|
|
|
|
+ user.setCertifiedTime(DateUtils.getNowTime());
|
|
|
|
|
+ user.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
|
+ userMapper.updateById(user);
|
|
|
|
|
+
|
|
|
|
|
+ UserOcrAddBo bo = new UserOcrAddBo();
|
|
|
|
|
+ bo.setBestFrame(imgBestFrameFileName);
|
|
|
|
|
+ bo.setOcrFront(OcrFrontFileName);
|
|
|
|
|
+ bo.setOcrBack(OcrBackFileName);
|
|
|
|
|
+ bo.setUserId(userId);
|
|
|
|
|
+ bo.setOcrInfo(JSONObject.toJSONString(entry));
|
|
|
|
|
+ bo.setStatus(1);
|
|
|
|
|
+ iUserOcrService.insertByAddBo(bo);
|
|
|
|
|
+ ossService.closeClient();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
} catch (TencentCloudSDKException e) {
|
|
} catch (TencentCloudSDKException e) {
|
|
|
System.out.println(e.toString());
|
|
System.out.println(e.toString());
|
|
|
}
|
|
}
|