Commit 90c57853 by 徐高华

标签同步

parent 6fab5b6e
......@@ -141,14 +141,23 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
@Override
public ServiceResponse syncTagToQywx(String wxEnterpriseId, String enterpriseId, QywxTagInfoDTO infoDTO, List<QywxTagItemDTO> items) {
logger.info("标签同步到企业微信,wxEnterpriseId={},memberTagId={}",wxEnterpriseId,infoDTO.getMemberTagId());
String memberTagId = infoDTO.getMemberTagId() ;
logger.info("标签同步到企业微信,wxEnterpriseId={},memberTagId={}",wxEnterpriseId,memberTagId);
List<MemberTagItemDTO> tagItems = memberTagApiService.queryMemberTagItem(memberTagId);
items = tagItems.stream().map(item -> {
QywxTagItemDTO mid = new QywxTagItemDTO();
mid.setMemberTagItemId(item.getTagItemId());
mid.setQywxTagKey(item.getTagItemId());
mid.setQywxTagName(item.getTagItemName());
return mid;
}).collect(Collectors.toList());
ServiceResponse ret = new ServiceResponse();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
// 判断更新
List<String> needDelList = new ArrayList<>() ;
List<QywxTagItemDTO> needAddList = new ArrayList<>() ;
List<String> memberTagItemIdList = items.stream().map(o->o.getMemberTagItemId()).collect(Collectors.toList()); ;
List<TabQywxTagRelation> relationList = this.qywxTagRelationMapper.listByMemberTagId(wxEnterpriseId,infoDTO.getMemberTagId()) ;
List<TabQywxTagRelation> relationList = this.qywxTagRelationMapper.listByMemberTagId(wxEnterpriseId,memberTagId) ;
if(CollectionUtils.isNotEmpty(relationList)) {
String hbTagId = relationList.get(0).getQywxTagId() ;
TabQywxTag tag = this.qywxTagService.getQywxTagByQywxTagId(wxEnterpriseId,hbTagId) ;
......@@ -162,15 +171,17 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
infoDTO.setQywxGroupKey(qwGroupKey);
// 需要删除的标签值
for(TabQywxTagRelation relation : relationList) {
String memberTagId = relation.getTagItemId() ;
if(!memberTagItemIdList.contains(memberTagId)) {
String memberItemTagId = relation.getTagItemId() ;
if(!memberTagItemIdList.contains(memberItemTagId)) {
this.qywxTagRelationMapper.deleteByPrimaryKey(relation.getQywxTagRelationId()) ;
String hbTagItemId = relation.getQywxTagItemId() ;
TabQywxTagItem tagItem = tagItemMap.get(hbTagItemId) ;
this.qywxTagService.delQywxTagItemById(wxEnterpriseId,hbTagItemId) ;
TabQywxTagItem tagItem = tagItemMap.get(hbTagItemId) ;
if(null != tagItem) {
needDelList.add(tagItem.getQywxTagKey()) ;
}
}
}
if(CollectionUtils.isNotEmpty(needDelList)) {
this.qywxSuiteApiService.delCorpTag(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), needDelList, 1, qwDTO.isSelf(),qwDTO.getUrlHost());
}
......@@ -260,8 +271,6 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
/**
* 调用企业微信接口 保存标签
*
* @param wxEnterpriseDTO
* @param infoDTO
* @param items
* @return
......
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