Эх сурвалжийг харах

2022年8月通讯录升级企业微信V2分支

zhouy 3 жил өмнө
parent
commit
2585e5f6ba

+ 17 - 0
qywx-sdk/src/main/java/com/usoftchina/qywx/sdk/AddrBookSdk.java

@@ -115,7 +115,9 @@ public class AddrBookSdk extends BaseSdk {
      *
      *
      * @param departmentId 部门ID
      * @param departmentId 部门ID
      * @param fetchChild   是否递归获取子部门下面的成员:1-递归获取,0-只获取本部门
      * @param fetchChild   是否递归获取子部门下面的成员:1-递归获取,0-只获取本部门
+     * 企业微信升级,方法不可用
      */
      */
+    @Deprecated
     public List<GetSimpleUserListResp.User> getSimpleUserList(Integer departmentId, boolean fetchChild) {
     public List<GetSimpleUserListResp.User> getSimpleUserList(Integer departmentId, boolean fetchChild) {
         ResponseEntity<GetSimpleUserListResp> resp = restTemplate.getForEntity(baseUrl + "/cgi-bin/user/simplelist?access_token={access_token}&department_id={department_id}&fetch_child={fetch_child}",
         ResponseEntity<GetSimpleUserListResp> resp = restTemplate.getForEntity(baseUrl + "/cgi-bin/user/simplelist?access_token={access_token}&department_id={department_id}&fetch_child={fetch_child}",
                 GetSimpleUserListResp.class,
                 GetSimpleUserListResp.class,
@@ -131,8 +133,10 @@ public class AddrBookSdk extends BaseSdk {
      *
      *
      * @param departmentId 部门ID
      * @param departmentId 部门ID
      * @param fetchChild   是否递归获取子部门下面的成员:1-递归获取,0-只获取本部门
      * @param fetchChild   是否递归获取子部门下面的成员:1-递归获取,0-只获取本部门
+     * 企业微信升级,方法不可用
      * @return
      * @return
      */
      */
+    @Deprecated
     public List<GetUserListResp.User> getUserList(Integer departmentId, boolean fetchChild) {
     public List<GetUserListResp.User> getUserList(Integer departmentId, boolean fetchChild) {
         ResponseEntity<GetUserListResp> resp = restTemplate.getForEntity(baseUrl + "/cgi-bin/user/list?access_token={access_token}&department_id={department_id}&fetch_child={fetch_child}",
         ResponseEntity<GetUserListResp> resp = restTemplate.getForEntity(baseUrl + "/cgi-bin/user/list?access_token={access_token}&department_id={department_id}&fetch_child={fetch_child}",
                 GetUserListResp.class,
                 GetUserListResp.class,
@@ -331,4 +335,17 @@ public class AddrBookSdk extends BaseSdk {
         assertOK(resp);
         assertOK(resp);
         return resp.getBody();
         return resp.getBody();
     }
     }
+    /**
+     * 获取用户UserID
+     *
+     * @param mobile 手机号
+     * */
+    public GetUserInfoResp getUserInfoByMobile(String mobile) {
+        ResponseEntity<GetUserInfoResp> resp = restTemplate.getForEntity(baseUrl + "/cgi-bin/user/getuserid?access_token={access_token}&mobile={mobile}",
+                GetUserInfoResp.class,
+                new ModelMap("access_token", getAccessToken(ADDRESS_BOOK_AGENT_CODE))
+                        .addAttribute("mobile", mobile));
+        assertOK(resp);
+        return resp.getBody();
+    }
 }
 }

+ 1 - 1
uas-office-dingtalk-server/src/main/java/com/usoftchina/uas/office/dingtalk/config/WebMvcConfig.java

@@ -1,4 +1,4 @@
-package com.usoftchina.uas.office.dingtalk.config;
+package com.usoftchina..office.dingtalk.config;
 
 
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpHeaders;

+ 13 - 0
uas-office-qywx-server/src/test/java/com/usoftchina/uas/office/qywx/Test.java

@@ -0,0 +1,13 @@
+package com.usoftchina.uas.office.qywx;
+
+/**
+ * @author: zhouy
+ * @date: 2022/7/20 14:27
+ * @desc:
+ */
+public class Test {
+    public static void main(String[] args) {
+        String url = "http://erp.yitoa.com:8888/ERP/uasMobile/#/uasEntry/";
+        System.out.println(url.substring(url.indexOf("/",1),url.indexOf("/",2)));
+    }
+}

+ 4 - 2
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/controller/QywxAuthController.java

@@ -64,7 +64,9 @@ public class QywxAuthController {
         try {
         try {
             DataSourceHolder.set(dataCenter);
             DataSourceHolder.set(dataCenter);
             Employee employee = employeeService.getByQywx(infoResp.getUserId());
             Employee employee = employeeService.getByQywx(infoResp.getUserId());
-            if (null == employee) {
+           /**
+            * 企业微信限制不允许通过userID返回详细人员信息
+           if (null == employee) {
                 GetUserResp userResp = addrBookSdk.getUser(infoResp.getUserId());
                 GetUserResp userResp = addrBookSdk.getUser(infoResp.getUserId());
                 if (StringUtils.hasText(userResp.getMobile())) {
                 if (StringUtils.hasText(userResp.getMobile())) {
                     employee = employeeService.getByMobile(userResp.getMobile());
                     employee = employeeService.getByMobile(userResp.getMobile());
@@ -76,7 +78,7 @@ public class QywxAuthController {
                     employee.setEm_qywx(infoResp.getUserId());
                     employee.setEm_qywx(infoResp.getUserId());
                     employeeService.setQywx(employee);
                     employeeService.setQywx(employee);
                 }
                 }
-            }
+            }*/
             if (null == employee) {
             if (null == employee) {
                 return new ModelAndView("/error");
                 return new ModelAndView("/error");
             }
             }

+ 2 - 2
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/listener/UasEmployeeListener.java

@@ -38,7 +38,7 @@ public class UasEmployeeListener {
                     addrBookSdk.deleteUser(employee.getEm_qywx());
                     addrBookSdk.deleteUser(employee.getEm_qywx());
                 }
                 }
             } else {
             } else {
-                employeeService.sync(employee);
+                employeeService.sync_UpGrade(employee);
             }
             }
         }
         }
     }
     }
@@ -86,7 +86,7 @@ public class UasEmployeeListener {
                     addrBookSdk.deleteUser(employee.getEm_qywx());
                     addrBookSdk.deleteUser(employee.getEm_qywx());
                 }
                 }
             } else {
             } else {
-                employeeService.sync(employee);
+                employeeService.sync_UpGrade(employee);
             }
             }
         }
         }
     }
     }

+ 61 - 0
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/service/UasEmployeeService.java

@@ -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);
+        }
+
+    }
 }
 }

+ 1 - 1
uas-office-web/wxuasapproval/src/components/approvalAdd/FormInput.jsx

@@ -339,7 +339,7 @@ export default class FormInput extends Component {
       modalOpen: false,
       modalOpen: false,
     })
     })
 
 
-    prompt('拜访单位', '请完善单位名称', [
+    prompt('完善信息', '请完善准确名称', [
       {
       {
         text: '跳过此步', onPress: value => {
         text: '跳过此步', onPress: value => {
           billModel.value = location.title;
           billModel.value = location.title;