大华口门对接1.1

(cherry picked from commit 65ad2b538e)
dahua_koumen
zhangxiongfeng 2026-08-05 08:38:28 +08:00
parent 285764928c
commit e4c8ddb7b0
4 changed files with 85 additions and 22 deletions

View File

@ -89,7 +89,7 @@ public class UserAddExe {
private final UserCorpRecordGateway userCorpRecordGateway;
private ZcloudRedisUtil zcloudRedisUtil;
private final UserCorpRecordRepository userCorpRecordRepository;
@DubboReference(check = false)
@DubboReference
private UserFacade userFacade;
// private final String sourceCode;
// @Value("${seng.message:MS000087}")
@ -100,7 +100,7 @@ public class UserAddExe {
private final UserExpandInfoRepository userExpandInfoRepository;
private final ImgFilesRepository imgFilesRepository;
private final DaHuaConfig daHuaConfig;
@DubboReference(version = "1.0.0", group = "primeport")
@DubboReference
private ZcloudDaHuaFacade zcloudDaHuaFacade;
@Transactional(rollbackFor = Exception.class)
@ -452,12 +452,41 @@ public class UserAddExe {
if (plainIdCard != null && plainIdCard.length() >= 14) {
maskedIdCard = plainIdCard.substring(0, 6) + "********" + plainIdCard.substring(plainIdCard.length() - 4);
}
log.info("Dubbo调用primeport.zcloudDaHuaFacade.syncPerson, name={}, departmentId(corpId)={}, idCardMask={}",
cmd.getName(), cmd.getDepartmentId(), maskedIdCard);
log.info("========== 开始Dubbo调用primeport.zcloudDaHuaFacade.syncPerson ==========");
log.info("Dubbo调用参数: name={}, departmentId(corpId)={}, idCardMask={}, phone={}, code={}",
cmd.getName(), cmd.getDepartmentId(), maskedIdCard, cmd.getPhone(), cmd.getCode());
log.info("Dubbo调用参数: paperType={}, departmentType={}, type={}, nation={}, nationName={}",
cmd.getPaperType(), cmd.getDepartmentType(), cmd.getType(), cmd.getNation(), cmd.getNationName());
if (cmd.getPersonBiosignatures() != null) {
log.info("Dubbo调用携带人脸生物特征, size={}", cmd.getPersonBiosignatures().size());
} else {
log.info("Dubbo调用未携带人脸生物特征");
}
log.info("Dubbo调用 cmd对象完整打印: {}", JSONUtil.toJsonStr(cmd));
SingleResponse<Object> syncResp = null;
try {
log.info("即将执行 zcloudDaHuaFacade.syncPerson(cmd)...");
syncResp = zcloudDaHuaFacade.syncPerson(cmd);
log.info("zcloudDaHuaFacade.syncPerson(cmd) 执行完成,已返回");
} catch (Exception e) {
log.error("========== Dubbo调用primeport.zcloudDaHuaFacade.syncPerson 发生异常 ==========", e);
log.error("异常类型: {}", e.getClass().getName());
log.error("异常信息: {}", e.getMessage());
if (throwOnFail) {
throw new BizException("同步大华平台失败Dubbo调用异常" + e.getMessage());
} else {
log.warn("同步大华平台Dubbo调用异常不影响本地数据保存: {}", e.getMessage());
return result;
}
}
log.info("========== Dubbo调用返回结果 ==========");
log.info("返回对象: syncResp={}", syncResp);
if (syncResp != null) {
log.info("返回详情: success={}, errCode={}, errMessage={}, data={}",
syncResp.isSuccess(), syncResp.getErrCode(), syncResp.getErrMessage(), syncResp.getData());
}
SingleResponse<Object> syncResp = zcloudDaHuaFacade.syncPerson(cmd);
result.setDahuaCode(plainIdCard);
userE.setDahuaCode(plainIdCard);
if (syncResp == null || !syncResp.isSuccess()) {
@ -476,7 +505,12 @@ public class UserAddExe {
if (data != null) {
if (data instanceof Map) {
Map<String, Object> dataMap = (Map<String, Object>) data;
Object idObj = dataMap.get("id");
log.info("大华返回data Map内容: {}", dataMap);
// primeport返回的是personId不是id
Object idObj = dataMap.get("personId");
if (idObj == null) {
idObj = dataMap.get("id");
}
if (idObj != null) {
try {
Integer dahuaId = Integer.valueOf(idObj.toString());
@ -486,10 +520,16 @@ public class UserAddExe {
} catch (Exception e) {
log.warn("转换大华返回id为Integer失败, idObj={}", idObj);
}
} else {
log.warn("大华返回数据中未找到personId或id字段, dataMap keys={}", dataMap.keySet());
}
} else if (data instanceof cn.hutool.json.JSONObject) {
cn.hutool.json.JSONObject dataJson = (cn.hutool.json.JSONObject) data;
Object idObj = dataJson.get("id");
log.info("大华返回data JSONObject内容: {}", dataJson);
Object idObj = dataJson.get("personId");
if (idObj == null) {
idObj = dataJson.get("id");
}
if (idObj != null) {
try {
Integer dahuaId = Integer.valueOf(idObj.toString());
@ -499,6 +539,8 @@ public class UserAddExe {
} catch (Exception e) {
log.warn("转换大华返回id为Integer失败, idObj={}", idObj);
}
} else {
log.warn("大华返回数据中未找到personId或id字段");
}
}
}

View File

@ -49,13 +49,13 @@ public class UserRemoveExe {
private final UserChangeRecordGateway userChangeRecordGateway;
private final UserJobHandoverRepository userJobHandoverRepository;
private final HumanUserUpdateExe humanUserUpdateExe;
@DubboReference(check = false)
@DubboReference
private UserFacade userFacade;
// @Autowired
private final ZcloudRedisUtil zcloudRedisUtil;
private final UserCorpRecordRepository userCorpRecordRepository;
private final DaHuaConfig daHuaConfig;
@DubboReference(version = "1.0.0", group = "primeport")
@DubboReference
private ZcloudDaHuaFacade zcloudDaHuaFacade;
@Transactional(rollbackFor = Exception.class)

View File

@ -78,7 +78,7 @@ public class UserUpdateExe {
@DubboReference
private ZcloudRiskFacade zcloudRiskFacade;
private final DaHuaConfig daHuaConfig;
@DubboReference(version = "1.0.0", group = "primeport")
@DubboReference
private ZcloudDaHuaFacade zcloudDaHuaFacade;

View File

@ -355,11 +355,23 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
roleDeptAddCmd.setDeptId(userDO.getDepartmentId());
List<RoleDeptAddCmd> roleDeptAddCmdList = Collections.singletonList(roleDeptAddCmd);
userAddCmd.setRoleDepts(roleDeptAddCmdList);
log.info("GBS新增用户开始,用户信息:{}", JSONUtil.toJsonStr(userAddCmd));
// 打印详细参数,方便排查底座报错原因
log.info("【普通用户-底座新增】开始");
log.info("【普通用户-底座新增】参数详情: account={}, name={}, password={}, tenantId(corpinfoId)={}, roleId={}, departmentId={}",
userAddCmd.getAccount(), userAddCmd.getName(),
userDO.getPassword() != null ? "已设置(长度:" + userDO.getPassword().length() + ")" : "null",
userDO.getCorpinfoId(), userDO.getRoleId(), userDO.getDepartmentId());
log.info("【普通用户-底座新增】完整JSON: {}", JSONUtil.toJsonStr(userAddCmd));
log.info("【普通用户-底座新增】userDO完整JSON: {}", JSONUtil.toJsonStr(userDO));
SingleResponse<Long> gbsResult = userFacade.add(userAddCmd);
log.info("GBS新增用户结束,用户id:{},结果:{}", gbsResult.getData(), JSONUtil.toJsonStr(gbsResult));
log.info("【普通用户-底座新增】结束,用户id:{},结果:{}", gbsResult.getData(), JSONUtil.toJsonStr(gbsResult));
if (!gbsResult.isSuccess()) {
throw new RuntimeException("GBS新增用户失败,用户id:" + gbsResult.getData());
String errMsg = String.format("【普通用户-底座新增失败】errCode=%s, errMessage=%s, 用户id=%s",
gbsResult.getErrCode(), gbsResult.getErrMessage(), gbsResult.getData());
log.error(errMsg);
throw new RuntimeException(errMsg);
}
userDO.setId(gbsResult.getData());
if (userDO.getSort() == null) {
@ -386,11 +398,14 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
roleDeptAddCmd.setDeptId(userDO.getDepartmentId());
List<RoleDeptAddCmd> roleDeptAddCmdList = Collections.singletonList(roleDeptAddCmd);
userAddCmd.setRoleDepts(roleDeptAddCmdList);
log.info("GBS新增用户开始,用户信息:{}", JSONUtil.toJsonStr(userAddCmd));
log.info("【演示用户-底座新增】开始,用户信息:{}", JSONUtil.toJsonStr(userAddCmd));
SingleResponse<Long> gbsResult = userFacade.add(userAddCmd);
log.info("GBS新增用户结束,用户id:{},结果:{}", gbsResult.getData(), JSONUtil.toJsonStr(gbsResult));
log.info("【演示用户-底座新增】结束,用户id:{},结果:{}", gbsResult.getData(), JSONUtil.toJsonStr(gbsResult));
if (!gbsResult.isSuccess()) {
throw new RuntimeException("GBS新增用户失败,用户id:" + gbsResult.getData());
String errMsg = String.format("【演示用户-底座新增失败】errCode=%s, errMessage=%s, 用户id=%s",
gbsResult.getErrCode(), gbsResult.getErrMessage(), gbsResult.getData());
log.error(errMsg);
throw new RuntimeException(errMsg);
}
userDO.setId(gbsResult.getData());
if (userDO.getSort() == null) {
@ -455,11 +470,14 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
userAddCmd.setRoleDepts(roleDeptAddCmdList);
userAddCmd.setId(userDO.getId());
userAddCmd.setPassword(userDO.getPassword());
log.info("GBS新增用户开始,用户信息:{}", JSONUtil.toJsonStr(userAddCmd));
log.info("【相关方用户-底座新增】开始,用户信息:{}", JSONUtil.toJsonStr(userAddCmd));
SingleResponse<Long> gbsResult = userFacade.add(userAddCmd);
log.info("GBS新增用户结束,用户id:{},结果:{}", gbsResult.getData(), JSONUtil.toJsonStr(gbsResult));
log.info("【相关方用户-底座新增】结束,用户id:{},结果:{}", gbsResult.getData(), JSONUtil.toJsonStr(gbsResult));
if (!gbsResult.isSuccess()) {
throw new RuntimeException("GBS新增用户失败,用户id:" + gbsResult.getData());
String errMsg = String.format("【相关方用户-底座新增失败】errCode=%s, errMessage=%s, 用户id=%s",
gbsResult.getErrCode(), gbsResult.getErrMessage(), gbsResult.getData());
log.error(errMsg);
throw new RuntimeException(errMsg);
}
}
@ -772,11 +790,14 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
List<RoleDeptAddCmd> roleDeptAddCmdList = Collections.singletonList(roleDeptAddCmd);
userAddCmd.setRoleDepts(roleDeptAddCmdList);
userAddCmd.setId(userE.getId());
log.info("GBS新增用户开始,用户信息:{}", JSONUtil.toJsonStr(userAddCmd));
log.info("【用户恢复入职-底座新增】开始,用户信息:{}", JSONUtil.toJsonStr(userAddCmd));
SingleResponse<Long> gbsResult = userFacade.add(userAddCmd);
log.info("GBS新增用户结束,用户id:{},结果:{}", gbsResult.getData(), JSONUtil.toJsonStr(gbsResult));
log.info("【用户恢复入职-底座新增】结束,用户id:{},结果:{}", gbsResult.getData(), JSONUtil.toJsonStr(gbsResult));
if (!gbsResult.isSuccess()) {
throw new RuntimeException("GBS新增用户失败,用户id:" + gbsResult.getData());
String errMsg = String.format("【用户恢复入职-底座新增失败】errCode=%s, errMessage=%s, 用户id=%s",
gbsResult.getErrCode(), gbsResult.getErrMessage(), gbsResult.getData());
log.error(errMsg);
throw new RuntimeException(errMsg);
}
}
}