|
|
@@ -5,17 +5,16 @@ import cn.hutool.core.lang.tree.Tree;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.jzg.annotation.IgnoreTenant;
|
|
|
-import com.jzg.core.page.HttpResult;
|
|
|
-import com.jzg.exception.SystemException;
|
|
|
+import com.jzg.commons.core.page.HttpResult;
|
|
|
+import com.jzg.commons.exception.SystemException;
|
|
|
import com.jzg.organization.entity.po.SysDept;
|
|
|
import com.jzg.organization.entity.vo.SysDeptVo;
|
|
|
import com.jzg.organization.mapper.SysDeptMapper;
|
|
|
-import com.jzg.organization.service.DeptService;
|
|
|
-import com.jzg.util.AssertionUtils;
|
|
|
-import com.jzg.util.TreeBuildUtils;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
+import com.jzg.organization.service.SysDeptService;
|
|
|
+import com.jzg.commons.util.AssertionUtils;
|
|
|
+import com.jzg.commons.util.TreeBuildUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
@@ -24,8 +23,16 @@ import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
-@Slf4j
|
|
|
-public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements DeptService {
|
|
|
+public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysDeptMapper sysDeptMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int test() {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public SysDeptVo addDept(SysDeptVo sysDeptVo) {
|
|
|
@@ -41,7 +48,7 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
|
|
|
} else if (comlevel.equals("3")) {
|
|
|
AssertionUtils.isStringEmpty(sysDept.getCity(), "三级机构市必填");
|
|
|
number = sysDept.getCity().substring(0, 4);
|
|
|
- String maxId = baseMapper.getMaxId(parentId, sysDeptVo.getDeptType(), comlevel);
|
|
|
+ String maxId = sysDeptMapper.getMaxId(parentId, sysDeptVo.getDeptType(), comlevel);
|
|
|
if (!maxId.equals("0")) {
|
|
|
String substring = maxId.substring(sysDept.getParentId().length() + 1);
|
|
|
int i = Integer.parseInt("1" + substring) + 1;
|
|
|
@@ -52,7 +59,7 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
|
|
|
} else if (comlevel.equals("4")) {
|
|
|
AssertionUtils.isStringEmpty(sysDept.getArea(), "四级机构区必填");
|
|
|
number = sysDept.getArea().substring(0, 6);
|
|
|
- String maxId = baseMapper.getMaxId(parentId, sysDeptVo.getDeptType(), comlevel);
|
|
|
+ String maxId = sysDeptMapper.getMaxId(parentId, sysDeptVo.getDeptType(), comlevel);
|
|
|
if (!maxId.equals("0")) {
|
|
|
String substring = maxId.substring(sysDept.getParentId().length() + 1);
|
|
|
int i = Integer.parseInt("1" + substring) + 1;
|
|
|
@@ -70,7 +77,7 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
|
|
|
deptType = "M";
|
|
|
}
|
|
|
|
|
|
- String maxId = baseMapper.getMaxId(parentId, deptType, comlevel);
|
|
|
+ String maxId = sysDeptMapper.getMaxId(parentId, deptType, comlevel);
|
|
|
if (!maxId.equals("0")) {
|
|
|
String substring = maxId.substring(sysDept.getParentId().length() + 1);
|
|
|
int i = Integer.parseInt("1" + substring) + 1;
|
|
|
@@ -94,7 +101,7 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
|
|
|
if (!ObjectUtils.isEmpty(dept)) {
|
|
|
throw new SystemException("机构编号为:" + dept.getId() + " " + dept.getName() + "已被占用");
|
|
|
}
|
|
|
- SysDept parentDept = baseMapper.selectById(sysDept.getParentId());
|
|
|
+ SysDept parentDept = sysDeptMapper.selectById(sysDept.getParentId());
|
|
|
|
|
|
if (parentDept.getComLevel().equals("5")) {
|
|
|
sysDept.setManagementSource(parentDept.getManagementSource());
|
|
|
@@ -105,7 +112,7 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
|
|
|
qw.eq(SysDept::getDelFlag, 0); // 删除标志为未删除
|
|
|
qw.eq(SysDept::getParentId, sysDept.getParentId()); // 父级部门ID相同
|
|
|
qw.eq(SysDept::getOrderNum, sysDept.getOrderNum()); // 排序号相同
|
|
|
- boolean exists = baseMapper.exists(qw);
|
|
|
+ boolean exists = sysDeptMapper.exists(qw);
|
|
|
|
|
|
if (exists) {
|
|
|
// 如果存在,查询该父级部门下排序号大于当前部门的部门列表
|
|
|
@@ -121,7 +128,6 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
|
|
|
});
|
|
|
}
|
|
|
boolean b = save(sysDept);
|
|
|
- log.info("------------------添加部门成功-----------------------");
|
|
|
AssertionUtils.isSucceed(b, "删除失败");
|
|
|
sysDeptVo.setId(sysDept.getId());
|
|
|
return sysDeptVo;
|
|
|
@@ -135,10 +141,10 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
|
|
|
qw.eq(SysDept::getDelFlag, 0); // 删除标志为未删除
|
|
|
qw.eq(SysDept::getParentId, sysDeptVo.getParentId()); // 父级部门ID相同
|
|
|
qw.eq(SysDept::getOrderNum, sysDeptVo.getOrderNum()); // 排序号相同
|
|
|
- boolean exists = baseMapper.exists(qw);
|
|
|
+ boolean exists = sysDeptMapper.exists(qw);
|
|
|
//不存在则直接修改
|
|
|
if (!exists) {
|
|
|
- baseMapper.updateById(sysDeptVo);
|
|
|
+ sysDeptMapper.updateById(sysDeptVo);
|
|
|
return HttpResult.ok();
|
|
|
}
|
|
|
|
|
|
@@ -164,7 +170,7 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- baseMapper.updateById(sysDeptVo);
|
|
|
+ sysDeptMapper.updateById(sysDeptVo);
|
|
|
}
|
|
|
//向下换位
|
|
|
if (newOrderNum > orderNum) {
|
|
|
@@ -182,10 +188,10 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- baseMapper.updateById(sysDeptVo);
|
|
|
+ sysDeptMapper.updateById(sysDeptVo);
|
|
|
}
|
|
|
if (newOrderNum.equals(orderNum)) {
|
|
|
- baseMapper.updateById(sysDeptVo);
|
|
|
+ sysDeptMapper.updateById(sysDeptVo);
|
|
|
}
|
|
|
return HttpResult.ok();
|
|
|
}
|
|
|
@@ -200,7 +206,7 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
|
|
|
throw new SystemException("机构不存在");
|
|
|
}
|
|
|
sysDept.setLeaderId(sysDeptVo.getLeaderId());
|
|
|
- baseMapper.updateById(sysDept);
|
|
|
+ sysDeptMapper.updateById(sysDept);
|
|
|
}
|
|
|
return HttpResult.ok("批量设置负责人成功。");
|
|
|
}
|
|
|
@@ -221,7 +227,7 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
|
|
|
// throw new SystemException(sysDept.getName() + "机构下还有其他用户请将这些用户删除后,再进行删除");
|
|
|
// }
|
|
|
sysDept.setDelFlag(1);
|
|
|
- baseMapper.updateById(sysDept);
|
|
|
+ sysDeptMapper.updateById(sysDept);
|
|
|
return HttpResult.ok("删除机构成功");
|
|
|
}
|
|
|
|
|
|
@@ -243,7 +249,7 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
|
|
|
// throw new SystemException(sysDept.getName() + "机构下还有其他用户请将这些用户删除后,再进行删除");
|
|
|
// }
|
|
|
sysDept.setDelFlag(1);
|
|
|
- baseMapper.updateById(sysDept);
|
|
|
+ sysDeptMapper.updateById(sysDept);
|
|
|
}
|
|
|
return HttpResult.ok("批量删除机构成功");
|
|
|
}
|
|
|
@@ -263,7 +269,7 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
|
|
|
@Override
|
|
|
public List<Tree<String>> selectDeptTreeList(String systemCode) {
|
|
|
LambdaQueryWrapper<SysDept> lqw = buildQueryWrapper(systemCode);
|
|
|
- List<SysDept> depts = baseMapper.selectDeptList(lqw);
|
|
|
+ List<SysDept> depts = sysDeptMapper.selectDeptList(lqw);
|
|
|
return buildDeptTreeSelect(depts);
|
|
|
}
|
|
|
|