| | |
| | | package com.qianwen.smartman.modules.sync.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.collection.ListUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.core.util.XmlUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.jeecg.qywx.api.department.vo.Department; |
| | | import java.lang.invoke.SerializedLambda; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | import java.util.Objects; |
| | | import java.util.function.Consumer; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.jeewx.api.mp.aes.AesException; |
| | | import org.jeewx.api.mp.aes.WXBizMsgCrypt; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.qianwen.smartman.common.cache.RegionCache; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.w3c.dom.Document; |
| | | import org.w3c.dom.Element; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.jeecg.qywx.api.department.vo.Department; |
| | | import com.qianwen.smartman.common.constant.CommonConstant; |
| | | import com.qianwen.smartman.common.enums.CommonGroupTypeEnum; |
| | | 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.cps.entity.EmployeePost; |
| | | import com.qianwen.smartman.modules.cps.mapper.CommonGroupMapper; |
| | |
| | | import com.qianwen.smartman.modules.system.entity.UserOauth; |
| | | import com.qianwen.smartman.modules.system.service.impl.PostServiceImpl; |
| | | import com.qianwen.smartman.modules.system.service.impl.UserOauthServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.w3c.dom.Document; |
| | | import org.w3c.dom.Element; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.collection.ListUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.core.util.XmlUtil; |
| | | |
| | | @Service |
| | | /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/sync/service/impl/WechatCallbackServiceImpl.class */ |
| | | public class WechatCallbackServiceImpl implements IWechatCallbackService { |
| | | private static final Logger log = LoggerFactory.getLogger(WechatCallbackServiceImpl.class); |
| | | private final Map<WechatEventEnum, Consumer<String>> xmlParseMap = new HashMap(); |
| | | private final Map<WechatEventEnum, Consumer<String>> xmlParseMap = new HashMap<>(); |
| | | private final WechatSyncServiceImpl wechatSyncService; |
| | | private final PostServiceImpl postService; |
| | | private final IEmployeePostService employeePostService; |
| | |
| | | private final CommonGroupMapper commonGroupMapper; |
| | | private final IOuterAppConfigService outerAppConfigService; |
| | | |
| | | private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) { |
| | | String implMethodName = lambda.getImplMethodName(); |
| | | boolean z = true; |
| | | switch (implMethodName.hashCode()) { |
| | | case -1492577373: |
| | | if (implMethodName.equals("getGroupType")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case -1219083612: |
| | | if (implMethodName.equals("getOrganizationId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case -129715105: |
| | | if (implMethodName.equals("getEmployeeId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case -75080655: |
| | | if (implMethodName.equals("getUuid")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 517353092: |
| | | if (implMethodName.equals("getItemId")) { |
| | | z = false; |
| | | break; |
| | | } |
| | | break; |
| | | case 713563345: |
| | | if (implMethodName.equals("getPostId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 799509265: |
| | | if (implMethodName.equals("getSource")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 1330288580: |
| | | if (implMethodName.equals("getGroupId")) { |
| | | 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/cps/entity/CommonGroupOfItem") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getItemId(); |
| | | }; |
| | | } |
| | | 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/cps/entity/Employee") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getOrganizationId(); |
| | | }; |
| | | } |
| | | 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.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(); |
| | | }; |
| | | } |
| | | 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(); |
| | | }; |
| | | } |
| | | 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/modules/cps/entity/EmployeePost") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getPostId(); |
| | | }; |
| | | } |
| | | 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/cps/entity/EmployeePost") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getPostId(); |
| | | }; |
| | | } |
| | | 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/cps/entity/CommonGroupOfItem") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getGroupType(); |
| | | }; |
| | | } |
| | | 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/cps/entity/EmployeePost") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getEmployeeId(); |
| | | }; |
| | | } |
| | | 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/cps/entity/EmployeePost") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getEmployeeId(); |
| | | }; |
| | | } |
| | | 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/cps/entity/CommonGroupOfItem") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getGroupId(); |
| | | }; |
| | | } |
| | | 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/cps/entity/CommonGroupOfItem") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getGroupId(); |
| | | }; |
| | | } |
| | | break; |
| | | } |
| | | throw new IllegalArgumentException("Invalid lambda deserialization"); |
| | | } |
| | | |
| | | public WechatCallbackServiceImpl(final WechatSyncServiceImpl wechatSyncService, final PostServiceImpl postService, final IEmployeePostService employeePostService, final UserOauthServiceImpl userOauthService, final CommonGroupServiceImpl commonGroupService, final CommonGroupOfItemServiceImpl commonGroupOfItemService, final EmployeeServiceImpl employeeService, final CommonGroupMapper commonGroupMapper, final IOuterAppConfigService outerAppConfigService) { |
| | | this.xmlParseMap.put(WechatEventEnum.USER_ADD_EVENT, this::parseUserAddEvent); |
| | |
| | | |
| | | private List<String> parseCallbackStr(String callbackData) { |
| | | if (StrUtil.isEmpty(callbackData)) { |
| | | return new ArrayList(); |
| | | return new ArrayList<>(); |
| | | } |
| | | String[] dataArr = callbackData.split(","); |
| | | return ListUtil.toList(dataArr); |
| | |
| | | return; |
| | | } |
| | | QyUser qyUser = QyWechatApi.getUserById(userId); |
| | | UserOauth userOauth = this.userOauthService.getOne(Wrappers.<UserOauth>lambdaQuery().eq(UserOauth::getUuid, userId) |
| | | .eq(UserOauth::getSource, "WECHAT_ENTERPRISE_WEB"), Boolean.TRUE.booleanValue()); |
| | | /* |
| | | UserOauth userOauth = (UserOauth) this.userOauthService.getOne((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getUuid(); |
| | | }, userId)).eq((v0) -> { |
| | | return v0.getSource(); |
| | | }, QyWechatConstant.QY_SOURCE), Boolean.TRUE.booleanValue()); |
| | | }, QyWechatConstant.QY_SOURCE), Boolean.TRUE.booleanValue());*/ |
| | | this.wechatSyncService.createOrModifyEmployee(qyUser, userOauth); |
| | | } |
| | | |
| | |
| | | if (StrUtil.isEmpty(userId)) { |
| | | return; |
| | | } |
| | | UserOauth userOauth = this.userOauthService.getOne(Wrappers.<UserOauth>lambdaQuery().eq(UserOauth::getUuid, userId)); |
| | | /* |
| | | UserOauth userOauth = (UserOauth) this.userOauthService.getOne((Wrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getUuid(); |
| | | }, userId)); |
| | | }, userId));*/ |
| | | if (Objects.isNull(userOauth)) { |
| | | return; |
| | | } |
| | |
| | | return; |
| | | } |
| | | this.employeeService.removeById(employee); |
| | | this.commonGroupOfItemService.remove(Wrappers.<CommonGroupOfItem>lambdaQuery() |
| | | .eq(CommonGroupOfItem::getGroupId, employee.getOrganizationId()) |
| | | .eq(CommonGroupOfItem::getItemId, employee.getId())); |
| | | /* |
| | | this.commonGroupOfItemService.remove((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupId(); |
| | | }, employee.getOrganizationId())).eq((v0) -> { |
| | | return v0.getItemId(); |
| | | }, employee.getId())); |
| | | }, employee.getId()));*/ |
| | | this.employeePostService.remove(Wrappers.<EmployeePost>lambdaQuery() |
| | | .eq(EmployeePost::getPostId, employee.getPostId()) |
| | | .eq(EmployeePost::getEmployeeId, employee.getId())); |
| | | /* |
| | | this.employeePostService.remove((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getPostId(); |
| | | }, employee.getPostId())).eq((v0) -> { |
| | | return v0.getEmployeeId(); |
| | | }, employee.getId())); |
| | | }, employee.getId()));*/ |
| | | } |
| | | |
| | | private void parseDeptAddEvent(String xmlBody) { |
| | |
| | | return; |
| | | } |
| | | String localDeptId = QyWechatConstant.ID_SALT + deptId; |
| | | long count = this.employeeService.count(Wrappers.<Employee>lambdaQuery().eq(Employee::getOrganizationId, localDeptId)); |
| | | /* |
| | | long count = this.employeeService.count((Wrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getOrganizationId(); |
| | | }, localDeptId)); |
| | | }, localDeptId));*/ |
| | | if (count > 0) { |
| | | log.warn("[部门删除回调事件].[当前部门下有{}个员工,无法删除]", Long.valueOf(count)); |
| | | return; |
| | | } |
| | | this.commonGroupMapper.removeOrgByIds(ListUtil.of(new String[]{localDeptId})); |
| | | this.commonGroupOfItemService.remove(Wrappers.<CommonGroupOfItem>lambdaQuery() |
| | | .eq(CommonGroupOfItem::getGroupId, localDeptId).eq(CommonGroupOfItem::getGroupType, CommonGroupTypeEnum.ORGANIZATION.getName())); |
| | | /* |
| | | this.commonGroupOfItemService.remove((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupId(); |
| | | }, localDeptId)).eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, CommonGroupTypeEnum.ORGANIZATION.getName())); |
| | | }, CommonGroupTypeEnum.ORGANIZATION.getName()));*/ |
| | | } |
| | | |
| | | private void parseTagModifyEvent(String xmlBody) { |
| | |
| | | List<Employee> employees = getEmpList(tagBody.getDeleteList()); |
| | | employees.forEach(emp -> { |
| | | String handlerPostId = handlerPostId(Boolean.TRUE, emp.getPostId(), tagBody.getTagId()); |
| | | this.employeePostService.remove(Wrappers.<EmployeePost>lambdaQuery().eq(EmployeePost::getPostId, tagBody.getTagId()) |
| | | .eq(EmployeePost::getEmployeeId, emp.getId())); |
| | | /* |
| | | this.employeePostService.remove((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getPostId(); |
| | | }, tagBody.getTagId())).eq((v0) -> { |
| | | return v0.getEmployeeId(); |
| | | }, emp.getId())); |
| | | }, emp.getId()));*/ |
| | | emp.setPostId(handlerPostId); |
| | | }); |
| | | this.employeeService.updateBatchById(employees); |
| | |
| | | } |
| | | |
| | | private List<Employee> getEmpList(List<String> userIds) { |
| | | List<UserOauth> auths = this.userOauthService.list(Wrappers.<UserOauth>lambdaQuery().in(UserOauth::getUuid, userIds)); |
| | | /* |
| | | List<UserOauth> auths = this.userOauthService.list((Wrapper) Wrappers.lambdaQuery().in((v0) -> { |
| | | return v0.getUuid(); |
| | | }, userIds)); |
| | | }, userIds));*/ |
| | | if (CollectionUtil.isEmpty(auths)) { |
| | | return new ArrayList(); |
| | | return new ArrayList<>(); |
| | | } |
| | | List<Long> empIds = (List) auths.parallelStream().map((v0) -> { |
| | | List<Long> empIds = auths.parallelStream().map((v0) -> { |
| | | return v0.getUserId(); |
| | | }).collect(Collectors.toList()); |
| | | return this.employeeService.listByIds(empIds); |