diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index eb54cbe..171b9ce 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,55 +4,16 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -222,7 +183,8 @@
-
+
+
@@ -232,7 +194,23 @@
1713854151245
-
+
+
+ 1714529359654
+
+
+
+ 1714529359654
+
+
+
+ 1714529580181
+
+
+
+ 1714529580181
+
+
@@ -307,6 +285,7 @@
-
+
+
\ No newline at end of file
diff --git a/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/controller/AuthenController.java b/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/controller/AuthenController.java
index 028af19..a5b08e2 100644
--- a/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/controller/AuthenController.java
+++ b/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/controller/AuthenController.java
@@ -27,22 +27,20 @@ public class AuthenController {
}
@PostMapping("ocrScan")
- public Result ocrScan(@RequestBody OCRReq ocrReq) throws IOException {
- Result result = authenService.ocrScan(ocrReq);
+ public Result ocrScan(@RequestParam String side,@RequestParam("file") MultipartFile url) throws IOException {
+ Result result = authenService.ocrScan(side,url);
return result;
}
@PostMapping("commitAuthen")
- public Result commitAuthen(@RequestBody AuthenReq authenReq) throws ExecutionException, InterruptedException {
- Result result = authenService.commitAuthen(authenReq);
+ public Result commitAuthen(@RequestParam("face") MultipartFile img1,
+ @RequestParam("back") MultipartFile img2,
+ @RequestParam("file") MultipartFile movie,
+ AuthenReq authenReq) throws ExecutionException, InterruptedException {
+ Result result = authenService.commitAuthen(img1,img2,movie,authenReq);
return result;
}
-
-
-
-
-
@PostMapping("upload")
public Result upload(@RequestParam("file")MultipartFile multipartFile) throws IOException {
String upload = authenService.upload(multipartFile);
diff --git a/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/service/AuthenService.java b/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/service/AuthenService.java
index 09dc195..572d606 100644
--- a/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/service/AuthenService.java
+++ b/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/service/AuthenService.java
@@ -3,20 +3,15 @@ package com.bwie.authen.service;
import com.bwie.authen.vo.AliveReq;
import com.bwie.authen.vo.AuthenReq;
import com.bwie.authen.vo.IdCheckReq;
-import com.bwie.authen.vo.OCRReq;
import com.bwie.common.result.Result;
-import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.Map;
import java.util.concurrent.ExecutionException;
public interface AuthenService {
- Result ocrScan(OCRReq ocrReq) throws IOException;
-
- Result commitAuthen(AuthenReq authenReq) throws ExecutionException, InterruptedException;
+ Result ocrScan(String side, MultipartFile url) throws IOException;
+ Result commitAuthen(MultipartFile img1, MultipartFile img2, MultipartFile movie, AuthenReq authenReq) throws ExecutionException, InterruptedException;
@@ -30,4 +25,7 @@ public interface AuthenService {
Result idCheck(IdCheckReq ocrReq);
Result alive(AliveReq ocrReq);
+
+
+
}
diff --git a/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/service/AuthenServiceImpl.java b/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/service/AuthenServiceImpl.java
index a4eed41..111eb29 100644
--- a/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/service/AuthenServiceImpl.java
+++ b/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/service/AuthenServiceImpl.java
@@ -9,12 +9,9 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.Serializable;
-import java.util.Arrays;
-import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadPoolExecutor;
-import java.util.stream.Collectors;
@Service
@Log4j2
@@ -35,27 +32,39 @@ public class AuthenServiceImpl implements AuthenService{
}
@Override
- public Result ocrScan(OCRReq ocrReq) throws IOException {
- OCRResponse send = ocrUtil.send(ocrReq);
+ public Result ocrScan( String side, MultipartFile url) throws IOException {
+ OCRResponse send = ocrUtil.send(side,url);
return Result.success(send);
}
@Override
- public Result commitAuthen(AuthenReq authenReq) throws ExecutionException, InterruptedException {
+ public Result commitAuthen(MultipartFile img1, MultipartFile img2, MultipartFile movie, AuthenReq authenReq) throws ExecutionException, InterruptedException {
ThreadPoolExecutor threadPoolExecutor = config.threadPoolExecutor();
CompletableFuture f1 = CompletableFuture.supplyAsync(() -> {
IdCheckReq idCheckReq = new IdCheckReq();
idCheckReq.setName(authenReq.getName());
idCheckReq.setIdCardNo(authenReq.getIdCord());
IdCheckResponse idcheck = idCheckUtil.idcheck(idCheckReq);
- return idcheck.getIdData().getResult();
+ Integer result = idcheck.getIdData().getResult();
+ if(result!=0){
+ return 1;
+ }
+ try {
+ OCRResponse send = ocrUtil.send("face", img1);
+ if(send.getNum().equals(authenReq.getIdCord())&&send.getName().equals(authenReq.getName())){
+ return 0;
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ return 1;
},threadPoolExecutor);
CompletableFuture extends Serializable> f2= CompletableFuture.supplyAsync(() -> {
String upload = null;
try {
- upload = osSupload.upload(authenReq.getMovie());
+ upload = osSupload.upload(movie);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -76,13 +85,13 @@ public class AuthenServiceImpl implements AuthenService{
CompletableFuture f3 = CompletableFuture.supplyAsync(() -> {
String upload = null;
try {
- upload = osSupload.upload(authenReq.getImg2());
+ upload = osSupload.upload(img2);
} catch (IOException e) {
throw new RuntimeException(e);
}
String upload2 = null;
try {
- upload2 = osSupload.upload(authenReq.getMovie());
+ upload2 = osSupload.upload(movie);
} catch (IOException e) {
throw new RuntimeException(e);
}
diff --git a/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/util/OCRUtil.java b/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/util/OCRUtil.java
index 5781b4a..8446230 100644
--- a/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/util/OCRUtil.java
+++ b/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/util/OCRUtil.java
@@ -7,8 +7,10 @@ import com.bwie.authen.vo.OCRReq;
import com.bwie.authen.vo.OCRResponse;
+import com.bwie.common.result.Result;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
+import org.springframework.web.multipart.MultipartFile;
import java.io.File;
@@ -31,17 +33,17 @@ public class OCRUtil {
@Value("${ocr.path}")
private String path;
- public OCRResponse send(OCRReq ocrReq) throws IOException {
+ public OCRResponse send(String side, MultipartFile url) throws IOException {
// 对图像进行base64编码
- String encode = Base64.encode(ocrReq.getUrl().getBytes());
+ String encode = Base64.encode(url.getBytes());
// 拼装请求body的json字符串
JSONObject requestObj = new JSONObject();
requestObj.put("image", encode);
- requestObj.put("side", ocrReq.getSide()); // 假设ocrReq有getSide()方法返回要识别的身份证面(正/反)
+ requestObj.put("side", side); // 假设ocrReq有getSide()方法返回要识别的身份证面(正/反)
// 如果API还有其他配置参数,可以从ocrReq中获取并添加到requestObj中
String bodys = requestObj.toString();
@@ -60,7 +62,7 @@ public class OCRUtil {
OCRResponse msgResponse = JSON.parseObject(result, OCRResponse.class);
// 检查是否成功,而不是使用Assert(Assert通常用于测试)
- if (!msgResponse.equals("true")) {
+ if (!msgResponse.getSuccess().equals("true")) {
// 处理失败情况,例如记录日志或返回错误信息给调用者
throw new RuntimeException("扫描失败" ); // 假设OCRResponse有一个getErrorMessage方法
}
diff --git a/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/vo/AuthenReq.java b/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/vo/AuthenReq.java
index 9963129..d38d4b0 100644
--- a/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/vo/AuthenReq.java
+++ b/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/vo/AuthenReq.java
@@ -9,10 +9,8 @@ import org.springframework.web.multipart.MultipartFile;
@AllArgsConstructor
@NoArgsConstructor
public class AuthenReq {
+
private String motions;
- private MultipartFile img1;
- private MultipartFile img2;
- private MultipartFile movie;
private String name;
private String idCord;
@@ -28,4 +26,5 @@ public class AuthenReq {
+
}
diff --git a/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/vo/OCRReq.java b/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/vo/OCRReq.java
index 8d88bc7..6bc5bd0 100644
--- a/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/vo/OCRReq.java
+++ b/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/vo/OCRReq.java
@@ -5,11 +5,11 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.web.multipart.MultipartFile;
+import java.io.Serializable;
+
@Data
@NoArgsConstructor
public class OCRReq {
private String side;
private MultipartFile url;
-
-
}
diff --git a/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/vo/OCRResponse.java b/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/vo/OCRResponse.java
index dac2037..f168ff3 100644
--- a/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/vo/OCRResponse.java
+++ b/bwie-modules/bwie-authen/src/main/java/com/bwie/authen/vo/OCRResponse.java
@@ -13,7 +13,7 @@ public class OCRResponse {
private String sex;
private String num;
private String birth;
- private boolean success;
+ private String success;