Commit 24881d29 by 徐高华

同步通讯录优化

parent 81db3fa3
...@@ -30,6 +30,9 @@ public interface StaffApiService { ...@@ -30,6 +30,9 @@ public interface StaffApiService {
*/ */
ServiceResponse getWxSaveNew(String userId, String wxEnterpriseId); ServiceResponse getWxSaveNew(String userId, String wxEnterpriseId);
// 是否是同步通讯录,如果是不用每次都查询开启联系我的列表
ServiceResponse getWxSaveNew(String userId, String wxEnterpriseId ,boolean isSyncDepart);
/** /**
* 新增成员 * 新增成员
* *
......
...@@ -526,9 +526,10 @@ public class DealSyncOperationApiServiceImpl implements DealSyncOperationApiServ ...@@ -526,9 +526,10 @@ public class DealSyncOperationApiServiceImpl implements DealSyncOperationApiServ
return page; return page;
} }
// 同步通讯录
@Override @Override
public String dealQywxDepartment(String taskId, String wxEnterpriseId) { public String dealQywxDepartment(String taskId, String wxEnterpriseId) {
logger.info("同步通讯录开始={},taskId={}",wxEnterpriseId,taskId);
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ; WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(qwDTO.getWxEnterpriseId(), SecretTypeEnum.CUSTOMIZED_APP.getVal()); SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(qwDTO.getWxEnterpriseId(), SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) { if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
......
...@@ -248,8 +248,12 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -248,8 +248,12 @@ public class StaffApiServiceImpl implements StaffApiService {
} }
} }
@Override
public ServiceResponse getWxSaveNew(String wxUserId, String wxEnterpriseId) { public ServiceResponse getWxSaveNew(String wxUserId, String wxEnterpriseId) {
return this.getWxSaveNew(wxUserId,wxEnterpriseId,false) ;
}
@Override
public ServiceResponse getWxSaveNew(String wxUserId, String wxEnterpriseId,boolean isSyncDepart) {
ServiceResponse res = new ServiceResponse(); ServiceResponse res = new ServiceResponse();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
if (null == qwDTO) { if (null == qwDTO) {
...@@ -348,7 +352,7 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -348,7 +352,7 @@ public class StaffApiServiceImpl implements StaffApiService {
staff.setQrCode(qr_code); staff.setQrCode(qr_code);
} }
//判断成员是否开启联系我 //判断成员是否开启联系我
if (this.openConcatFlag(wxEnterpriseId,wxUserId)) { if (this.openConcatFlag(wxEnterpriseId,wxUserId,isSyncDepart)) {
logger.info("成员开启联系我"); logger.info("成员开启联系我");
staff.setOpenConcatFlag(1); staff.setOpenConcatFlag(1);
} }
...@@ -369,15 +373,28 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -369,15 +373,28 @@ public class StaffApiServiceImpl implements StaffApiService {
res.setResult(staff.getStaffName()); res.setResult(staff.getStaffName());
return res; return res;
} }
private Boolean openConcatFlag(String wxEnterpriseId,String userId){ private Boolean openConcatFlag(String wxEnterpriseId,String userId , boolean isSyncDepart){
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
//企微已经开启联系我
List<String> wxUserIdsList = null ; List<String> wxUserIdsList = null ;
//企微已经开启联系我
Boolean flag = false; Boolean flag = false;
if(qwDTO.isSelf()) { String key = "get_follow_user_list:"+wxEnterpriseId ;
wxUserIdsList = qywxUserApiService.listCorpExternalUserSelf(qwDTO.getDkCorpid(), qwDTO.getSelfSecret(),qwDTO.getUrlHost()); if(isSyncDepart) {
}else { Object o = RedisUtil.getCache(key) ;
wxUserIdsList = qywxUserApiService.listCorpExternalUser(qwDTO.getThirdCorpid(), config.getWxSuiteid()); if(null != o) {
logger.info("从缓存中获取联系我列表={}",wxEnterpriseId);
wxUserIdsList = (List<String>) o ;
}
}
if(null == wxUserIdsList) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
if(qwDTO.isSelf()) {
wxUserIdsList = qywxUserApiService.listCorpExternalUserSelf(qwDTO.getDkCorpid(), qwDTO.getSelfSecret(),qwDTO.getUrlHost());
}else {
wxUserIdsList = qywxUserApiService.listCorpExternalUser(qwDTO.getThirdCorpid(), config.getWxSuiteid());
}
if(isSyncDepart) {
RedisUtil.setCache(key,wxUserIdsList);
}
} }
if (CollUtil.isNotEmpty(wxUserIdsList) && wxUserIdsList.contains(userId)) { if (CollUtil.isNotEmpty(wxUserIdsList) && wxUserIdsList.contains(userId)) {
logger.info("成员开启联系我"); logger.info("成员开启联系我");
......
...@@ -61,7 +61,7 @@ public class QywxStaffSyncOperation implements BaseSyncOperation { ...@@ -61,7 +61,7 @@ public class QywxStaffSyncOperation implements BaseSyncOperation {
try { try {
String taskId = dataPre.getTaskId() ; String taskId = dataPre.getTaskId() ;
String wxUserId = dealParamMqDTO.getData() ; String wxUserId = dealParamMqDTO.getData() ;
ServiceResponse response = staffApiService.getWxSaveNew(wxUserId, dataPre.getWxEnterpriseId()); ServiceResponse response = staffApiService.getWxSaveNew(wxUserId, dataPre.getWxEnterpriseId(),true);
if (response.getCode() != 1) { if (response.getCode() != 1) {
dealFlag = false; dealFlag = false;
reason = response.getMessage(); reason = response.getMessage();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment