|
@@ -65,7 +65,11 @@ public class UasOrgService extends AbstractService {
|
|
|
* 同步 uas组织资料 -> 企业微信部门资料
|
|
* 同步 uas组织资料 -> 企业微信部门资料
|
|
|
*/
|
|
*/
|
|
|
public void sync(HrOrg org) {
|
|
public void sync(HrOrg org) {
|
|
|
- if (null != org.getOr_qywx() && !addrBookSdk.isReadonly()) {
|
|
|
|
|
|
|
+ if(addrBookSdk.isReadonly()){
|
|
|
|
|
+ logger.debug("update qywx department addrBookSdk isReadonly");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (null != org.getOr_qywx()) {
|
|
|
if (null == org.getOr_subof() || 0 == org.getOr_subof()) {
|
|
if (null == org.getOr_subof() || 0 == org.getOr_subof()) {
|
|
|
UpdateDepartmentReq req = new UpdateDepartmentReq()
|
|
UpdateDepartmentReq req = new UpdateDepartmentReq()
|
|
|
.id(org.getOr_qywx())
|
|
.id(org.getOr_qywx())
|
|
@@ -87,66 +91,27 @@ public class UasOrgService extends AbstractService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- List<GetDepartmentSimpleListResp.Department> departmentList = addrBookSdk.getSimpleDepartmentList();
|
|
|
|
|
- if (null == org.getOr_subof() || 0 == org.getOr_subof()) {
|
|
|
|
|
- GetDepartmentSimpleListResp.Department rootDept = null;
|
|
|
|
|
- for (GetDepartmentSimpleListResp.Department department : departmentList) {
|
|
|
|
|
- if (department.getParentid() == 0) {
|
|
|
|
|
- rootDept = department;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (!addrBookSdk.isReadonly()) {
|
|
|
|
|
- UpdateDepartmentReq req = new UpdateDepartmentReq()
|
|
|
|
|
- .id(rootDept.getId())
|
|
|
|
|
- .name(org.getOr_name())
|
|
|
|
|
- .parent(0);
|
|
|
|
|
- logger.debug("update qywx department " + JSON.toJSONString(req.build()));
|
|
|
|
|
- // 修改部门名称
|
|
|
|
|
- addrBookSdk.updateDepartment(req);
|
|
|
|
|
- }
|
|
|
|
|
- updateOrgQywxId(org, rootDept.getId());
|
|
|
|
|
- } else {
|
|
|
|
|
- try {
|
|
|
|
|
- // 只需考虑父级组织已同步的情况
|
|
|
|
|
- HrOrg parentOrg = getBindById(org.getOr_subof());
|
|
|
|
|
-// GetDepartmentListResp.Department dept = null;
|
|
|
|
|
-// for (GetDepartmentListResp.Department department : departmentList) {
|
|
|
|
|
-// if (department.getParentid().equals(parentOrg.getOr_qywx())
|
|
|
|
|
-// && department.getName().equals(org.getOr_name())
|
|
|
|
|
-// ) {
|
|
|
|
|
-// dept = department;
|
|
|
|
|
-// break;
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
- /* if (null != dept) {
|
|
|
|
|
- if (!addrBookSdk.isReadonly()) {
|
|
|
|
|
- UpdateDepartmentReq req = new UpdateDepartmentReq()
|
|
|
|
|
- .id(dept.getId())
|
|
|
|
|
- .name(org.getOr_name());
|
|
|
|
|
- logger.debug("update qywx department " + JSON.toJSONString(req.build()));
|
|
|
|
|
- // 修改部门名称
|
|
|
|
|
- addrBookSdk.updateDepartment(req);
|
|
|
|
|
- // 存在旧的已禁用的同名组织
|
|
|
|
|
- jdbcTemplate.update("update HrOrg set or_qywx=null where or_qywx=? and or_statuscode='DISABLE'", dept.getId());
|
|
|
|
|
- }
|
|
|
|
|
- updateOrgQywxId(org, dept.getId());
|
|
|
|
|
- } else {*/
|
|
|
|
|
- //如果上级没有对接不触发对接操作
|
|
|
|
|
- if (!addrBookSdk.isReadonly()
|
|
|
|
|
- && parentOrg.getOr_qywx() != null && !parentOrg.getOr_qywx().equals(0)) {
|
|
|
|
|
- CreateDepartmentReq req = new CreateDepartmentReq()
|
|
|
|
|
- .name(org.getOr_name())
|
|
|
|
|
- .parent(parentOrg.getOr_qywx());
|
|
|
|
|
- logger.debug("create qywx department " + JSON.toJSONString(req.build()));
|
|
|
|
|
- Integer departmentId = addrBookSdk.createDepartment(req);
|
|
|
|
|
- updateOrgQywxId(org, departmentId);
|
|
|
|
|
|
|
+ int subof = (org.getOr_subof() == null) ? 0:org.getOr_subof();
|
|
|
|
|
+ int parentId = 0;
|
|
|
|
|
+ if(subof>0){
|
|
|
|
|
+ HrOrg parentOrg = getBindById(subof);
|
|
|
|
|
+ if(parentOrg!=null){
|
|
|
|
|
+ parentId = (parentOrg.getOr_qywx() == null)?0:parentOrg.getOr_qywx();
|
|
|
|
|
+ if(parentId == 0){
|
|
|
|
|
+ logger.debug("create qywx department Or_subof:"+subof+" not exists qywx");
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
-// }
|
|
|
|
|
- } catch (EmptyResultDataAccessException e) {
|
|
|
|
|
|
|
+ }else {//如果上级没有对接不触发对接操作
|
|
|
|
|
+ logger.debug("create qywx department Or_subof:"+subof+" not exists qywx");
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ CreateDepartmentReq req = new CreateDepartmentReq()
|
|
|
|
|
+ .name(org.getOr_name())
|
|
|
|
|
+ .parent(parentId);
|
|
|
|
|
+ logger.debug("create qywx department " + JSON.toJSONString(req.build()));
|
|
|
|
|
+ Integer departmentId = addrBookSdk.createDepartment(req);
|
|
|
|
|
+ updateOrgQywxId(org, departmentId);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|