|
@@ -1,19 +1,11 @@
|
|
|
package org.fouram.service;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
import org.fouram.core.base.service.BaseService;
|
|
|
-import org.fouram.core.plugin.weixin.cp.util.WXCpUserUtil;
|
|
|
-import org.fouram.entity.SapUser;
|
|
|
import org.fouram.enums.DelFlagEnum;
|
|
|
-import org.fouram.enums.SapUserResultEnum;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import me.chanjar.weixin.cp.bean.WxCpUser;
|
|
|
-
|
|
|
@Service
|
|
|
public class SyncSapUserToWxService extends BaseService {
|
|
|
|
|
@@ -21,19 +13,23 @@ public class SyncSapUserToWxService extends BaseService {
|
|
|
private WxUserService wxUserService;
|
|
|
@Autowired
|
|
|
private SapUserService sapUserService;
|
|
|
+ @Autowired
|
|
|
+ private WxDepartService wxDepartService;
|
|
|
|
|
|
@Transactional
|
|
|
public void taskBiz() throws Exception {
|
|
|
- // 1.更新微信用户
|
|
|
+ // 更新微信部门
|
|
|
+ wxDepartService.saveDeparts();
|
|
|
+ // 更新微信用户
|
|
|
wxUserService.saveUsers();
|
|
|
- // 2.更新所有数据无效
|
|
|
+ // 更新所有数据无效
|
|
|
sapUserService.updateAllDelFlag(DelFlagEnum.UNABLE.getCode());
|
|
|
- // 3.保存SAP用户数据
|
|
|
+ // 保存SAP用户数据
|
|
|
sapUserService.saveOrUpdateSapUsers();
|
|
|
- // 4.根据SAP用户数据情况更新result字段
|
|
|
- sapUserService.updateResultByCondition();
|
|
|
- // 5.更新用户头像
|
|
|
- this.updateAvatar();
|
|
|
+ // 更新异常情况,敏感数据、入职
|
|
|
+ sapUserService.updateAbnormalResult();
|
|
|
+ // 更新用户头像
|
|
|
+ sapUserService.updateAvatars();
|
|
|
|
|
|
// 部分数据插入微信未成功,处理数据后,重新插入
|
|
|
// List<SapUser> unSyncSapUsers = sapUserService.selectUnSyncList();
|
|
@@ -44,18 +40,6 @@ public class SyncSapUserToWxService extends BaseService {
|
|
|
// LoggerUtil.info("同步结束->" + DateUtil.getTime());
|
|
|
}
|
|
|
|
|
|
- // 更新用户头像
|
|
|
- private void updateAvatar() throws Exception {
|
|
|
- List<SapUser> successUsers = sapUserService.selectListByResult(SapUserResultEnum.SUCCESS.getCode());
|
|
|
- for (SapUser sapUser : successUsers) {
|
|
|
- WxCpUser user = WXCpUserUtil.getByIdOrEmail(sapUser.getPersonId(), sapUser.getEmail());
|
|
|
- if (user != null && StringUtils.isNotBlank(user.getAvatar())) {
|
|
|
- sapUser.setAvatar(user.getAvatar());
|
|
|
- sapUserService.updateAvatar(sapUser);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// 发送禁用企业微信账号信息
|
|
|
// private void sendQuitUserMsg() throws Exception {
|
|
|
// List<SapUser> unableSapUsers = sapUserService.selectListByDelFlag(DelFlagEnum.UNABLE.getCode());
|