feat(sis): 支持黑名单人员管理
- 新增人员标签类型字段,用于区分红名单、白名单和黑名单 - 修改授权逻辑,黑名单人员不进行授权记录和E8平台同步 - 优化定时任务,对不同名单类型的人员进行差异化处理 - 增加黑名单人员入内的告警功能
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package org.dromara.job.entity.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author lsm
|
||||
* @apiNote RosterTypeEnum
|
||||
* @since 2025/8/7
|
||||
*/
|
||||
@Getter
|
||||
public enum RosterTypeEnum {
|
||||
/**
|
||||
* 红名单
|
||||
*/
|
||||
RED_LIST(1),
|
||||
|
||||
/**
|
||||
* 白名单
|
||||
*/
|
||||
WHITE_LIST(2),
|
||||
|
||||
/**
|
||||
* 黑名单名单
|
||||
*/
|
||||
BLACK_LIST(3);
|
||||
|
||||
private final Integer code;
|
||||
|
||||
RosterTypeEnum(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
@@ -8,6 +8,7 @@ import com.aizuda.snailjob.client.job.core.dto.JobArgs;
|
||||
import com.aizuda.snailjob.client.model.ExecuteResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.job.entity.enums.RosterTypeEnum;
|
||||
import org.dromara.property.api.RemoteResidentPersonService;
|
||||
import org.dromara.property.api.domain.vo.RemoteResidentPersonVo;
|
||||
import org.dromara.resource.api.RemoteFileService;
|
||||
@@ -18,6 +19,7 @@ import org.springframework.stereotype.Component;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
@@ -53,20 +55,9 @@ public class SyncGrantAuthTask {
|
||||
try {
|
||||
if (CollUtil.isNotEmpty(unAuthPerson)) {
|
||||
for (RemoteResidentPersonVo person : unAuthPerson) {
|
||||
log.info("开始定时授权:{}----{}", person.getName(), person.getId());
|
||||
|
||||
// 判断是否存在授权
|
||||
Boolean auth = remoteSisAuthService.queryPersonAuth(person.getAuthGroupId(), person.getId());
|
||||
if (!auth) {
|
||||
log.info("无授权记录:{}----{}", person.getName(), person.getId());
|
||||
|
||||
// 补录授权记录、人像信息
|
||||
Boolean flag = syncAuthRecord(person);
|
||||
if (!flag) {
|
||||
log.info("补录授权记录、人像信息失败:{}----{}", person.getName(), person.getId());
|
||||
continue;
|
||||
}
|
||||
|
||||
// 下载人像
|
||||
byte[] imgByte;
|
||||
try {
|
||||
@@ -78,10 +69,30 @@ public class SyncGrantAuthTask {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 当前人员是黑名单
|
||||
if (Objects.equals(person.getRosterType(), RosterTypeEnum.BLACK_LIST.getCode())) {
|
||||
// 计算图片MD5
|
||||
String nowMd5 = calculateMD5(imgByte);
|
||||
// 通过MD5、入驻员工id查询相同图片
|
||||
Long remoteId = remoteSisAuthService.queryHuaweiBoxIdByImgMd5(nowMd5);
|
||||
// 人像信息已上传,跳过
|
||||
if (remoteId != null) continue;
|
||||
}
|
||||
|
||||
log.info("开始定时授权:{}----{}", person.getName(), person.getId());
|
||||
|
||||
// 补录授权记录、人像信息
|
||||
Boolean flag = syncAuthRecord(person);
|
||||
if (!flag) {
|
||||
log.info("录入授权记录、人像信息失败:{}----{}", person.getName(), person.getId());
|
||||
remoteSisAuthService.deletePersonAuth(List.of(person.getId()), new ArrayList<>());
|
||||
continue;
|
||||
}
|
||||
|
||||
// // 计算图片MD5
|
||||
// String nowMd5 = calculateMD5(imgByte);
|
||||
// // 通过MD5查询相同图片
|
||||
// Long remoteId = remoteSisAuthService.queryImgIdByImgMd5(nowMd5);
|
||||
// Long remoteId = remoteSisAuthService.queryHuaweiBoxIdByImgMd5(nowMd5);
|
||||
//
|
||||
// Long huaweiId;
|
||||
// if (remoteId == null) {
|
||||
@@ -102,6 +113,7 @@ public class SyncGrantAuthTask {
|
||||
// update = remoteSisAuthService.updateImgByPersonId(person.getId(), huaweiId, nowMd5);
|
||||
// } catch (Exception e) {
|
||||
// remoteSisAuthService.deletePersonAuth(List.of(person.getId()), new ArrayList<>());
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (!update) {
|
||||
@@ -110,18 +122,20 @@ public class SyncGrantAuthTask {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// 同步人像到E8平台
|
||||
Long e8Id = syncE8Plat(person, imgByte);
|
||||
if (e8Id == null) {
|
||||
log.info("同步人像到E8平台失败:{}-----{}", person.getName(), person.getId());
|
||||
remoteSisAuthService.deletePersonAuth(List.of(person.getId()), new ArrayList<>());
|
||||
continue;
|
||||
// 黑名单不授权到E8
|
||||
if (!Objects.equals(person.getRosterType(), RosterTypeEnum.BLACK_LIST.getCode())) {
|
||||
// 同步人像到E8平台
|
||||
Long e8Id = syncE8Plat(person, imgByte);
|
||||
if (e8Id == null) {
|
||||
log.info("同步人像到E8平台失败:{}-----{}", person.getName(), person.getId());
|
||||
remoteSisAuthService.deletePersonAuth(List.of(person.getId()), new ArrayList<>());
|
||||
continue;
|
||||
}
|
||||
// 更新入驻员工E8平台id
|
||||
remoteResidentPersonService.updateE8Id(person.getId(), e8Id);
|
||||
}
|
||||
|
||||
// 更新入驻员工E8平台id
|
||||
remoteResidentPersonService.updateE8Id(person.getId(), e8Id);
|
||||
} else {
|
||||
// 存在授权记录,为了避免重复授权,删除授权记录
|
||||
// 存在授权记录,为了避免重复授权,删除授权记录,等待下次定时任务
|
||||
remoteSisAuthService.deletePersonAuth(List.of(person.getId()), new ArrayList<>());
|
||||
}
|
||||
}
|
||||
@@ -144,14 +158,14 @@ public class SyncGrantAuthTask {
|
||||
* @param person bean
|
||||
*/
|
||||
private Boolean syncAuthRecord(RemoteResidentPersonVo person) {
|
||||
log.info("开始补录授权记录、人像信息:{}----{}", person.getName(), person.getId());
|
||||
log.info("开始录入授权记录、人像信息:{}----{}", person.getName(), person.getId());
|
||||
RemotePersonAuth personAuth = getRemotePersonAuth(person);
|
||||
|
||||
Boolean flag;
|
||||
try {
|
||||
flag = remoteSisAuthService.personAuth(personAuth);
|
||||
if (flag) {
|
||||
log.info("补录授权记录、人像信息完成:{}----{}", person.getName(), person.getId());
|
||||
log.info("录入授权记录、人像信息完成:{}----{}", person.getName(), person.getId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
@@ -168,11 +182,12 @@ public class SyncGrantAuthTask {
|
||||
personAuth.setOssId(person.getOssId());
|
||||
personAuth.setName(person.getName());
|
||||
personAuth.setPhone(person.getPhone());
|
||||
personAuth.setSex(person.getGender().intValue());
|
||||
personAuth.setIdCardNumber(person.getIdCard());
|
||||
personAuth.setSex(person.getGender().intValue());
|
||||
personAuth.setAuthGroupId(person.getAuthGroupId());
|
||||
personAuth.setAuthBegDate(person.getAuthBegDate());
|
||||
personAuth.setAuthEndDate(person.getAuthEndDate());
|
||||
personAuth.setRosterType(person.getRosterType());
|
||||
return personAuth;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user