Prechádzať zdrojové kódy

uas人员离职同步

yingp 6 rokov pred
rodič
commit
09b2169ece

+ 44 - 0
uas-office-dingtalk/src/main/java/com/usoftchina/uas/office/dingtalk/listener/UasEmpTurnoverListener.java

@@ -0,0 +1,44 @@
+package com.usoftchina.uas.office.dingtalk.listener;
+
+import com.usoftchina.dingtalk.sdk.AddrBookSdk;
+import com.usoftchina.uas.office.dingtalk.entity.Employee;
+import com.usoftchina.uas.office.dingtalk.service.UasEmpTurnoverService;
+import com.usoftchina.uas.office.dingtalk.service.UasEmployeeService;
+import com.usoftchina.uas.office.dto.UasEvent;
+import com.usoftchina.uas.office.entity.DataCenter;
+import com.usoftchina.uas.office.listener.UasEventListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author yingp
+ * @date 2020/4/10
+ */
+@Component
+public class UasEmpTurnoverListener {
+    @Autowired
+    private AddrBookSdk addrBookSdk;
+
+    @Autowired
+    private UasEmpTurnoverService empTurnoverService;
+
+    @Autowired
+    private UasEmployeeService employeeService;
+
+    /**
+     * uas人员离职,删除企业微信通讯录人员
+     */
+    @UasEventListener(caller = "Turnover", operation = "AUDIT")
+    public void onEmployeeLeave(UasEvent event) {
+        if (!event.getMaster().equals(DataCenter.INSTANCE.getUsername())) {
+            return;
+        }
+        String emCode = empTurnoverService.getEmCodeById(Integer.parseInt(event.getKey().toString()));
+        if (null != emCode) {
+            Employee employee = employeeService.getByCode(emCode);
+            if (null != employee && null != employee.getEm_ding()) {
+                addrBookSdk.deleteUser("Uas", employee.getEm_ding());
+            }
+        }
+    }
+}

+ 17 - 0
uas-office-dingtalk/src/main/java/com/usoftchina/uas/office/dingtalk/service/UasEmpTurnoverService.java

@@ -0,0 +1,17 @@
+package com.usoftchina.uas.office.dingtalk.service;
+
+import com.usoftchina.uas.office.dingtalk.entity.Employee;
+import com.usoftchina.uas.office.service.AbstractService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author yingp
+ * @date 2020/2/16
+ */
+@Service
+public class UasEmpTurnoverService extends AbstractService {
+
+    public String getEmCodeById(Integer id) {
+        return queryForObject("select to_applymancode from Turnover where to_id=?", String.class, id);
+    }
+}

+ 44 - 0
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/listener/UasEmpTurnoverListener.java

@@ -0,0 +1,44 @@
+package com.usoftchina.uas.office.qywx.listener;
+
+import com.usoftchina.qywx.sdk.AddrBookSdk;
+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.UasEmpTurnoverService;
+import com.usoftchina.uas.office.qywx.service.UasEmployeeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author yingp
+ * @date 2020/4/10
+ */
+@Component
+public class UasEmpTurnoverListener {
+    @Autowired
+    private AddrBookSdk addrBookSdk;
+
+    @Autowired
+    private UasEmpTurnoverService empTurnoverService;
+
+    @Autowired
+    private UasEmployeeService employeeService;
+
+    /**
+     * uas人员离职,删除企业微信通讯录人员
+     */
+    @UasEventListener(caller = "Turnover", operation = "AUDIT")
+    public void onEmployeeLeave(UasEvent event) {
+        if (!addrBookSdk.enabled() || !event.getMaster().equals(DataCenter.INSTANCE.getUsername())) {
+            return;
+        }
+        String emCode = empTurnoverService.getEmCodeById(Integer.parseInt(event.getKey().toString()));
+        if (null != emCode) {
+            Employee employee = employeeService.getByCode(emCode);
+            if (null != employee && null != employee.getEm_qywx() && !addrBookSdk.isReadonly()) {
+                addrBookSdk.deleteUser(employee.getEm_qywx());
+            }
+        }
+    }
+}

+ 16 - 0
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/service/UasEmpTurnoverService.java

@@ -0,0 +1,16 @@
+package com.usoftchina.uas.office.qywx.service;
+
+import com.usoftchina.uas.office.service.AbstractService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author yingp
+ * @date 2020/2/16
+ */
+@Service
+public class UasEmpTurnoverService extends AbstractService {
+
+    public String getEmCodeById(Integer id) {
+        return queryForObject("select to_applymancode from Turnover where to_id=?", String.class, id);
+    }
+}