Browse Source

增加参数配置,离职人员时支持仅禁用人员

zhouy 2 years ago
parent
commit
bcbbfc784c

+ 10 - 1
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/listener/UasEmpTurnoverListener.java

@@ -1,10 +1,12 @@
 package com.usoftchina.uas.office.qywx.listener;
 
 import com.usoftchina.qywx.sdk.AddrBookSdk;
+import com.usoftchina.qywx.sdk.dto.UpdateUserReq;
 import com.usoftchina.uas.office.dto.UasEvent;
 import com.usoftchina.uas.office.entity.DataCenter;
 import com.usoftchina.uas.office.listener.UasEventListener;
 import com.usoftchina.uas.office.qywx.entity.Employee;
+import com.usoftchina.uas.office.qywx.service.UasConfigService;
 import com.usoftchina.uas.office.qywx.service.UasEmpTurnoverService;
 import com.usoftchina.uas.office.qywx.service.UasEmployeeService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -25,6 +27,9 @@ public class UasEmpTurnoverListener {
     @Autowired
     private UasEmployeeService employeeService;
 
+    @Autowired
+    private UasConfigService configService;
+
     /**
      * uas人员离职,删除企业微信通讯录人员
      */
@@ -37,7 +42,11 @@ public class UasEmpTurnoverListener {
         if (null != emCode) {
             Employee employee = employeeService.getByCode(emCode);
             if (null != employee && null != employee.getEm_qywx() && !addrBookSdk.isReadonly()) {
-                addrBookSdk.deleteUser(employee.getEm_qywx());
+               if (configService.isTrueConfig("DisableQywx","Turnover")) {
+                   addrBookSdk.updateUser(new UpdateUserReq().userId(employee.getEm_qywx()).enable(false));
+               } else {
+                   addrBookSdk.deleteUser(employee.getEm_qywx());
+               }
             }
         }
     }

+ 29 - 0
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/service/UasConfigService.java

@@ -0,0 +1,29 @@
+package com.usoftchina.uas.office.qywx.service;
+
+import com.usoftchina.uas.office.qywx.entity.HrOrg;
+import com.usoftchina.uas.office.service.AbstractService;
+import com.usoftchina.uas.office.util.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author: zhouy
+ * @date: 2023/1/11 17:34
+ * @desc: 配置中心
+ */
+@Service
+public class UasConfigService extends AbstractService {
+
+    public boolean isTrueConfig(String code, String caller) {
+       caller = StringUtils.hasText(caller) ? caller : "SYS";
+       int config = 0;
+       try {
+           config = queryForObject("select data from configs where code=? and caller=?",
+                   Integer.class, code , caller);
+        }catch (Exception e) {
+
+       }
+       return config == 1;
+    }
+}