From 9502b52bf6d95eda665dfc3384a050bc30ca97ed Mon Sep 17 00:00:00 2001 From: shenzhidan Date: Wed, 29 Jul 2026 16:52:12 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E4=BA=BA=E8=84=B8=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=A4=A7=E5=8D=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../primeport/command/DaHuaPersonSyncExe.java | 47 ++++++++----------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/web-app/src/main/java/com/zcloud/primeport/command/DaHuaPersonSyncExe.java b/web-app/src/main/java/com/zcloud/primeport/command/DaHuaPersonSyncExe.java index 62d113e..59d3547 100644 --- a/web-app/src/main/java/com/zcloud/primeport/command/DaHuaPersonSyncExe.java +++ b/web-app/src/main/java/com/zcloud/primeport/command/DaHuaPersonSyncExe.java @@ -1,10 +1,10 @@ package com.zcloud.primeport.command; import com.alibaba.cola.exception.BizException; -import com.zcloud.gbscommon.dahua.cmd.DaHuaPersonSyncCmd; import com.zcloud.gbscommon.utils.Base64Util; import com.zcloud.primeport.domain.gateway.DaHuaGateway; import com.zcloud.primeport.domain.gateway.PersonApplyGateway; +import com.zcloud.primeport.domain.model.DaHuaPersonSyncCmd; import com.zcloud.primeport.domain.model.PersonApplyE; import com.zcloud.primeport.domain.model.XgfApplyPersonE; import com.zcloud.primeport.dto.PersonApplyUpdateCmd; @@ -20,7 +20,7 @@ import java.util.List; import java.util.Map; /** - * 相关方及临时访客人员同步大华平台。 + * 相关方人员同步大华平台。 */ @Slf4j @Component @@ -28,7 +28,6 @@ import java.util.Map; public class DaHuaPersonSyncExe { private static final int RELATED_PARTY = 3; - private static final int TEMPORARY_VISITOR = 4; private final DaHuaGateway daHuaGateway; private final PersonApplyGateway personApplyGateway; @@ -37,11 +36,11 @@ public class DaHuaPersonSyncExe { private String fileUrl; /** - * 相关方及临时访客人员审核通过后,按证件号判断新增或更新大华人员。 + * 相关方人员审核通过后,按证件号判断新增或更新大华人员。 */ public void syncApprovedPersons(Long applyId) { XgfApplyPersonE apply = personApplyGateway.getXgfApplyPersonById(applyId); - if (apply == null || !isDahuaSyncPerson(apply.getPersonBelongType())) { + if (apply == null || !Integer.valueOf(RELATED_PARTY).equals(apply.getPersonBelongType())) { return; } List persons = personApplyGateway.personListByxgfApplyPersonId(applyId); @@ -53,7 +52,7 @@ public class DaHuaPersonSyncExe { Long dahuaPersonId = daHuaGateway.findPersonIdByPaperNumber(paperNumber); DaHuaPersonSyncCmd syncCmd = buildSyncCmd(dahuaPersonId, person.getEmployeePersonUserName(), paperNumber, person.getUserPhone(), person.getUserFaceUrl(), - apply.getVisitStartTime(), apply.getVisitEndTime(), person.getPersonCorpId()); + apply.getVisitStartTime(), apply.getVisitEndTime()); Map result; if (dahuaPersonId == null) { syncCmd.setId(daHuaGateway.generatePersonId()); @@ -66,10 +65,10 @@ public class DaHuaPersonSyncExe { } /** - * 相关方及临时访客人员信息修改后,同步更新大华人员。 + * 相关方人员信息修改后,同步更新大华人员。 */ public void syncUpdatedPerson(PersonApplyE original, PersonApplyUpdateCmd updated) { - if (original == null || !isDahuaSyncPerson(updated.getPersonBelongType())) { + if (original == null || !Integer.valueOf(RELATED_PARTY).equals(updated.getPersonBelongType())) { return; } String originalPaperNumber = decodeUserCard(original.getUserCard()); @@ -80,12 +79,12 @@ public class DaHuaPersonSyncExe { String updatedPaperNumber = decodeUserCard(updated.getUserCard()); DaHuaPersonSyncCmd syncCmd = buildSyncCmd(dahuaPersonId, updated.getEmployeePersonUserName(), updatedPaperNumber, updated.getUserPhone(), updated.getUserFaceUrl(), - updated.getVisitStartTime(), updated.getVisitEndTime(), updated.getPersonCorpId()); + updated.getVisitStartTime(), updated.getVisitEndTime()); checkResult(daHuaGateway.updatePerson(syncCmd), "修改大华人员失败"); } /** - * 删除相关方及临时访客人员时,同步删除对应的大华人员。 + * 删除相关方人员时,同步删除对应的大华人员。 */ public void syncDeletedPersons(List persons) { if (persons == null || persons.isEmpty()) { @@ -94,7 +93,7 @@ public class DaHuaPersonSyncExe { List dahuaPersonIds = new ArrayList<>(); for (PersonApplyE person : persons) { XgfApplyPersonE apply = personApplyGateway.getXgfApplyPersonById(person.getXgfApplyPersonId()); - if (apply == null || !isDahuaSyncPerson(apply.getPersonBelongType())) { + if (apply == null || !Integer.valueOf(RELATED_PARTY).equals(apply.getPersonBelongType())) { continue; } Long dahuaPersonId = daHuaGateway.findPersonIdByPaperNumber(decodeUserCard(person.getUserCard())); @@ -108,7 +107,7 @@ public class DaHuaPersonSyncExe { } private DaHuaPersonSyncCmd buildSyncCmd(Long id, String name, String paperNumber, String phone, - String faceUrl, String startTime, String endTime, Long corpId) { + String faceUrl, String startTime, String endTime) { DaHuaPersonSyncCmd cmd = new DaHuaPersonSyncCmd(); cmd.setService("evo-thirdParty"); cmd.setId(id); @@ -116,11 +115,7 @@ public class DaHuaPersonSyncExe { cmd.setCode("hbqa" + paperNumber); cmd.setPaperType(111); cmd.setPaperNumber(paperNumber); - Long dahuaDeptId = daHuaGateway.findDahuaDepartmentIdByCorpId(corpId); - if (dahuaDeptId == null) { - throw new BizException("未找到大华部门映射配置, corpId=" + corpId); - } - cmd.setDepartmentId(dahuaDeptId); + cmd.setDepartmentId(1L); cmd.setDepartmentType(2); cmd.setType(3); cmd.setPhone(phone); @@ -130,18 +125,19 @@ public class DaHuaPersonSyncExe { DaHuaPersonSyncCmd.PersonBiosignature face = new DaHuaPersonSyncCmd.PersonBiosignature(); face.setType(3); face.setIndex(1); + // userFaceUrl 是文件服务器相对路径,读取图片并转换为 Base64 后交给大华网关。 face.setBase64Data(resolveFaceBase64(faceUrl)); cmd.setPersonBiosignatures(Collections.singletonList(face)); return cmd; } /** - * 根据文件服务地址读取人员头像并转换为图片 Base64。 + * 根据文件服务地址读取相关方人员头像并转换为图片 Base64。 * 大华人员接口的 path 必须是大华图片上传接口返回的 fileUrl,不能直接使用本系统路径。 */ private String resolveFaceBase64(String faceUrl) { if (faceUrl == null || faceUrl.trim().isEmpty()) { - throw new BizException("人员头像不能为空"); + throw new BizException("相关方人员头像不能为空"); } if (fileUrl == null || fileUrl.trim().isEmpty()) { throw new BizException("文件访问地址未配置"); @@ -154,14 +150,14 @@ public class DaHuaPersonSyncExe { try { String faceBase64 = Base64Util.urlToBase64(imageUrl); if (faceBase64 == null || faceBase64.trim().isEmpty()) { - throw new BizException("人员头像转换失败"); + throw new BizException("相关方人员头像转换失败"); } return faceBase64; } catch (BizException e) { throw e; } catch (Exception e) { - log.error("获取人员头像失败, imageUrl={}", imageUrl, e); - throw new BizException("获取人员头像失败"); + log.error("获取相关方人员头像失败, imageUrl={}", imageUrl, e); + throw new BizException("获取相关方人员头像失败"); } } @@ -169,11 +165,6 @@ public class DaHuaPersonSyncExe { 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) { try { return Base64.decodeToString(userCard); @@ -188,4 +179,4 @@ public class DaHuaPersonSyncExe { throw new BizException(message + (errorMessage == null ? "" : ": " + errorMessage)); } } -} \ No newline at end of file +}