|
@@ -3,13 +3,17 @@ package org.jeecg.dataSync.task;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.alibaba.fastjson2.TypeReference;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.jeecg.common.util.PasswordUtil;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.config.sign.util.HttpUtils;
|
|
|
import org.jeecg.dataSync.config.HrConfigurer;
|
|
|
+import org.jeecg.modules.system.entity.SysDepart;
|
|
|
import org.jeecg.modules.system.entity.SysUser;
|
|
|
import org.jeecg.modules.system.entity.SysUserDepart;
|
|
|
import org.jeecg.modules.system.entity.SysUserRole;
|
|
|
+import org.jeecg.modules.system.service.ISysDepartService;
|
|
|
import org.jeecg.modules.system.service.ISysUserDepartService;
|
|
|
import org.jeecg.modules.system.service.ISysUserRoleService;
|
|
|
import org.jeecg.modules.system.service.ISysUserService;
|
|
@@ -41,6 +45,9 @@ public class UserDataSync implements Job {
|
|
|
@Autowired
|
|
|
private ISysUserDepartService sysUserDepartService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDepartService departService;
|
|
|
+
|
|
|
private static final Logger logger = LoggerFactory.getLogger(UserDataSync.class);
|
|
|
|
|
|
@Override
|
|
@@ -90,10 +97,19 @@ public class UserDataSync implements Job {
|
|
|
|
|
|
//保存用户与hr系统部门的关联关系
|
|
|
String departOldId = item.get("department_id") == null ? "0" : item.get("department_id").toString();
|
|
|
- SysUserDepart sysUserDepart = new SysUserDepart();
|
|
|
- sysUserDepart.setUserId(sysUser.getId());
|
|
|
- sysUserDepart.setDepId(departOldId);
|
|
|
- sysUserDepartService.save(sysUserDepart);
|
|
|
+ LambdaQueryWrapper<SysDepart> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(SysDepart::getOldId,departOldId);
|
|
|
+ List<SysDepart> list1 = departService.list(wrapper);
|
|
|
+ SysDepart depart = null;
|
|
|
+ if (list1 != null && !list1.isEmpty()) {
|
|
|
+ depart = list1.get(0);
|
|
|
+ }
|
|
|
+ if (depart != null && ObjectUtils.isNotEmpty(depart.getId())) {
|
|
|
+ SysUserDepart sysUserDepart = new SysUserDepart();
|
|
|
+ sysUserDepart.setUserId(sysUser.getId());
|
|
|
+ sysUserDepart.setDepId(depart.getId());
|
|
|
+ sysUserDepartService.save(sysUserDepart);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|