|
@@ -187,6 +187,32 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
return faceDbId;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public Boolean isExistFaceDbId(DeviceInfo deviceInfo, String companyName) throws Exception {
|
|
|
+ if (StringUtils.isBlank(companyName)) {
|
|
|
+ throw new Exception("公司名称为空");
|
|
|
+ }
|
|
|
+ String faceDbId = "";
|
|
|
+ JSONObject jsonObject = LApiUtil.GetRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.GETFACEDB);
|
|
|
+ JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
+ JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
+ List listData = response.getJSONArray("LibList");
|
|
|
+ if (listData.size() <= 0) {
|
|
|
+ //
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < listData.size(); i++) {
|
|
|
+ JSONObject jsonObject1 = (JSONObject) JSONArray.toJSON(listData.get(i));
|
|
|
+ String name = jsonObject1.getString("Name");
|
|
|
+ if (StringUtils.isNotBlank(name) && companyName.equals(name)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<LapiMsgResult> deletePerson(Long id) throws Exception {
|
|
|
|
|
@@ -340,8 +366,8 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
if (deviceInfo == null) {
|
|
|
throw new Exception("设备不存在");
|
|
|
}
|
|
|
- String companyLibId = getFaceDbId(deviceInfo, companyInfo.getName());
|
|
|
- if (StringUtils.isNotBlank(companyLibId) && !companyLibId.equals(deviceInfo.getDefaultFaceLibraryId())) {
|
|
|
+ Boolean isExist = isExistFaceDbId(deviceInfo, companyInfo.getName());
|
|
|
+ if (isExist) {
|
|
|
throw new Exception("已有人脸库不可重复创建");
|
|
|
}
|
|
|
HashMap map = new HashMap();
|