entry : meta.entrySet()) {
+ String key = entry.getKey();
+ String resultStr = entry.getValue().toString();
+ JSONObject result = JSON.parseObject(resultStr);
+ String value = result.getString("words");
+ switch (key) {
+ case LicenseKeywords.UNIT_NAME:
+ license.setUnitName(value);
+ break;
+ case LicenseKeywords.UNIT_TYPE:
+ license.setUnitType(value);
+ break;
+ case LicenseKeywords.LEGAL_PERSON:
+ license.setLegalPerson(value);
+ break;
+ case LicenseKeywords.ADDRESS:
+ license.setAddress(value);
+ break;
+ case LicenseKeywords.CODE:
+ license.setCode(value);
+ break;
+ case LicenseKeywords.ID_NUMBER:
+ license.setIdNumber(value);
+ break;
+ case LicenseKeywords.VALIDITY:
+ license.setValidity(value);
+ break;
+ case LicenseKeywords.REGISTERED_CAPITAL:
+ license.setRegisteredCapital(value);
+ break;
+ case LicenseKeywords.COMPANY_CREATE_DATE:
+ license.setCompanyCreateDate(value);
+ break;
+ case LicenseKeywords.LAYOUT:
+ license.setLayout(value);
+ break;
+ case LicenseKeywords.BUSINESS_SCOPE:
+ license.setBusinessScope(value);
+ break;
+ default:
+ }
+ }
+ }
+
+ /**
+ * 获取目标文件类型的返回结果
+ *
+ * @param file File或MultipartFile类型
+ * @return
+ * @throws Exception
+ */
+ private static File transferToFile(Object file) throws Exception {
+ File img;
+ if (file instanceof File) {
+ img = (File) file;
+ } else if (file instanceof MultipartFile) {
+ img = FileUtils.multipartFileToFile((MultipartFile) file);
+ } else {
+ throw new UnsupportedOperationException("仅支持File或MultipartFile类型的参数");
+ }
+ return img;
+ }
+
+ /**
+ * 获取接口请求参数的base64编码格式的图片参数
+ *
+ * @param file
+ * @return
+ * @throws Exception
+ */
+ private static String getImageBase64Param(Object file) throws Exception {
+ File img;
+ if (file instanceof File) {
+ img = (File) file;
+ } else if (file instanceof MultipartFile) {
+ img = FileUtils.multipartFileToFile((MultipartFile) file);
+ } else {
+ throw new UnsupportedOperationException("仅支持File或MultipartFile类型的参数");
+ }
+ byte[] bytes = FileUtil.readFileByBytes(img);
+ String encode = Base64Util.encode(bytes);
+ return URLEncoder.encode(encode, BaiduOcrConstant.CHARSET);
+ }
+
+ /**
+ * 获取百度云API的access_token
+ * 所需参数:grant_type - 固定值:client_credentials
+ * client_id - 百度智能云注册的应用程序API Key
+ * client_secret - 百度智能云注册的应用程序Secret Key
+ *
+ * @return access_token
+ */
+ public static String getAccessToken() {
+ try {
+ org.json.JSONObject jsonObject = DevAuth.oauth(BaiduOcrConstant.CLIENT_ID, BaiduOcrConstant.CLIENT_SECRET, config());
+ return jsonObject.getString("access_token");
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ }
+ return null;
+ }
+
+ /**
+ * 请求额外参数配置
+ *
+ */
+ private static AipClientConfiguration config() {
+ AipClientConfiguration config = new AipClientConfiguration();
+ config.setConnectionTimeoutMillis(60000);
+ config.setSocketTimeoutMillis(60000);
+ return config;
+ }
+
+}
diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/Base64Util.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/Base64Util.java
new file mode 100644
index 00000000..f5a99b5c
--- /dev/null
+++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/Base64Util.java
@@ -0,0 +1,67 @@
+package cn.iocoder.yudao.module.bs.utils;
+
+/**
+ * @author MrFang
+ * @date 2023年08月15日 11:38
+ */
+public class Base64Util {
+ private static final char last2byte = (char) Integer.parseInt("00000011", 2);
+ private static final char last4byte = (char) Integer.parseInt("00001111", 2);
+ private static final char last6byte = (char) Integer.parseInt("00111111", 2);
+ private static final char lead6byte = (char) Integer.parseInt("11111100", 2);
+ private static final char lead4byte = (char) Integer.parseInt("11110000", 2);
+ private static final char lead2byte = (char) Integer.parseInt("11000000", 2);
+ private static final char[] encodeTable = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};
+
+ public Base64Util() {
+ }
+
+ public static String encode(byte[] from) {
+ StringBuilder to = new StringBuilder((int) ((double) from.length * 1.34D) + 3);
+ int num = 0;
+ char currentByte = 0;
+
+ int i;
+ for (i = 0; i < from.length; ++i) {
+ for (num %= 8; num < 8; num += 6) {
+ switch (num) {
+ case 0:
+ currentByte = (char) (from[i] & lead6byte);
+ currentByte = (char) (currentByte >>> 2);
+ case 1:
+ case 3:
+ case 5:
+ default:
+ break;
+ case 2:
+ currentByte = (char) (from[i] & last6byte);
+ break;
+ case 4:
+ currentByte = (char) (from[i] & last4byte);
+ currentByte = (char) (currentByte << 2);
+ if (i + 1 < from.length) {
+ currentByte = (char) (currentByte | (from[i + 1] & lead2byte) >>> 6);
+ }
+ break;
+ case 6:
+ currentByte = (char) (from[i] & last2byte);
+ currentByte = (char) (currentByte << 4);
+ if (i + 1 < from.length) {
+ currentByte = (char) (currentByte | (from[i + 1] & lead4byte) >>> 4);
+ }
+ }
+
+ to.append(encodeTable[currentByte]);
+ }
+ }
+
+ if (to.length() % 4 != 0) {
+ for (i = 4 - to.length() % 4; i > 0; --i) {
+ to.append("=");
+ }
+ }
+
+ return to.toString();
+ }
+
+}
diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/BusinessLicense.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/BusinessLicense.java
new file mode 100644
index 00000000..2982dcb7
--- /dev/null
+++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/BusinessLicense.java
@@ -0,0 +1,46 @@
+package cn.iocoder.yudao.module.bs.utils;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * @author MrFang
+ * @date 2023年08月15日 11:37
+ */
+@Data
+public class BusinessLicense {
+
+ @Schema(description = "单位名称")
+ private String unitName;
+
+ @Schema(description = "类型")
+ private String unitType;
+
+ @Schema(description = "公司法人")
+ private String legalPerson;
+
+ @Schema(description = "地址")
+ private String address;
+
+ @Schema(description = "有效期")
+ private String validity;
+
+ @Schema(description = "证件编号")
+ private String idNumber;
+
+ @Schema(description = "社会信用代码")
+ private String code;
+
+ @Schema(description = "注册资本")
+ private String registeredCapital;
+
+ @Schema(description = "成立日期")
+ private String companyCreateDate;
+
+ @Schema(description = "组成形式")
+ private String layout;
+
+ @Schema(description = "经营范围")
+ private String businessScope;
+
+}
diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/FileUtil.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/FileUtil.java
new file mode 100644
index 00000000..558ac277
--- /dev/null
+++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/FileUtil.java
@@ -0,0 +1,66 @@
+package cn.iocoder.yudao.module.bs.utils;
+
+import java.io.*;
+
+/**
+ * @author MrFang
+ * @date 2023年08月15日 11:39
+ */
+public class FileUtil {
+ /**
+ * 读取文件内容,作为字符串返回
+ */
+ public static String readFileAsString(String filePath) throws IOException {
+ File file = new File(filePath);
+ if (!file.exists()) {
+ throw new FileNotFoundException(filePath);
+ }
+
+ if (file.length() > 1024 * 1024 * 1024) {
+ throw new IOException("File is too large");
+ }
+
+ StringBuilder sb = new StringBuilder((int) (file.length()));
+ // 创建字节输入流
+ FileInputStream fis = new FileInputStream(filePath);
+ // 创建一个长度为10240的Buffer
+ byte[] bbuf = new byte[10240];
+ // 用于保存实际读取的字节数
+ int hasRead = 0;
+ while ((hasRead = fis.read(bbuf)) > 0) {
+ sb.append(new String(bbuf, 0, hasRead));
+ }
+ fis.close();
+ return sb.toString();
+ }
+
+ /**
+ * 根据文件路径读取byte[] 数组
+ */
+ public static byte[] readFileByBytes(String filePath) throws IOException {
+ File file = new File(filePath);
+ if (!file.exists()) {
+ throw new FileNotFoundException(filePath);
+ }
+ return readFileByBytes(file);
+ }
+
+ /**
+ * 根据文件读取byte[] 数组
+ */
+ public static byte[] readFileByBytes(File file) throws IOException {
+ try (ByteArrayOutputStream bos = new ByteArrayOutputStream((int) file.length())) {
+ BufferedInputStream in = null;
+ in = new BufferedInputStream(new FileInputStream(file));
+ short bufSize = 1024;
+ byte[] buffer = new byte[bufSize];
+ int len1;
+ while (-1 != (len1 = in.read(buffer, 0, bufSize))) {
+ bos.write(buffer, 0, len1);
+ }
+ byte[] var7 = bos.toByteArray();
+ return var7;
+ }
+ }
+
+}
diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/FileUtils.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/FileUtils.java
new file mode 100644
index 00000000..fb6532e0
--- /dev/null
+++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/FileUtils.java
@@ -0,0 +1,127 @@
+package cn.iocoder.yudao.module.bs.utils;
+
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Objects;
+
+/**
+ * @author MrFang
+ * @date 2023年08月15日 11:38
+ */
+public class FileUtils {
+ /**
+ * 读取classpath下的文件数据
+ *
+ * @param fileClassPath classpath下的文件
+ * @return
+ */
+ public static InputStream readFileStreamWithClassPath(String fileClassPath) {
+ return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileClassPath);
+ }
+
+ /**
+ * 读取classpath下的文件数据
+ *
+ * @param fileClassPath classpath下的文件
+ * @return
+ */
+ public static File readFileWithClassPath(String fileClassPath) throws IOException {
+ return new ClassPathResource(fileClassPath).getFile();
+ }
+
+ /**
+ * 读取classpath下的文件数据
+ *
+ * @param absoluteFilePath 文件绝对路径
+ * @return
+ */
+ public static InputStream readFile(String absoluteFilePath) throws IOException {
+ return Files.newInputStream(Paths.get(absoluteFilePath));
+ }
+
+ /**
+ * 复制文件到目标路径
+ *
+ * @param sourceFilePath
+ * @param targetFilePath
+ * @throws IOException
+ */
+ public static void copy(String sourceFilePath, String targetFilePath) throws IOException {
+ Files.copy(Paths.get(sourceFilePath), Paths.get(targetFilePath));
+ }
+
+ /**
+ * MultipartFile转File
+ *
+ * 选择用缓冲区来实现这个转换即使用java 创建的临时文件 使用 MultipartFile.transferto()方法 。
+ *
+ * @param multipartFile
+ * @return
+ */
+ public static File transferToFile(MultipartFile multipartFile) {
+ File file = null;
+ try {
+ String originalFilename = multipartFile.getOriginalFilename();
+ String[] filename = originalFilename.split("\\.");
+ file = File.createTempFile(filename[0], filename[1]);
+ multipartFile.transferTo(file);
+ file.deleteOnExit();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return file;
+ }
+
+ /**
+ * MultipartFile 转 File
+ *
+ * @param file
+ * @throws Exception
+ */
+ public static File multipartFileToFile(MultipartFile file) throws Exception {
+ File toFile = null;
+ InputStream ins;
+ ins = file.getInputStream();
+ toFile = new File(Objects.requireNonNull(file.getOriginalFilename()));
+ inputStreamToFile(ins, toFile);
+ ins.close();
+ return toFile;
+ }
+
+ /**
+ * 获取流文件
+ * @param ins
+ * @param file
+ */
+ private static void inputStreamToFile(InputStream ins, File file) {
+ try {
+ OutputStream os = new FileOutputStream(file);
+ int bytesRead = 0;
+ byte[] buffer = new byte[8192];
+ while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
+ os.write(buffer, 0, bytesRead);
+ }
+ os.close();
+ ins.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 删除本地临时文件
+ * @param file
+ */
+ public static boolean deleteTempFile(File file) {
+ if (file != null) {
+ File del = new File(file.toURI());
+ return del.delete();
+ }
+ return false;
+ }
+
+}
diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/HttpUtil.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/HttpUtil.java
new file mode 100644
index 00000000..70f9f1e3
--- /dev/null
+++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/HttpUtil.java
@@ -0,0 +1,77 @@
+package cn.iocoder.yudao.module.bs.utils;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author MrFang
+ * @date 2023年08月15日 11:39
+ */
+public class HttpUtil {
+ public static String post(String requestUrl, String accessToken, String params)
+ throws Exception {
+ String contentType = "application/x-www-form-urlencoded";
+ return HttpUtil.post(requestUrl, accessToken, contentType, params);
+ }
+
+ public static String post(String requestUrl, String accessToken, String contentType, String params)
+ throws Exception {
+ String encoding = "UTF-8";
+ if (requestUrl.contains("nlp")) {
+ encoding = "GBK";
+ }
+ return HttpUtil.post(requestUrl, accessToken, contentType, params, encoding);
+ }
+
+ public static String post(String requestUrl, String accessToken, String contentType, String params, String encoding)
+ throws Exception {
+ String url = requestUrl + "?access_token=" + accessToken;
+ return HttpUtil.postGeneralUrl(url, contentType, params, encoding);
+ }
+
+ public static String postGeneralUrl(String generalUrl, String contentType, String params, String encoding)
+ throws Exception {
+ URL url = new URL(generalUrl);
+ // 打开和URL之间的连接
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("POST");
+ // 设置通用的请求属性
+ connection.setRequestProperty("Content-Type", contentType);
+ connection.setRequestProperty("Connection", "Keep-Alive");
+ connection.setUseCaches(false);
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+
+ // 得到请求的输出流对象
+ DataOutputStream out = new DataOutputStream(connection.getOutputStream());
+ out.write(params.getBytes(encoding));
+ out.flush();
+ out.close();
+
+ // 建立实际的连接
+ connection.connect();
+ // 获取所有响应头字段
+ Map> headers = connection.getHeaderFields();
+ // 遍历所有的响应头字段
+ for (String key : headers.keySet()) {
+ System.err.println(key + "--->" + headers.get(key));
+ }
+ // 定义 BufferedReader输入流来读取URL的响应
+ BufferedReader in = null;
+ in = new BufferedReader(
+ new InputStreamReader(connection.getInputStream(), encoding));
+ String result = "";
+ String getLine;
+ while ((getLine = in.readLine()) != null) {
+ result += getLine;
+ }
+ in.close();
+ System.err.println("result:" + result);
+ return result;
+ }
+}
diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/IdCard.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/IdCard.java
new file mode 100644
index 00000000..6abaad97
--- /dev/null
+++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/IdCard.java
@@ -0,0 +1,41 @@
+package cn.iocoder.yudao.module.bs.utils;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * @author MrFang
+ * @date 2023年08月15日 11:37
+ */
+
+@Data
+public class IdCard {
+
+ @Schema(description = "姓名")
+ private String name;
+
+ @Schema(description = "性别")
+ private String sex;
+
+ @Schema(description = "民族")
+ private String nation;
+
+ @Schema(description = "出生日期")
+ private String birthDate;
+
+ @Schema(description = "住址")
+ private String address;
+
+ @Schema(description = "公民身份号码")
+ private String cardNumber;
+
+ @Schema(description = "签发机关")
+ private String signOrg;
+
+ @Schema(description = "签发日期")
+ private String signDate;
+
+ @Schema(description = "失效日期")
+ private String expiredDate;
+
+}
diff --git a/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/LicenseKeywords.java b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/LicenseKeywords.java
new file mode 100644
index 00000000..52ef42af
--- /dev/null
+++ b/yudao-module-bs/yudao-module-bs-biz/src/main/java/cn/iocoder/yudao/module/bs/utils/LicenseKeywords.java
@@ -0,0 +1,19 @@
+package cn.iocoder.yudao.module.bs.utils;
+
+/**
+ * @author MrFang
+ * @date 2023年08月15日 14:08
+ */
+public class LicenseKeywords {
+ public static final String UNIT_NAME = "单位名称";
+ public static final String BUSINESS_SCOPE = "经营范围";
+ public static final String LAYOUT = "组成形式";
+ public static final String UNIT_TYPE = "类型";
+ public static final String LEGAL_PERSON = "法定代表人";
+ public static final String ADDRESS = "地址";
+ public static final String CODE = "社会信用代码";
+ public static final String ID_NUMBER = "证件编号";
+ public static final String VALIDITY = "有效期";
+ public static final String REGISTERED_CAPITAL = "注册资本";
+ public static final String COMPANY_CREATE_DATE = "成立日期";
+}