package com.qianwen.smartman.modules.notify.service.impl; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.core.toolkit.Wrappers; 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.BusinessNotifyStateConvert; import com.qianwen.smartman.modules.notify.dto.BusinessNotifyStateDTO; import com.qianwen.smartman.modules.notify.entity.BusinessNotifyState; import com.qianwen.smartman.modules.notify.enums.ObjectTypeEnum; import com.qianwen.smartman.modules.notify.mapper.BusinessNotifyStateMapper; import com.qianwen.smartman.modules.notify.service.IBusinessNotifyStateService; import com.qianwen.smartman.modules.notify.vo.BusinessNotifyStateVO; import com.qianwen.smartman.modules.sync.constant.DingConstant; @Service /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/notify/service/impl/BusinessNotifyStateServiceImpl.class */ public class BusinessNotifyStateServiceImpl extends BaseServiceImpl implements IBusinessNotifyStateService { @Autowired private IEmployeeService employeeService; @Autowired private ICommonGroupService commonGroupService; @Override // org.springblade.modules.notify.service.IBusinessNotifyStateService public List listByBusinessKey(String businessKey) { return listByBusinessKeyAndBusinessId(businessKey, null); } @Override // org.springblade.modules.notify.service.IBusinessNotifyStateService public BusinessNotifyStateVO getByBusinessKeyAndBusinessId(String businessKey, Long businessId) { List states = listByBusinessKeyAndBusinessId(businessKey, businessId); return buildBusinessNotifyStateVO(states); } private BusinessNotifyStateVO buildBusinessNotifyStateVO(List states) { BusinessNotifyStateVO stateVO = new BusinessNotifyStateVO(); Map> notifyStateMap = states.parallelStream().collect(Collectors.groupingBy((v0) -> { return v0.getPersonType(); }, Collectors.mapping((v0) -> { return v0.getPersonId(); }, Collectors.toSet()))); if (notifyStateMap.containsKey(Integer.valueOf(ObjectTypeEnum.EMP.getCode()))) { Set ids = notifyStateMap.get(Integer.valueOf(ObjectTypeEnum.EMP.getCode())); List employees = this.employeeService.listByIds(ids); List stateDTOS = BusinessNotifyStateConvert.INSTANCE.convertByEmpList(employees); stateVO.setEmpList(stateDTOS); } if (notifyStateMap.containsKey(Integer.valueOf(ObjectTypeEnum.ORG.getCode()))) { Set ids2 = notifyStateMap.get(Integer.valueOf(ObjectTypeEnum.ORG.getCode())); List list = this.commonGroupService.list(Wrappers.lambdaQuery().eq(CommonGroup::getStatus, Boolean.valueOf(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 stateDTOS2 = BusinessNotifyStateConvert.INSTANCE.convertByOrgList(list); stateVO.setOrgList(stateDTOS2); } return stateVO; } private List listByBusinessKeyAndBusinessId(String businessKey, Long businessId) { boolean notEmpty = Func.isNotEmpty(businessId); return list(Wrappers.lambdaQuery().eq(BusinessNotifyState::getBusinessKey, businessKey) .eq(notEmpty, BusinessNotifyState::getBusinessId, businessId)); /* return list(((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { return v0.getBusinessKey(); }, businessKey)).eq(notEmpty, (v0) -> { return v0.getBusinessId(); }, businessId));*/ } @Override // org.springblade.modules.notify.service.IBusinessNotifyStateService @Transactional(rollbackFor = {Exception.class}) public void saveBatchByIds(String businessKey, Long businessId, List empIds, List orgIds) { deleteListByBusinessId(businessKey, businessId); List states = new ArrayList<>(); for (Long empId : empIds) { BusinessNotifyState businessNotifyState = new BusinessNotifyState(); businessNotifyState.setBusinessKey(businessKey); businessNotifyState.setPersonId(empId); businessNotifyState.setBusinessId(businessId); businessNotifyState.setPersonType(Integer.valueOf(ObjectTypeEnum.EMP.getCode())); states.add(businessNotifyState); } for (Long orgId : orgIds) { BusinessNotifyState businessNotifyState2 = new BusinessNotifyState(); businessNotifyState2.setBusinessKey(businessKey); businessNotifyState2.setPersonId(orgId); businessNotifyState2.setBusinessId(businessId); businessNotifyState2.setPersonType(Integer.valueOf(ObjectTypeEnum.EMP.getCode())); states.add(businessNotifyState2); } saveBatch(states); } void deleteListByBusinessId(String businessKey, Long businessId) { remove(Wrappers.lambdaQuery().eq(BusinessNotifyState::getBusinessKey, businessKey) .eq(BusinessNotifyState::getBusinessId, businessId)); /* remove((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { return v0.getBusinessKey(); }, businessKey)).eq((v0) -> { return v0.getBusinessId(); }, businessId));*/ } }