任务717、718,添加iwork同步参数以及当日变更用户同步任务

This commit is contained in:
yangchaojin
2026-01-21 17:26:41 +08:00
parent b93cc1ec51
commit c1ca1d5372
4 changed files with 148 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
package com.zt.plat.module.system.controller.admin.integration.iwork.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.zt.plat.module.system.enums.integration.IWorkSyncEntityTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
@@ -42,6 +43,66 @@ public class IWorkFullSyncReqVO {
@Schema(description = "是否允许更新已存在的本地实体", example = "false")
private Boolean allowUpdate = Boolean.FALSE;
@JsonProperty("departmentcode")
@Schema(description = "部门编号")
private String departmentCode;
@JsonProperty("departmentname")
@Schema(description = "部门名称")
private String departmentName;
@JsonProperty("subcompanycode")
@Schema(description = "分部编号")
private String subcompanyCode;
@JsonProperty("subcompanyname")
@Schema(description = "分部名称")
private String subcompanyName;
@JsonProperty("subcompanyid1")
@Schema(description = "分部 ID")
private String subcompanyId1;
@JsonProperty("jobtitlename")
@Schema(description = "岗位名称")
private String jobTitleName;
@JsonProperty("workcode")
@Schema(description = "人员编号")
private String workCode;
@JsonProperty("loginid")
@Schema(description = "登录名")
private String loginId;
@JsonProperty("created")
@Schema(description = "创建时间戳(>=")
private String created;
@JsonProperty("modified")
@Schema(description = "修改时间戳(>=")
private String modified;
@JsonProperty("canceled")
@Schema(description = "封存标志默认查询非封存数据。1:封存")
private String canceled;
@JsonProperty("custom_data")
@Schema(description = "自定义字段列表(逗号分隔)")
private String customData;
@JsonProperty("base_custom_data")
@Schema(description = "基本信息自定义字段列表(逗号分隔)")
private String baseCustomData;
@JsonProperty("person_custom_data")
@Schema(description = "个人信息自定义字段列表(逗号分隔)")
private String personCustomData;
@JsonProperty("work_custom_data")
@Schema(description = "工作信息自定义字段列表(逗号分隔)")
private String workCustomData;
public Set<IWorkSyncEntityTypeEnum> resolveScopes() {
EnumSet<IWorkSyncEntityTypeEnum> defaults = EnumSet.allOf(IWorkSyncEntityTypeEnum.class);
if (scopes == null || scopes.isEmpty()) {

View File

@@ -0,0 +1,39 @@
package com.zt.plat.module.system.job.sync;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.zt.plat.framework.tenant.core.job.TenantJob;
import com.zt.plat.module.system.service.sync.SyncIWorkUserChangeService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 用于定时同步iWork当日修改的用户数据
* 同步时间每日23:00
*/
@Component
@Slf4j
public class SyncIWorkUserChangeJob {
@Resource
private SyncIWorkUserChangeService syncIWorkUserChangeService;
/**
* 执行批量重跑任务
* 配置执行频率每日23:00时执行一次
* cron表达式0 0 23 * * ?
*/
@XxlJob("syncIWorkUserChangeJob")
@TenantJob
public void execute() {
log.info("[syncLogBatchRerunJob][开始执行同步iWork当日变更用户任务]");
try{
int processedCount = syncIWorkUserChangeService.process();
if (processedCount > 0) {
log.info("[syncLogBatchRerunJob][同步任务执行完成,处理了 {} 条记录]", processedCount);
}
} catch (Exception e) {
log.error("[syncLogBatchRerunJob][同步iWork当日变更用户任务执行异常]", e);
}
}
}

View File

@@ -0,0 +1,14 @@
package com.zt.plat.module.system.service.sync;
/**
* 同步iWork当日修改的用户数据
*/
public interface SyncIWorkUserChangeService {
/**
* 同步入口
* @return
*/
int process();
}

View File

@@ -0,0 +1,34 @@
package com.zt.plat.module.system.service.sync;
import com.zt.plat.module.system.controller.admin.integration.iwork.vo.IWorkFullSyncReqVO;
import com.zt.plat.module.system.controller.admin.integration.iwork.vo.IWorkFullSyncRespVO;
import com.zt.plat.module.system.service.integration.iwork.IWorkSyncService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
@Service
public class SyncIWorkUserChangeServiceImpl implements SyncIWorkUserChangeService {
@Resource
private IWorkSyncService iWorkSyncService;
@Override
public int process() {
IWorkFullSyncReqVO reqVO = new IWorkFullSyncReqVO();
reqVO.setPageSize(10);
// 设置修改日期的查询条件为当日0时起
ZoneId zone = ZoneId.of("Asia/Shanghai");
String startOfToday = LocalDate.now(zone)
.atStartOfDay(zone)
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
reqVO.setModified(startOfToday);
IWorkFullSyncRespVO respVO = iWorkSyncService.fullSyncUsers(reqVO);
if(respVO!=null && respVO.getProcessedPages()!=null && respVO.getPageSize()!=null)
return respVO.getProcessedPages() * respVO.getPageSize();
return 0;
}
}