|
@@ -95,48 +95,63 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
|
|
|
List<LapiResult> lapiResultList = new ArrayList<>();
|
|
|
for (DeviceInfo deviceInfo : deviceList) {
|
|
|
- HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("Num", 1L);
|
|
|
- HashMap<String, Object> map1 = new HashMap<>();
|
|
|
- map1.put("PersonID", personInfo.getId());
|
|
|
- map1.put("LastChange", new Date().getTime());
|
|
|
- map1.put("PersonCode", personInfo.getId().toString());
|
|
|
- map1.put("PersonName", personInfo.getName() + "_" + personInfo.getId().toString());
|
|
|
- map1.put("Remarks", companyInfo.getName());
|
|
|
-
|
|
|
- //TimeTemplateNum 首字符必须大写
|
|
|
- map1.put("TimeTemplateNum", 0L);
|
|
|
-
|
|
|
- map1.put("IdentificationNum", 1L);
|
|
|
- HashMap<String, Object> map2 = new HashMap<>();
|
|
|
- List listMap2 = new ArrayList();
|
|
|
- listMap2.add(map2);
|
|
|
- map2.put("Type", 0L);
|
|
|
- map2.put("Number", personInfo.getIdCard());
|
|
|
- map1.put("IdentificationList", listMap2);
|
|
|
- map1.put("ImageNum", 1L);
|
|
|
-
|
|
|
- HashMap<String, Object> map3 = new HashMap<>();
|
|
|
- map3.put("FaceID", personInfo.getId());
|
|
|
- map3.put("Name", personInfo.getId() + ".jpg");
|
|
|
-
|
|
|
- //照片base64长度
|
|
|
- Integer imageSize = base64Data.length();
|
|
|
- map3.put("Size", imageSize);
|
|
|
- map3.put("Data", base64Data);
|
|
|
- List listMap3 = new ArrayList();
|
|
|
- listMap3.add(map3);
|
|
|
- map1.put("ImageList", listMap3);
|
|
|
- List listMap1 = new ArrayList();
|
|
|
- listMap1.add(map1);
|
|
|
- map.put("PersonInfoList", listMap1);
|
|
|
-
|
|
|
try {
|
|
|
- //照片字节大小
|
|
|
- Integer fileSize = imageSize - (imageSize/8)*2;
|
|
|
- if (fileSize > 512 * 1024 || fileSize < 10 * 1024) {
|
|
|
- throw new Exception("人员照片大小限定为10k~512k");
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("Num", 1L);
|
|
|
+ HashMap<String, Object> map1 = new HashMap<>();
|
|
|
+ map1.put("PersonID", personInfo.getId());
|
|
|
+ map1.put("LastChange", new Date().getTime());
|
|
|
+ map1.put("PersonCode", personInfo.getId().toString());
|
|
|
+ map1.put("PersonName", personInfo.getName() + "_" + personInfo.getId().toString());
|
|
|
+ map1.put("Remarks", companyInfo.getName());
|
|
|
+
|
|
|
+ //TimeTemplateNum 首字符必须大写
|
|
|
+ map1.put("TimeTemplateNum", 0L);
|
|
|
+
|
|
|
+ map1.put("IdentificationNum", 1L);
|
|
|
+ HashMap<String, Object> map2 = new HashMap<>();
|
|
|
+ List listMap2 = new ArrayList();
|
|
|
+ listMap2.add(map2);
|
|
|
+ map2.put("Type", 0L);
|
|
|
+ map2.put("Number", personInfo.getIdCard());
|
|
|
+ map1.put("IdentificationList", listMap2);
|
|
|
+
|
|
|
+
|
|
|
+ HashMap<String, Object> map3 = new HashMap<>();
|
|
|
+
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(base64Data)){
|
|
|
+
|
|
|
+ Integer imageSize = base64Data.length();
|
|
|
+ //照片字节大小
|
|
|
+ Integer fileSize = imageSize - (imageSize / 8) * 2;
|
|
|
+ if (fileSize > 512 * 1024 || fileSize < 10 * 1024) {
|
|
|
+ throw new Exception("人员照片大小限定为10k~512k");
|
|
|
+ }
|
|
|
+ map3.put("Size", imageSize);
|
|
|
+ map3.put("Data", base64Data);
|
|
|
+ map3.put("FaceID", personInfo.getId());
|
|
|
+ map3.put("Name", personInfo.getId() + ".jpg");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ map1.put("ImageNum", 0);
|
|
|
+ map3.put("FaceID", 0);
|
|
|
+ map3.put("Name", "");
|
|
|
+ map3.put("Size", 0);
|
|
|
+ map3.put("Data", "");
|
|
|
}
|
|
|
+
|
|
|
+ //照片base64长度
|
|
|
+
|
|
|
+ List listMap3 = new ArrayList();
|
|
|
+ listMap3.add(map3);
|
|
|
+ map1.put("ImageList", listMap3);
|
|
|
+ List listMap1 = new ArrayList();
|
|
|
+ listMap1.add(map1);
|
|
|
+ map.put("PersonInfoList", listMap1);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//获取人员人脸库id
|
|
|
String faceDbId = getFaceDbId(deviceInfo, companyInfo.getName());
|
|
|
|
|
@@ -144,18 +159,18 @@ 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("personName",personInfo.getName());
|
|
|
+ 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){
|
|
|
+ if (success) {
|
|
|
lapiResult.setMsg("绑定成功");
|
|
|
lapiResult.setSuccess(true);
|
|
|
lapiResult.setData(dataMap);
|
|
|
lapiResultList.add(lapiResult);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
lapiResult.setMsg("绑定失败");
|
|
|
lapiResult.setSuccess(false);
|
|
|
lapiResult.setData(dataMap);
|
|
@@ -165,13 +180,13 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
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());
|
|
|
+ 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.setMsg(e.getMessage().contains("timed out") ? "设备连接超时" : e.getMessage());
|
|
|
lapiResult.setData(dataMap);
|
|
|
lapiResultList.add(lapiResult);
|
|
|
}
|
|
@@ -182,7 +197,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
|
|
|
@Override
|
|
|
public List<LapiResult> addPersonForDeviceIds(Long id, String deviceIds) throws Exception {
|
|
|
- if (StringUtils.isBlank(deviceIds)){
|
|
|
+ if (StringUtils.isBlank(deviceIds)) {
|
|
|
throw new Exception("设备为空");
|
|
|
}
|
|
|
PersonInfo personInfo = personInfoService.get(id);
|
|
@@ -192,97 +207,111 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
List<String> deviceIdList = Arrays.asList(deviceIds.split(","));
|
|
|
List<LapiResult> lapiResultList = new ArrayList<>();
|
|
|
|
|
|
- for (String deviceId : deviceIdList) {
|
|
|
- DeviceInfo deviceInfo = deviceInfoService.get(deviceId);
|
|
|
- try {
|
|
|
- HashMap<String, Object> map = new HashMap<>();
|
|
|
- map.put("Num", 1L);
|
|
|
- HashMap<String, Object> map1 = new HashMap<>();
|
|
|
- map1.put("PersonID", personInfo.getId());
|
|
|
- map1.put("LastChange", new Date().getTime());
|
|
|
- map1.put("PersonCode", personInfo.getId().toString());
|
|
|
- map1.put("PersonName", personInfo.getName() + "_" + personInfo.getId().toString());
|
|
|
- map1.put("Remarks", companyInfo.getName());
|
|
|
-
|
|
|
- //TimeTemplateNum 首字符必须大写
|
|
|
- map1.put("TimeTemplateNum", 0L);
|
|
|
-
|
|
|
- map1.put("IdentificationNum", 1L);
|
|
|
- HashMap<String, Object> map2 = new HashMap<>();
|
|
|
- List listMap2 = new ArrayList();
|
|
|
- listMap2.add(map2);
|
|
|
- map2.put("Type", 0L);
|
|
|
- map2.put("Number", personInfo.getIdCard());
|
|
|
- map1.put("IdentificationList", listMap2);
|
|
|
- map1.put("ImageNum", 1L);
|
|
|
+ for (String deviceId : deviceIdList) {
|
|
|
+ DeviceInfo deviceInfo = deviceInfoService.get(deviceId);
|
|
|
+ try {
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("Num", 1L);
|
|
|
+ HashMap<String, Object> map1 = new HashMap<>();
|
|
|
+ map1.put("PersonID", personInfo.getId());
|
|
|
+ map1.put("LastChange", new Date().getTime());
|
|
|
+ map1.put("PersonCode", personInfo.getId().toString());
|
|
|
+ map1.put("PersonName", personInfo.getName() + "_" + personInfo.getId().toString());
|
|
|
+ map1.put("Remarks", companyInfo.getName());
|
|
|
+
|
|
|
+ //TimeTemplateNum 首字符必须大写
|
|
|
+ map1.put("TimeTemplateNum", 0L);
|
|
|
+
|
|
|
+ map1.put("IdentificationNum", 1L);
|
|
|
+ HashMap<String, Object> map2 = new HashMap<>();
|
|
|
+ List listMap2 = new ArrayList();
|
|
|
+ listMap2.add(map2);
|
|
|
+ map2.put("Type", 0L);
|
|
|
+ map2.put("Number", personInfo.getIdCard());
|
|
|
+ map1.put("IdentificationList", listMap2);
|
|
|
+
|
|
|
+
|
|
|
+ HashMap<String, Object> map3 = new HashMap<>();
|
|
|
+
|
|
|
|
|
|
- HashMap<String, Object> map3 = new HashMap<>();
|
|
|
- map3.put("FaceID", personInfo.getId());
|
|
|
- map3.put("Name", personInfo.getId() + ".jpg");
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(base64Data)){
|
|
|
+ map1.put("ImageNum", 1L);
|
|
|
//照片base64长度
|
|
|
Integer imageSize = base64Data.length();
|
|
|
+ map3.put("Name", personInfo.getId() + ".jpg");
|
|
|
map3.put("Size", imageSize);
|
|
|
map3.put("Data", base64Data);
|
|
|
- List listMap3 = new ArrayList();
|
|
|
- listMap3.add(map3);
|
|
|
- map1.put("ImageList", listMap3);
|
|
|
- List listMap1 = new ArrayList();
|
|
|
- listMap1.add(map1);
|
|
|
- map.put("PersonInfoList", listMap1);
|
|
|
+ map3.put("FaceID", personInfo.getId());
|
|
|
|
|
|
//照片字节大小
|
|
|
- Integer fileSize = imageSize - (imageSize/8)*2;
|
|
|
+ Integer fileSize = imageSize - (imageSize / 8) * 2;
|
|
|
|
|
|
if (fileSize > 512 * 1024 || fileSize < 10 * 1024) {
|
|
|
throw new Exception("人员照片大小限定为10k~512k");
|
|
|
}
|
|
|
- //获取人员人脸库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");
|
|
|
- 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("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);
|
|
|
- }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ map1.put("ImageNum", 0);
|
|
|
+ map3.put("FaceID", 0);
|
|
|
+ map3.put("Name", "");
|
|
|
+ map3.put("Size", 0);
|
|
|
+ map3.put("Data", "");
|
|
|
+ }
|
|
|
|
|
|
+ List listMap3 = new ArrayList();
|
|
|
+ listMap3.add(map3);
|
|
|
+ map1.put("ImageList", listMap3);
|
|
|
+ List listMap1 = new ArrayList();
|
|
|
+ listMap1.add(map1);
|
|
|
+ map.put("PersonInfoList", listMap1);
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ //获取人员人脸库id
|
|
|
+ String faceDbId = getFaceDbId(deviceInfo, companyInfo.getName());
|
|
|
|
|
|
- }catch (Exception e){
|
|
|
- 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());
|
|
|
+ JSONObject jsonObject = LApiUtil.PostRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.ADDPERSON + faceDbId + "/People", map);
|
|
|
+ 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("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);
|
|
|
+ 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());
|
|
|
+ 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);
|
|
|
}
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
return lapiResultList;
|
|
|
}
|
|
@@ -322,8 +351,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
|
|
|
|
|
|
}
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
faceDbId = getDefaultLib(deviceInfo.getId());
|
|
|
}
|
|
|
|
|
@@ -691,11 +719,11 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean isSuccessAddPerson(PersonInfo personInfo,DeviceInfo deviceInfo,String faceDbId) {
|
|
|
+ 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);
|
|
|
+ map.put("Limit", 3);
|
|
|
+ map.put("Offset", 0);
|
|
|
List list = new ArrayList();
|
|
|
HashMap map1 = new HashMap();
|
|
|
map1.put("QryType", 27);
|
|
@@ -703,15 +731,15 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
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);
|
|
|
+ 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){
|
|
|
+ if (num > 0) {
|
|
|
return true;
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
|
return false;
|
|
|
}
|