|
@@ -1,29 +1,29 @@
|
|
package com.zbkj.service.service.impl;
|
|
package com.zbkj.service.service.impl;
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
import com.zbkj.common.model.organization.OrganizationDepartment;
|
|
import com.zbkj.common.model.organization.OrganizationDepartment;
|
|
|
|
|
|
|
|
+import com.zbkj.common.model.organization.OrganizationDepartmentUser;
|
|
import com.zbkj.common.model.organization.VO.OrganizationDepartmentVO;
|
|
import com.zbkj.common.model.organization.VO.OrganizationDepartmentVO;
|
|
|
|
+import com.zbkj.common.model.user.User;
|
|
import com.zbkj.common.model.user.UserBypassAccount;
|
|
import com.zbkj.common.model.user.UserBypassAccount;
|
|
import com.zbkj.common.model.user.UserEnterprise;
|
|
import com.zbkj.common.model.user.UserEnterprise;
|
|
import com.zbkj.common.result.CommonResult;
|
|
import com.zbkj.common.result.CommonResult;
|
|
import com.zbkj.service.dao.OrganizationDeparementDao;
|
|
import com.zbkj.service.dao.OrganizationDeparementDao;
|
|
import com.zbkj.service.dao.UserBypassAccountDao;
|
|
import com.zbkj.service.dao.UserBypassAccountDao;
|
|
import com.zbkj.service.dao.UserEnterpriseDao;
|
|
import com.zbkj.service.dao.UserEnterpriseDao;
|
|
-import com.zbkj.service.service.OrganizationDepartmentService;
|
|
|
|
|
|
+import com.zbkj.service.service.*;
|
|
|
|
|
|
-import com.zbkj.service.service.UserBypassAccountService;
|
|
|
|
-import com.zbkj.service.service.UserEnterpriseService;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@@ -39,6 +39,12 @@ public class OrganizationDepartmentServiceImpl extends ServiceImpl<OrganizationD
|
|
private UserBypassAccountService userBypassAccountService;
|
|
private UserBypassAccountService userBypassAccountService;
|
|
@Autowired
|
|
@Autowired
|
|
private UserEnterpriseService userEnterpriseService;
|
|
private UserEnterpriseService userEnterpriseService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private OrganizationDepartmentUserService organizationDepartmentUserService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private OrganizationDepartmentService organizationDepartmentService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private UserService userService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<OrganizationDepartmentVO> selectMain(String id) {
|
|
public List<OrganizationDepartmentVO> selectMain(String id) {
|
|
@@ -55,17 +61,17 @@ public class OrganizationDepartmentServiceImpl extends ServiceImpl<OrganizationD
|
|
deparementDao.updateById(request);
|
|
deparementDao.updateById(request);
|
|
String id = request.getId();
|
|
String id = request.getId();
|
|
LambdaQueryWrapper<UserEnterprise> enterpriseLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<UserEnterprise> enterpriseLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
- enterpriseLambdaQueryWrapper.eq(UserEnterprise::getOrganizationId,request.getOrganizationId());
|
|
|
|
|
|
+ enterpriseLambdaQueryWrapper.eq(UserEnterprise::getOrganizationId, request.getOrganizationId());
|
|
UserEnterprise userEnterprise = userEnterpriseService.getOne(enterpriseLambdaQueryWrapper);
|
|
UserEnterprise userEnterprise = userEnterpriseService.getOne(enterpriseLambdaQueryWrapper);
|
|
- if (null!=userEnterprise){
|
|
|
|
|
|
+ if (null != userEnterprise) {
|
|
userEnterprise.setDepartment(request.getName());
|
|
userEnterprise.setDepartment(request.getName());
|
|
userEnterpriseService.updateById(userEnterprise);
|
|
userEnterpriseService.updateById(userEnterprise);
|
|
|
|
|
|
LambdaQueryWrapper<UserBypassAccount> queryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<UserBypassAccount> queryWrapper = new LambdaQueryWrapper<>();
|
|
- queryWrapper.eq(UserBypassAccount::getDepartmentId,id);
|
|
|
|
- queryWrapper.eq(UserBypassAccount::getEnterpriseId,userEnterprise.getId());
|
|
|
|
|
|
+ queryWrapper.eq(UserBypassAccount::getDepartmentId, id);
|
|
|
|
+ queryWrapper.eq(UserBypassAccount::getEnterpriseId, userEnterprise.getId());
|
|
List<UserBypassAccount> list = userBypassAccountService.list(queryWrapper);
|
|
List<UserBypassAccount> list = userBypassAccountService.list(queryWrapper);
|
|
- if (null!=list&&list.size()>0){
|
|
|
|
|
|
+ if (null != list && list.size() > 0) {
|
|
for (UserBypassAccount userBypassAccount : list) {
|
|
for (UserBypassAccount userBypassAccount : list) {
|
|
userBypassAccount.setDepartment(request.getName());
|
|
userBypassAccount.setDepartment(request.getName());
|
|
userBypassAccountService.updateById(userBypassAccount);
|
|
userBypassAccountService.updateById(userBypassAccount);
|
|
@@ -76,85 +82,73 @@ public class OrganizationDepartmentServiceImpl extends ServiceImpl<OrganizationD
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public CommonResult<?> departUser(String departmentId, String organizationId) {
|
|
public CommonResult<?> departUser(String departmentId, String organizationId) {
|
|
- if (StringUtils.isNotBlank(departmentId)) {
|
|
|
|
- List<UserBypassAccount> list = new ArrayList<>();
|
|
|
|
- String[] split = departmentId.split(",");
|
|
|
|
- LambdaQueryWrapper<OrganizationDepartment> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
- queryWrapper.in(OrganizationDepartment::getId, split);
|
|
|
|
-
|
|
|
|
- List<OrganizationDepartment> departmentList = this.list(queryWrapper);
|
|
|
|
- for (OrganizationDepartment organizationDepartment : departmentList) {
|
|
|
|
-
|
|
|
|
- String organizationId1 = organizationDepartment.getOrganizationId();
|
|
|
|
- String name = organizationDepartment.getName();
|
|
|
|
-
|
|
|
|
- LambdaQueryWrapper<UserEnterprise> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
|
- queryWrapper2.eq(UserEnterprise::getOrganizationId, organizationId1);
|
|
|
|
- UserEnterprise userEnterprise2 = userEnterpriseService.getOne(queryWrapper2);
|
|
|
|
- if (null!=userEnterprise2){
|
|
|
|
- Integer id2 = userEnterprise2.getId();
|
|
|
|
- LambdaQueryWrapper<UserBypassAccount> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
|
- queryWrapper3.eq(UserBypassAccount::getEnterpriseId, id2);
|
|
|
|
- queryWrapper3.eq(UserBypassAccount::getDepartment, name);
|
|
|
|
- queryWrapper3.eq(UserBypassAccount::getIsDelete, 0);
|
|
|
|
- List<UserBypassAccount> list1 = userBypassAccountService.list(queryWrapper3);
|
|
|
|
- for (UserBypassAccount userBypassAccount : list1) {
|
|
|
|
- list.add(userBypassAccount);
|
|
|
|
- }
|
|
|
|
- if (null == list1 || list1.size() == 0) {
|
|
|
|
- LambdaQueryWrapper<UserEnterprise> queryWrapper4 = new LambdaQueryWrapper<>();
|
|
|
|
- queryWrapper4.eq(UserEnterprise::getOrganizationId, organizationId);
|
|
|
|
- UserEnterprise userEnterprise4 = userEnterpriseService.getOne(queryWrapper4);
|
|
|
|
- if (null!=userEnterprise4){
|
|
|
|
- UserBypassAccount userBypassAccount = new UserBypassAccount();
|
|
|
|
- userBypassAccount.setId(userEnterprise4.getId());
|
|
|
|
- userBypassAccount.setEnterpriseId(userEnterprise4.getId());
|
|
|
|
- userBypassAccount.setUserId(userEnterprise4.getUserId());
|
|
|
|
- userBypassAccount.setRealName(userEnterprise4.getRealName());
|
|
|
|
- userBypassAccount.setNickname(userEnterprise4.getNickname());
|
|
|
|
- userBypassAccount.setPhone(userEnterprise4.getPhone());
|
|
|
|
- userBypassAccount.setAvatar(userEnterprise4.getAvatar());
|
|
|
|
- userBypassAccount.setIsDelete(userEnterprise4.getIsDelete());
|
|
|
|
- userBypassAccount.setDepartment(userEnterprise4.getDepartment());
|
|
|
|
- userBypassAccount.setDepartmentId(organizationDepartment.getId());
|
|
|
|
- list.add(userBypassAccount);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
- }
|
|
|
|
- return CommonResult.success(list);
|
|
|
|
- } else if (StringUtils.isNotBlank(organizationId)) {
|
|
|
|
- LambdaQueryWrapper<UserEnterprise> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
- queryWrapper.eq(UserEnterprise::getOrganizationId, organizationId);
|
|
|
|
- UserEnterprise userEnterprise = userEnterpriseService.getOne(queryWrapper);
|
|
|
|
- Integer id = userEnterprise.getId();
|
|
|
|
- LambdaQueryWrapper<UserBypassAccount> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
|
- queryWrapper2.eq(UserBypassAccount::getEnterpriseId, id);
|
|
|
|
- queryWrapper2.eq(UserBypassAccount::getIsDelete, 0);
|
|
|
|
- List<UserBypassAccount> list1 = userBypassAccountService.list(queryWrapper2);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- LambdaQueryWrapper<UserEnterprise> queryWrapper4 = new LambdaQueryWrapper<>();
|
|
|
|
- queryWrapper4.eq(UserEnterprise::getOrganizationId, organizationId);
|
|
|
|
- UserEnterprise userEnterprise4 = userEnterpriseService.getOne(queryWrapper4);
|
|
|
|
- UserBypassAccount userBypassAccount = new UserBypassAccount();
|
|
|
|
- userBypassAccount.setId(userEnterprise4.getId());
|
|
|
|
- userBypassAccount.setEnterpriseId(userEnterprise4.getId());
|
|
|
|
- userBypassAccount.setUserId(userEnterprise4.getUserId());
|
|
|
|
- userBypassAccount.setRealName(userEnterprise4.getRealName());
|
|
|
|
- userBypassAccount.setNickname(userEnterprise4.getNickname());
|
|
|
|
- userBypassAccount.setPhone(userEnterprise4.getPhone());
|
|
|
|
- userBypassAccount.setAvatar(userEnterprise4.getAvatar());
|
|
|
|
- userBypassAccount.setIsDelete(userEnterprise4.getIsDelete());
|
|
|
|
- userBypassAccount.setDepartment(userEnterprise4.getDepartment());
|
|
|
|
- userBypassAccount.setDepartmentId(departmentId);
|
|
|
|
- list1.add(userBypassAccount);
|
|
|
|
|
|
+ String[] split = departmentId.split(",");
|
|
|
|
+ User user = userService.getInfo();
|
|
|
|
+ Integer isEnterpriseUser = user.getIsEnterpriseUser();
|
|
|
|
+ Integer isAllOrders = user.getIsAllOrders();
|
|
|
|
+
|
|
|
|
+ LambdaQueryWrapper<OrganizationDepartmentUser> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper1.eq(OrganizationDepartmentUser::getOrganizationId, organizationId);
|
|
|
|
+ queryWrapper1.in(OrganizationDepartmentUser::getDepartmentId, split);
|
|
|
|
+ List<OrganizationDepartmentUser> list = organizationDepartmentUserService.list(queryWrapper1);
|
|
|
|
+ List<String> ids = list.stream().map(OrganizationDepartmentUser::getDepartmentId).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ LambdaQueryWrapper<UserBypassAccount> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper2.eq(UserBypassAccount::getIsDelete, 0);
|
|
|
|
+ if (ids.size() > 0) {
|
|
|
|
+ queryWrapper2.in(UserBypassAccount::getDepartmentId, ids);
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ List<UserBypassAccount> list1 = userBypassAccountService.list(queryWrapper2);
|
|
|
|
+
|
|
|
|
+ LambdaQueryWrapper<UserEnterprise> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper3.eq(UserEnterprise::getIsDelete, 0);
|
|
|
|
+ queryWrapper3.eq(UserEnterprise::getOrganizationId, organizationId);
|
|
|
|
+ queryWrapper3.eq(UserEnterprise::getOrganizationId, organizationId);
|
|
|
|
+ if (ids.size() > 0) {
|
|
|
|
+ queryWrapper3.in(UserEnterprise::getDepartId, ids);
|
|
|
|
+ }
|
|
|
|
+ List<UserEnterprise> list2 = userEnterpriseService.list(queryWrapper3);
|
|
|
|
+ if (2 == isEnterpriseUser) {
|
|
|
|
+ for (UserEnterprise userEnterprise : list2) {
|
|
|
|
+ UserBypassAccount userBypassAccount = new UserBypassAccount();
|
|
|
|
+ userBypassAccount.setId(userEnterprise.getId());
|
|
|
|
+ userBypassAccount.setEnterpriseId(userEnterprise.getId());
|
|
|
|
+ userBypassAccount.setUserId(userEnterprise.getUserId());
|
|
|
|
+ userBypassAccount.setRealName(userEnterprise.getRealName());
|
|
|
|
+ userBypassAccount.setNickname(userEnterprise.getNickname());
|
|
|
|
+ userBypassAccount.setPhone(userEnterprise.getPhone());
|
|
|
|
+ userBypassAccount.setAvatar(userEnterprise.getAvatar());
|
|
|
|
+ userBypassAccount.setIsDelete(userEnterprise.getIsDelete());
|
|
|
|
+ userBypassAccount.setDepartment(userEnterprise.getDepartment());
|
|
|
|
+ userBypassAccount.setDepartmentId(userEnterprise.getDepartId());
|
|
|
|
+ list1.add(userBypassAccount);
|
|
|
|
+ }
|
|
return CommonResult.success(list1);
|
|
return CommonResult.success(list1);
|
|
|
|
+ } else {
|
|
|
|
+ if (3 == isEnterpriseUser && 1 == isAllOrders) {
|
|
|
|
+ for (UserEnterprise userEnterprise : list2) {
|
|
|
|
+ UserBypassAccount userBypassAccount = new UserBypassAccount();
|
|
|
|
+ userBypassAccount.setId(userEnterprise.getId());
|
|
|
|
+ userBypassAccount.setEnterpriseId(userEnterprise.getId());
|
|
|
|
+ userBypassAccount.setUserId(userEnterprise.getUserId());
|
|
|
|
+ userBypassAccount.setRealName(userEnterprise.getRealName());
|
|
|
|
+ userBypassAccount.setNickname(userEnterprise.getNickname());
|
|
|
|
+ userBypassAccount.setPhone(userEnterprise.getPhone());
|
|
|
|
+ userBypassAccount.setAvatar(userEnterprise.getAvatar());
|
|
|
|
+ userBypassAccount.setIsDelete(userEnterprise.getIsDelete());
|
|
|
|
+ userBypassAccount.setDepartment(userEnterprise.getDepartment());
|
|
|
|
+ userBypassAccount.setDepartmentId(userEnterprise.getDepartId());
|
|
|
|
+ list1.add(userBypassAccount);
|
|
|
|
+ }
|
|
|
|
+ return CommonResult.success(list1);
|
|
|
|
+ } else {
|
|
|
|
+ return CommonResult.success(list1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- return CommonResult.success("部门下用户为空");
|
|
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|