@ -37,6 +37,9 @@ import com.baiye.model.enums.ResponseCode;
import com.baiye.modules.platform.domain.* ;
import com.baiye.modules.platform.domain.* ;
import com.baiye.modules.platform.repository.* ;
import com.baiye.modules.platform.repository.* ;
import com.baiye.modules.platform.service.* ;
import com.baiye.modules.platform.service.* ;
import com.baiye.modules.platform.service.dto.* ;
import com.baiye.modules.report.service.QueryReportService ;
import com.baiye.modules.system.mapstruct.UserMapper ;
import com.baiye.modules.platform.service.dto.BuyComboDTO ;
import com.baiye.modules.platform.service.dto.BuyComboDTO ;
import com.baiye.modules.platform.service.dto.CompanyDto ;
import com.baiye.modules.platform.service.dto.CompanyDto ;
import com.baiye.modules.platform.service.dto.CreateUserDTO ;
import com.baiye.modules.platform.service.dto.CreateUserDTO ;
@ -48,17 +51,20 @@ import com.baiye.modules.system.mapstruct.UserMapper;
import com.baiye.modules.system.repository.RoleRepository ;
import com.baiye.modules.system.repository.RoleRepository ;
import com.baiye.modules.system.repository.UserRepository ;
import com.baiye.modules.system.repository.UserRepository ;
import com.baiye.modules.system.service.UserService ;
import com.baiye.modules.system.service.UserService ;
import com.baiye.modules.telemarkting.service.ExtensionNumberService ;
import com.baiye.util.* ;
import com.baiye.util.* ;
import com.google.common.collect.ImmutableMap ;
import com.google.common.collect.ImmutableMap ;
import com.google.common.collect.Sets ;
import com.google.common.collect.Sets ;
import lombok.RequiredArgsConstructor ;
import lombok.RequiredArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.cache.Cache ;
import org.springframework.cache.annotation.CacheConfig ;
import org.springframework.cache.annotation.CacheConfig ;
import org.springframework.cache.annotation.CacheEvict ;
import org.springframework.cache.annotation.CacheEvict ;
import org.springframework.cache.annotation.Cacheable ;
import org.springframework.cache.annotation.Cacheable ;
import org.springframework.data.domain.Page ;
import org.springframework.data.domain.Page ;
import org.springframework.data.domain.Pageable ;
import org.springframework.data.domain.Pageable ;
import org.springframework.http.HttpStatus ;
import org.springframework.http.ResponseEntity ;
import org.springframework.http.ResponseEntity ;
import org.springframework.security.crypto.password.PasswordEncoder ;
import org.springframework.security.crypto.password.PasswordEncoder ;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Service ;
@ -125,6 +131,12 @@ public class UserServiceImpl implements UserService {
private final CallDeductService callDeductService ;
private final LabelOrganizeService labelOrganizeService ;
private final ExtensionNumberService extensionNumberService ;
private final QueryReportService queryReportService ;
private final TaskImeiService taskImeiService ;
private final TaskTagRepository taskTagRepository ;
@Override
@Override
@Transactional ( rollbackFor = Exception . class )
@Transactional ( rollbackFor = Exception . class )
public Boolean fileCreateUser ( List < UserFavorOfExcel > excels , Long companyId , UserDto userDto ) {
public Boolean fileCreateUser ( List < UserFavorOfExcel > excels , Long companyId , UserDto userDto ) {
@ -599,6 +611,13 @@ public class UserServiceImpl implements UserService {
// 踢出用户
// 踢出用户
this . remoteAuthService . delete ( Sets . newHashSet ( userIds ) ) ;
this . remoteAuthService . delete ( Sets . newHashSet ( userIds ) ) ;
//TODO 删除逻辑待补充?
//TODO 删除逻辑待补充?
//11、删除分机号
extensionNumberService . deleteExtensionNumberByCompany ( user . getCompanyId ( ) ) ;
//12、删除统计信息
queryReportService . deleteReport ( user . getCompanyId ( ) ) ;
//13.删除imei和tag
taskImeiService . deleteTaskImei ( taskIds ) ;
taskTagRepository . deleteByTaskIds ( taskIds ) ;
return ;
return ;
} else if ( roleIds . contains ( RoleNumberConstants . MINUS_NINE_NUMBER ) ) {
} else if ( roleIds . contains ( RoleNumberConstants . MINUS_NINE_NUMBER ) ) {
// 二: 删除或者替换组长
// 二: 删除或者替换组长
@ -607,18 +626,15 @@ public class UserServiceImpl implements UserService {
throw new BadRequestException ( "请选择组长角色的用户" ) ;
throw new BadRequestException ( "请选择组长角色的用户" ) ;
organizeUserRepository . updateUser ( userId , replaceUserId ) ;
organizeUserRepository . updateUser ( userId , replaceUserId ) ;
organizeUserRepository . updateCreateBy ( replaceUserId , userId ) ;
organizeUserRepository . updateCreateBy ( replaceUserId , userId ) ;
this . sourceDel ( isDel, userId, replaceUserId ) ;
this . sourceDel ( userId, replaceUserId ) ;
} else if ( roleIds . contains ( RoleNumberConstants . MINUS_FIVE_NUMBER ) ) {
} else if ( roleIds . contains ( RoleNumberConstants . MINUS_FIVE_NUMBER ) ) {
// 三: 删除或者替换业务员
// 三: 删除或者替换业务员
if ( isDel ) organizeUserRepository . deleteByUserId ( userId ) ;
if ( replaceUserId = = null ) organizeUserRepository . deleteByUserId ( userId ) ;
else {
else organizeUserRepository . updateUser ( userId , replaceUserId ) ;
if ( replaceUserId = = null ) throw new BadRequestException ( "请选择替换人员" ) ;
this . sourceDel ( userId , replaceUserId ) ;
if ( CollUtil . isNotEmpty ( replaceRoleIds ) & & ! roleIds . contains ( RoleNumberConstants . MINUS_FIVE_NUMBER ) )
throw new BadRequestException ( "请选择业务管理员角色的用户" ) ;
organizeUserRepository . updateUser ( userId , replaceUserId ) ;
}
this . sourceDel ( isDel , userId , replaceUserId ) ;
}
}
//分机号
extensionNumberService . updateExtensionNumber ( userId , replaceUserId ) ;
// 清理缓存
// 清理缓存
delCaches ( userId , user . getUsername ( ) ) ;
delCaches ( userId , user . getUsername ( ) ) ;
// 踢出用户
// 踢出用户
@ -626,8 +642,8 @@ public class UserServiceImpl implements UserService {
userRepository . deleteById ( userId ) ;
userRepository . deleteById ( userId ) ;
}
}
private void sourceDel ( Boolean isDel , Long userId , Long replaceUserId ) {
private void sourceDel ( Long userId , Long replaceUserId ) {
if ( isDe l) {
if ( replaceUserId = = nul l) {
ResponseEntity < Map < Long , Integer > > response = sourceClueClient . delClueByUser ( userId ) ;
ResponseEntity < Map < Long , Integer > > response = sourceClueClient . delClueByUser ( userId ) ;
if ( response . getStatusCode ( ) . value ( ) ! = 200 ) throw new BadRequestException ( "删除失败" ) ;
if ( response . getStatusCode ( ) . value ( ) ! = 200 ) throw new BadRequestException ( "删除失败" ) ;
//更新任务资源数量
//更新任务资源数量