Jelajahi Sumber

添加百度orc

周箭河 5 tahun lalu
induk
melakukan
90ebbcd2d3

+ 104 - 98
edu-thirdparty/pom.xml

@@ -1,102 +1,108 @@
 <?xml version="1.0"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>com.keao.edu</groupId>
-    <artifactId>edu-saas</artifactId>
-    <version>1.0</version>
-  </parent>
-  <artifactId>edu-thirdparty</artifactId>
-  <name>edu-thirdparty</name>
-  <url>http://maven.apache.org</url>
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-  <dependencies>
-      <dependency>
-          <groupId>org.springframework</groupId>
-          <artifactId>spring-context</artifactId>
-          <scope>compile</scope>
-      </dependency>
-      <dependency>
-        <groupId>com.aliyun.oss</groupId>
-        <artifactId>aliyun-sdk-oss</artifactId>
-        <version>2.8.3</version>
-      </dependency>
-    <dependency>
-      <groupId>com.keao.edu</groupId>
-      <artifactId>edu-util</artifactId>
-    </dependency>
-		
-		<dependency>
-			<groupId>com.timevale</groupId>
-			<artifactId>tech-sdk</artifactId>
-			<version>2.1.20</version>
-			<scope>system</scope>
-			<systemPath>${project.basedir}/libs/tech-sdk-2.1.20.jar</systemPath>
-		</dependency>
-		
-		<dependency>
-			<groupId>com.timevale</groupId>
-			<artifactId>smUtil</artifactId>
-			<version>1.0</version>
-			<scope>system</scope>
-			<systemPath>${project.basedir}/libs/smUtil-1.0.jar</systemPath>
-		</dependency>
-		
-		<dependency>
-			<groupId>com.timevale</groupId>
-			<artifactId>tgtext</artifactId>
-			<version>3.2.14</version>
-			<scope>system</scope>
-			<systemPath>${project.basedir}/libs/tgtext-3.2.14.jar</systemPath>
-		</dependency>
-		
-		<dependency>
-			<groupId>com.timevale</groupId>
-			<artifactId>utils</artifactId>
-			<version>3.0.6</version>
-			<scope>system</scope>
-			<systemPath>${project.basedir}/libs/utils-3.0.6.jar</systemPath>
-		</dependency>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.keao.edu</groupId>
+        <artifactId>edu-saas</artifactId>
+        <version>1.0</version>
+    </parent>
+    <artifactId>edu-thirdparty</artifactId>
+    <name>edu-thirdparty</name>
+    <url>http://maven.apache.org</url>
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.aliyun.oss</groupId>
+            <artifactId>aliyun-sdk-oss</artifactId>
+            <version>2.8.3</version>
+        </dependency>
+        <dependency>
+            <groupId>com.keao.edu</groupId>
+            <artifactId>edu-util</artifactId>
+        </dependency>
 
-		<dependency>
-			<groupId>cfca.sadk</groupId>
-			<artifactId>cfca.sadk</artifactId>
-			<version>1.0.0</version>
-			<scope>system</scope>
-			<systemPath>${project.basedir}/libs/SADK-3.2.5.2.jar</systemPath>
-		</dependency>
-		<dependency>
-			<groupId>adapay</groupId>
-			<artifactId>adapay-java-sdk</artifactId>
-			<version>1.0.2</version>
-			<scope>system</scope>
-			<systemPath>${project.basedir}/libs/adapay-java-sdk-1.0.2.jar
-			</systemPath>
-		</dependency>
-		<dependency>
-			<groupId>org.eclipse.paho</groupId>
-			<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
-			<version>1.2.0</version>
-		</dependency>
+        <dependency>
+            <groupId>com.timevale</groupId>
+            <artifactId>tech-sdk</artifactId>
+            <version>2.1.20</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/libs/tech-sdk-2.1.20.jar</systemPath>
+        </dependency>
 
