Commit 43bf1d61 by 徐高华

标签同步

parent 138644f4
...@@ -30,14 +30,6 @@ public interface QywxTagApiService { ...@@ -30,14 +30,6 @@ public interface QywxTagApiService {
public ServiceResponse syncTagToQywx(String wxEnterpriseId, String enterpriseId, QywxTagInfoDTO infoDTO, List<QywxTagItemDTO> items); public ServiceResponse syncTagToQywx(String wxEnterpriseId, String enterpriseId, QywxTagInfoDTO infoDTO, List<QywxTagItemDTO> items);
/** /**
* 更新标签同步更新企微侧
* @param enterpriseId
* @param memberTagId
* @return
*/
public com.gic.api.base.commons.ServiceResponse syncTagToQywx(String enterpriseId, String memberTagId);
/**
* 关闭同步 * 关闭同步
* *
* @param wxEnterpriseId * @param wxEnterpriseId
......
...@@ -113,33 +113,6 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -113,33 +113,6 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
} }
@Override @Override
public com.gic.api.base.commons.ServiceResponse syncTagToQywx(String enterpriseId, String memberTagId) {
logger.info("更新企微标签,memberTagId={}",memberTagId);
List<TabQywxTagRelation> relationList = this.qywxTagRelationMapper.listByMemberTagId(null,memberTagId) ;
if(CollectionUtils.isEmpty(relationList)) {
logger.info("标签未同步过企微");
return com.gic.api.base.commons.ServiceResponse.success() ;
}
String wxEnterpriseId = relationList.get(0).getWxEnterpriseId() ;
com.gic.member.tag.api.dto.MemberTagDTO memberTagDTO = memberTagApiService.getMemberTagById(memberTagId);
List<MemberTagItemDTO> tagItems = memberTagApiService.queryMemberTagItem(memberTagId);
QywxTagInfoDTO qywxTagInfoDTO = new QywxTagInfoDTO();
qywxTagInfoDTO.setWxEnterpriseId(wxEnterpriseId);
qywxTagInfoDTO.setMemberTagId(memberTagDTO.getTagId());
qywxTagInfoDTO.setQywxGroupName(memberTagDTO.getTagName());
List<QywxTagItemDTO> 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());
//保存同步
this.syncTagToQywx(wxEnterpriseId,enterpriseId,qywxTagInfoDTO,items);
return com.gic.api.base.commons.ServiceResponse.success() ;
}
@Override
public ServiceResponse syncTagToQywx(String wxEnterpriseId, String enterpriseId, QywxTagInfoDTO infoDTO, List<QywxTagItemDTO> items) { public ServiceResponse syncTagToQywx(String wxEnterpriseId, String enterpriseId, QywxTagInfoDTO infoDTO, List<QywxTagItemDTO> items) {
String memberTagId = infoDTO.getMemberTagId() ; String memberTagId = infoDTO.getMemberTagId() ;
logger.info("标签同步到企业微信,wxEnterpriseId={},memberTagId={}",wxEnterpriseId,memberTagId); logger.info("标签同步到企业微信,wxEnterpriseId={},memberTagId={}",wxEnterpriseId,memberTagId);
...@@ -154,9 +127,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -154,9 +127,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
ServiceResponse ret = new ServiceResponse(); ServiceResponse ret = new ServiceResponse();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ; WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
// 判断更新 // 判断更新
List<String> needDelList = new ArrayList<>() ;
List<QywxTagItemDTO> needAddList = 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,memberTagId) ; List<TabQywxTagRelation> relationList = this.qywxTagRelationMapper.listByMemberTagId(wxEnterpriseId,memberTagId) ;
if(CollectionUtils.isNotEmpty(relationList)) { if(CollectionUtils.isNotEmpty(relationList)) {
String hbTagId = relationList.get(0).getQywxTagId() ; String hbTagId = relationList.get(0).getQywxTagId() ;
...@@ -165,26 +136,8 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -165,26 +136,8 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
logger.info("已经存在企微标签,进行更新处理={}",qwGroupKey); logger.info("已经存在企微标签,进行更新处理={}",qwGroupKey);
QywxGetCorpTagListDTO tagListDTO = this.qywxSuiteApiService.getCorpTagList(qwDTO.getThirdCorpid(),qwDTO.getSelf3thSecret(),Arrays.asList(qwGroupKey),0,qwDTO.isSelf(),qwDTO.getUrlHost()) ; QywxGetCorpTagListDTO tagListDTO = this.qywxSuiteApiService.getCorpTagList(qwDTO.getThirdCorpid(),qwDTO.getSelf3thSecret(),Arrays.asList(qwGroupKey),0,qwDTO.isSelf(),qwDTO.getUrlHost()) ;
logger.info("企微侧标签={}",JSONObject.toJSONString(tagListDTO)); logger.info("企微侧标签={}",JSONObject.toJSONString(tagListDTO));
List<TabQywxTagItem> tagItemList = this.qywxTagService.listByQywxTagId(wxEnterpriseId,hbTagId) ;
Map<String,TabQywxTagItem> tagItemMap = tagItemList.stream().collect(Collectors.toMap(TabQywxTagItem::getQywxTagItemId,o->o,(k1,k2)->k1)) ;
// 更新赋值 // 更新赋值
infoDTO.setQywxGroupKey(qwGroupKey); infoDTO.setQywxGroupKey(qwGroupKey);
// 需要删除的标签值
/* for(TabQywxTagRelation relation : relationList) {
String memberItemTagId = relation.getTagItemId() ;
if(!memberTagItemIdList.contains(memberItemTagId) && relation.getRelationType()==1) {
this.qywxTagRelationMapper.deleteByPrimaryKey(relation.getQywxTagRelationId()) ;
String hbTagItemId = relation.getQywxTagItemId() ;
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());
}*/
// 需要添加的标签值 // 需要添加的标签值
List<String> existMemberTagIdList = relationList.stream().map(o->o.getTagItemId()).collect(Collectors.toList()); List<String> existMemberTagIdList = relationList.stream().map(o->o.getTagItemId()).collect(Collectors.toList());
for(QywxTagItemDTO memberTag : items) { for(QywxTagItemDTO memberTag : items) {
...@@ -193,7 +146,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService { ...@@ -193,7 +146,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
} }
} }
items = needAddList ; items = needAddList ;
logger.info("更新标签,删除={},新增={}",needDelList,needAddList); logger.info("更新标签,新增={}",needAddList);
} }
if(CollectionUtils.isEmpty(items)) { if(CollectionUtils.isEmpty(items)) {
logger.info("没有需要处理的标签"); logger.info("没有需要处理的标签");
......
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