package com.qianwen.smartman.modules.notify.service.impl; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import java.lang.invoke.SerializedLambda; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import com.qianwen.core.mp.base.BaseServiceImpl; import com.qianwen.core.tool.utils.Func; import com.qianwen.smartman.modules.cps.entity.CommonGroup; import com.qianwen.smartman.modules.cps.entity.Employee; import com.qianwen.smartman.modules.cps.service.ICommonGroupService; import com.qianwen.smartman.modules.cps.service.IEmployeeService; import com.qianwen.smartman.modules.notify.convert.NotifyDefaultPersonConvert; import com.qianwen.smartman.modules.notify.dto.NotifyDefaultPersonDTO; import com.qianwen.smartman.modules.notify.entity.NotifyDefaultPerson; import com.qianwen.smartman.modules.notify.enums.ObjectTypeEnum; import com.qianwen.smartman.modules.notify.mapper.NotifyDefaultPersonMapper; import com.qianwen.smartman.modules.notify.service.INotifyDefaultPersonService; import com.qianwen.smartman.modules.notify.vo.NotifyDefaultObjectVO; import com.qianwen.smartman.modules.sync.constant.DingConstant; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/notify/service/impl/NotifyDefaultPersonServiceImpl.class */ public class NotifyDefaultPersonServiceImpl extends BaseServiceImpl implements INotifyDefaultPersonService { @Autowired private IEmployeeService employeeService; @Autowired private ICommonGroupService commonGroupService; @Override // org.springblade.modules.notify.service.INotifyDefaultPersonService public NotifyDefaultObjectVO getByBusinessKey(String businessKey) { NotifyDefaultObjectVO notifyDefaultObjectVO = new NotifyDefaultObjectVO(); List personList = getNotifyDefaultPerson(businessKey); Map> notifyDefaultPersonMap = personList.parallelStream().collect(Collectors.groupingBy((v0) -> { return v0.getPersonType(); }, Collectors.mapping((v0) -> { return v0.getPersonId(); }, Collectors.toSet()))); if (notifyDefaultPersonMap.containsKey(Integer.valueOf(ObjectTypeEnum.EMP.getCode()))) { Set ids = notifyDefaultPersonMap.get(Integer.valueOf(ObjectTypeEnum.EMP.getCode())); List employees = this.employeeService.listByIds(ids); List notifyDefaultPersonDTOS = NotifyDefaultPersonConvert.INSTANCE.convertByEmpList(employees); notifyDefaultObjectVO.setEmpList(notifyDefaultPersonDTOS); } if (notifyDefaultPersonMap.containsKey(Integer.valueOf(ObjectTypeEnum.ORG.getCode()))) { Set ids2 = notifyDefaultPersonMap.get(Integer.valueOf(ObjectTypeEnum.ORG.getCode())); List list = this.commonGroupService.list(Wrappers.lambdaQuery().eq(CommonGroup::getStatus, true) .in(CommonGroup::getId, ids2).eq(CommonGroup::getGroupType, DingConstant.GROUPTYPE)); ; /* List list = this.commonGroupService.list((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { return v0.getStatus(); }, true)).in((v0) -> { return v0.getId(); }, ids2)).eq((v0) -> { return v0.getGroupType(); }, DingConstant.GROUPTYPE));*/ List notifyDefaultPersonDTOS2 = NotifyDefaultPersonConvert.INSTANCE.convertByOrgList(list); notifyDefaultObjectVO.setOrgList(notifyDefaultPersonDTOS2); } return notifyDefaultObjectVO; } @Override // org.springblade.modules.notify.service.INotifyDefaultPersonService public void saveNotifyDefaultPerson(NotifyDefaultObjectVO notifyDefaultObjectVO) { List empIds = notifyDefaultObjectVO.getEmpIds(); List orgIds = notifyDefaultObjectVO.getOrgIds(); String businessKey = notifyDefaultObjectVO.getBusinessKey(); remove(businessKey); List defaultPersonList = new ArrayList<>(); if (Func.isNotEmpty(orgIds)) { for (Long orgId : orgIds) { NotifyDefaultPerson person = new NotifyDefaultPerson(); person.setBusinessKey(businessKey); person.setPersonId(orgId); person.setPersonType(Integer.valueOf(ObjectTypeEnum.ORG.getCode())); defaultPersonList.add(person); } } if (Func.isNotEmpty(empIds)) { for (Long empId : empIds) { NotifyDefaultPerson person2 = new NotifyDefaultPerson(); person2.setBusinessKey(businessKey); person2.setPersonId(empId); person2.setPersonType(Integer.valueOf(ObjectTypeEnum.EMP.getCode())); defaultPersonList.add(person2); } } saveBatch(defaultPersonList); } private void remove(String businessKey) { remove(Wrappers.lambdaQuery().eq(NotifyDefaultPerson::getBusinessKey, businessKey)); /* remove((Wrapper) Wrappers.lambdaQuery().eq((v0) -> { return v0.getBusinessKey(); }, businessKey));*/ } private List getNotifyDefaultPerson(String businessKey) { Wrapper defaultPersonWrapper = Wrappers.lambdaQuery().eq(NotifyDefaultPerson::getBusinessKey, businessKey); /* Wrapper defaultPersonWrapper = (Wrapper) Wrappers.lambdaQuery().eq((v0) -> { return v0.getBusinessKey(); }, businessKey);*/ return list(defaultPersonWrapper); } }