|
@@ -16,6 +16,7 @@ import com.tzld.piaoquan.wecom.utils.LarkRobotUtil;
|
|
|
import com.tzld.piaoquan.wecom.utils.page.Page;
|
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -193,11 +194,18 @@ public class WeComUserDataJob {
|
|
|
}
|
|
|
List<Staff> staffList = staffMapper.selectByExample(staffExample);
|
|
|
for (Staff staff : staffList) {
|
|
|
- List<String> externalUserIds = getUserList(staff.getCarrierId(), corp.getId());
|
|
|
- if (CollectionUtils.isEmpty(externalUserIds)) {
|
|
|
+ List<String> existExternalUserIds = getUserList(staff.getCarrierId(), corp.getId());
|
|
|
+ List<String> allExternalUserIds = staffWithUserMapper.selectExternalUserIdByStaffId(staff.getId());
|
|
|
+ allExternalUserIds.removeAll(existExternalUserIds);
|
|
|
+ if (!CollectionUtils.isEmpty(allExternalUserIds)) {
|
|
|
+ for (String delExternalUserId : allExternalUserIds) {
|
|
|
+ userService.delStaffWithUser(delExternalUserId, staff.getCarrierId(), System.currentTimeMillis());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isEmpty(existExternalUserIds)) {
|
|
|
continue;
|
|
|
}
|
|
|
- for (String externalUserId : externalUserIds) {
|
|
|
+ for (String externalUserId : existExternalUserIds) {
|
|
|
userService.insertStaffWithUser(externalUserId, staff, corp.getId());
|
|
|
}
|
|
|
}
|