|
|
@@ -0,0 +1,40 @@
|
|
|
+package com.usoftchina.uas.office.dingtalk.task;
|
|
|
+
|
|
|
+import com.usoftchina.uas.office.dingtalk.service.UasEmployeeService;
|
|
|
+import com.usoftchina.uas.office.dingtalk.service.UasOrgService;
|
|
|
+import com.usoftchina.uas.office.entity.DataCenter;
|
|
|
+import com.usoftchina.uas.office.jdbc.DataSourceHolder;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author yingp
|
|
|
+ * @date 2020/5/14
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class DingAddrBookTask {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UasEmployeeService uasEmployeeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UasOrgService uasOrgService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 清除在uas有绑定,而在钉钉已删除的部门、人员
|
|
|
+ */
|
|
|
+ @Scheduled(cron = "0 0 23 * * ? ")
|
|
|
+ public void clearInvalid() {
|
|
|
+ DataCenter dataCenter = DataCenter.INSTANCE;
|
|
|
+ if (null != dataCenter.getUsername() && null != dataCenter.getPassword() && null != dataCenter.getUrl()) {
|
|
|
+ try {
|
|
|
+ DataSourceHolder.set(dataCenter);
|
|
|
+ uasOrgService.clearInvalidBinding();
|
|
|
+ uasEmployeeService.clearInvalidBinding();
|
|
|
+ } finally {
|
|
|
+ DataSourceHolder.clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|