1.临时访客同步大华
parent
11e495a15a
commit
1d93c0a201
|
|
@ -20,7 +20,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 相关方人员同步大华平台。
|
* 相关方及临时访客人员同步大华平台。
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
|
|
@ -28,6 +28,7 @@ import java.util.Map;
|
||||||
public class DaHuaPersonSyncExe {
|
public class DaHuaPersonSyncExe {
|
||||||
|
|
||||||
private static final int RELATED_PARTY = 3;
|
private static final int RELATED_PARTY = 3;
|
||||||
|
private static final int TEMPORARY_VISITOR = 4;
|
||||||
|
|
||||||
private final DaHuaGateway daHuaGateway;
|
private final DaHuaGateway daHuaGateway;
|
||||||
private final PersonApplyGateway personApplyGateway;
|
private final PersonApplyGateway personApplyGateway;
|
||||||
|
|
@ -36,11 +37,11 @@ public class DaHuaPersonSyncExe {
|
||||||
private String fileUrl;
|
private String fileUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 相关方人员审核通过后,按证件号判断新增或更新大华人员。
|
* 相关方及临时访客人员审核通过后,按证件号判断新增或更新大华人员。
|
||||||
*/
|
*/
|
||||||
public void syncApprovedPersons(Long applyId) {
|
public void syncApprovedPersons(Long applyId) {
|
||||||
XgfApplyPersonE apply = personApplyGateway.getXgfApplyPersonById(applyId);
|
XgfApplyPersonE apply = personApplyGateway.getXgfApplyPersonById(applyId);
|
||||||
if (apply == null || !Integer.valueOf(RELATED_PARTY).equals(apply.getPersonBelongType())) {
|
if (apply == null || !isDahuaSyncPerson(apply.getPersonBelongType())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<PersonApplyE> persons = personApplyGateway.personListByxgfApplyPersonId(applyId);
|
List<PersonApplyE> persons = personApplyGateway.personListByxgfApplyPersonId(applyId);
|
||||||
|
|
@ -65,10 +66,10 @@ public class DaHuaPersonSyncExe {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 相关方人员信息修改后,同步更新大华人员。
|
* 相关方及临时访客人员信息修改后,同步更新大华人员。
|
||||||
*/
|
*/
|
||||||
public void syncUpdatedPerson(PersonApplyE original, PersonApplyUpdateCmd updated) {
|
public void syncUpdatedPerson(PersonApplyE original, PersonApplyUpdateCmd updated) {
|
||||||
if (original == null || !Integer.valueOf(RELATED_PARTY).equals(updated.getPersonBelongType())) {
|
if (original == null || !isDahuaSyncPerson(updated.getPersonBelongType())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String originalPaperNumber = decodeUserCard(original.getUserCard());
|
String originalPaperNumber = decodeUserCard(original.getUserCard());
|
||||||
|
|
@ -84,7 +85,7 @@ public class DaHuaPersonSyncExe {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除相关方人员时,同步删除对应的大华人员。
|
* 删除相关方及临时访客人员时,同步删除对应的大华人员。
|
||||||
*/
|
*/
|
||||||
public void syncDeletedPersons(List<PersonApplyE> persons) {
|
public void syncDeletedPersons(List<PersonApplyE> persons) {
|
||||||
if (persons == null || persons.isEmpty()) {
|
if (persons == null || persons.isEmpty()) {
|
||||||
|
|
@ -93,7 +94,7 @@ public class DaHuaPersonSyncExe {
|
||||||
List<Long> dahuaPersonIds = new ArrayList<>();
|
List<Long> dahuaPersonIds = new ArrayList<>();
|
||||||
for (PersonApplyE person : persons) {
|
for (PersonApplyE person : persons) {
|
||||||
XgfApplyPersonE apply = personApplyGateway.getXgfApplyPersonById(person.getXgfApplyPersonId());
|
XgfApplyPersonE apply = personApplyGateway.getXgfApplyPersonById(person.getXgfApplyPersonId());
|
||||||
if (apply == null || !Integer.valueOf(RELATED_PARTY).equals(apply.getPersonBelongType())) {
|
if (apply == null || !isDahuaSyncPerson(apply.getPersonBelongType())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Long dahuaPersonId = daHuaGateway.findPersonIdByPaperNumber(decodeUserCard(person.getUserCard()));
|
Long dahuaPersonId = daHuaGateway.findPersonIdByPaperNumber(decodeUserCard(person.getUserCard()));
|
||||||
|
|
@ -132,12 +133,12 @@ public class DaHuaPersonSyncExe {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据文件服务地址读取相关方人员头像并转换为图片 Base64。
|
* 根据文件服务地址读取人员头像并转换为图片 Base64。
|
||||||
* 大华人员接口的 path 必须是大华图片上传接口返回的 fileUrl,不能直接使用本系统路径。
|
* 大华人员接口的 path 必须是大华图片上传接口返回的 fileUrl,不能直接使用本系统路径。
|
||||||
*/
|
*/
|
||||||
private String resolveFaceBase64(String faceUrl) {
|
private String resolveFaceBase64(String faceUrl) {
|
||||||
if (faceUrl == null || faceUrl.trim().isEmpty()) {
|
if (faceUrl == null || faceUrl.trim().isEmpty()) {
|
||||||
throw new BizException("相关方人员头像不能为空");
|
throw new BizException("人员头像不能为空");
|
||||||
}
|
}
|
||||||
if (fileUrl == null || fileUrl.trim().isEmpty()) {
|
if (fileUrl == null || fileUrl.trim().isEmpty()) {
|
||||||
throw new BizException("文件访问地址未配置");
|
throw new BizException("文件访问地址未配置");
|
||||||
|
|
@ -150,14 +151,14 @@ public class DaHuaPersonSyncExe {
|
||||||
try {
|
try {
|
||||||
String faceBase64 = Base64Util.urlToBase64(imageUrl);
|
String faceBase64 = Base64Util.urlToBase64(imageUrl);
|
||||||
if (faceBase64 == null || faceBase64.trim().isEmpty()) {
|
if (faceBase64 == null || faceBase64.trim().isEmpty()) {
|
||||||
throw new BizException("相关方人员头像转换失败");
|
throw new BizException("人员头像转换失败");
|
||||||
}
|
}
|
||||||
return faceBase64;
|
return faceBase64;
|
||||||
} catch (BizException e) {
|
} catch (BizException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("获取相关方人员头像失败, imageUrl={}", imageUrl, e);
|
log.error("获取人员头像失败, imageUrl={}", imageUrl, e);
|
||||||
throw new BizException("获取相关方人员头像失败");
|
throw new BizException("获取人员头像失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,6 +166,11 @@ public class DaHuaPersonSyncExe {
|
||||||
return path.startsWith("/") ? path.substring(1) : path;
|
return path.startsWith("/") ? path.substring(1) : path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isDahuaSyncPerson(Integer personBelongType) {
|
||||||
|
return Integer.valueOf(RELATED_PARTY).equals(personBelongType)
|
||||||
|
|| Integer.valueOf(TEMPORARY_VISITOR).equals(personBelongType);
|
||||||
|
}
|
||||||
|
|
||||||
private String decodeUserCard(String userCard) {
|
private String decodeUserCard(String userCard) {
|
||||||
try {
|
try {
|
||||||
return Base64.decodeToString(userCard);
|
return Base64.decodeToString(userCard);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue