|
@@ -1118,7 +1118,6 @@ public class WeiXinCorpController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if ("update_party".equals(changeType)) {
|
|
} else if ("update_party".equals(changeType)) {
|
|
-
|
|
|
|
//变更部门,可能是名称变化或者父部门变化
|
|
//变更部门,可能是名称变化或者父部门变化
|
|
Integer deptId = jsonObject.getInt("Id");
|
|
Integer deptId = jsonObject.getInt("Id");
|
|
if (wxCorpInfo.getSaasSyncContact() == 1) {
|
|
if (wxCorpInfo.getSaasSyncContact() == 1) {
|
|
@@ -1141,10 +1140,14 @@ public class WeiXinCorpController {
|
|
//发生父部门的结构变化了
|
|
//发生父部门的结构变化了
|
|
Department department = departmentMapper.selectOne(new QueryWrapper<Department>().eq("company_id", wxCorpInfo.getCompanyId()).eq("corpwx_deptid", deptId));
|
|
Department department = departmentMapper.selectOne(new QueryWrapper<Department>().eq("company_id", wxCorpInfo.getCompanyId()).eq("corpwx_deptid", deptId));
|
|
if (department != null) {
|
|
if (department != null) {
|
|
- Department parentDept = departmentMapper.selectOne(new QueryWrapper<Department>().eq("company_id", wxCorpInfo.getCompanyId()).eq("corpwx_deptid", parentDeptId));
|
|
|
|
- if (parentDept != null) {
|
|
|
|
- department.setSuperiorId(parentDept.getDepartmentId());
|
|
|
|
- departmentMapper.updateById(department);
|
|
|
|
|
|
+ if (parentDeptId == 1) {//是一级部门
|
|
|
|
+ departmentMapper.updateNullSuperior(department.getDepartmentId());
|
|
|
|
+ } else {
|
|
|
|
+ Department parentDept = departmentMapper.selectOne(new QueryWrapper<Department>().eq("company_id", wxCorpInfo.getCompanyId()).eq("corpwx_deptid", parentDeptId));
|
|
|
|
+ if (parentDept != null) {
|
|
|
|
+ department.setSuperiorId(parentDept.getDepartmentId());
|
|
|
|
+ departmentMapper.updateById(department);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2282,10 +2285,17 @@ public class WeiXinCorpController {
|
|
} else {
|
|
} else {
|
|
//
|
|
//
|
|
System.out.println("找到了已有部门== name=="+curDept.getDepartmentName());
|
|
System.out.println("找到了已有部门== name=="+curDept.getDepartmentName());
|
|
- if (parentId != 1 && curDept.getCorpwxDeptpid() == null) {
|
|
|
|
- //有父部门需要更新
|
|
|
|
- curDept.setCorpwxDeptpid(parentId);
|
|
|
|
- departmentMapper.updateById(curDept);
|
|
|
|
|
|
+ if (parentId == 1) {
|
|
|
|
+ if (curDept.getSuperiorId() != null) {
|
|
|
|
+ //变更到一级部门了,此处不依赖于其他部门是否存在,可以直接更新
|
|
|
|
+ departmentMapper.updateNullSuperior(curDept.getDepartmentId());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (curDept.getCorpwxDeptpid() == null) {
|
|
|
|
+ //有父部门需要更新
|
|
|
|
+ curDept.setCorpwxDeptpid(parentId);
|
|
|
|
+ departmentMapper.updateById(curDept);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//获取部门下的人员
|
|
//获取部门下的人员
|