bug修复
This commit is contained in:
parent
af10a1fa0f
commit
3e0eca85bf
@ -239,13 +239,15 @@ public class HikvisionCall {
|
||||
jsonBody.put("certificateType", "111");
|
||||
jsonBody.put("certificateNo", workerInfo.getIdCard());
|
||||
jsonBody.put("jobNo", workerInfo.getPersonSn());
|
||||
ArrayList<HashMap<String, String>> faceList = new ArrayList<>();
|
||||
HashMap<String, String> faceMap = new HashMap<>();
|
||||
faceMap.put("faceData", Base64Util.convertFileToBase64(PathUtil.reviseSlash(basePath + "/" + workerInfo.getFieldAcquisitionUrl())));
|
||||
faceList.add(faceMap);
|
||||
jsonBody.put("faces", faceList);
|
||||
String body = jsonBody.toJSONString();
|
||||
return body;
|
||||
String fieldAcquisitionUrl = workerInfo.getFieldAcquisitionUrl();
|
||||
if (StringUtils.isNotBlank(fieldAcquisitionUrl)) {
|
||||
ArrayList<HashMap<String, String>> faceList = new ArrayList<>();
|
||||
HashMap<String, String> faceMap = new HashMap<>();
|
||||
faceMap.put("faceData", Base64Util.convertFileToBase64(PathUtil.reviseSlash(basePath + "/" + fieldAcquisitionUrl)));
|
||||
faceList.add(faceMap);
|
||||
jsonBody.put("faces", faceList);
|
||||
}
|
||||
return jsonBody.toJSONString();
|
||||
}
|
||||
|
||||
private String getOrgIndexCode(WorkerInfo workerInfo) {
|
||||
@ -286,6 +288,25 @@ public class HikvisionCall {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加人脸
|
||||
*
|
||||
* @param workerInfo
|
||||
* @param project
|
||||
*/
|
||||
private void addWorkerFace(WorkerInfo workerInfo, Project project) {
|
||||
String fieldAcquisitionUrl = workerInfo.getFieldAcquisitionUrl();
|
||||
if (StringUtils.isNotBlank(fieldAcquisitionUrl)) {
|
||||
final String ARTEMIS_PATH = "/artemis";
|
||||
final String path = ARTEMIS_PATH + "/api/resource/v1/face/single/add";
|
||||
String host = "https://" + project.getArtemisConfigHost();
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("personId", String.valueOf(workerInfo.getId()));
|
||||
jo.put("faceData", Base64Util.convertFileToBase64(PathUtil.reviseSlash(basePath + "/" + fieldAcquisitionUrl)));
|
||||
HikvisionUtil.doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑人脸
|
||||
*
|
||||
@ -295,15 +316,16 @@ public class HikvisionCall {
|
||||
private void editWorkerFace(WorkerInfo workerInfo, Project project) {
|
||||
ArrayList<String> workerFaceIds = getWorkerFaceIds(workerInfo, project);
|
||||
if (CollUtil.isNotEmpty(workerFaceIds)) {
|
||||
for (String workerFaceId : workerFaceIds) {
|
||||
final String ARTEMIS_PATH = "/artemis";
|
||||
final String path = ARTEMIS_PATH + "/api/resource/v1/face/single/update";
|
||||
String host = "https://" + project.getArtemisConfigHost();
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("faceId", workerFaceId);
|
||||
jo.put("faceData", Base64Util.convertFileToBase64(PathUtil.reviseSlash(basePath + "/" + workerInfo.getFieldAcquisitionUrl())));
|
||||
HikvisionUtil.doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
||||
}
|
||||
String workerFaceId = workerFaceIds.get(0);
|
||||
final String ARTEMIS_PATH = "/artemis";
|
||||
final String path = ARTEMIS_PATH + "/api/resource/v1/face/single/update";
|
||||
String host = "https://" + project.getArtemisConfigHost();
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("faceId", workerFaceId);
|
||||
jo.put("faceData", Base64Util.convertFileToBase64(PathUtil.reviseSlash(basePath + "/" + workerInfo.getFieldAcquisitionUrl())));
|
||||
HikvisionUtil.doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
||||
} else {
|
||||
addWorkerFace(workerInfo, project);
|
||||
}
|
||||
}
|
||||
|
||||
@ -317,6 +339,8 @@ public class HikvisionCall {
|
||||
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
||||
return;
|
||||
}
|
||||
deleteWorkerFace(workerInfo, project);
|
||||
|
||||
final String ARTEMIS_PATH = "/artemis";
|
||||
final String path = ARTEMIS_PATH + "/api/resource/v1/person/batch/delete";
|
||||
String host = "https://" + project.getArtemisConfigHost();
|
||||
@ -324,9 +348,6 @@ public class HikvisionCall {
|
||||
jsonBody.put("personIds", Arrays.asList(workerInfo.getId()));
|
||||
String body = jsonBody.toJSONString();
|
||||
HikvisionUtil.doPost(host, path, body, null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
||||
|
||||
deleteWorkerFace(workerInfo, project);
|
||||
|
||||
}
|
||||
|
||||
private void deleteWorkerFace(WorkerInfo workerInfo, Project project) {
|
||||
|
||||
@ -32,6 +32,10 @@ public class HikvisionUtil {
|
||||
}
|
||||
|
||||
public static String doPost(String host, String path, String body, Map<String, String> querys, String appKey, String appSecret) {
|
||||
return doPost(host, path, body, querys, appKey, appSecret, false);
|
||||
}
|
||||
|
||||
public static String doPost(String host, String path, String body, Map<String, String> querys, String appKey, String appSecret, boolean isRetry) {
|
||||
log.info("HikvisionUtil#doPost.url:{}", host + path);
|
||||
log.info("HikvisionUtil#doPost.body:{}", body);
|
||||
String responseStr = null;
|
||||
@ -48,18 +52,20 @@ public class HikvisionUtil {
|
||||
log.info("HikvisionUtil#doPost.getResponseResult:{}", responseStr);
|
||||
} catch (Exception var10) {
|
||||
var10.printStackTrace();
|
||||
HikvisionRequestRetry entity = new HikvisionRequestRetry();
|
||||
entity.setUrl(host + path);
|
||||
entity.setHost(host);
|
||||
entity.setPath(path);
|
||||
entity.setMethod(2);
|
||||
entity.setParam(JSON.toJSONString(querys));
|
||||
entity.setBody(body);
|
||||
entity.setLastResult(null);
|
||||
entity.setRequestNum(1);
|
||||
entity.setAppKey(appKey);
|
||||
entity.setAppSecret(appSecret);
|
||||
hikvisionRequestRetryMapper.insert(entity);
|
||||
if (!isRetry) {
|
||||
HikvisionRequestRetry entity = new HikvisionRequestRetry();
|
||||
entity.setUrl(host + path);
|
||||
entity.setHost(host);
|
||||
entity.setPath(path);
|
||||
entity.setMethod(2);
|
||||
entity.setParam(JSON.toJSONString(querys));
|
||||
entity.setBody(body);
|
||||
entity.setLastResult(null);
|
||||
entity.setRequestNum(1);
|
||||
entity.setAppKey(appKey);
|
||||
entity.setAppSecret(appSecret);
|
||||
hikvisionRequestRetryMapper.insert(entity);
|
||||
}
|
||||
}
|
||||
return responseStr;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user