|
@@ -1,9 +1,12 @@
|
1
|
1
|
package com.community.huiju.service.impl;
|
2
|
2
|
|
|
3
|
+import com.alibaba.fastjson.JSON;
|
3
|
4
|
import com.alibaba.fastjson.JSONObject;
|
4
|
5
|
import com.community.commom.ailiyun.AESDecode;
|
5
|
6
|
import com.community.commom.constant.Constant;
|
6
|
7
|
import com.community.commom.mode.ResponseBean;
|
|
8
|
+import com.community.huiju.common.hk.HKConstant;
|
|
9
|
+import com.community.huiju.common.hk.OpenapiUtil;
|
7
|
10
|
import com.community.huiju.controller.ImageController;
|
8
|
11
|
import com.community.huiju.dao.TaFaceMapper;
|
9
|
12
|
import com.community.huiju.dao.TaSysRoleMapper;
|
|
@@ -13,12 +16,16 @@ import com.community.huiju.model.TaSysRole;
|
13
|
16
|
import com.community.huiju.model.TaUser;
|
14
|
17
|
import com.community.huiju.service.ImageServiceI;
|
15
|
18
|
import com.community.huiju.service.FaceServicel;
|
|
19
|
+import com.hikvision.cms.api.common.util.Digests;
|
|
20
|
+import com.hikvision.cms.api.common.util.HttpClientSSLUtils;
|
16
|
21
|
import org.springframework.beans.factory.annotation.Autowired;
|
17
|
22
|
import org.springframework.stereotype.Service;
|
18
|
23
|
import org.springframework.web.multipart.MultipartFile;
|
19
|
24
|
|
20
|
25
|
import java.io.IOException;
|
21
|
26
|
import java.util.Date;
|
|
27
|
+import java.util.HashMap;
|
|
28
|
+import java.util.Map;
|
22
|
29
|
|
23
|
30
|
@Service
|
24
|
31
|
public class FaceServicelimpl implements FaceServicel {
|
|
@@ -82,6 +89,8 @@ public class FaceServicelimpl implements FaceServicel {
|
82
|
89
|
ResponseBean responseBean = new ResponseBean();
|
83
|
90
|
boolean resps=checKout(faceImg,taFace,isA,null);
|
84
|
91
|
if (resps==true) {
|
|
92
|
+ //校验通过后
|
|
93
|
+ imgPush(user.getUserName(),faceImg);
|
85
|
94
|
responseBean.addSuccess("图片录入成功");
|
86
|
95
|
}else {
|
87
|
96
|
responseBean.addError("7771","请录入正确的图片");
|
|
@@ -93,6 +102,7 @@ public class FaceServicelimpl implements FaceServicel {
|
93
|
102
|
ResponseBean responseBeans = new ResponseBean();
|
94
|
103
|
boolean resps=checKout(faceImg,taFace,isA,null);
|
95
|
104
|
if (resps==true) {
|
|
105
|
+ imgPush(user.getUserName(),faceImg);
|
96
|
106
|
responseBeans.addSuccess("图片录入成功");
|
97
|
107
|
}else {
|
98
|
108
|
responseBeans.addError("7771","请录入正确的图片");
|
|
@@ -166,4 +176,25 @@ public class FaceServicelimpl implements FaceServicel {
|
166
|
176
|
}
|
167
|
177
|
return false;
|
168
|
178
|
}
|
|
179
|
+ //在图片验证通过的情况下,推送到海康
|
|
180
|
+ public Object imgPush(String name,String img){
|
|
181
|
+ String url = HKConstant.OPENAPI_IP_PORT_HTTP + HKConstant.OP_IMG;
|
|
182
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
183
|
+ map.put("appkey", HKConstant.APPKEY);//设置APPKEY
|
|
184
|
+ map.put("time", System.currentTimeMillis());//设置时间参数
|
|
185
|
+ map.put("facePhotos", System.currentTimeMillis());//设置时间参数 //bs64转码
|
|
186
|
+ map.put("personName",name);//名字
|
|
187
|
+ map.put("personName",System.currentTimeMillis());//时间取毫秒
|
|
188
|
+ String params = JSON.toJSONString(map);
|
|
189
|
+ System.out.println(" ====== testGetDefaultUserUUID 请求参数:【" + params + "】");
|
|
190
|
+ String data = null;
|
|
191
|
+ try {
|
|
192
|
+ data = HttpClientSSLUtils.doPost(url + "?token=" + Digests.buildToken(url + "?" + params, params, HKConstant.SECRET), params);
|
|
193
|
+ } catch (Exception e) {
|
|
194
|
+ e.printStackTrace();
|
|
195
|
+ }
|
|
196
|
+ System.out.println(" ====== testGetDefaultUserUUID 请求返回结果:【{" + data + "}】");
|
|
197
|
+ return data;
|
|
198
|
+ }
|
|
199
|
+
|
169
|
200
|
}
|