|
@@ -7,15 +7,14 @@ import com.community.commom.constant.Constant;
|
7
|
7
|
import com.community.commom.mode.ResponseBean;
|
8
|
8
|
import com.community.huiju.common.PicUtils;
|
9
|
9
|
import com.community.huiju.common.hk.HKConstant;
|
10
|
|
-import com.community.huiju.common.hk.HKOpenApi;
|
11
|
10
|
import com.community.huiju.dao.TaFaceMapper;
|
12
|
11
|
import com.community.huiju.dao.TaSysRoleMapper;
|
13
|
12
|
import com.community.huiju.dao.TaUserMapper;
|
14
|
13
|
import com.community.huiju.model.TaFace;
|
15
|
14
|
import com.community.huiju.model.TaSysRole;
|
16
|
15
|
import com.community.huiju.model.TaUser;
|
|
16
|
+import com.community.huiju.service.FaceServiceI;
|
17
|
17
|
import com.community.huiju.service.ImageServiceI;
|
18
|
|
-import com.community.huiju.service.FaceServicel;
|
19
|
18
|
import com.hikvision.cms.api.common.util.Digests;
|
20
|
19
|
import com.hikvision.cms.api.common.util.HttpClientSSLUtils;
|
21
|
20
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -28,8 +27,9 @@ import java.util.Date;
|
28
|
27
|
import java.util.HashMap;
|
29
|
28
|
import java.util.Map;
|
30
|
29
|
|
31
|
|
-@Service
|
32
|
|
-public class FaceServicelimpl implements FaceServicel {
|
|
30
|
+@Service("faceServicel")
|
|
31
|
+@Transactional
|
|
32
|
+public class FaceServicelimpl implements FaceServiceI {
|
33
|
33
|
|
34
|
34
|
|
35
|
35
|
@Autowired
|
|
@@ -45,7 +45,6 @@ public class FaceServicelimpl implements FaceServicel {
|
45
|
45
|
private ImageServiceI imageServiceI;
|
46
|
46
|
|
47
|
47
|
@Override
|
48
|
|
- @Transactional
|
49
|
48
|
public ResponseBean addFace(Integer userid,MultipartFile uploadFile) {
|
50
|
49
|
String faceImg = null;
|
51
|
50
|
try {
|
|
@@ -85,7 +84,7 @@ public class FaceServicelimpl implements FaceServicel {
|
85
|
84
|
|
86
|
85
|
//查询当前用户是否有人脸记录
|
87
|
86
|
TaFace User = taFaceMapper.getByUserId(userid);
|
88
|
|
- if (null == User) { //为业主,已认证
|
|
87
|
+ if (null == User) {
|
89
|
88
|
boolean isA=true;
|
90
|
89
|
if (Constant.OWNER.equals(sysRole.getRoleName()) && "1".equals(taUser.getVerifyStatus())) {
|
91
|
90
|
ResponseBean responseBean = new ResponseBean();
|
|
@@ -117,24 +116,11 @@ public class FaceServicelimpl implements FaceServicel {
|
117
|
116
|
}
|
118
|
117
|
return responseBeans;
|
119
|
118
|
}
|
120
|
|
- } else {
|
121
|
|
- //为业主,未认证情况下
|
122
|
|
- if (Constant.OWNER.equals(sysRole.getRoleName()) && "1".equals(taUser.getVerifyStatus())) {
|
123
|
|
- response.addError("8885", "您的信息已存在");
|
124
|
|
- return response;
|
125
|
|
- }
|
126
|
|
- //家属或者租客,未认证情况下
|
127
|
|
- if (Constant.RELATION.equals(sysRole.getRoleName()) || Constant.TENANT.equals(sysRole.getDescription()) && "1".equals(taUser.getVerifyStatus())) {
|
128
|
|
- response.addError("8885", "您的信息已存在");
|
129
|
|
- return response;
|
130
|
|
- }
|
131
|
119
|
}
|
132
|
|
- response.addError("9995", "无法确认您的身份,请联系物业");
|
133
|
120
|
return response;
|
134
|
121
|
}
|
135
|
122
|
|
136
|
123
|
@Override
|
137
|
|
- @Transactional
|
138
|
124
|
public ResponseBean upDateFace(Integer userId,MultipartFile uploadFile) {
|
139
|
125
|
boolean isA=false;
|
140
|
126
|
String faceImg = null;
|
|
@@ -162,14 +148,15 @@ public class FaceServicelimpl implements FaceServicel {
|
162
|
148
|
}
|
163
|
149
|
return responseBean;
|
164
|
150
|
}
|
165
|
|
-
|
166
|
|
- //人脸录入验证
|
167
|
|
- @Transactional
|
|
151
|
+
|
|
152
|
+ /**
|
|
153
|
+ * 人脸录入验证
|
|
154
|
+ */
|
168
|
155
|
public Object checKout(String faceImg, TaFace taFace, boolean isA,Integer user,String name,MultipartFile uploadFile) {
|
169
|
156
|
AESDecode aesd = new AESDecode();
|
170
|
|
- String body = "{\"type\": \"0\", \"image_url\":\"" + faceImg + "\"}";
|
|
157
|
+ String body = "{\"type\": \"0\", \"image_url\":\"" + faceImg + "\"}";
|
171
|
158
|
try {
|
172
|
|
- ResponseBean responseBean = aesd.send(body);
|
|
159
|
+ ResponseBean responseBean = aesd.send(body);
|
173
|
160
|
JSONObject jsonObject = JSONObject.parseObject(responseBean.getMessage());
|
174
|
161
|
Integer type = (Integer) jsonObject.get("errno");
|
175
|
162
|
Integer faceNum= (Integer) jsonObject.get("face_num");
|
|
@@ -198,7 +185,13 @@ public class FaceServicelimpl implements FaceServicel {
|
198
|
185
|
}
|
199
|
186
|
return false;
|
200
|
187
|
}
|
201
|
|
- //在图片验证通过的情况下,推送到海康
|
|
188
|
+
|
|
189
|
+ /**
|
|
190
|
+ * 在图片验证通过的情况下,推送到海康
|
|
191
|
+ * @param name
|
|
192
|
+ * @param uploadFile
|
|
193
|
+ * @return
|
|
194
|
+ */
|
202
|
195
|
public Object imgPush(String name,MultipartFile uploadFile){
|
203
|
196
|
//把图片压缩成100K以下
|
204
|
197
|
// 压缩后的图片字节数组
|
|
@@ -211,22 +204,22 @@ public class FaceServicelimpl implements FaceServicel {
|
211
|
204
|
} catch (IOException e) {
|
212
|
205
|
e.printStackTrace();
|
213
|
206
|
}
|
214
|
|
- // String imgs = hkOpenApi.getImgStr(uploadFile);
|
215
|
|
- String imgs = HKOpenApi.getImgStr(picByte);
|
|
207
|
+ // 推送海康服务器
|
|
208
|
+ String imgs = PicUtils.getImgStr(picByte);
|
216
|
209
|
String pgId= (String) HKpersonGroupId();
|
217
|
210
|
JSONObject jsonObject = JSONObject.parseObject(pgId);
|
218
|
211
|
Integer personGroupId = (Integer) jsonObject.get("personGroupId");
|
219
|
212
|
System.out.println(personGroupId);
|
220
|
213
|
String url = HKConstant.OPENAPI_IP_PORT_HTTP + HKConstant.OP_IMG;
|
221
|
214
|
Map<String, Object> map = new HashMap<String, Object>();
|
222
|
|
- map.put("appkey", HKConstant.APPKEY);//设置APPKEY
|
223
|
|
- map.put("time", System.currentTimeMillis());//设置时间参数
|
224
|
|
- map.put("token", HKConstant.SECRET);//认证token
|
225
|
|
- map.put("opUserUuid",HKConstant.OP_USER_UUID);//操作用户UUID
|
226
|
|
- map.put("facePhotos", imgs); //bs64转码
|
227
|
|
- map.put("personName",name);//名字
|
228
|
|
- map.put("personGroupId",personGroupId);//分组用户ID
|
229
|
|
- map.put("birthday",System.currentTimeMillis());//时间取毫秒
|
|
215
|
+ map.put("appkey", HKConstant.APPKEY);
|
|
216
|
+ map.put("time", System.currentTimeMillis());
|
|
217
|
+ map.put("token", HKConstant.SECRET);
|
|
218
|
+ map.put("opUserUuid",HKConstant.OP_USER_UUID);
|
|
219
|
+ map.put("facePhotos", imgs);
|
|
220
|
+ map.put("personName",name);
|
|
221
|
+ map.put("personGroupId",personGroupId);
|
|
222
|
+ map.put("birthday",System.currentTimeMillis());
|
230
|
223
|
String params = JSON.toJSONString(map);
|
231
|
224
|
System.out.println(" ====== testGetDefaultUserUUID 请求参数:【" + params + "】");
|
232
|
225
|
String data = null;
|
|
@@ -239,20 +232,21 @@ public class FaceServicelimpl implements FaceServicel {
|
239
|
232
|
System.out.println(" ====== testGetDefaultUserUUID 请求返回结果:【{" + data + "}】");
|
240
|
233
|
return data;
|
241
|
234
|
}
|
242
|
|
-
|
243
|
|
- //把图片推送海康,需要获得海康人员分组下的
|
244
|
|
- // **personGroupId**
|
245
|
|
- @Transactional
|
|
235
|
+
|
|
236
|
+ /**
|
|
237
|
+ * 把图片推送海康,需要获得海康人员分组下的
|
|
238
|
+ * @return
|
|
239
|
+ */
|
246
|
240
|
public Object HKpersonGroupId(){
|
247
|
241
|
String url = HKConstant.OPENAPI_IP_PORT_HTTP + HKConstant.OP_PERSON_ID;
|
248
|
242
|
Map<String, Object> map = new HashMap<String, Object>();
|
249
|
|
- map.put("appkey", HKConstant.APPKEY);//设置APPKEY
|
250
|
|
- map.put("time", System.currentTimeMillis());//设置时间参数
|
251
|
|
- map.put("token", HKConstant.SECRET);//认证token
|
252
|
|
- map.put("opUserUuid",HKConstant.OP_USER_UUID);//操作用户UUID
|
253
|
|
- map.put("pageNo",1);//当前页码
|
254
|
|
- map.put("pageSize",100);//每页数据记录数
|
255
|
|
- map.put("birthday",System.currentTimeMillis());//时间取毫秒
|
|
243
|
+ map.put("appkey", HKConstant.APPKEY);
|
|
244
|
+ map.put("time", System.currentTimeMillis());
|
|
245
|
+ map.put("token", HKConstant.SECRET);
|
|
246
|
+ map.put("opUserUuid",HKConstant.OP_USER_UUID);
|
|
247
|
+ map.put("pageNo",1);
|
|
248
|
+ map.put("pageSize",100);
|
|
249
|
+ map.put("birthday",System.currentTimeMillis());
|
256
|
250
|
String params = JSON.toJSONString(map);
|
257
|
251
|
String data = null;
|
258
|
252
|
try {
|