Merge branch 'dev' into test
This commit is contained in:
@@ -268,10 +268,10 @@ public class DeptDataPermissionRule implements DataPermissionRule {
|
||||
}
|
||||
|
||||
// 拼接条件
|
||||
if (StrUtil.isBlank(workCode)) {
|
||||
return new EqualsTo(MyBatisUtils.buildColumn(tableName, tableAlias, columnName), new LongValue(userId));
|
||||
if (StrUtil.isNotBlank(workCode) && "system_users".equals(tableName)) {
|
||||
return new EqualsTo(MyBatisUtils.buildColumn(tableName, tableAlias, "workcode"), new StringValue(workCode));
|
||||
} else {
|
||||
return new EqualsTo(MyBatisUtils.buildColumn(tableName, tableAlias, columnName), new StringValue(workCode));
|
||||
return new EqualsTo(MyBatisUtils.buildColumn(tableName, tableAlias, columnName), new LongValue(userId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
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.SyncIWorkOrgChangeService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 用于定时同步 iWork 当日变更的组织数据
|
||||
* 同步时间:每日23:00
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SyncIWorkOrgChangeJob {
|
||||
|
||||
@Resource
|
||||
private SyncIWorkOrgChangeService syncIWorkOrgChangeService;
|
||||
|
||||
/**
|
||||
* 执行定时任务
|
||||
* 配置执行频率:每日23:00时执行一次
|
||||
* cron表达式:0 0 23 * * ?
|
||||
*/
|
||||
@XxlJob("syncIWorkOrgChangeJob")
|
||||
@TenantJob
|
||||
public void execute() {
|
||||
log.info("[syncIWorkOrgChangeJob][开始执行同步 iWork 当日变更组织任务]");
|
||||
try {
|
||||
int processedCount = syncIWorkOrgChangeService.process();
|
||||
if (processedCount > 0) {
|
||||
log.info("[syncIWorkOrgChangeJob][同步任务执行完成,处理了 {} 条记录]", processedCount);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("[syncIWorkOrgChangeJob][同步任务执行失败]", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,13 @@
|
||||
package com.zt.plat.module.system.service.sync;
|
||||
|
||||
/**
|
||||
* 定时同步 iWork 组织变更服务
|
||||
*/
|
||||
public interface SyncIWorkOrgChangeService {
|
||||
|
||||
/**
|
||||
* 执行同步
|
||||
* @return 拉取记录数量
|
||||
*/
|
||||
int process();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
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 SyncIWorkOrgChangeServiceImpl implements SyncIWorkOrgChangeService {
|
||||
|
||||
@Resource
|
||||
private IWorkSyncService iWorkSyncService;
|
||||
|
||||
@Override
|
||||
public int process() {
|
||||
IWorkFullSyncReqVO reqVO = new IWorkFullSyncReqVO();
|
||||
reqVO.setPageSize(10);
|
||||
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 subcompanyResp = iWorkSyncService.fullSyncSubcompanies(reqVO);
|
||||
IWorkFullSyncRespVO departmentResp = iWorkSyncService.fullSyncDepartments(reqVO);
|
||||
return countPulled(subcompanyResp) + countPulled(departmentResp);
|
||||
}
|
||||
|
||||
private int countPulled(IWorkFullSyncRespVO respVO) {
|
||||
if (respVO == null || respVO.getBatches() == null) {
|
||||
return 0;
|
||||
}
|
||||
return respVO.getBatches().stream()
|
||||
.mapToInt(batch -> batch.getPulled() == null ? 0 : batch.getPulled())
|
||||
.sum();
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,13 @@ public interface UserDeptService {
|
||||
*/
|
||||
void deleteUserDeptByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID与部门ID集合删除用户与部门关系
|
||||
* @param userId 用户ID
|
||||
* @param deptIds 部门ID集合
|
||||
*/
|
||||
void deleteUserDeptByUserIdAndDeptIds(Long userId, Collection<Long> deptIds);
|
||||
|
||||
/**
|
||||
* 批量创建用户与部门关系
|
||||
* @param createReqVOList 创建信息列表
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.zt.plat.module.system.service.userdept;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.security.core.LoginUser;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.system.dal.dataobject.userdept.UserDeptDO;
|
||||
import com.zt.plat.module.system.dal.mysql.userdept.UserDeptMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -128,10 +129,20 @@ public class UserDeptServiceImpl implements UserDeptService {
|
||||
@Override
|
||||
public void deleteUserDeptByUserId(Long userId) {
|
||||
if (userId == null) return;
|
||||
userDeptMapper.delete(new com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX<UserDeptDO>()
|
||||
userDeptMapper.delete(new LambdaQueryWrapperX<UserDeptDO>()
|
||||
.eq(UserDeptDO::getUserId, userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUserDeptByUserIdAndDeptIds(Long userId, Collection<Long> deptIds) {
|
||||
if (userId == null || CollUtil.isEmpty(deptIds)) {
|
||||
return;
|
||||
}
|
||||
userDeptMapper.delete(new LambdaQueryWrapperX<UserDeptDO>()
|
||||
.eq(UserDeptDO::getUserId, userId)
|
||||
.in(UserDeptDO::getDeptId, deptIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchCreateUserDept(List<UserDeptDO> createReqVOList) {
|
||||
|
||||
Reference in New Issue
Block a user