| | |
| | | |
| | | @Value("${spring.profiles.active}") |
| | | private String env; |
| | | @Scheduled(cron = "0 0 1 * * ?") // 每天零点执行 |
| | | |
| | | @Scheduled(cron = "0 00 00 * * ?") // 每天零点执行 |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void run() { |
| | | if ("online".equals(env)) { |
| | |
| | | /** |
| | | // * 根据组织code 查询 通讯录人员信息 |
| | | // */ |
| | | //查询用户组织关联表 |
| | | List<UmsDepartManage> empOrgList = departManageService.list(); |
| | | //查询所有用户 |
| | | Set<DingUserInfo> dingList = dingCommon.getPersonInfoByOrgCode(); |
| | | Set<DingUserInfo> dingUsers = new HashSet<>(dingList); |
| | | log.info("dinglistStart----->{}", dingList); |
| | | |
| | | log.info("查询所有用户------->{}", dingUsers); |
| | | List<UmsAdmin> userList = umsAdminService.list(); |
| | | //查询用户组织关联表 |
| | | List<UmsDepartManage> empOrgList = departManageService.list(); |
| | | Iterator<DingUserInfo> iterator = dingUsers.iterator(); |
| | | while (iterator.hasNext()) { |
| | | DingUserInfo dingUserInfo = iterator.next(); |
| | |
| | | } |
| | | |
| | | |
| | | log.info("dinglistEnd----->{}", dingUsers); |
| | | ArrayList<UmsAdminRoleRelation> relations = new ArrayList<>(); |
| | | // log.info(TAG + " elapsed time:" + timer.interval()); |
| | | for (DingUserInfo dingUserInfo : dingUsers) { |
| | |
| | | } |
| | | //code |
| | | //accountId |
| | | log.info("员工账户id{}", dingUserInfo.getAccountId()); |
| | | user.setAccountId(dingUserInfo.getAccountId()); |
| | | //头像 |
| | | user.setIcon(dingUserInfo.getGovEmpAvatar()); |
| | |
| | | //状态为停用(不可用状态)点击登录后才能使用 |
| | | user.setStatus(1); |
| | | umsAdminService.save(user); |
| | | // //员工信息,关联组织 |
| | | // UmsDepartManage departManage = new UmsDepartManage(); |
| | | // departManage.setDepartId(dingUserInfo.getOrgId()); |
| | | // departManage.setIsLeader(0); |
| | | // departManage.setUserId(dingUserInfo.getUserId()); |
| | | // departManageService.saveOrUpdate(departManage); |
| | | // //角色信息 |
| | | // List<String> roleCode = dingUserInfo.getRoleCodeList(); |
| | | // if (CollectionUtils.isNotEmpty(roleCode)) { |
| | | // List<UmsRole> roleList = roleService.getRoleListByCodes(roleCode); |
| | | // roleList.forEach(item -> { |
| | | // UmsAdminRoleRelation relation = new UmsAdminRoleRelation(); |
| | | // relation.setAdminId(dingUserInfo.getUserId()); |
| | | // relation.setRoleId(item.getId()); |
| | | // relations.add(relation); |
| | | // }); |
| | | // } |
| | | // } |
| | | // if (CollUtil.isNotEmpty(relations)) { |
| | | // umsAdminRoleRelationService.saveBatch(relations, IService.DEFAULT_BATCH_SIZE); |
| | | //员工信息,关联组织 |
| | | UmsDepartManage departManage = new UmsDepartManage(); |
| | | departManage.setDepartId(dingUserInfo.getOrgId()); |
| | | departManage.setIsLeader(0); |
| | | departManage.setUserId(dingUserInfo.getUserId()); |
| | | departManageService.saveOrUpdate(departManage); |
| | | //角色信息 |
| | | List<String> roleCode = dingUserInfo.getRoleCodeList(); |
| | | if (CollectionUtils.isNotEmpty(roleCode)) { |
| | | List<UmsRole> roleList = roleService.getRoleListByCodes(roleCode); |
| | | roleList.forEach(item -> { |
| | | UmsAdminRoleRelation relation = new UmsAdminRoleRelation(); |
| | | relation.setAdminId(dingUserInfo.getUserId()); |
| | | relation.setRoleId(item.getId()); |
| | | relations.add(relation); |
| | | }); |
| | | } |
| | | } |
| | | if (CollUtil.isNotEmpty(relations)) { |
| | | umsAdminRoleRelationService.saveBatch(relations, IService.DEFAULT_BATCH_SIZE); |
| | | } |
| | | log.info("同步任务结束"); |
| | | // log.info(TAG + "update user size " + dingList.size()); |
| | | // getEmployeeAvatar(); |
| | | log.info(TAG + "update user size " + dingList.size()); |
| | | getEmployeeAvatar(); |
| | | } |
| | | } |
| | | |