|
@@ -159,6 +159,90 @@ public class LapiServiceImpl implements ILapiService {
|
|
return lapiMsgResults;
|
|
return lapiMsgResults;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<LapiMsgResult> addPersonForDeviceIds(Long id, String deviceIds) throws Exception {
|
|
|
|
+ if (StringUtils.isBlank(deviceIds)){
|
|
|
|
+ throw new Exception("设备为空");
|
|
|
|
+ }
|
|
|
|
+ PersonInfo personInfo = personInfoService.get(id);
|
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
|
|
+ String base64Data = OSSUtil.downloadToBase64(personInfo.getFaceImageUrl());
|
|
|
|
+ if (base64Data.length() > 512 * 1024 || base64Data.length() < 10 * 1024) {
|
|
|
|
+ throw new Exception("人员照片大小限定为10k~512k");
|
|
|
|
+ }
|
|
|
|
+ List<String> deviceIdList = Arrays.asList(deviceIds.split(","));
|
|
|
|
+ List<LapiMsgResult> lapiMsgResults = 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);
|
|
|
|
+
|
|
|
|
+ HashMap<String, Object> map3 = new HashMap<>();
|
|
|
|
+ map3.put("FaceID", personInfo.getId());
|
|
|
|
+ map3.put("Name", personInfo.getId() + ".jpg");
|
|
|
|
+
|
|
|
|
+ map3.put("Size", base64Data.length());
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+ //获取人员人脸库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) {
|
|
|
|
+ LapiMsgResult lapiMsgResult = new LapiMsgResult();
|
|
|
|
+ lapiMsgResult.setPersonName(personInfo.getName());
|
|
|
|
+ lapiMsgResult.setSuccess(true);
|
|
|
|
+ lapiMsgResult.setAliasName(deviceInfo.getAliasName());
|
|
|
|
+ lapiMsgResults.add(lapiMsgResult);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }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);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return lapiMsgResults;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public String getFaceDbId(DeviceInfo deviceInfo, String companyName) throws Exception {
|
|
public String getFaceDbId(DeviceInfo deviceInfo, String companyName) throws Exception {
|
|
if (StringUtils.isBlank(companyName)) {
|
|
if (StringUtils.isBlank(companyName)) {
|