Browse Source

优化非行政支持列表查询接口

dev
vincent 10 hours ago
parent
commit
91b1f0d2bd
  1. 9
      zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/controller/app/enforcement/AppEnforcementRegistrationController.java
  2. 99
      zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/service/impl/NonEnforcementRegistrationServiceImpl.java

9
zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/controller/app/enforcement/AppEnforcementRegistrationController.java

@ -403,7 +403,8 @@ public class AppEnforcementRegistrationController extends BaseController {
if (sysUserVo != null){
String lawCN = sysUserVo.getUserName() +" "+sysUserVo.getLawCertificateNum();
if(StringUtils.isEmpty(sysUserVo.getLawCertificateNum())){
lawCN=sysUserVo.getUserName() +" "+ CommonUtil.encryptPhone(sysUserVo.getPhonenumber());
// 修复: 双轨改造后 phonenumber 为 HSM 密文, 走备份字段解密后脱敏
lawCN=sysUserVo.getUserName() +" "+ CommonUtil.encryptPhone(sysUserVo.getPhonenumber(), sysUserVo.getCryptoRemarkTwo());
}
reg.setLawEnforcer(lawCN);
}
@ -435,7 +436,8 @@ public class AppEnforcementRegistrationController extends BaseController {
for (SysUserVo ub : sysUserVos) {
String temp = ub.getLawCertificateNum();
if(StringUtils.isEmpty(temp)){
temp= CommonUtil.encryptPhone(ub.getPhonenumber());
// 修复: 双轨改造后 phonenumber 为 HSM 密文, 走备份字段解密后脱敏
temp= CommonUtil.encryptPhone(ub.getPhonenumber(), ub.getCryptoRemarkTwo());
}
tmpUserShow += ub.getUserName() +" "+ temp + ",";
}
@ -807,7 +809,8 @@ public class AppEnforcementRegistrationController extends BaseController {
String phone = user.getPhonenumber();
if (StringUtils.isNotEmpty(phone)) {
return userName + " " + CommonUtil.encryptPhone(phone);
// 修复: 双轨改造后 phonenumber 为 HSM 密文, 走备份字段解密后脱敏
return userName + " " + CommonUtil.encryptPhone(phone, user.getCryptoRemarkTwo());
}
return userName;

99
zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/service/impl/NonEnforcementRegistrationServiceImpl.java

@ -254,7 +254,9 @@ public class NonEnforcementRegistrationServiceImpl implements INonEnforcementReg
}
/**
* 补充执法人员信息
* 补充执法人员信息(批量优化版)
* <p>先收集整页执法人员ID一次性批量查询用户,再在内存中填充,
* 消除逐行 selectUserById / selectUserByIds 的 N+1 查询。</p>
*
* @param list 记录列表
*/
@ -263,52 +265,83 @@ public class NonEnforcementRegistrationServiceImpl implements INonEnforcementReg
return;
}
// 执法人员 没有执法证件号展示加密手机号
// 1. 收集整页所有执法人员ID(主执法人员 + 其他执法人员),去重
java.util.Set<String> userIdStrSet = new java.util.LinkedHashSet<>();
for (NonEnforcementRegistrationVo li : list) {
if (StringUtils.isNotEmpty(li.getLawEnforcerId())) {
userIdStrSet.add(li.getLawEnforcerId().trim());
}
if (StringUtils.isNotEmpty(li.getLawEnforcerIdOther())) {
for (String id : li.getLawEnforcerIdOther().split(",")) {
if (StringUtils.isNotEmpty(id.trim())) {
userIdStrSet.add(id.trim());
}
}
}
}
if (userIdStrSet.isEmpty()) {
return;
}
// 2. 一次批量查询用户(含 crypto_remark_two 备份字段)
Map<Long, SysUserVo> userMap = new HashMap<>();
List<SysUserVo> userBeans = sysUserMapper.selectUserByIds(Convert.toStrArray(userIdStrSet));
if (userBeans != null) {
for (SysUserVo u : userBeans) {
if (u != null && u.getUserId() != null) {
userMap.put(u.getUserId(), u);
}
}
}
// 3. 在内存中填充执法人员信息(无数据库查询)
list.forEach(li -> {
// 处理主执法人员信息
if (StringUtils.isNotEmpty(li.getLawEnforcerId())) {
try {
SysUserVo sysUserVo = sysUserMapper.selectUserById(Long.valueOf(li.getLawEnforcerId()));
if (sysUserVo != null) {
String lawCN = sysUserVo.getLawCertificateNum();
if (StringUtils.isEmpty(lawCN)) {
// 修复: 双轨改造后 phonenumber 为 HSM 密文, 走备份字段解密后脱敏
lawCN = CommonUtil.encryptPhone(sysUserVo.getPhonenumber(), sysUserVo.getCryptoRemarkTwo());
}
li.setLawEnforcer(sysUserVo.getUserName() + " " + lawCN);
} else {
li.setLawEnforcer(li.getLawEnforcer());
SysUserVo sysUserVo = userMap.get(parseUserId(li.getLawEnforcerId()));
if (sysUserVo != null) {
String lawCN = sysUserVo.getLawCertificateNum();
if (StringUtils.isEmpty(lawCN)) {
// 双轨改造后 phonenumber 为 HSM 密文, 走备份字段解密后脱敏
lawCN = CommonUtil.encryptPhone(sysUserVo.getPhonenumber(), sysUserVo.getCryptoRemarkTwo());
}
} catch (NumberFormatException e) {
log.warn("无效的执法人员ID: {}", li.getLawEnforcerId());
li.setLawEnforcer(sysUserVo.getUserName() + " " + lawCN);
}
}
// 处理其他执法人员信息
List<String> lawTwoList = new ArrayList<>();
if (StringUtils.isNotEmpty(li.getLawEnforcerOther()) && StringUtils.isNotEmpty(li.getLawEnforcerIdOther())) {
try {
List<SysUserVo> userBeans = sysUserMapper.selectUserByIds(Convert.toStrArray(li.getLawEnforcerIdOther()));
if (userBeans != null && !userBeans.isEmpty()) {
userBeans.forEach(u -> {
if (u != null) {
String temp = u.getLawCertificateNum();
if (StringUtils.isEmpty(temp)) {
// 修复: 双轨改造后 phonenumber 为 HSM 密文, 走备份字段解密后脱敏
temp = CommonUtil.encryptPhone(u.getPhonenumber(), u.getCryptoRemarkTwo());
}
lawTwoList.add(u.getUserName() + " " + temp);
}
});
li.setLawEnforcerOtherList(lawTwoList);
if (StringUtils.isNotEmpty(li.getLawEnforcerIdOther())) {
List<String> lawTwoList = new ArrayList<>();
for (String id : li.getLawEnforcerIdOther().split(",")) {
SysUserVo u = userMap.get(parseUserId(id));
if (u != null) {
String temp = u.getLawCertificateNum();
if (StringUtils.isEmpty(temp)) {
// 双轨改造后 phonenumber 为 HSM 密文, 走备份字段解密后脱敏
temp = CommonUtil.encryptPhone(u.getPhonenumber(), u.getCryptoRemarkTwo());
}
lawTwoList.add(u.getUserName() + " " + temp);
}
} catch (NumberFormatException e) {
log.warn("无效的其他执法人员ID: {}", li.getLawEnforcerIdOther());
}
if (!lawTwoList.isEmpty()) {
li.setLawEnforcerOtherList(lawTwoList);
}
}
});
}
/**
* 安全解析用户ID(无效ID返回null并记日志)
*/
private Long parseUserId(String id) {
try {
return Long.parseLong(id.trim());
} catch (NumberFormatException e) {
log.warn("无效的执法人员ID: {}", id);
return null;
}
}
/**
* 查询非行政执法登记列表
*

Loading…
Cancel
Save