84 lines
4.3 KiB
Java
84 lines
4.3 KiB
Java
package com.zhgd.xmgl.util;
|
||
|
||
import cn.hutool.http.HttpUtil;
|
||
import cn.hutool.json.JSONObject;
|
||
import com.zhgd.xmgl.modules.project.entity.ProjectUfaceConfig;
|
||
import com.zhgd.xmgl.modules.worker.entity.UfaceDev;
|
||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||
import lombok.extern.slf4j.Slf4j;
|
||
import org.apache.commons.lang3.StringUtils;
|
||
|
||
/**
|
||
* @program: wisdomSite
|
||
* @description: 佳信捷人脸设备
|
||
* @author: Mr.Peng
|
||
* @create: 2021-01-20 11:24
|
||
**/
|
||
@Slf4j
|
||
public class JxjUfaceUtil {
|
||
|
||
public static void addUfaceDev(UfaceDev ufaceDev, ProjectUfaceConfig projectUfaceConfig) {
|
||
JSONObject jsonObject = new JSONObject();
|
||
jsonObject.put("devSn", ufaceDev.getDevSn());
|
||
jsonObject.put("devName", ufaceDev.getDevName());
|
||
jsonObject.put("projectSn", ufaceDev.getProjectSn());
|
||
String result = HttpUtil.post(projectUfaceConfig.getServiceUrl() + "/addDev", jsonObject.toString());
|
||
log.info("添加设备结果:" + result);
|
||
}
|
||
|
||
public static void deleteUfaceDev(UfaceDev ufaceDev, ProjectUfaceConfig projectUfaceConfig) {
|
||
JSONObject jsonObject = new JSONObject();
|
||
jsonObject.put("devSn", ufaceDev.getDevSn());
|
||
jsonObject.put("projectSn", ufaceDev.getProjectSn());
|
||
String result = HttpUtil.post(projectUfaceConfig.getServiceUrl() + "/deleteDev", jsonObject.toString());
|
||
log.info("删除设备结果:" + result);
|
||
}
|
||
|
||
public static void addWorkerInfo(WorkerInfo workerInfo, ProjectUfaceConfig projectUfaceConfig, String basePath) {
|
||
JSONObject jsonObject = new JSONObject();
|
||
jsonObject.put("personSn", workerInfo.getPersonSn());
|
||
jsonObject.put("idCard", workerInfo.getIdCard());
|
||
jsonObject.put("projectSn", workerInfo.getProjectSn());
|
||
jsonObject.put("workerName", workerInfo.getWorkerName());
|
||
//jsonObject.put("imageContent",Base64Util.getFileToBase64(basePath+"/"+workerInfo.getFieldAcquisitionUrl()));
|
||
if (StringUtils.isNotEmpty(workerInfo.getFieldAcquisitionUrl()) && workerInfo.getFieldAcquisitionUrl().startsWith("http")) {
|
||
jsonObject.put("imageContent", workerInfo.getFieldAcquisitionUrl());
|
||
} else {
|
||
jsonObject.put("imageContent", basePath + workerInfo.getFieldAcquisitionUrl());
|
||
}
|
||
jsonObject.put("attendanceNumber", workerInfo.getAttendanceNumber());
|
||
String url = projectUfaceConfig.getServiceUrl() + "/addOrUpdateWorkerInfo";
|
||
String body = jsonObject.toString();
|
||
log.info("http添加人员结果addWorkerInfo:url:{},body:{}", url, body);
|
||
String result = HttpUtil.post(url, body);
|
||
log.info("添加人员结果:" + result);
|
||
}
|
||
|
||
public static void deleteWorkerInfo(WorkerInfo workerInfo, ProjectUfaceConfig projectUfaceConfig) {
|
||
JSONObject jsonObject = new JSONObject();
|
||
jsonObject.put("personSn", workerInfo.getPersonSn());
|
||
jsonObject.put("idCard", workerInfo.getIdCard());
|
||
jsonObject.put("projectSn", workerInfo.getProjectSn());
|
||
jsonObject.put("workerName", workerInfo.getWorkerName());
|
||
String result = HttpUtil.post(projectUfaceConfig.getServiceUrl() + "/deleteWorkerInfo", jsonObject.toString());
|
||
log.info("删除人员结果:" + result);
|
||
}
|
||
|
||
public static void updateWorkerInfo(WorkerInfo workerInfo, ProjectUfaceConfig projectUfaceConfig, String basePath) {
|
||
JSONObject jsonObject = new JSONObject();
|
||
jsonObject.put("personSn", workerInfo.getPersonSn());
|
||
jsonObject.put("idCard", workerInfo.getIdCard());
|
||
jsonObject.put("projectSn", workerInfo.getProjectSn());
|
||
jsonObject.put("workerName", workerInfo.getWorkerName());
|
||
if (StringUtils.isNotEmpty(workerInfo.getFieldAcquisitionUrl()) && workerInfo.getFieldAcquisitionUrl().startsWith("http")) {
|
||
jsonObject.put("imageContent", workerInfo.getFieldAcquisitionUrl());
|
||
} else {
|
||
jsonObject.put("imageContent", basePath + workerInfo.getFieldAcquisitionUrl());
|
||
}
|
||
//jsonObject.put("imageContent",basePath+workerInfo.getFieldAcquisitionUrl());
|
||
jsonObject.put("attendanceNumber", workerInfo.getAttendanceNumber());
|
||
String result = HttpUtil.post(projectUfaceConfig.getServiceUrl() + "/addOrUpdateWorkerInfo", jsonObject.toString());
|
||
log.info("编辑人员结果:" + result);
|
||
}
|
||
}
|