Browse Source

人事资料同步限制资料中心账套

yingp 6 years ago
parent
commit
e5c9fa6f8d

+ 7 - 0
uas-office-dingtalk/src/main/java/com/usoftchina/uas/office/dingtalk/listener/UasEmployeeListener.java

@@ -4,6 +4,7 @@ import com.usoftchina.dingtalk.sdk.AddrBookSdk;
 import com.usoftchina.uas.office.dingtalk.entity.Employee;
 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;
@@ -26,6 +27,9 @@ public class UasEmployeeListener {
      */
     @UasEventListener(caller = "Employeemanager", operation = "AUDIT")
     public void onEmployeeAudit(UasEvent event) {
+        if (!event.getMaster().equals(DataCenter.INSTANCE.getUsername())) {
+            return;
+        }
         Employee employee = employeeService.getById(Integer.parseInt(event.getKey().toString()));
         if (null != employee) {
             if ("离职".equals(employee.getEm_class())) {
@@ -43,6 +47,9 @@ public class UasEmployeeListener {
      */
     @UasEventListener(caller = "Employeemanager", operation = "DELETE")
     public void onEmployeeDelete(UasEvent event) {
+        if (!event.getMaster().equals(DataCenter.INSTANCE.getUsername())) {
+            return;
+        }
         Employee employee = employeeService.getRemovedById(Integer.parseInt(event.getKey().toString()));
         if (null != employee && null != employee.getEm_ding()) {
             addrBookSdk.deleteUser("Uas", employee.getEm_ding());

+ 7 - 0
uas-office-dingtalk/src/main/java/com/usoftchina/uas/office/dingtalk/listener/UasOrgListener.java

@@ -7,6 +7,7 @@ import com.usoftchina.uas.office.dingtalk.entity.HrOrg;
 import com.usoftchina.uas.office.dingtalk.service.UasEmployeeService;
 import com.usoftchina.uas.office.dingtalk.service.UasOrgService;
 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;
@@ -32,6 +33,9 @@ public class UasOrgListener {
 
     @UasEventListener(caller = "HrOrg", operation = {"DELETE",  "BANNED"})
     public void onOrgDelete(UasEvent event) {
+        if (!event.getMaster().equals(DataCenter.INSTANCE.getUsername())) {
+            return;
+        }
         HrOrg org = null;
         if ("DELETE".equals(event.getOperation())) {
             org = orgService.getRemovedById(Integer.parseInt(event.getKey().toString()));
@@ -48,6 +52,9 @@ public class UasOrgListener {
 
     @UasEventListener(caller = "HrOrg", operation = {"SAVE", "UPDATE", "RESBANNED"})
     public void onOrgSave(UasEvent event) {
+        if (!event.getMaster().equals(DataCenter.INSTANCE.getUsername())) {
+            return;
+        }
         HrOrg org = orgService.getById(Integer.parseInt(event.getKey().toString()));
         if (null != org) {
             orgService.sync(org);