|
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
|
16
|
16
|
import org.springframework.web.multipart.MultipartFile;
|
17
|
17
|
|
18
|
18
|
import java.util.Arrays;
|
|
19
|
+import java.util.HashMap;
|
19
|
20
|
import java.util.List;
|
20
|
21
|
|
21
|
22
|
@Slf4j
|
|
@@ -25,6 +26,17 @@ public class EquipmentServiceImpl implements IEquipmentService {
|
25
|
26
|
@Autowired
|
26
|
27
|
private IHKServer ihkServer;
|
27
|
28
|
|
|
29
|
+ private ResponseBean getResponseBean(String result){
|
|
30
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
31
|
+ ResponseBean responseBean = jsonObject.toJavaObject(ResponseBean.class);
|
|
32
|
+ if ("1".equals(responseBean.getCode())) {
|
|
33
|
+ throw new WisdomException(responseBean.getMessage());
|
|
34
|
+ }
|
|
35
|
+
|
|
36
|
+ responseBean.addSuccess(jsonObject.getJSONObject("data").getInnerMap());
|
|
37
|
+ return responseBean;
|
|
38
|
+ }
|
|
39
|
+
|
28
|
40
|
@Override
|
29
|
41
|
public String pushPerson(TpEquipmentTree tpEquipmentTree, TpUnitHkSetting unitHkSetting, TaUser user, TaUserHk taUserHk, Integer expirationTime) {
|
30
|
42
|
|
|
@@ -45,10 +57,8 @@ public class EquipmentServiceImpl implements IEquipmentService {
|
45
|
57
|
pushPerson.setType(tpEquipmentTree.getFactory());
|
46
|
58
|
pushPerson.setPerson(personBean);
|
47
|
59
|
|
48
|
|
- ResponseBean responseBean = ihkServer.pushPerson(JSONObject.toJSONString(pushPerson));
|
49
|
|
- if ("1".equals(responseBean.getCode())) {
|
50
|
|
- throw new WisdomException(responseBean.getMessage());
|
51
|
|
- }
|
|
60
|
+ String result = ihkServer.pushPerson(JSONObject.toJSONString(pushPerson));
|
|
61
|
+ ResponseBean responseBean = getResponseBean(result);
|
52
|
62
|
return JSONObject.toJSONString(responseBean.getData());
|
53
|
63
|
}
|
54
|
64
|
|
|
@@ -63,8 +73,8 @@ public class EquipmentServiceImpl implements IEquipmentService {
|
63
|
73
|
|
64
|
74
|
// 人脸图片
|
65
|
75
|
AddFace.FaceBean.PersonBean person = new AddFace.FaceBean.PersonBean();
|
66
|
|
- person.setAppkey(tpEquipmentTree.getSecret());
|
67
|
|
- person.setSecret(tpEquipmentTree.getAppkey());
|
|
76
|
+ person.setAppkey(tpEquipmentTree.getAppkey());
|
|
77
|
+ person.setSecret(tpEquipmentTree.getSecret());
|
68
|
78
|
person.setOpenapi_ip_port_http(tpEquipmentTree.getHttpServer());
|
69
|
79
|
person.setOpUserUuid(tpEquipmentTree.getOpUserUuid());
|
70
|
80
|
person.setPersonId(taUserHk.getHkUserId());
|
|
@@ -78,8 +88,8 @@ public class EquipmentServiceImpl implements IEquipmentService {
|
78
|
88
|
if (CollectionUtils.isNotEmpty(visualList)) {
|
79
|
89
|
// 门口机卡权限(可是对讲)
|
80
|
90
|
AddFace.FaceBean.DoorPermissionsBean doorPermissionsBean = new AddFace.FaceBean.DoorPermissionsBean();
|
81
|
|
- doorPermissionsBean.setAppkey(tpEquipmentTree.getSecret());
|
82
|
|
- doorPermissionsBean.setSecret(tpEquipmentTree.getAppkey());
|
|
91
|
+ doorPermissionsBean.setAppkey(tpEquipmentTree.getAppkey());
|
|
92
|
+ doorPermissionsBean.setSecret(tpEquipmentTree.getSecret());
|
83
|
93
|
doorPermissionsBean.setOpenapi_ip_port_http(tpEquipmentTree.getHttpServer());
|
84
|
94
|
doorPermissionsBean.setOpUserUuid(tpEquipmentTree.getOpUserUuid());
|
85
|
95
|
doorPermissionsBean.setAuthName(user.getUserName()+userVerify.getId());
|
|
@@ -88,8 +98,8 @@ public class EquipmentServiceImpl implements IEquipmentService {
|
88
|
98
|
|
89
|
99
|
// 门口机人脸权限(可视对讲)
|
90
|
100
|
AddFace.FaceBean.DoorFaceBean doorFaceBean = new AddFace.FaceBean.DoorFaceBean();
|
91
|
|
- doorFaceBean.setAppkey(tpEquipmentTree.getSecret());
|
92
|
|
- doorFaceBean.setSecret(tpEquipmentTree.getAppkey());
|
|
101
|
+ doorFaceBean.setAppkey(tpEquipmentTree.getAppkey());
|
|
102
|
+ doorFaceBean.setSecret(tpEquipmentTree.getSecret());
|
93
|
103
|
doorFaceBean.setOpenapi_ip_port_http(tpEquipmentTree.getHttpServer());
|
94
|
104
|
doorFaceBean.setOpUserUuid(tpEquipmentTree.getOpUserUuid());
|
95
|
105
|
doorFaceBean.setOpType(1);
|
|
@@ -104,8 +114,8 @@ public class EquipmentServiceImpl implements IEquipmentService {
|
104
|
114
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(doorUuids)) {
|
105
|
115
|
// 门禁卡权限下发
|
106
|
116
|
AddFace.FaceBean.EntranceGuardPermissionsBean entranceGuardPermissionsBean = new AddFace.FaceBean.EntranceGuardPermissionsBean();
|
107
|
|
- entranceGuardPermissionsBean.setAppkey(tpEquipmentTree.getSecret());
|
108
|
|
- entranceGuardPermissionsBean.setSecret(tpEquipmentTree.getAppkey());
|
|
117
|
+ entranceGuardPermissionsBean.setAppkey(tpEquipmentTree.getAppkey());
|
|
118
|
+ entranceGuardPermissionsBean.setSecret(tpEquipmentTree.getSecret());
|
109
|
119
|
entranceGuardPermissionsBean.setOpenapi_ip_port_http(tpEquipmentTree.getHttpServer());
|
110
|
120
|
entranceGuardPermissionsBean.setOpUserUuid(tpEquipmentTree.getOpUserUuid());
|
111
|
121
|
entranceGuardPermissionsBean.setPersonIds(String.valueOf(taUserHk.getHkUserId()));
|
|
@@ -118,8 +128,8 @@ public class EquipmentServiceImpl implements IEquipmentService {
|
118
|
128
|
|
119
|
129
|
// 门禁人脸权限下发
|
120
|
130
|
AddFace.FaceBean.EntranceGuardFaceBean entranceGuardFaceBean = new AddFace.FaceBean.EntranceGuardFaceBean();
|
121
|
|
- entranceGuardFaceBean.setAppkey(tpEquipmentTree.getSecret());
|
122
|
|
- entranceGuardFaceBean.setSecret(tpEquipmentTree.getAppkey());
|
|
131
|
+ entranceGuardFaceBean.setAppkey(tpEquipmentTree.getAppkey());
|
|
132
|
+ entranceGuardFaceBean.setSecret(tpEquipmentTree.getSecret());
|
123
|
133
|
entranceGuardFaceBean.setOpenapi_ip_port_http(tpEquipmentTree.getHttpServer());
|
124
|
134
|
entranceGuardFaceBean.setOpUserUuid(tpEquipmentTree.getOpUserUuid());
|
125
|
135
|
entranceGuardFaceBean.setDeviceUuids(deviceUuids.substring(0, deviceUuids.lastIndexOf(",")));
|
|
@@ -132,10 +142,8 @@ public class EquipmentServiceImpl implements IEquipmentService {
|
132
|
142
|
addFace.setType(tpEquipmentTree.getFactory());
|
133
|
143
|
addFace.setFace(faceBean);
|
134
|
144
|
// 添加人脸
|
135
|
|
- ResponseBean responseBean = ihkServer.addFace(faceImg, JSONObject.toJSONString(addFace));
|
136
|
|
- if ("1".equals(responseBean.getCode())) {
|
137
|
|
- throw new WisdomException(responseBean.getMessage());
|
138
|
|
- }
|
|
145
|
+ String result = ihkServer.addFace(faceImg, JSONObject.toJSONString(addFace));
|
|
146
|
+ ResponseBean responseBean = getResponseBean(result);
|
139
|
147
|
return JSONObject.toJSONString(responseBean.getData());
|
140
|
148
|
}
|
141
|
149
|
|
|
@@ -147,8 +155,8 @@ public class EquipmentServiceImpl implements IEquipmentService {
|
147
|
155
|
|
148
|
156
|
// 人脸图片
|
149
|
157
|
UpdateFace.FaceBean.PersonBean person = new UpdateFace.FaceBean.PersonBean();
|
150
|
|
- person.setAppkey(tpEquipmentTree.getSecret());
|
151
|
|
- person.setSecret(tpEquipmentTree.getAppkey());
|
|
158
|
+ person.setAppkey(tpEquipmentTree.getAppkey());
|
|
159
|
+ person.setSecret(tpEquipmentTree.getSecret());
|
152
|
160
|
person.setOpenapi_ip_port_http(tpEquipmentTree.getHttpServer());
|
153
|
161
|
person.setOpUserUuid(tpEquipmentTree.getOpUserUuid());
|
154
|
162
|
person.setPersonId(taUserHk.getHkUserId());
|
|
@@ -163,8 +171,8 @@ public class EquipmentServiceImpl implements IEquipmentService {
|
163
|
171
|
|
164
|
172
|
// 门口机人脸权限(可视对讲)
|
165
|
173
|
UpdateFace.FaceBean.DoorFaceBean doorFaceBean = new UpdateFace.FaceBean.DoorFaceBean();
|
166
|
|
- doorFaceBean.setAppkey(tpEquipmentTree.getSecret());
|
167
|
|
- doorFaceBean.setSecret(tpEquipmentTree.getAppkey());
|
|
174
|
+ doorFaceBean.setAppkey(tpEquipmentTree.getAppkey());
|
|
175
|
+ doorFaceBean.setSecret(tpEquipmentTree.getSecret());
|
168
|
176
|
doorFaceBean.setOpenapi_ip_port_http(tpEquipmentTree.getHttpServer());
|
169
|
177
|
doorFaceBean.setOpUserUuid(tpEquipmentTree.getOpUserUuid());
|
170
|
178
|
doorFaceBean.setOpType(1);
|
|
@@ -178,8 +186,8 @@ public class EquipmentServiceImpl implements IEquipmentService {
|
178
|
186
|
|
179
|
187
|
// 门禁人脸权限下发
|
180
|
188
|
UpdateFace.FaceBean.EntranceGuardFaceBean entranceGuardFaceBean = new UpdateFace.FaceBean.EntranceGuardFaceBean();
|
181
|
|
- entranceGuardFaceBean.setAppkey(tpEquipmentTree.getSecret());
|
182
|
|
- entranceGuardFaceBean.setSecret(tpEquipmentTree.getAppkey());
|
|
189
|
+ entranceGuardFaceBean.setAppkey(tpEquipmentTree.getAppkey());
|
|
190
|
+ entranceGuardFaceBean.setSecret(tpEquipmentTree.getSecret());
|
183
|
191
|
entranceGuardFaceBean.setOpenapi_ip_port_http(tpEquipmentTree.getHttpServer());
|
184
|
192
|
entranceGuardFaceBean.setOpUserUuid(tpEquipmentTree.getOpUserUuid());
|
185
|
193
|
entranceGuardFaceBean.setDeviceUuids(deviceUuids.substring(0, deviceUuids.lastIndexOf(",")));
|
|
@@ -192,10 +200,8 @@ public class EquipmentServiceImpl implements IEquipmentService {
|
192
|
200
|
addFace.setType(tpEquipmentTree.getFactory());
|
193
|
201
|
addFace.setFace(faceBean);
|
194
|
202
|
// 添加人脸
|
195
|
|
- ResponseBean responseBean = ihkServer.updateFace(faceImg, JSONObject.toJSONString(addFace));
|
196
|
|
- if ("1".equals(responseBean.getCode())) {
|
197
|
|
- throw new WisdomException(responseBean.getMessage());
|
198
|
|
- }
|
|
203
|
+ String result = ihkServer.updateFace(faceImg, JSONObject.toJSONString(addFace));
|
|
204
|
+ ResponseBean responseBean = getResponseBean(result);
|
199
|
205
|
return JSONObject.toJSONString(responseBean.getData());
|
200
|
206
|
}
|
201
|
207
|
}
|