|
|
@@ -18,6 +18,9 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
|
|
|
+/**
|
|
|
+ * 员工花名册同步与查询服务实现。
|
|
|
+ */
|
|
|
@Service
|
|
|
public class EmployeeRosterServiceImpl implements EmployeeRosterService {
|
|
|
|
|
|
@@ -34,6 +37,16 @@ public class EmployeeRosterServiceImpl implements EmployeeRosterService {
|
|
|
private final EmployeeRosterRepository repository;
|
|
|
private final EmployeeRosterProperties properties;
|
|
|
|
|
|
+ /**
|
|
|
+ * 创建员工花名册服务实现。
|
|
|
+ *
|
|
|
+ * @param dingTalkClient 钉钉基础客户端
|
|
|
+ * @param contactsClient 钉钉通讯录客户端
|
|
|
+ * @param dingTalkConfiguration 钉钉应用配置
|
|
|
+ * @param rosterClient 钉钉花名册客户端
|
|
|
+ * @param repository 员工花名册本地仓储
|
|
|
+ * @param properties 员工花名册同步配置
|
|
|
+ */
|
|
|
public EmployeeRosterServiceImpl(DDClient dingTalkClient,
|
|
|
DDClient_Contacts contactsClient,
|
|
|
DDConf dingTalkConfiguration,
|
|
|
@@ -48,6 +61,13 @@ public class EmployeeRosterServiceImpl implements EmployeeRosterService {
|
|
|
this.properties = properties;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 从钉钉同步指定部门范围内的员工花名册,并写入本地表。
|
|
|
+ *
|
|
|
+ * @param departmentId 钉钉部门 ID
|
|
|
+ * @param type 查询范围,0 表示包含子部门,1 表示仅当前部门
|
|
|
+ * @return 本次同步统计结果
|
|
|
+ */
|
|
|
@Override
|
|
|
public EmployeeRosterSyncResult sync(long departmentId, int type) {
|
|
|
if (departmentId < 1) {
|
|
|
@@ -84,17 +104,33 @@ public class EmployeeRosterServiceImpl implements EmployeeRosterService {
|
|
|
return new EmployeeRosterSyncResult(departmentId, type == INCLUDE_CHILD_DEPARTMENTS, records.size(), fieldCodes.size(), syncedCount);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 使用配置中的默认部门和范围同步员工花名册。
|
|
|
+ *
|
|
|
+ * @return 本次同步统计结果
|
|
|
+ */
|
|
|
public EmployeeRosterSyncResult syncDefaultDepartment() {
|
|
|
long departmentId = properties.getDepartmentId();
|
|
|
int type = properties.isIncludeSubDepartments() ? INCLUDE_CHILD_DEPARTMENTS : CURRENT_DEPARTMENT_ONLY;
|
|
|
return sync(departmentId, type);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 从根部门开始完整同步员工花名册。
|
|
|
+ *
|
|
|
+ * @return 本次同步统计结果
|
|
|
+ */
|
|
|
@Override
|
|
|
public EmployeeRosterSyncResult syncFull() {
|
|
|
return sync(ROOT_DEPARTMENT_ID, INCLUDE_CHILD_DEPARTMENTS);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据钉钉用户 ID 查询本地员工花名册记录。
|
|
|
+ *
|
|
|
+ * @param userId 钉钉用户 ID
|
|
|
+ * @return 员工花名册信息,不存在时返回 null
|
|
|
+ */
|
|
|
@Override
|
|
|
public EmployeeRosterInfo findByUserId(String userId) {
|
|
|
if (userId == null || userId.trim().isEmpty()) {
|
|
|
@@ -103,6 +139,12 @@ public class EmployeeRosterServiceImpl implements EmployeeRosterService {
|
|
|
return repository.findByDingtalkId(userId.trim());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据员工工号查询本地员工花名册记录。
|
|
|
+ *
|
|
|
+ * @param employeeNo 员工工号
|
|
|
+ * @return 员工花名册信息,不存在时返回 null
|
|
|
+ */
|
|
|
@Override
|
|
|
public EmployeeRosterInfo findByEmployeeNo(String employeeNo) {
|
|
|
if (employeeNo == null || employeeNo.trim().isEmpty()) {
|