|
@@ -1,6 +1,7 @@
|
|
|
package com.zbkj.service.service.impl;
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.zbkj.common.model.admin.SystemAdmin;
|
|
|
import com.zbkj.common.model.organization.Organization;
|
|
@@ -8,22 +9,19 @@ 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.OrganizationVO;
|
|
|
+import com.zbkj.common.model.user.UserBypassAccount;
|
|
|
import com.zbkj.common.model.user.UserEnterprise;
|
|
|
+import com.zbkj.common.result.CommonResult;
|
|
|
import com.zbkj.service.dao.OrganizationDao;
|
|
|
import com.zbkj.service.dao.OrganizationDeparementDao;
|
|
|
import com.zbkj.service.dao.OrganizationDeparementUserDao;
|
|
|
-import com.zbkj.service.service.OrganizationDepartmentService;
|
|
|
-import com.zbkj.service.service.OrganizationDepartmentUserService;
|
|
|
-import com.zbkj.service.service.OrganizationService;
|
|
|
-import com.zbkj.service.service.UserEnterpriseService;
|
|
|
+import com.zbkj.service.service.*;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.UUID;
|
|
|
+import javax.xml.transform.Result;
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
|
@Service
|
|
@@ -41,6 +39,8 @@ public class OrganizationServiceImpl extends ServiceImpl<OrganizationDao, Organi
|
|
|
private OrganizationDepartmentUserService organizationDepartmentUserService;
|
|
|
@Autowired
|
|
|
private UserEnterpriseService userEnterpriseService;
|
|
|
+ @Autowired
|
|
|
+ private UserBypassAccountService userBypassAccountService;
|
|
|
|
|
|
@Override
|
|
|
public void saveMain(OrganizationVO request, SystemAdmin systemAdmin) {
|
|
@@ -93,8 +93,8 @@ public class OrganizationServiceImpl extends ServiceImpl<OrganizationDao, Organi
|
|
|
Organization organization = new Organization();
|
|
|
BeanUtils.copyProperties(request, organization);
|
|
|
this.updateById(organization);
|
|
|
- List<UserEnterprise> userEnterprises= userEnterpriseService.selectByOrganId(id);
|
|
|
- if (null!=userEnterprises&&userEnterprises.size()>0){
|
|
|
+ List<UserEnterprise> userEnterprises = userEnterpriseService.selectByOrganId(id);
|
|
|
+ if (null != userEnterprises && userEnterprises.size() > 0) {
|
|
|
for (UserEnterprise userEnterpris : userEnterprises) {
|
|
|
String name = request.getName();
|
|
|
userEnterpris.setEnterpriseName(name);
|
|
@@ -104,7 +104,6 @@ public class OrganizationServiceImpl extends ServiceImpl<OrganizationDao, Organi
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
List<OrganizationDepartmentVO> department = request.getChildren();
|
|
|
for (OrganizationDepartmentVO departmentVO : department) {
|
|
|
organizationDepartmentService.removeById(departmentVO.getId());
|
|
@@ -175,21 +174,63 @@ public class OrganizationServiceImpl extends ServiceImpl<OrganizationDao, Organi
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void deleteDepartment(String id) {
|
|
|
+ public CommonResult<?> deleteDepartment(String id) {
|
|
|
+ OrganizationDepartment organizationDepartment = organizationDeparementDao.selectById(id);
|
|
|
+ String departmentName = organizationDepartment.getName();
|
|
|
+ String organizationId = organizationDepartment.getOrganizationId();
|
|
|
+
|
|
|
+ //企业账户
|
|
|
+ LambdaQueryWrapper<UserEnterprise> enterpriseLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ enterpriseLambdaQueryWrapper.eq(UserEnterprise::getOrganizationId,organizationId);
|
|
|
+ enterpriseLambdaQueryWrapper.eq(UserEnterprise::getDepartment,departmentName);
|
|
|
+ List<UserEnterprise> userEnterprises = userEnterpriseService.list(enterpriseLambdaQueryWrapper);
|
|
|
+ if (null != userEnterprises && userEnterprises.size() > 0){
|
|
|
+ return CommonResult.failed("该部门已关联企业账户,请解除关联后进行删除");
|
|
|
+ }
|
|
|
+
|
|
|
+ //企业子账户
|
|
|
+ LambdaQueryWrapper<UserBypassAccount> userBypassAccountLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ userBypassAccountLambdaQueryWrapper.eq(UserBypassAccount::getDepartmentId,id);
|
|
|
+ List<UserBypassAccount> userBypassAccounts = userBypassAccountService.list(userBypassAccountLambdaQueryWrapper);
|
|
|
+ if (null != userBypassAccounts && userBypassAccounts.size() > 0){
|
|
|
+ return CommonResult.failed("该部门已关联企业子账户,请解除关联后进行删除");
|
|
|
+ }
|
|
|
|
|
|
organizationDeparementDao.deleteById(id);
|
|
|
List<OrganizationDepartmentUser> organizationDepartmentUsers = organizationDeparementUserDao.selectMainBydepartmentId(id);
|
|
|
for (OrganizationDepartmentUser user : organizationDepartmentUsers) {
|
|
|
organizationDeparementUserDao.deleteById(user.getId());
|
|
|
}
|
|
|
+ return CommonResult.success("操作成功");
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void deleteUser(String id) {
|
|
|
-
|
|
|
+ public CommonResult deleteUser(String id) {
|
|
|
+ OrganizationDepartmentUser organizationDepartmentUser = organizationDeparementUserDao.selectById(id);
|
|
|
+ String organizationId = organizationDepartmentUser.getOrganizationId();
|
|
|
+ String departmentId = organizationDepartmentUser.getDepartmentId();
|
|
|
+ OrganizationDepartment organizationDepartment = organizationDeparementDao.selectById(departmentId);
|
|
|
+ String departmentName = organizationDepartment.getName();
|
|
|
+ //企业账户
|
|
|
+ LambdaQueryWrapper<UserEnterprise> enterpriseLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ enterpriseLambdaQueryWrapper.eq(UserEnterprise::getOrganizationId,organizationId);
|
|
|
+ enterpriseLambdaQueryWrapper.eq(UserEnterprise::getDepartment,departmentName);
|
|
|
+ enterpriseLambdaQueryWrapper.eq(UserEnterprise::getRealName,organizationDepartmentUser.getName());
|
|
|
+ List<UserEnterprise> userEnterprises = userEnterpriseService.list(enterpriseLambdaQueryWrapper);
|
|
|
+ if (null != userEnterprises && userEnterprises.size() > 0){
|
|
|
+ return CommonResult.failed("该用户已关联企业账户,请解除关联后进行删除");
|
|
|
+ }
|
|
|
+ //企业子账户
|
|
|
+ LambdaQueryWrapper<UserBypassAccount> userBypassAccountLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ userBypassAccountLambdaQueryWrapper.eq(UserBypassAccount::getDepartmentId,departmentId);
|
|
|
+ userBypassAccountLambdaQueryWrapper.eq(UserBypassAccount::getRealName,organizationDepartmentUser.getName());
|
|
|
+ List<UserBypassAccount> userBypassAccounts = userBypassAccountService.list(userBypassAccountLambdaQueryWrapper);
|
|
|
+ if (null != userBypassAccounts && userBypassAccounts.size() > 0){
|
|
|
+ return CommonResult.failed("该用户已关联企业子账户,请解除关联后进行删除");
|
|
|
+ }
|
|
|
organizationDeparementUserDao.deleteById(id);
|
|
|
-
|
|
|
+ return CommonResult.success("操作成功");
|
|
|
|
|
|
}
|
|
|
|
|
@@ -202,5 +243,28 @@ public class OrganizationServiceImpl extends ServiceImpl<OrganizationDao, Organi
|
|
|
request.setUpdateBy(systemAdmin.getRealName());
|
|
|
organizationDao.insert(request);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult<?> deleteOrgan(String id) {
|
|
|
+ List<UserEnterprise> userEnterprises = userEnterpriseService.selectByOrganId(id);
|
|
|
+ if (null != userEnterprises && userEnterprises.size() > 0){
|
|
|
+ return CommonResult.failed("该企业已关联企业账户,请解除关联后进行删除");
|
|
|
+ }
|
|
|
+ ArrayList<String> strings = new ArrayList<>();
|
|
|
+ LambdaQueryWrapper<OrganizationDepartment> departmentLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ departmentLambdaQueryWrapper.eq(OrganizationDepartment::getOrganizationId,id);
|
|
|
+ List<OrganizationDepartment> departmentList = organizationDeparementDao.selectList(departmentLambdaQueryWrapper);
|
|
|
+ for (OrganizationDepartment organizationDepartment : departmentList) {
|
|
|
+ strings.add(organizationDepartment.getId());
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<UserBypassAccount> accountLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ accountLambdaQueryWrapper.in(UserBypassAccount::getDepartmentId,strings);
|
|
|
+ List<UserBypassAccount> userBypassAccounts = userBypassAccountService.list(accountLambdaQueryWrapper);
|
|
|
+ if (null != userBypassAccounts && userBypassAccounts.size() > 0){
|
|
|
+ return CommonResult.failed("该企业已关联企业子账户,请解除关联后进行删除");
|
|
|
+ }
|
|
|
+ return CommonResult.success("操作成功");
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|