|
|
@@ -7,9 +7,13 @@ 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.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @author yingp
|
|
|
* @date 2020/4/10
|
|
|
@@ -24,7 +28,7 @@ public class UasEmpTurnoverListener {
|
|
|
|
|
|
@Autowired
|
|
|
private UasEmployeeService employeeService;
|
|
|
-
|
|
|
+ private final Logger logger = LoggerFactory.getLogger(UasEmpTurnoverListener.class);
|
|
|
/**
|
|
|
* uas人员离职,删除企业微信通讯录人员
|
|
|
*/
|
|
|
@@ -33,12 +37,33 @@ public class UasEmpTurnoverListener {
|
|
|
if (!addrBookSdk.enabled() || !event.getMaster().equals(DataCenter.INSTANCE.getUsername())) {
|
|
|
return;
|
|
|
}
|
|
|
- String emCode = empTurnoverService.getEmCodeById(Integer.parseInt(event.getKey().toString()));
|
|
|
+ onEmployeeLeaveSingle(Integer.parseInt(event.getKey().toString()));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void onEmployeeLeaveSingle(Integer toid){
|
|
|
+ String emCode = empTurnoverService.getEmCodeById(toid);
|
|
|
if (null != emCode) {
|
|
|
Employee employee = employeeService.getByCode(emCode);
|
|
|
- if (null != employee && null != employee.getEm_qywx() && !addrBookSdk.isReadonly()) {
|
|
|
+ if (null != employee && null != employee.getEm_qywx() && !addrBookSdk.isReadonly()&& employee.getEm_class().equals("离职")) {
|
|
|
+ try {
|
|
|
addrBookSdk.deleteUser(employee.getEm_qywx());
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("onEmployeeLeaveSingle error", e);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @UasEventListener(caller = "TurnoverConfirm!Deal", operation = "UPDATE")
|
|
|
+ public void onEmployeeLeaveFromConfirm(UasEvent event) {
|
|
|
+ if (!addrBookSdk.enabled() || !event.getMaster().equals(DataCenter.INSTANCE.getUsername())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (event.getKey() instanceof List) {
|
|
|
+ List<Integer> toIdList = (List<Integer>) event.getKey();
|
|
|
+ toIdList.forEach(toId -> {
|
|
|
+ onEmployeeLeaveSingle(toId);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|