|
@@ -120,7 +120,9 @@ public class LapiServiceImpl implements ILapiService {
|
|
map3.put("FaceID", personInfo.getId());
|
|
map3.put("FaceID", personInfo.getId());
|
|
map3.put("Name", personInfo.getId() + ".jpg");
|
|
map3.put("Name", personInfo.getId() + ".jpg");
|
|
|
|
|
|
- map3.put("Size", base64Data.length());
|
|
|
|
|
|
+ //照片base64长度
|
|
|
|
+ Integer imageSize = base64Data.length();
|
|
|
|
+ map3.put("Size", imageSize);
|
|
map3.put("Data", base64Data);
|
|
map3.put("Data", base64Data);
|
|
List listMap3 = new ArrayList();
|
|
List listMap3 = new ArrayList();
|
|
listMap3.add(map3);
|
|
listMap3.add(map3);
|
|
@@ -130,7 +132,9 @@ public class LapiServiceImpl implements ILapiService {
|
|
map.put("PersonInfoList", listMap1);
|
|
map.put("PersonInfoList", listMap1);
|
|
|
|
|
|
try {
|
|
try {
|
|
- if (base64Data.length() > 512 * 1024 || base64Data.length() < 10 * 1024) {
|
|
|
|
|
|
+ //照片字节大小
|
|
|
|
+ Integer fileSize = imageSize - (imageSize/8)*2;
|
|
|
|
+ if (fileSize > 512 * 1024 || fileSize < 10 * 1024) {
|
|
throw new Exception("人员照片大小限定为10k~512k");
|
|
throw new Exception("人员照片大小限定为10k~512k");
|
|
}
|
|
}
|
|
//获取人员人脸库id
|
|
//获取人员人脸库id
|
|
@@ -140,25 +144,34 @@ public class LapiServiceImpl implements ILapiService {
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
if (dataJson.getInteger("ResponseCode") == 0 && dataJson.getInteger("StatusCode") == 0) {
|
|
if (dataJson.getInteger("ResponseCode") == 0 && dataJson.getInteger("StatusCode") == 0) {
|
|
|
|
+ Boolean success = isSuccessAddPerson(personInfo,deviceInfo,faceDbId);
|
|
HashMap<String,Object> dataMap = new HashMap<>();
|
|
HashMap<String,Object> dataMap = new HashMap<>();
|
|
dataMap.put("deviceId",deviceInfo.getId());
|
|
dataMap.put("deviceId",deviceInfo.getId());
|
|
dataMap.put("deviceAliasName",deviceInfo.getAliasName());
|
|
dataMap.put("deviceAliasName",deviceInfo.getAliasName());
|
|
- dataMap.put("persoName",personInfo.getName());
|
|
|
|
|
|
+ dataMap.put("personName",personInfo.getName());
|
|
LapiResult lapiResult = new LapiResult();
|
|
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) {
|
|
} catch (Exception e) {
|
|
log.error(e.getMessage());
|
|
log.error(e.getMessage());
|
|
HashMap<String,Object> dataMap = new HashMap<>();
|
|
HashMap<String,Object> dataMap = new HashMap<>();
|
|
dataMap.put("deviceId",deviceInfo.getId());
|
|
dataMap.put("deviceId",deviceInfo.getId());
|
|
dataMap.put("deviceAliasName",deviceInfo.getAliasName());
|
|
dataMap.put("deviceAliasName",deviceInfo.getAliasName());
|
|
- dataMap.put("persoName",personInfo.getName());
|
|
|
|
|
|
+ dataMap.put("personName",personInfo.getName());
|
|
LapiResult lapiResult = new LapiResult();
|
|
LapiResult lapiResult = new LapiResult();
|
|
lapiResult.setSuccess(false);
|
|
lapiResult.setSuccess(false);
|
|
- lapiResult.setMsg(e.getMessage());
|
|
|
|
|
|
+ lapiResult.setMsg(e.getMessage().contains("timed out")?"设备连接超时":e.getMessage());
|
|
lapiResult.setData(dataMap);
|
|
lapiResult.setData(dataMap);
|
|
lapiResultList.add(lapiResult);
|
|
lapiResultList.add(lapiResult);
|
|
}
|
|
}
|
|
@@ -168,7 +181,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@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)){
|
|
if (StringUtils.isBlank(deviceIds)){
|
|
throw new Exception("设备为空");
|
|
throw new Exception("设备为空");
|
|
}
|
|
}
|
|
@@ -177,7 +190,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
String base64Data = OSSUtil.downloadToBase64(personInfo.getFaceImageUrl());
|
|
String base64Data = OSSUtil.downloadToBase64(personInfo.getFaceImageUrl());
|
|
|
|
|
|
List<String> deviceIdList = Arrays.asList(deviceIds.split(","));
|
|
List<String> deviceIdList = Arrays.asList(deviceIds.split(","));
|
|
- List<LapiMsgResult> lapiMsgResults = new ArrayList<>();
|
|
|
|
|
|
+ List<LapiResult> lapiResultList = new ArrayList<>();
|
|
|
|
|
|
for (String deviceId : deviceIdList) {
|
|
for (String deviceId : deviceIdList) {
|
|
DeviceInfo deviceInfo = deviceInfoService.get(deviceId);
|
|
DeviceInfo deviceInfo = deviceInfoService.get(deviceId);
|
|
@@ -207,7 +220,9 @@ public class LapiServiceImpl implements ILapiService {
|
|
map3.put("FaceID", personInfo.getId());
|
|
map3.put("FaceID", personInfo.getId());
|
|
map3.put("Name", personInfo.getId() + ".jpg");
|
|
map3.put("Name", personInfo.getId() + ".jpg");
|
|
|
|
|
|
- map3.put("Size", base64Data.length());
|
|
|
|
|
|
+ //照片base64长度
|
|
|
|
+ Integer imageSize = base64Data.length();
|
|
|
|
+ map3.put("Size", imageSize);
|
|
map3.put("Data", base64Data);
|
|
map3.put("Data", base64Data);
|
|
List listMap3 = new ArrayList();
|
|
List listMap3 = new ArrayList();
|
|
listMap3.add(map3);
|
|
listMap3.add(map3);
|
|
@@ -216,7 +231,10 @@ public class LapiServiceImpl implements ILapiService {
|
|
listMap1.add(map1);
|
|
listMap1.add(map1);
|
|
map.put("PersonInfoList", listMap1);
|
|
map.put("PersonInfoList", listMap1);
|
|
|
|
|
|
- if (base64Data.length() > 512 * 1024 || base64Data.length() < 10 * 1024) {
|
|
|
|
|
|
+ //照片字节大小
|
|
|
|
+ Integer fileSize = imageSize - (imageSize/8)*2;
|
|
|
|
+
|
|
|
|
+ if (fileSize > 512 * 1024 || fileSize < 10 * 1024) {
|
|
throw new Exception("人员照片大小限定为10k~512k");
|
|
throw new Exception("人员照片大小限定为10k~512k");
|
|
}
|
|
}
|
|
//获取人员人脸库id
|
|
//获取人员人脸库id
|
|
@@ -226,22 +244,39 @@ public class LapiServiceImpl implements ILapiService {
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
if (dataJson.getInteger("ResponseCode") == 0 && dataJson.getInteger("StatusCode") == 0) {
|
|
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("personName",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){
|
|
}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("personName",personInfo.getName());
|
|
|
|
+ LapiResult lapiResult = new LapiResult();
|
|
|
|
+ lapiResult.setSuccess(false);
|
|
|
|
+ lapiResult.setMsg(e.getMessage().contains("timed out")?"设备连接超时":e.getMessage());
|
|
|
|
+ lapiResult.setData(dataMap);
|
|
|
|
+ lapiResultList.add(lapiResult);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -249,7 +284,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- return lapiMsgResults;
|
|
|
|
|
|
+ return lapiResultList;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -324,7 +359,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
@Override
|
|
@Override
|
|
public List<LapiMsgResult> deletePerson(Long id) throws Exception {
|
|
public List<LapiMsgResult> deletePerson(Long id) throws Exception {
|
|
|
|
|
|
- PersonInfo personInfo = personInfoService.get(id);
|
|
|
|
|
|
+ PersonInfo personInfo = personInfoService.getIgnoreDelFlag(id);
|
|
if (personInfo == null) {
|
|
if (personInfo == null) {
|
|
throw new Exception("人员不存在");
|
|
throw new Exception("人员不存在");
|
|
}
|
|
}
|
|
@@ -384,7 +419,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
if (StringUtils.isBlank(deviceIds)) {
|
|
if (StringUtils.isBlank(deviceIds)) {
|
|
throw new Exception("相关设备不能为空");
|
|
throw new Exception("相关设备不能为空");
|
|
}
|
|
}
|
|
- PersonInfo personInfo = personInfoService.get(id);
|
|
|
|
|
|
+ PersonInfo personInfo = personInfoService.getIgnoreDelFlag(id);
|
|
if (personInfo == null) {
|
|
if (personInfo == null) {
|
|
throw new Exception("人员信息不存在");
|
|
throw new Exception("人员信息不存在");
|
|
}
|
|
}
|
|
@@ -655,5 +690,35 @@ public class LapiServiceImpl implements ILapiService {
|
|
return lapiResultList;
|
|
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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|