use of com.bc.pmpheep.back.vo.PmphUserDepartmentVO in project pmph by BCSquad.
the class PmphDepartmentSeviceTest method department.
// 部门对比
@Test
@Rollback(Const.ISROLLBACK)
public void department() {
// 查询现在所有父级部门,
PmphUserDepartmentVO departmentVO = pmphDepartmentService.listPmphDepartment(null);
// 部门总数为28,超过则是多余部门
if (ObjectUtil.notNull(departmentVO) && departmentVO.getSonDepartment().size() > 28) {
for (PmphUserDepartmentVO pmphDepartment : departmentVO.getSonDepartment()) {
// 查询该部门下的所有成员
List<PmphUser> pmphUsers = pmphUserService.listPmphUserByDepartmentId(pmphDepartment.getId());
switch(pmphDepartment.getDpName()) {
case "出版社科室1":
if (ObjectUtil.notNull(pmphUsers)) {
for (PmphUser pmphUser : pmphUsers) {
// 把该部门人员移到人民卫生出版社部门下
pmphUser.setDepartmentId(0L);
pmphUserService.updateUser(pmphUser);
}
}
// 删除多余的部门
pmphDepartmentService.deletePmphDepartmentBatch(pmphDepartment.getId());
break;
case "公司领导":
// 查询该部门下的所有成员
if (ObjectUtil.notNull(pmphUsers)) {
for (PmphUser pmphUser : pmphUsers) {
// 把该部门人员移到人民卫生出版社部门下
pmphUser.setDepartmentId(0L);
pmphUserService.updateUser(pmphUser);
}
}
// 删除多余的部门
pmphDepartmentService.deletePmphDepartmentBatch(pmphDepartment.getId());
break;
case "其他":
// 查询该部门下的所有成员
if (ObjectUtil.notNull(pmphUsers)) {
for (PmphUser pmphUser : pmphUsers) {
// 把该部门人员移到人民卫生出版社部门下
pmphUser.setDepartmentId(0L);
pmphUserService.updateUser(pmphUser);
}
}
// 删除多余的部门
pmphDepartmentService.deletePmphDepartmentBatch(pmphDepartment.getId());
break;
case "农协":
// 查询该部门下的所有成员
if (ObjectUtil.notNull(pmphUsers)) {
for (PmphUser pmphUser : pmphUsers) {
// 把该部门人员移到人民卫生出版社部门下
pmphUser.setDepartmentId(0L);
pmphUserService.updateUser(pmphUser);
}
}
// 删除多余的部门
pmphDepartmentService.deletePmphDepartmentBatch(pmphDepartment.getId());
break;
default:
break;
}
}
}
}
use of com.bc.pmpheep.back.vo.PmphUserDepartmentVO in project pmph by BCSquad.
the class PmphDepartmentServiceImpl method listPmphDepartment.
@Override
public PmphUserDepartmentVO listPmphDepartment(Long id) throws CheckedServiceException {
PmphUserDepartmentVO pmphUserDepartmentVO = new PmphUserDepartmentVO();
if (null == id) {
// 初始化列表
List<PmphUserDepartmentVO> list = pmphDepartmentDao.listPmphDepartment(0L);
pmphUserDepartmentVO = list.get(0);
pmphUserDepartmentVO.setSonDepartment(pmphDepartmentDao.listPmphDepartment(pmphUserDepartmentVO.getId()));
} else {
// 获取当前点击的部门id
List<PmphUserDepartmentVO> list = pmphDepartmentDao.getDepartmentId(id);
pmphUserDepartmentVO = list.get(0);
pmphUserDepartmentVO.setSonDepartment(pmphDepartmentDao.listPmphDepartment(id));
}
return pmphUserDepartmentVO;
}
use of com.bc.pmpheep.back.vo.PmphUserDepartmentVO in project pmph by BCSquad.
the class PmphDepartmentServiceImpl method recursionPmphDepartment.
/**
* 功能描述:使用递归的方法将部门转化为树状图 使用示范:
*
* @param departmentVO
* ids (为后面删除做准备) 父级部门
*/
private void recursionPmphDepartment(PmphUserDepartmentVO pmphUserDepartmentVO, List<Long> ids) {
List<PmphUserDepartmentVO> list = pmphDepartmentDao.listPmphDepartment(pmphUserDepartmentVO.getId());
if (null != list && list.size() > 0) {
pmphUserDepartmentVO.setSonDepartment(list);
pmphUserDepartmentVO.setIsLeaf(false);
for (PmphUserDepartmentVO userDepartmentVO : list) {
ids.add(userDepartmentVO.getId());
recursionPmphDepartment(userDepartmentVO, ids);
}
}
}
use of com.bc.pmpheep.back.vo.PmphUserDepartmentVO in project pmph by BCSquad.
the class PmphDepartmentServiceImpl method deletePmphDepartmentBatch.
@Override
public Integer deletePmphDepartmentBatch(Long id) {
if (null == id) {
throw new CheckedServiceException(CheckedExceptionBusiness.PMPH_DEPARTMENT, CheckedExceptionResult.NULL_PARAM, "主键为空");
}
List<Long> ids = new ArrayList<Long>();
ids.add(id);
recursionPmphDepartment(new PmphUserDepartmentVO(id), ids);
for (Long departmentId : ids) {
if (pmphUserDao.getPmphUserByDepartmentId(departmentId).size() > 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.PMPH_DEPARTMENT, CheckedExceptionResult.ILLEGAL_PARAM, "部门中还有用户,不能删除部门");
}
}
List<PmphUserDepartmentVO> idList = pmphDepartmentDao.getDepartmentId(id);
for (PmphUserDepartmentVO idListVo : idList) {
// 检查是否是子节点
List<PmphUserDepartmentVO> idLists = pmphDepartmentDao.listPmphDepartment(idListVo.getId());
if (idLists.size() > 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.PMPH_DEPARTMENT, CheckedExceptionResult.NULL_PARAM, "部门下还有子部门,不能删除部门");
}
}
return pmphDepartmentDao.deletePmphDepartmentBatch(ids);
}
use of com.bc.pmpheep.back.vo.PmphUserDepartmentVO in project pmph by BCSquad.
the class MigrationPlus method department.
// 清除冗余部门
protected void department() {
// 查询现在所有部门,
PmphUserDepartmentVO departmentVO = pmphDepartmentService.listPmphDepartment(null);
// 部门总数为28,超过则是多余部门
if (ObjectUtil.notNull(departmentVO) && departmentVO.getSonDepartment().size() > 28) {
for (PmphUserDepartmentVO pmphDepartment : departmentVO.getSonDepartment()) {
// 查询该部门下的所有成员
List<PmphUser> pmphUsers = pmphUserService.listPmphUserByDepartmentId(pmphDepartment.getId());
switch(pmphDepartment.getDpName()) {
case "出版社科室1":
if (ObjectUtil.notNull(pmphUsers)) {
for (PmphUser pmphUser : pmphUsers) {
// 把该部门人员移到人民卫生出版社部门下
pmphUser.setDepartmentId(0L);
pmphUserService.updateUser(pmphUser);
}
}
// 删除多余的部门
pmphDepartmentService.deletePmphDepartmentBatch(pmphDepartment.getId());
break;
case "公司领导":
// 查询该部门下的所有成员
if (ObjectUtil.notNull(pmphUsers)) {
for (PmphUser pmphUser : pmphUsers) {
// 把该部门人员移到人民卫生出版社部门下
pmphUser.setDepartmentId(0L);
pmphUserService.updateUser(pmphUser);
}
}
// 删除多余的部门
pmphDepartmentService.deletePmphDepartmentBatch(pmphDepartment.getId());
break;
case "其他":
// 查询该部门下的所有成员
if (ObjectUtil.notNull(pmphUsers)) {
for (PmphUser pmphUser : pmphUsers) {
// 把该部门人员移到人民卫生出版社部门下
pmphUser.setDepartmentId(0L);
pmphUserService.updateUser(pmphUser);
}
}
// 删除多余的部门
pmphDepartmentService.deletePmphDepartmentBatch(pmphDepartment.getId());
break;
case "农协":
// 查询该部门下的所有成员
if (ObjectUtil.notNull(pmphUsers)) {
for (PmphUser pmphUser : pmphUsers) {
// 把该部门人员移到人民卫生出版社部门下
pmphUser.setDepartmentId(0L);
pmphUserService.updateUser(pmphUser);
}
}
// 删除多余的部门
pmphDepartmentService.deletePmphDepartmentBatch(pmphDepartment.getId());
break;
default:
break;
}
}
}
}
Aggregations