Browse Source

人员资料更新事件

yingp 4 năm trước cách đây
mục cha
commit
025d0f385f

+ 27 - 2
uas-office-core/src/main/java/com/usoftchina/uas/office/jdbc/SchemaUtils.java

@@ -49,7 +49,8 @@ public class SchemaUtils {
             builder.add(newColumn(column.getName())
                     .type(column.getType())
                     .notNull(column.isNotNull())
-                    .primaryKey(column.isPrimaryKey()));
+                    .primaryKey(column.isPrimaryKey())
+                    .defaultValue(column.getDefaultValue()));
         });
         if (null != table.getIndices()) {
             table.getIndices().forEach(index -> {
@@ -145,6 +146,7 @@ public class SchemaUtils {
         private String type;
         private boolean notNull;
         private boolean primaryKey;
+        private Object defaultValue;
 
         public String getName() {
             return name;
@@ -177,6 +179,14 @@ public class SchemaUtils {
         public void setPrimaryKey(boolean primaryKey) {
             this.primaryKey = primaryKey;
         }
+
+        public Object getDefaultValue() {
+            return defaultValue;
+        }
+
+        public void setDefaultValue(Object defaultValue) {
+            this.defaultValue = defaultValue;
+        }
     }
 
     private static class ColumnBuilder {
@@ -184,6 +194,7 @@ public class SchemaUtils {
         private String type;
         private boolean notNull;
         private boolean primaryKey;
+        private Object defaultValue;
 
         public ColumnBuilder(String name) {
             this.name = name;
@@ -214,6 +225,11 @@ public class SchemaUtils {
             return this;
         }
 
+        public ColumnBuilder defaultValue(Object defaultValue) {
+            this.defaultValue = defaultValue;
+            return this;
+        }
+
         private void add(TableBuilder builder, JdbcTemplate jdbcTemplate) {
             create(builder, jdbcTemplate, false);
         }
@@ -232,13 +248,22 @@ public class SchemaUtils {
         @Override
         public String toString() {
             StringBuffer str = new StringBuffer(name).append(" ");
-            str.append(StringUtils.nvl(type, "varchar2(255)"));
+            String colType = StringUtils.nvl(type, "varchar2(255)");
+            str.append(colType);
             if (notNull) {
                 str.append(" not null");
             }
             if (primaryKey) {
                 str.append(" primary key");
             }
+            if (null != defaultValue) {
+                str.append("default ");
+                if (colType.toLowerCase().startsWith("varchar")) {
+                    str.append("'").append(defaultValue).append("'");
+                } else {
+                    str.append(defaultValue);
+                }
+            }
             return str.toString();
         }
     }

+ 10 - 0
uas-office-dingtalk-server/src/main/resources/erp_schema.json

@@ -76,5 +76,15 @@
         "type": "varchar2(64)"
       }
     ]
+  },
+  {
+    "name": "empsjobs",
+    "columns": [
+      {
+        "name": "job_scope",
+        "type": "number(1)",
+        "defaultValue": 0
+      }
+    ]
   }
 ]

+ 9 - 0
uas-office-dingtalk/src/main/java/com/usoftchina/uas/office/dingtalk/entity/Employee.java

@@ -19,6 +19,7 @@ public class Employee {
     private String em_csshortname;
     private String em_class;
     private String em_ding;
+    private String em_statuscode;
 
     public Integer getEm_id() {
         return em_id;
@@ -115,4 +116,12 @@ public class Employee {
     public void setEm_ding(String em_ding) {
         this.em_ding = em_ding;
     }
+
+    public String getEm_statuscode() {
+        return em_statuscode;
+    }
+
+    public void setEm_statuscode(String em_statuscode) {
+        this.em_statuscode = em_statuscode;
+    }
 }

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

@@ -55,4 +55,24 @@ public class UasEmployeeListener {
             addrBookSdk.deleteUser("Uas", employee.getEm_ding());
         }
     }
+
+    /**
+     * uas人员资料修改(审核状态下,关键信息直接修改),修改企业微信通讯录人员
+     */
+    @UasEventListener(caller = "Employeemanager", operation = "UPDATE")
+    public void onEmployeeUpdate(UasEvent event) {
+        if (!event.getMaster().equals(DataCenter.INSTANCE.getUsername())) {
+            return;
+        }
+        Employee employee = employeeService.getById(Integer.parseInt(event.getKey().toString()));
+        if (null != employee && "AUDITED".equals(employee.getEm_statuscode())) {
+            if ("离职".equals(employee.getEm_class())) {
+                if (null != employee.getEm_ding()) {
+                    addrBookSdk.deleteUser("Uas", employee.getEm_ding());
+                }
+            } else {
+                employeeService.sync(employee);
+            }
+        }
+    }
 }

+ 10 - 0
uas-office-qywx-server/src/main/resources/erp_schema.json

@@ -85,5 +85,15 @@
         "type": "varchar2(50)"
       }
     ]
+  },
+  {
+    "name": "empsjobs",
+    "columns": [
+      {
+        "name": "job_scope",
+        "type": "number(1)",
+        "defaultValue": 0
+      }
+    ]
   }
 ]

+ 9 - 0
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/entity/Employee.java

@@ -22,6 +22,7 @@ public class Employee {
     private String em_csshortname;
     private String em_class;
     private String em_qywx;
+    private String em_statuscode;
 
     public Integer getEm_id() {
         return em_id;
@@ -118,4 +119,12 @@ public class Employee {
     public void setEm_qywx(String em_qywx) {
         this.em_qywx = em_qywx;
     }
+
+    public String getEm_statuscode() {
+        return em_statuscode;
+    }
+
+    public void setEm_statuscode(String em_statuscode) {
+        this.em_statuscode = em_statuscode;
+    }
 }

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

@@ -70,4 +70,24 @@ public class UasEmployeeListener {
             addrBookSdk.deleteUser(employee.getEm_qywx());
         }
     }
+
+    /**
+     * uas人员资料修改(审核状态下,关键信息直接修改),修改企业微信通讯录人员
+     */
+    @UasEventListener(caller = "Employeemanager", operation = "UPDATE")
+    public void onEmployeeUpdate(UasEvent event) {
+        if (!addrBookSdk.enabled() || !event.getMaster().equals(DataCenter.INSTANCE.getUsername())) {
+            return;
+        }
+        Employee employee = employeeService.getById(Integer.parseInt(event.getKey().toString()));
+        if (null != employee && "AUDITED".equals(employee.getEm_statuscode())) {
+            if ("离职".equals(employee.getEm_class())) {
+                if (null != employee.getEm_qywx() && !addrBookSdk.isReadonly()) {
+                    addrBookSdk.deleteUser(employee.getEm_qywx());
+                }
+            } else {
+                employeeService.sync(employee);
+            }
+        }
+    }
 }

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

@@ -113,7 +113,7 @@ public class UasEmployeeService extends AbstractService {
 
     public List<HrOrg> getOrgListByEmployee(Employee employee) {
         // 只需考虑所属组织已同步的情况
-        return queryForBeanList("select * from hrorg where or_statuscode<>'DISABLE' and or_qywx is not null and (or_id=? or exists (select 1 from empsjobs where org_id=or_id and emp_id=?))",
+        return queryForBeanList("select * from hrorg where or_statuscode<>'DISABLE' and or_qywx is not null and (or_id=? or exists (select 1 from empsjobs where org_id=or_id and emp_id=? and nvl(job_scope,0)=0))",
                 HrOrg.class, employee.getEm_defaultorid(), employee.getEm_id());
     }