zhangyuewww 2 tahun lalu
induk
melakukan
03a2fb6d24

+ 6 - 1
unimall-admin-api/src/main/java/com/iotechn/unimall/admin/api/tourism/IProductManagementService.java

@@ -8,6 +8,7 @@ import com.iotechn.unimall.core.annotation.HttpParam;
 import com.iotechn.unimall.core.annotation.HttpParamType;
 import com.iotechn.unimall.core.annotation.HttpParamType;
 import com.iotechn.unimall.core.annotation.param.NotNull;
 import com.iotechn.unimall.core.annotation.param.NotNull;
 import com.iotechn.unimall.core.exception.ServiceException;
 import com.iotechn.unimall.core.exception.ServiceException;
+import com.iotechn.unimall.data.dto.DistinguishView;
 import com.iotechn.unimall.data.model.Page;
 import com.iotechn.unimall.data.model.Page;
 import java.util.Date;
 import java.util.Date;
 
 
@@ -57,7 +58,11 @@ public interface IProductManagementService{
 
 
 	@HttpMethod(description = "查询", permissionName = "生活服务信息管理")
 	@HttpMethod(description = "查询", permissionName = "生活服务信息管理")
 	public ProductManagement get(@NotNull @HttpParam(name = "id", type = HttpParamType.COMMON, description = "")Long id)throws ServiceException;
 	public ProductManagement get(@NotNull @HttpParam(name = "id", type = HttpParamType.COMMON, description = "")Long id)throws ServiceException;
-	
+
+	@HttpMethod(description = "识别身份证",  permissionName = "生活服务信息管理")
+	public DistinguishView personShibie(@HttpParam(name = "personImageFront", type = HttpParamType.COMMON, description = "身份证正面") String personImageFront)throws ServiceException;
+
+
 	@HttpMethod(description = "导出excl表",  permissionName = "生活服务信息管理")
 	@HttpMethod(description = "导出excl表",  permissionName = "生活服务信息管理")
 	public String export(
 	public String export(
 								@HttpParam(name = "commonId", type = HttpParamType.COMMON, description = "个人id") Long commonId,
 								@HttpParam(name = "commonId", type = HttpParamType.COMMON, description = "个人id") Long commonId,

+ 57 - 1
unimall-admin-api/src/main/java/com/iotechn/unimall/admin/api/tourism/impl/ProductManagementServiceImpl.java

@@ -1,7 +1,19 @@
 package com.iotechn.unimall.admin.api.tourism.impl;
 package com.iotechn.unimall.admin.api.tourism.impl;
 
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
+import com.alibaba.fastjson.JSONObject;
+import com.iotechn.unimall.data.dto.DistinguishView;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
 import org.apache.ibatis.session.RowBounds;
 import org.apache.ibatis.session.RowBounds;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -134,7 +146,51 @@ public class ProductManagementServiceImpl implements IProductManagementService{
 	public ProductManagement get(Long id) throws ServiceException {
 	public ProductManagement get(Long id) throws ServiceException {
 		return productManagementMapper.selectById(id);
 		return productManagementMapper.selectById(id);
 	}
 	}
-	
+
+	@Override
+	public DistinguishView personShibie(String personImageFront) throws ServiceException {
+		String appcode = "2d59bfa794994f5f94d1d98b7b5bd102";
+		//API产品路径
+		String requestUrl = "https://personcard.market.alicloudapi.com/ai_market/ai_ocr_universal/shen_fen_zheng/ch/v1";
+		//阿里云APPCODE
+		DistinguishView distinguishView = new DistinguishView();
+		CloseableHttpClient httpClient = null;
+		try {
+			httpClient = HttpClients.createDefault();
+			List<NameValuePair> params = new ArrayList<NameValuePair>();
+			//启用URL方式进行识别
+			//内容数据类型是图像文件URL链接
+			params.add(new BasicNameValuePair("IMAGE", personImageFront));
+			params.add(new BasicNameValuePair("IMAGE_TYPE", "1"));
+
+			// 创建一个HttpPost实例
+			HttpPost httpPost = new HttpPost(requestUrl);
+			httpPost.addHeader("Authorization", "APPCODE " + appcode);
+			httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
+
+			// 设置请求参数
+			httpPost.setEntity(new UrlEncodedFormEntity(params, "utf-8"));
+
+			// 发送POST请求
+			HttpResponse execute = httpClient.execute(httpPost);
+
+			// 获取状态码
+			int statusCode = execute.getStatusLine().getStatusCode();
+			System.out.println(statusCode);
+
+			// 获取结果
+			HttpEntity entity = execute.getEntity();
+			String body = EntityUtils.toString(entity);
+			System.out.println(body);
+			JSONObject jsonObject = JSONObject.parseObject(body);
+			distinguishView.setRecPersonNo(jsonObject.getJSONObject("身份证识别实体信息").getJSONObject("身份证人像面实体信息").getString("身份证号"));
+			return distinguishView;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
 	@Override
 	@Override
 	public String export(Long commonId,String mainBody,String shopNames,String coverImage,String province,String city,String area,String location,String detailedAddress,String serviceDescription,String nickname,String phone,String realname,String personNo,String personImageFront,String personImageBack,String businessLicense,String status,Date gmtCreate,Date gmtUpdate,Long deleteFlag, Integer page, Integer limit)throws ServiceException {
 	public String export(Long commonId,String mainBody,String shopNames,String coverImage,String province,String city,String area,String location,String detailedAddress,String serviceDescription,String nickname,String phone,String realname,String personNo,String personImageFront,String personImageBack,String businessLicense,String status,Date gmtCreate,Date gmtUpdate,Long deleteFlag, Integer page, Integer limit)throws ServiceException {
 		Wrapper<ProductManagement> wrapper = new EntityWrapper<ProductManagement>();
 		Wrapper<ProductManagement> wrapper = new EntityWrapper<ProductManagement>();