|
@@ -362,13 +362,18 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|
|
SysDept dept = convertToSysDept(importDTO);
|
|
SysDept dept = convertToSysDept(importDTO);
|
|
|
|
|
|
|
|
// 根据父组织编码和名称查询父部门 ID
|
|
// 根据父组织编码和名称查询父部门 ID
|
|
|
- SysDept parentId = deptMapper.selectDeptByInfo(importDTO.getParentDeptCode(), importDTO.getParentDeptName());
|
|
|
|
|
|
|
+ SysDept parentId = null;
|
|
|
|
|
+ if (StringUtils.isNotBlank(importDTO.getParentDeptCode()) && StringUtils.isNotBlank(importDTO.getParentDeptName())) {
|
|
|
|
|
+ parentId = deptMapper.selectDeptByInfo(importDTO.getParentDeptCode(), importDTO.getParentDeptName());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 设置父部门 ID,如果为 null 则默认为顶级部门(0)
|
|
// 设置父部门 ID,如果为 null 则默认为顶级部门(0)
|
|
|
dept.setParentId(parentId == null ? 0L : parentId.getDeptId());
|
|
dept.setParentId(parentId == null ? 0L : parentId.getDeptId());
|
|
|
|
|
|
|
|
- // 检查部门名称是否唯一
|
|
|
|
|
- if (null != deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId())) {
|
|
|
|
|
|
|
+ if (null != deptMapper.checkDeptCodeUnique(dept.getDeptCode())) {
|
|
|
|
|
+ failureNum++;
|
|
|
|
|
+ failureMsg.append(String.format("%1$s、部门已存在;", dept.getDeptCode()));
|
|
|
|
|
+ } else if (null != deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId())) {
|
|
|
failureNum++;
|
|
failureNum++;
|
|
|
failureMsg.append(String.format("%1$s、部门已存在;", dept.getDeptName()));
|
|
failureMsg.append(String.format("%1$s、部门已存在;", dept.getDeptName()));
|
|
|
} else {
|
|
} else {
|