|
@@ -3,6 +3,7 @@ package com.usoftchina.uas.office.qywx.service;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.usoftchina.qywx.sdk.AddrBookSdk;
|
|
import com.usoftchina.qywx.sdk.AddrBookSdk;
|
|
|
import com.usoftchina.qywx.sdk.dto.CreateUserReq;
|
|
import com.usoftchina.qywx.sdk.dto.CreateUserReq;
|
|
|
|
|
+import com.usoftchina.qywx.sdk.dto.GetUserInfoResp;
|
|
|
import com.usoftchina.qywx.sdk.dto.GetUserListResp;
|
|
import com.usoftchina.qywx.sdk.dto.GetUserListResp;
|
|
|
import com.usoftchina.qywx.sdk.dto.UpdateUserReq;
|
|
import com.usoftchina.qywx.sdk.dto.UpdateUserReq;
|
|
|
import com.usoftchina.uas.office.qywx.entity.Employee;
|
|
import com.usoftchina.uas.office.qywx.entity.Employee;
|
|
@@ -380,6 +381,7 @@ public class UasEmployeeService extends AbstractService {
|
|
|
/**
|
|
/**
|
|
|
* 同步单个 uas人员资料 -> 企业微信成员资料
|
|
* 同步单个 uas人员资料 -> 企业微信成员资料
|
|
|
*/
|
|
*/
|
|
|
|
|
+ @Deprecated
|
|
|
public void sync(Employee employee) {
|
|
public void sync(Employee employee) {
|
|
|
employee.setEm_mobile(StringUtils.getValidMobile(employee.getEm_mobile()));
|
|
employee.setEm_mobile(StringUtils.getValidMobile(employee.getEm_mobile()));
|
|
|
employee.setEm_email(StringUtils.getValidEmail(employee.getEm_email()));
|
|
employee.setEm_email(StringUtils.getValidEmail(employee.getEm_email()));
|
|
@@ -421,4 +423,63 @@ public class UasEmployeeService extends AbstractService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 同步单个 uas人员资料 -> 企业微信成员资料
|
|
|
|
|
+ */
|
|
|
|
|
+ public void sync_UpGrade(Employee employee) {
|
|
|
|
|
+ employee.setEm_mobile(StringUtils.getValidMobile(employee.getEm_mobile()));
|
|
|
|
|
+ employee.setEm_email(StringUtils.getValidEmail(employee.getEm_email()));
|
|
|
|
|
+ employee.setEm_tel(StringUtils.getValidTelephone(employee.getEm_tel()));
|
|
|
|
|
+ if (StringUtils.isEmpty(employee.getEm_mobile()) && StringUtils.isEmpty(employee.getEm_email())) {
|
|
|
|
|
+ if (null != employee.getEm_qywx() && !addrBookSdk.isReadonly()) {
|
|
|
|
|
+ // 手机号和邮箱均为空,不符合微信要求,账号先封禁
|
|
|
|
|
+ addrBookSdk.updateUser(new UpdateUserReq().userId(employee.getEm_qywx()).enable(false));
|
|
|
|
|
+ logger.debug("disable qywx user " + employee.getEm_qywx() + ", because of " + JSON.toJSONString(employee));
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ GetUserInfoResp getUserInfoResp = addrBookSdk.getUserInfoByMobile(employee.getEm_mobile());
|
|
|
|
|
+ if(StringUtils.hasText(getUserInfoResp.getUserId())){
|
|
|
|
|
+ //--人员资料存在
|
|
|
|
|
+ if ("离职".equals(employee.getEm_class())) {
|
|
|
|
|
+ addrBookSdk.deleteUser(getUserInfoResp.getUserId());
|
|
|
|
|
+ logger.debug("delete qywx user " + employee.getEm_code() + ", because of 人员类型:离职" );
|
|
|
|
|
+ employee.setEm_qywx(null);
|
|
|
|
|
+ setQywx(employee);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //--更新人员信息
|
|
|
|
|
+ UpdateUserReq req = new UpdateUserReq();
|
|
|
|
|
+ if (StringUtils.hasText(employee.getEm_name())) {
|
|
|
|
|
+ req.name(employee.getEm_name());
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StringUtils.hasText(employee.getEm_mobile())) {
|
|
|
|
|
+ req.mobile(employee.getEm_mobile());
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StringUtils.hasText(employee.getEm_email())) {
|
|
|
|
|
+ req.email(employee.getEm_email());
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StringUtils.hasText(employee.getEm_tel())) {
|
|
|
|
|
+ req.telephone(employee.getEm_tel());
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StringUtils.hasText(employee.getEm_csshortname())){
|
|
|
|
|
+ req.address(employee.getEm_csshortname());
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StringUtils.hasText(employee.getEm_sex())){
|
|
|
|
|
+ UpdateUserReq.Gender gender = "男".equals(employee.getEm_sex()) ? UpdateUserReq.Gender.MALE : UpdateUserReq.Gender.FEMALE;
|
|
|
|
|
+ req.gender(gender);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StringUtils.hasText(employee.getEm_position())){
|
|
|
|
|
+ req.position(employee.getEm_position());
|
|
|
|
|
+ }
|
|
|
|
|
+ addrBookSdk.updateUser(new UpdateUserReq().userId(employee.getEm_qywx()).enable(true));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //--创建人员
|
|
|
|
|
+ List<HrOrg> orgList = getOrgListByEmployee(employee);
|
|
|
|
|
+ createUser(employee, orgList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|