| | |
| | | package com.qianwen.smartman.modules.sync.service.impl; |
| | | |
| | | import cn.hutool.core.lang.Snowflake; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.jdbc.datasource.DataSourceTransactionManager; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.TransactionStatus; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.support.DefaultTransactionDefinition; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.aliyun.dingtalkcontact_1_0.models.GetUserHeaders; |
| | |
| | | import com.aliyun.dingtalkoauth2_1_0.Client; |
| | | import com.aliyun.teaopenapi.models.Config; |
| | | import com.aliyun.teautil.models.RuntimeOptions; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.dingtalk.api.DefaultDingTalkClient; |
| | | import com.dingtalk.api.request.OapiAuthScopesRequest; |
| | | import com.dingtalk.api.request.OapiRoleListRequest; |
| | | import com.dingtalk.api.request.OapiRoleSimplelistRequest; |
| | | import com.dingtalk.api.request.OapiSnsGetuserinfoBycodeRequest; |
| | | import com.dingtalk.api.request.OapiUserGetbyunionidRequest; |
| | | import com.dingtalk.api.request.OapiV2DepartmentGetRequest; |
| | | import com.dingtalk.api.request.OapiV2DepartmentListsubRequest; |
| | | import com.dingtalk.api.request.OapiV2UserGetRequest; |
| | | import com.dingtalk.api.request.OapiV2UserListRequest; |
| | | import com.dingtalk.api.response.OapiAuthScopesResponse; |
| | | import com.dingtalk.api.response.OapiRoleListResponse; |
| | | import com.dingtalk.api.response.OapiRoleSimplelistResponse; |
| | | import com.dingtalk.api.response.OapiSnsGetuserinfoBycodeResponse; |
| | | import com.dingtalk.api.response.OapiUserGetbyunionidResponse; |
| | | import com.dingtalk.api.response.OapiV2DepartmentGetResponse; |
| | | import com.dingtalk.api.response.OapiV2DepartmentListsubResponse; |
| | | import com.dingtalk.api.response.OapiV2UserGetResponse; |
| | | import java.lang.invoke.SerializedLambda; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Date; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.qianwen.smartman.common.cache.RegionCache; |
| | | import com.dingtalk.api.response.OapiV2UserListResponse; |
| | | import com.qianwen.core.log.exception.ServiceException; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.core.tool.utils.StringUtil; |
| | | import com.qianwen.smartman.common.constant.CommonConstant; |
| | | import com.qianwen.smartman.common.constant.CommonGroupConstant; |
| | | import com.qianwen.smartman.common.enums.CommonGroupTypeEnum; |
| | | import com.qianwen.smartman.common.utils.MessageUtils; |
| | | import com.qianwen.core.log.exception.ServiceException; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.core.tool.utils.StringUtil; |
| | | import com.qianwen.smartman.modules.cps.entity.CommonGroup; |
| | | import com.qianwen.smartman.modules.cps.entity.CommonGroupOfItem; |
| | | import com.qianwen.smartman.modules.cps.entity.Employee; |
| | |
| | | import com.qianwen.smartman.modules.system.service.IParamService; |
| | | import com.qianwen.smartman.modules.system.service.IPostService; |
| | | import com.qianwen.smartman.modules.system.service.IUserOauthService; |
| | | import org.springframework.jdbc.datasource.DataSourceTransactionManager; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.TransactionStatus; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.support.DefaultTransactionDefinition; |
| | | import com.taobao.api.TaobaoRequest; |
| | | |
| | | import cn.hutool.core.lang.Snowflake; |
| | | import cn.hutool.core.util.IdUtil; |
| | | |
| | | @Service |
| | | /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/sync/service/impl/DingSyncServiceImpl.class */ |
| | |
| | | private final IParamService paramService; |
| | | private final IEmployeePostService employeePostService; |
| | | |
| | | private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) { |
| | | String implMethodName = lambda.getImplMethodName(); |
| | | boolean z = true; |
| | | switch (implMethodName.hashCode()) { |
| | | case -75080655: |
| | | if (implMethodName.equals("getUuid")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 98245393: |
| | | if (implMethodName.equals("getId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 242925765: |
| | | if (implMethodName.equals("getAppType")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 799509265: |
| | | if (implMethodName.equals("getSource")) { |
| | | z = false; |
| | | break; |
| | | } |
| | | break; |
| | | case 859984188: |
| | | if (implMethodName.equals("getUserId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 1722789684: |
| | | if (implMethodName.equals("getLastSyncTime")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | } |
| | | switch (z) { |
| | | case false: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/UserOauth") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getSource(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/UserOauth") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getSource(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/UserOauth") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getUuid(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getId(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/sync/entity/OuterAppConfig") && lambda.getImplMethodSignature().equals("()Ljava/util/Date;")) { |
| | | return (v0) -> { |
| | | return v0.getLastSyncTime(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/UserOauth") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getUserId(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/UserOauth") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getUserId(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/UserOauth") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getUserId(); |
| | | }; |
| | | } |
| | | break; |
| | | case RegionCache.VILLAGE_LEVEL /* 5 */: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/sync/entity/OuterAppConfig") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) { |
| | | return (v0) -> { |
| | | return v0.getAppType(); |
| | | }; |
| | | } |
| | | break; |
| | | } |
| | | throw new IllegalArgumentException("Invalid lambda deserialization"); |
| | | } |
| | | |
| | | public DingSyncServiceImpl(final IUserOauthService userOauthService, final IEmployeeService employeeService, final IPostService postService, final ICommonGroupService groupService, final CommonGroupMapper commonGroupMapper, final IDingEventService dingEventService, final ICommonGroupOfItemService commonGroupOfItemService, final Map<String, Set<String>> userPostRelationMap, final DataSourceTransactionManager dataSourceTransactionManager, final PostMapper postMapper, final IOuterAppConfigService outerAppConfigService, final IParamService paramService, final IEmployeePostService employeePostService) { |
| | | this.userOauthService = userOauthService; |
| | |
| | | |
| | | @Override // org.springblade.modules.sync.service.IDingSyncService |
| | | public SyncResultVO syncImmediately() { |
| | | List<Post> posts; |
| | | List<DingOriDept> oriGroups; |
| | | List<DingOriUser> oriUsers; |
| | | List<Long> permissionGroups; |
| | | OuterAppConfig dingAppConfig = this.outerAppConfigService.getAppConfig(OuterAppConfigConstant.DING); |
| | | |
| | | OuterAppConfig dingAppConfig = this.outerAppConfigService.getAppConfig(OuterAppConfigConstant.DING); |
| | | String appKey = dingAppConfig.getDingAppKey(); |
| | | String appSecret = dingAppConfig.getDingAppSecret(); |
| | | DefaultTransactionDefinition transDefinition = new DefaultTransactionDefinition(); |
| | | |
| | | List<Post> posts = new ArrayList<>(); |
| | | List<DingOriDept> oriGroups = new ArrayList<>(); |
| | | List<DingOriUser> oriUsers = new ArrayList<>(); |
| | | |
| | | |
| | | |
| | | TransactionStatus transStatus = this.dataSourceTransactionManager.getTransaction(transDefinition); |
| | | SyncResultVO syncResultVO = new SyncResultVO(); |
| | | try { |
| | | try { |
| | | posts = new ArrayList<>(); |
| | | oriGroups = new ArrayList<>(); |
| | | oriUsers = new ArrayList<>(); |
| | | getRoles(appKey, appSecret, posts, syncResultVO); |
| | | permissionGroups = getPermissionGroup(appKey, appSecret, syncResultVO); |
| | | if (Func.isEmpty(permissionGroups)) { |
| | | syncResultVO.setGroupResult(false); |
| | | syncResultVO.setUserReason("未获取到权限范围内的组织机构!"); |
| | | } |
| | | for (Long permissionGroup : permissionGroups) { |
| | | SyncEmployee(permissionGroup, appKey, appSecret, oriUsers, syncResultVO); |
| | | recursionGetGroup(permissionGroup, appKey, appSecret, oriGroups, oriUsers, syncResultVO, permissionGroups); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("同步钉钉通讯录异常,异常信息为:", e); |
| | | this.dataSourceTransactionManager.rollback(transStatus); |
| | | this.userPostRelationMap.clear(); |
| | | getRoles(appKey, appSecret, posts, syncResultVO); |
| | | |
| | | List<Long> permissionGroups = getPermissionGroup(appKey, appSecret, syncResultVO); |
| | | if (Func.isEmpty(permissionGroups)) { |
| | | syncResultVO.setGroupResult(false); |
| | | syncResultVO.setUserReason("未获取到权限范围内的组织机构!"); |
| | | } |
| | | for (Long permissionGroup : permissionGroups) { |
| | | SyncEmployee(permissionGroup, appKey, appSecret, oriUsers, syncResultVO); |
| | | recursionGetGroup(permissionGroup, appKey, appSecret, oriGroups, oriUsers, syncResultVO, permissionGroups); |
| | | } |
| | | |
| | | if (!syncResultVO.getGroupResult().booleanValue() || !syncResultVO.getPostResult().booleanValue() || !syncResultVO.getUserResult().booleanValue()) { |
| | | this.userPostRelationMap.clear(); |
| | | return syncResultVO; |
| | |
| | | this.commonGroupMapper.removeOrgContact(); |
| | | this.employeePostService.remove(Wrappers.lambdaQuery()); |
| | | handleAuthAndEmployee(oriUsers, employees, userOauths, commonGroupOfItems, employeePosts, updateEmployees); |
| | | this.employeeService.remove(Wrappers.<Employee>lambdaQuery().notIn(Func.isNotEmpty(updateEmployees), Employee::getId, updateEmployees.stream().map(Employee::getId).collect(Collectors.toList()))); |
| | | /* |
| | | this.employeeService.remove(Wrappers.lambdaQuery().notIn(Func.isNotEmpty(updateEmployees), (v0) -> { |
| | | return v0.getId(); |
| | | }, (Collection) updateEmployees.stream().map((v0) -> { |
| | | return v0.getId(); |
| | | }).collect(Collectors.toList()))); |
| | | }).collect(Collectors.toList())));*/ |
| | | this.employeeService.saveBatch(employees); |
| | | this.employeeService.updateBatchById(updateEmployees); |
| | | this.userOauthService.saveOrUpdateBatch(userOauths); |
| | |
| | | syncResultVO.setUserReason("同步钉钉员工数据库部分报错:" + e4.toString()); |
| | | } |
| | | if (syncResultVO.getGroupResult().booleanValue() && syncResultVO.getPostResult().booleanValue() && syncResultVO.getUserResult().booleanValue()) { |
| | | this.outerAppConfigService.update(Wrappers.<OuterAppConfig>lambdaUpdate().eq(OuterAppConfig::getAppType, OuterAppConfigConstant.DING) |
| | | .set(OuterAppConfig::getLastSyncTime, new Date())); |
| | | /* |
| | | this.outerAppConfigService.update((Wrapper) ((LambdaUpdateWrapper) Wrappers.lambdaUpdate().eq((v0) -> { |
| | | return v0.getAppType(); |
| | | }, OuterAppConfigConstant.DING)).set((v0) -> { |
| | | return v0.getLastSyncTime(); |
| | | }, new Date())); |
| | | }, new Date()));*/ |
| | | } |
| | | if (flag.booleanValue()) { |
| | | this.dataSourceTransactionManager.commit(transStatus); |
| | |
| | | } |
| | | this.userPostRelationMap.clear(); |
| | | return syncResultVO; |
| | | } catch (Throwable th) { |
| | | this.userPostRelationMap.clear(); |
| | | throw th; |
| | | } catch (Exception th) { |
| | | log.error("同步钉钉通讯录异常,异常信息为:", th); |
| | | this.dataSourceTransactionManager.rollback(transStatus); |
| | | |
| | | //throw th; |
| | | }finally { |
| | | this.userPostRelationMap.clear(); |
| | | } |
| | | |
| | | return syncResultVO; |
| | | } |
| | | |
| | | private List<Long> getPermissionGroup(String appKey, String appSecret, SyncResultVO syncResultVO) { |
| | |
| | | userObject = getDetailByUserId(userId, appKey, appSecret); |
| | | } |
| | | if (Func.isNotEmpty(userId) && Func.isNotEmpty(userObject)) { |
| | | UserOauth userOauth = this.userOauthService.getOne(Wrappers.<UserOauth>lambdaQuery().eq(UserOauth::getUuid, userId), false); |
| | | /* |
| | | UserOauth userOauth = (UserOauth) this.userOauthService.getOne((Wrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getUuid(); |
| | | }, userId), false); |
| | | }, userId), false);*/ |
| | | if (Func.isEmpty(userOauth)) { |
| | | throw new ServiceException(MessageUtils.message("sys.outer.user.not.exist", new Object[0])); |
| | | } |
| | |
| | | |
| | | @Override // org.springblade.modules.sync.service.IDingSyncService |
| | | public Boolean unbind(Long id, String source) { |
| | | UserOauth userOauth = this.userOauthService.getOne(Wrappers.<UserOauth>lambdaQuery().eq(UserOauth::getUserId, id).eq(UserOauth::getSource, source)); |
| | | /* |
| | | UserOauth userOauth = (UserOauth) this.userOauthService.getOne((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getUserId(); |
| | | }, id)).eq((v0) -> { |
| | | return v0.getSource(); |
| | | }, source)); |
| | | }, source));*/ |
| | | if (Func.isEmpty(userOauth)) { |
| | | throw new ServiceException(MessageUtils.message("cps.employee.not.band", new Object[0])); |
| | | } |
| | | |
| | | return Boolean.valueOf(this.userOauthService.update(Wrappers.<UserOauth>lambdaUpdate() |
| | | .set(UserOauth::getUserId, null).eq(UserOauth::getUserId, id).eq(UserOauth::getSource, source))); |
| | | /* |
| | | return Boolean.valueOf(this.userOauthService.update((Wrapper) ((LambdaUpdateWrapper) ((LambdaUpdateWrapper) Wrappers.lambdaUpdate().set((v0) -> { |
| | | return v0.getUserId(); |
| | | }, (Object) null)).eq((v0) -> { |
| | | return v0.getUserId(); |
| | | }, id)).eq((v0) -> { |
| | | return v0.getSource(); |
| | | }, source))); |
| | | }, source)));*/ |
| | | } |
| | | |
| | | @Override // org.springblade.modules.sync.service.IDingSyncService |
| | |
| | | if (Func.isNotEmpty(oriUsers)) { |
| | | String pinValue = this.paramService.getValue("employee.default.pin"); |
| | | List<Employee> dbEmployees = this.employeeService.list(); |
| | | Map<String, Employee> employeeMap = (Map) dbEmployees.parallelStream().filter(o -> { |
| | | |
| | | |
| | | Map<String, Employee> employeeMap = dbEmployees.parallelStream().filter(o -> { |
| | | return Func.isNotEmpty(o.getTel()); |
| | | }).collect(Collectors.toMap((v0) -> { |
| | | return v0.getTel(); |
| | | }, e -> { |
| | | return e; |
| | | }, k1, k2 -> { |
| | | }, (k1, k2) -> { |
| | | return k1; |
| | | })); |
| | | Snowflake snowflake = IdUtil.createSnowflake(1L, 1L); |
| | |
| | | } |
| | | } |
| | | |
| | | /* JADX WARN: Code restructure failed: missing block: B:20:0x0161, code lost: |
| | | r10.setPostResult(false); |
| | | r10.setPostReason("同步钉钉角色异常,结果为:" + r0 + "---------参数为:" + r0); |
| | | */ |
| | | /* |
| | | Code decompiled incorrectly, please refer to instructions dump. |
| | | To view partially-correct code enable 'Show inconsistent code' option in preferences |
| | | */ |
| | | private void getRoles(java.lang.String r7, java.lang.String r8, java.util.List<org.springblade.modules.system.entity.Post> r9, org.springblade.modules.sync.vo.SyncResultVO r10) { |
| | | /* |
| | | Method dump skipped, instructions count: 448 |
| | | To view this dump change 'Code comments level' option to 'DEBUG' |
| | | */ |
| | | throw new UnsupportedOperationException("Method not decompiled: org.springblade.modules.sync.service.impl.DingSyncServiceImpl.getRoles(java.lang.String, java.lang.String, java.util.List, org.springblade.modules.sync.vo.SyncResultVO):void"); |
| | | } |
| | | private void getRoles(String appKey, String appSecret, List<Post> postList, SyncResultVO syncResultVO) { |
| | | try { |
| | | DefaultDingTalkClient defaultDingTalkClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/role/list"); |
| | | OapiRoleListRequest req = new OapiRoleListRequest(); |
| | | req.setSize(DingConstant.ROLE_SIZE); |
| | | req.setOffset(DingConstant.START_OFFSET); |
| | | while (true) { |
| | | OapiRoleListResponse rsp = (OapiRoleListResponse)defaultDingTalkClient.execute((TaobaoRequest)req, this.dingEventService.getDingAccessToken(appKey, appSecret)); |
| | | JSONObject jsonObject = JSONObject.parseObject(rsp.getBody()); |
| | | if (jsonObject.getInteger("errcode").equals(DingConstant.SUCCESS)) { |
| | | Map<String, Object> resultMap = (Map<String, Object>)jsonObject.get("result"); |
| | | List<Map<String, Object>> resultList = (List<Map<String, Object>>)resultMap.get("list"); |
| | | if (Func.isNotEmpty(resultList)) |
| | | for (Map<String, Object> roleGroupMap : resultList) { |
| | | List<Map<String, Object>> roleList = (List<Map<String, Object>>)roleGroupMap.get("roles"); |
| | | if (Func.isNotEmpty(roleList)) |
| | | for (Map<String, Object> role : roleList) { |
| | | Post post = new Post(); |
| | | post.setPostCode(String.valueOf(role.get("id"))); |
| | | post.setId(Long.valueOf(String.valueOf(role.get("id")))); |
| | | post.setPostName(String.valueOf(role.get("name"))); |
| | | post.setStatus(CommonConstant.ENABLE); |
| | | postList.add(post); |
| | | getRoleContainsUser(post.getPostCode(), appKey, appSecret); |
| | | } |
| | | } |
| | | if (((Boolean)resultMap.get("hasMore")).booleanValue()) { |
| | | req.setOffset(Long.valueOf(req.getOffset().longValue() + DingConstant.ROLE_SIZE.longValue())); |
| | | continue; |
| | | } |
| | | break; |
| | | } |
| | | syncResultVO.setPostResult(Boolean.valueOf(false)); |
| | | syncResultVO.setPostReason("同步钉钉角色异常,结果为:" + jsonObject + "---------参数为:" + req); |
| | | break; |
| | | } |
| | | } catch (Exception e) { |
| | | syncResultVO.setPostResult(Boolean.valueOf(false)); |
| | | syncResultVO.setPostReason("同步钉钉角色报错:" + e.toString()); |
| | | } |
| | | } |
| | | |
| | | private void getRoleContainsUser(String postCode, String appKey, String appSecret) throws Exception { |
| | | DefaultDingTalkClient defaultDingTalkClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/role/simplelist"); |
| | |
| | | } |
| | | } |
| | | |
| | | /* JADX WARN: Code restructure failed: missing block: B:15:0x00cb, code lost: |
| | | r11.setUserResult(false); |
| | | r11.setUserReason("同步钉钉用户异常,结果为:" + r0 + "---------参数为:" + r0); |
| | | */ |
| | | /* |
| | | Code decompiled incorrectly, please refer to instructions dump. |
| | | To view partially-correct code enable 'Show inconsistent code' option in preferences |
| | | */ |
| | | private void SyncEmployee(java.lang.Long r7, java.lang.String r8, java.lang.String r9, java.util.List<org.springblade.modules.sync.entity.DingOriUser> r10, org.springblade.modules.sync.vo.SyncResultVO r11) { |
| | | /* |
| | | Method dump skipped, instructions count: 298 |
| | | To view this dump change 'Code comments level' option to 'DEBUG' |
| | | */ |
| | | throw new UnsupportedOperationException("Method not decompiled: org.springblade.modules.sync.service.impl.DingSyncServiceImpl.SyncEmployee(java.lang.Long, java.lang.String, java.lang.String, java.util.List, org.springblade.modules.sync.vo.SyncResultVO):void"); |
| | | } |
| | | private void SyncEmployee(Long deptId, String appKey, String appSecret, List<DingOriUser> oriUsers, SyncResultVO syncResultVO) { |
| | | try { |
| | | DefaultDingTalkClient defaultDingTalkClient = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/list"); |
| | | OapiV2UserListRequest req = new OapiV2UserListRequest(); |
| | | req.setSize(DingConstant.SIZE); |
| | | req.setDeptId(Long.valueOf(deptId.equals(Long.valueOf(3L)) ? 1L : deptId.longValue())); |
| | | req.setCursor(DingConstant.START_OFFSET); |
| | | while (true) { |
| | | OapiV2UserListResponse rsp = (OapiV2UserListResponse)defaultDingTalkClient.execute((TaobaoRequest)req, this.dingEventService.getDingAccessToken(appKey, appSecret)); |
| | | JSONObject jsonObject = JSONObject.parseObject(rsp.getBody()); |
| | | if (jsonObject.getInteger("errcode").equals(DingConstant.SUCCESS)) { |
| | | JSONObject resultMap = jsonObject.getJSONObject("result"); |
| | | List<DingOriUser> resultList = resultMap.getJSONArray("list").toJavaList(DingOriUser.class); |
| | | if (Func.isNotEmpty(resultList)) |
| | | resultList.forEach(userMap -> oriUsers.add(userMap)); |
| | | if (((Boolean)resultMap.get("has_more")).booleanValue()) { |
| | | req.setCursor(Long.valueOf(String.valueOf(resultMap.get("next_cursor")))); |
| | | continue; |
| | | } |
| | | break; |
| | | } |
| | | syncResultVO.setUserResult(Boolean.valueOf(false)); |
| | | syncResultVO.setUserReason("同步钉钉用户异常,结果为:" + jsonObject + "---------参数为:" + req); |
| | | break; |
| | | } |
| | | } catch (Exception e) { |
| | | syncResultVO.setUserResult(Boolean.valueOf(false)); |
| | | syncResultVO.setUserReason("同步钉钉用户报错:" + e.toString()); |
| | | } |
| | | } |
| | | |
| | | public static Client authClient() throws Exception { |
| | | Config config = new Config(); |