-		<dependency>
-			<groupId>org.springframework.cloud</groupId>
-			<artifactId>spring-cloud-starter-openfeign</artifactId>
-		</dependency>
-		<!-- https://mvnrepository.com/artifact/io.github.openfeign.form/feign-form-spring -->
-		<dependency>
-			<groupId>io.github.openfeign.form</groupId>
-			<artifactId>feign-form-spring</artifactId>
-			<version>2.0.5</version>
-		</dependency>
-		<!-- https://mvnrepository.com/artifact/io.github.openfeign.form/feign-form-spring -->
-		<dependency>
-			<groupId>io.github.openfeign.form</groupId>
-			<artifactId>feign-form-spring</artifactId>
-			<version>2.0.5</version>
-		</dependency>
-  </dependencies>
+        <dependency>
+            <groupId>com.timevale</groupId>
+            <artifactId>smUtil</artifactId>
+            <version>1.0</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/libs/smUtil-1.0.jar</systemPath>
+        </dependency>
+
+        <dependency>
+            <groupId>com.timevale</groupId>
+            <artifactId>tgtext</artifactId>
+            <version>3.2.14</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/libs/tgtext-3.2.14.jar</systemPath>
+        </dependency>
+
+        <dependency>
+            <groupId>com.timevale</groupId>
+            <artifactId>utils</artifactId>
+            <version>3.0.6</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/libs/utils-3.0.6.jar</systemPath>
+        </dependency>
+
+        <dependency>
+            <groupId>cfca.sadk</groupId>
+            <artifactId>cfca.sadk</artifactId>
+            <version>1.0.0</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/libs/SADK-3.2.5.2.jar</systemPath>
+        </dependency>
+        <dependency>
+            <groupId>adapay</groupId>
+            <artifactId>adapay-java-sdk</artifactId>
+            <version>1.0.2</version>
+            <scope>system</scope>
+            <systemPath>${project.basedir}/libs/adapay-java-sdk-1.0.2.jar
+            </systemPath>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.paho</groupId>
+            <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
+            <version>1.2.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-openfeign</artifactId>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/io.github.openfeign.form/feign-form-spring -->
+        <dependency>
+            <groupId>io.github.openfeign.form</groupId>
+            <artifactId>feign-form-spring</artifactId>
+            <version>2.0.5</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/io.github.openfeign.form/feign-form-spring -->
+        <dependency>
+            <groupId>io.github.openfeign.form</groupId>
+            <artifactId>feign-form-spring</artifactId>
+            <version>2.0.5</version>
+        </dependency>
+        <dependency>
+            <groupId>com.baidu.aip</groupId>
+            <artifactId>java-sdk</artifactId>
+            <version>4.12.0</version>
+        </dependency>
+    </dependencies>
 </project>

+ 32 - 0
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/ocr/baidu.java

@@ -0,0 +1,32 @@
+package com.keao.edu.thirdparty.ocr;
+
+import com.baidu.aip.http.AipRequest;
+import com.baidu.aip.ocr.AipOcr;
+import com.baidu.aip.util.Base64Util;
+import org.json.JSONObject;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+public class baidu {
+
+    public static final String APP_ID = "20569335";
+    public static final String API_KEY = "82FCqipUDtTqmy2qbrCRaHCo";
+    public static final String SECRET_KEY = "ab6QZclNrzzX1Hw8uQ05n787euLq7KXX";
+
+    public static JSONObject idcard(MultipartFile file, String idCardSide) throws IOException {
+        // 初始化一个AipOcr
+        AipOcr client = new AipOcr(APP_ID, API_KEY, SECRET_KEY);
+
+        // 可选:设置网络连接参数
+        client.setConnectionTimeoutInMillis(2000);
+        client.setSocketTimeoutInMillis(60000);
+        // 调用接口
+        byte[] imgBytes = file.getBytes();
+        JSONObject res = client.idcard(imgBytes, idCardSide, null);
+        return res;
+    }
+
+
+}

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/config/ResourceServerConfig.java

@@ -25,7 +25,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
 	@Override
 	public void configure(HttpSecurity http) throws Exception {
 		http.authorizeRequests()
-				.antMatchers("/v2/api-docs", "/su/**","/student/apply")
+				.antMatchers("/v2/api-docs", "/su/**","/student/apply","/examRegistration/ocr")
 				.permitAll()
 				.anyRequest().authenticated().and().csrf().disable().exceptionHandling().accessDeniedHandler(baseAccessDeniedHandler)
 				.authenticationEntryPoint(baseAuthenticationEntryPoint).and();

+ 12 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRegistrationController.java

@@ -5,16 +5,20 @@ import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.common.controller.BaseController;
 import com.keao.edu.common.entity.HttpResponseResult;
 import com.keao.edu.common.page.PageInfo;
+import com.keao.edu.thirdparty.ocr.baidu;
 import com.keao.edu.user.dto.ExamRegistrationStatisticsDto;
 import com.keao.edu.user.entity.ExamRegistration;
 import com.keao.edu.user.page.ExamRegistrationQueryInfo;
 import com.keao.edu.user.service.ExamRegistrationService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.io.IOException;
 import java.util.Objects;
 
 /**
@@ -68,4 +72,12 @@ public class ExamRegistrationController extends BaseController {
         return succeed(examRegistrationService.getExamRegistrationStaticsInfo(sysUser.getId(), examId));
     }
 
+
+    @ApiOperation(value = "修改学员报名信息")
+    @PostMapping(value = "ocr")
+    public HttpResponseResult ocr(@RequestParam("file") MultipartFile file,String idCardSide) throws IOException {
+        return succeed(baidu.idcard(file,idCardSide));
+    }
+
+
 }