|
|
@@ -1,5 +1,6 @@
|
|
|
package com.usoftchina.uas.office.qywx.service;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.usoftchina.qywx.sdk.AddrBookSdk;
|
|
|
import com.usoftchina.qywx.sdk.dto.CreateDepartmentReq;
|
|
|
import com.usoftchina.qywx.sdk.dto.GetDepartmentListResp;
|
|
|
@@ -7,6 +8,8 @@ import com.usoftchina.qywx.sdk.dto.GetSimpleUserListResp;
|
|
|
import com.usoftchina.qywx.sdk.dto.UpdateDepartmentReq;
|
|
|
import com.usoftchina.uas.office.qywx.entity.HrOrg;
|
|
|
import com.usoftchina.uas.office.service.AbstractService;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.dao.EmptyResultDataAccessException;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -23,6 +26,8 @@ public class UasOrgService extends AbstractService {
|
|
|
@Autowired
|
|
|
private AddrBookSdk addrBookSdk;
|
|
|
|
|
|
+ private final Logger logger = LoggerFactory.getLogger(UasOrgService.class);
|
|
|
+
|
|
|
public HrOrg getById(Integer id) {
|
|
|
return queryForBean("select * from HrOrg where or_statuscode<>'DISABLE' and or_qywx is not null and or_id=?", HrOrg.class,
|
|
|
id);
|
|
|
@@ -53,19 +58,23 @@ public class UasOrgService extends AbstractService {
|
|
|
public void sync(HrOrg org) {
|
|
|
if (null != org.getOr_qywx() && !addrBookSdk.isReadonly()) {
|
|
|
if (null == org.getOr_subof() || 0 == org.getOr_subof()) {
|
|
|
- // 修改部门
|
|
|
- addrBookSdk.updateDepartment(new UpdateDepartmentReq()
|
|
|
+ UpdateDepartmentReq req = new UpdateDepartmentReq()
|
|
|
.id(org.getOr_qywx())
|
|
|
.name(org.getOr_name())
|
|
|
- .parent(0));
|
|
|
+ .parent(0);
|
|
|
+ logger.debug("update qywx department " + JSON.toJSONString(req.build()));
|
|
|
+ // 修改部门
|
|
|
+ addrBookSdk.updateDepartment(req);
|
|
|
} else {
|
|
|
HrOrg parentOrg = getById(org.getOr_subof());
|
|
|
if (null != parentOrg) {
|
|
|
- // 修改部门
|
|
|
- addrBookSdk.updateDepartment(new UpdateDepartmentReq()
|
|
|
+ UpdateDepartmentReq req = new UpdateDepartmentReq()
|
|
|
.id(org.getOr_qywx())
|
|
|
.name(org.getOr_name())
|
|
|
- .parent(parentOrg.getOr_qywx()));
|
|
|
+ .parent(parentOrg.getOr_qywx());
|
|
|
+ logger.debug("update qywx department " + JSON.toJSONString(req.build()));
|
|
|
+ // 修改部门
|
|
|
+ addrBookSdk.updateDepartment(req);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
@@ -79,11 +88,13 @@ public class UasOrgService extends AbstractService {
|
|
|
}
|
|
|
}
|
|
|
if (!addrBookSdk.isReadonly()) {
|
|
|
- // 修改部门名称
|
|
|
- addrBookSdk.updateDepartment(new UpdateDepartmentReq()
|
|
|
+ UpdateDepartmentReq req = new UpdateDepartmentReq()
|
|
|
.id(rootDept.getId())
|
|
|
.name(org.getOr_name())
|
|
|
- .parent(0));
|
|
|
+ .parent(0);
|
|
|
+ logger.debug("update qywx department " + JSON.toJSONString(req.build()));
|
|
|
+ // 修改部门名称
|
|
|
+ addrBookSdk.updateDepartment(req);
|
|
|
}
|
|
|
updateOrgQywxId(org, rootDept.getId());
|
|
|
} else {
|
|
|
@@ -99,17 +110,21 @@ public class UasOrgService extends AbstractService {
|
|
|
}
|
|
|
if (null != dept) {
|
|
|
if (!addrBookSdk.isReadonly()) {
|
|
|
- // 修改部门名称
|
|
|
- addrBookSdk.updateDepartment(new UpdateDepartmentReq()
|
|
|
+ UpdateDepartmentReq req = new UpdateDepartmentReq()
|
|
|
.id(dept.getId())
|
|
|
- .name(org.getOr_name()));
|
|
|
+ .name(org.getOr_name());
|
|
|
+ logger.debug("update qywx department " + JSON.toJSONString(req.build()));
|
|
|
+ // 修改部门名称
|
|
|
+ addrBookSdk.updateDepartment(req);
|
|
|
}
|
|
|
updateOrgQywxId(org, dept.getId());
|
|
|
} else {
|
|
|
if (!addrBookSdk.isReadonly()) {
|
|
|
- Integer departmentId = addrBookSdk.createDepartment(new CreateDepartmentReq()
|
|
|
+ CreateDepartmentReq req = new CreateDepartmentReq()
|
|
|
.name(org.getOr_name())
|
|
|
- .parent(parentOrg.getOr_qywx()));
|
|
|
+ .parent(parentOrg.getOr_qywx());
|
|
|
+ logger.debug("create qywx department " + JSON.toJSONString(req.build()));
|
|
|
+ Integer departmentId = addrBookSdk.createDepartment(req);
|
|
|
updateOrgQywxId(org, departmentId);
|
|
|
}
|
|
|
}
|