|
@@ -144,15 +144,24 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
if (dataJson.getInteger("ResponseCode") == 0 && dataJson.getInteger("StatusCode") == 0) {
|
|
|
+ Boolean success = isSuccessAddPerson(personInfo,deviceInfo,faceDbId);
|
|
|
HashMap<String,Object> dataMap = new HashMap<>();
|
|
|
dataMap.put("deviceId",deviceInfo.getId());
|
|
|
dataMap.put("deviceAliasName",deviceInfo.getAliasName());
|
|
|
dataMap.put("persoName",personInfo.getName());
|
|
|
LapiResult lapiResult = new LapiResult();
|
|
|
- lapiResult.setMsg("绑定成功");
|
|
|
- lapiResult.setSuccess(true);
|
|
|
- lapiResult.setData(dataMap);
|
|
|
- lapiResultList.add(lapiResult);
|
|
|
+ if (success){
|
|
|
+ lapiResult.setMsg("绑定成功");
|
|
|
+ lapiResult.setSuccess(true);
|
|
|
+ lapiResult.setData(dataMap);
|
|
|
+ lapiResultList.add(lapiResult);
|
|
|
+ }else {
|
|
|
+ lapiResult.setMsg("绑定失败");
|
|
|
+ lapiResult.setSuccess(false);
|
|
|
+ lapiResult.setData(dataMap);
|
|
|
+ lapiResultList.add(lapiResult);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage());
|
|
@@ -162,7 +171,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
dataMap.put("persoName",personInfo.getName());
|
|
|
LapiResult lapiResult = new LapiResult();
|
|
|
lapiResult.setSuccess(false);
|
|
|
- lapiResult.setMsg(e.getMessage());
|
|
|
+ lapiResult.setMsg(e.getMessage().contains("time out")?"设备连接超时":e.getMessage());
|
|
|
lapiResult.setData(dataMap);
|
|
|
lapiResultList.add(lapiResult);
|
|
|
}
|
|
@@ -172,7 +181,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<LapiMsgResult> addPersonForDeviceIds(Long id, String deviceIds) throws Exception {
|
|
|
+ public List<LapiResult> addPersonForDeviceIds(Long id, String deviceIds) throws Exception {
|
|
|
if (StringUtils.isBlank(deviceIds)){
|
|
|
throw new Exception("设备为空");
|
|
|
}
|
|
@@ -181,7 +190,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
String base64Data = OSSUtil.downloadToBase64(personInfo.getFaceImageUrl());
|
|
|
|
|
|
List<String> deviceIdList = Arrays.asList(deviceIds.split(","));
|
|
|
- List<LapiMsgResult> lapiMsgResults = new ArrayList<>();
|
|
|
+ List<LapiResult> lapiResultList = new ArrayList<>();
|
|
|
|
|
|
for (String deviceId : deviceIdList) {
|
|
|
DeviceInfo deviceInfo = deviceInfoService.get(deviceId);
|
|
@@ -235,22 +244,39 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
if (dataJson.getInteger("ResponseCode") == 0 && dataJson.getInteger("StatusCode") == 0) {
|
|
|
- LapiMsgResult lapiMsgResult = new LapiMsgResult();
|
|
|
- lapiMsgResult.setPersonName(personInfo.getName());
|
|
|
- lapiMsgResult.setSuccess(true);
|
|
|
- lapiMsgResult.setAliasName(deviceInfo.getAliasName());
|
|
|
- lapiMsgResults.add(lapiMsgResult);
|
|
|
+ Boolean success = isSuccessAddPerson(personInfo,deviceInfo,faceDbId);
|
|
|
+ HashMap<String,Object> dataMap = new HashMap<>();
|
|
|
+ dataMap.put("deviceId",deviceInfo.getId());
|
|
|
+ dataMap.put("deviceAliasName",deviceInfo.getAliasName());
|
|
|
+ dataMap.put("persoName",personInfo.getName());
|
|
|
+ LapiResult lapiResult = new LapiResult();
|
|
|
+ if (success){
|
|
|
+ lapiResult.setMsg("绑定成功");
|
|
|
+ lapiResult.setSuccess(true);
|
|
|
+ lapiResult.setData(dataMap);
|
|
|
+ lapiResultList.add(lapiResult);
|
|
|
+ }else {
|
|
|
+ lapiResult.setMsg("绑定失败");
|
|
|
+ lapiResult.setSuccess(false);
|
|
|
+ lapiResult.setData(dataMap);
|
|
|
+ lapiResultList.add(lapiResult);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
- log.error(e.getMessage(),e);
|
|
|
- LapiMsgResult lapiMsgResult = new LapiMsgResult();
|
|
|
- lapiMsgResult.setAliasName(deviceInfo.getAliasName());
|
|
|
- lapiMsgResult.setMsg(e.getMessage());
|
|
|
- lapiMsgResult.setPersonName("");
|
|
|
- lapiMsgResult.setSuccess(false);
|
|
|
- lapiMsgResults.add(lapiMsgResult);
|
|
|
+ log.error(e.getMessage());
|
|
|
+ HashMap<String,Object> dataMap = new HashMap<>();
|
|
|
+ dataMap.put("deviceId",deviceInfo.getId());
|
|
|
+ dataMap.put("deviceAliasName",deviceInfo.getAliasName());
|
|
|
+ dataMap.put("persoName",personInfo.getName());
|
|
|
+ LapiResult lapiResult = new LapiResult();
|
|
|
+ lapiResult.setSuccess(false);
|
|
|
+ lapiResult.setMsg(e.getMessage().contains("time out")?"设备连接超时":e.getMessage());
|
|
|
+ lapiResult.setData(dataMap);
|
|
|
+ lapiResultList.add(lapiResult);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -258,7 +284,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
|
|
|
|
|
|
|
|
|
- return lapiMsgResults;
|
|
|
+ return lapiResultList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -664,5 +690,35 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
return lapiResultList;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean isSuccessAddPerson(PersonInfo personInfo,DeviceInfo deviceInfo,String faceDbId) {
|
|
|
+ HashMap map = new HashMap();
|
|
|
+ map.put("Num", 1);
|
|
|
+ map.put("Limit",3);
|
|
|
+ map.put("Offset",0);
|
|
|
+ List list = new ArrayList();
|
|
|
+ HashMap map1 = new HashMap();
|
|
|
+ map1.put("QryType", 27);
|
|
|
+ map1.put("QryCondition", 0);
|
|
|
+ map1.put("QryData", personInfo.getId().toString());
|
|
|
+ list.add(map1);
|
|
|
+ map.put("QueryInfos", list);
|
|
|
+ try{
|
|
|
+ JSONObject jsonObject = LApiUtil.PostRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.ADDPERSON +faceDbId +"/People/Info", map);
|
|
|
+ JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
+ JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
+ Integer num = response.getInteger("Total");
|
|
|
+ if (num >0){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|