|
@@ -1,5 +1,6 @@
|
|
|
package com.jpsoft.smart.modules.lapi.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.jpsoft.smart.modules.base.entity.CompanyInfo;
|
|
|
import com.jpsoft.smart.modules.base.entity.DeviceInfo;
|
|
@@ -18,6 +19,7 @@ import com.jpsoft.smart.modules.lapi.vo.IdentificationVo;
|
|
|
import com.jpsoft.smart.modules.lapi.vo.ImageVo;
|
|
|
import com.jpsoft.smart.modules.lapi.vo.LapiMsgResult;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -129,7 +131,9 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
|
|
|
|
|
|
try{
|
|
|
- JSONObject jsonObject = LApiUtil.PostRequest(deviceInfo.getIpAddress()+":"+deviceInfo.getPort()+LApiConstant.ADDPERSON,map);
|
|
|
+ //获取人员人脸库id
|
|
|
+ String faceDbId = getFaceDbId(deviceInfo,companyInfo.getName());
|
|
|
+ JSONObject jsonObject = LApiUtil.PostRequest(deviceInfo.getIpAddress()+":"+deviceInfo.getPort()+LApiConstant.ADDPERSON+faceDbId+"/People",map);
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
if (dataJson.getInteger("ResponseCode") ==0 && dataJson.getInteger("StatusCode") == 0){
|
|
|
LapiMsgResult lapiMsgResult = new LapiMsgResult();
|
|
@@ -154,4 +158,27 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
|
|
|
return lapiMsgResults;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getFaceDbId(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){
|
|
|
+ throw new Exception("设备没有配置人脸库");
|
|
|
+ }
|
|
|
+ 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)){
|
|
|
+ faceDbId = jsonObject1.getString("ID");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return faceDbId;
|
|
|
+ }
|
|
|
}
|