Commit 1e3f78ae by fudahua

授权绑定,授权门店列表,binlog

parent 30bd2df8
package com.gic.haoban.manage.service.service.out.impl; package com.gic.haoban.manage.service.service.out.impl;
import java.util.*; import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -284,13 +285,32 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi ...@@ -284,13 +285,32 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
Map<String, Set<String>> storeGroupChainMap = storeGroupList.stream().collect(Collectors.toMap(dto -> dto.getStoreGroupId(), Map<String, Set<String>> storeGroupChainMap = storeGroupList.stream().collect(Collectors.toMap(dto -> dto.getStoreGroupId(),
dto -> Arrays.stream(dto.getStoreGroupChain().split("-")).filter(str -> StringUtils.isNotBlank(str)).collect(Collectors.toSet()))); dto -> Arrays.stream(dto.getStoreGroupChain().split("-")).filter(str -> StringUtils.isNotBlank(str)).collect(Collectors.toSet())));
storeMapByGroupId.forEach((groupId, storeIds) -> { //获取集团门店的分组 然后根据分组来查询门店
Set<String> chainGroupIds = storeGroupChainMap.get(groupId); storeGroupChainMap.forEach((groupId, chainGroupIds) -> {
Sets.SetView<String> midGroupIds = Sets.intersection(chainGroupIds, rightGroupIds); Sets.SetView<String> midGroupIds = Sets.intersection(chainGroupIds, rightGroupIds);
if (CollectionUtils.isEmpty(midGroupIds)) { if (CollectionUtils.isEmpty(midGroupIds)) {
return;
}
String midGroupId = null;
//如果是1的话 加入对应企业
if (midGroupIds.size() == 1) {
midGroupId = midGroupIds.iterator().next();
} else {
//取交集层级最大 也就是冒泡最近的
midGroupId = midGroupIds.stream().sorted(Comparator.comparing(mid -> storeGroupChainMap.get(mid).size()).reversed()).findFirst().get();
}
relationMapByWxEid.get(groupMap.get(midGroupId)).add(groupId);
});
//组装门店的id
Map<String, Set<String>> ret = new HashMap<>();
relationMapByWxEid.forEach((wxEid, groupIds) -> {
Set<String> storeIds = groupIds.stream().filter(mid -> storeGroupChainMap.containsKey(mid))
.flatMap(midGid -> storeGroupChainMap.get(midGid).stream()).collect(Collectors.toSet());
ret.put(wxEid, storeIds);
});
}
});
return false; return false;
} }
......
...@@ -165,9 +165,10 @@ ...@@ -165,9 +165,10 @@
relation_id, relation_type, status_flag, relation_id, relation_type, status_flag,
create_time, update_time) create_time, update_time)
values values
<foreach collection="list" item="item" open="(" close=")" separator=","> <foreach collection="list" item="item" separator=",">
(#{storeRangeId,jdbcType=VARCHAR}, #{wxEnterpriseId,jdbcType=VARCHAR}, #{enterpriseId,jdbcType=VARCHAR}, (#{item.storeRangeId,jdbcType=VARCHAR}, #{item.wxEnterpriseId,jdbcType=VARCHAR},
#{relationId,jdbcType=VARCHAR}, #{relationType,jdbcType=INTEGER}, 1, #{item.enterpriseId,jdbcType=VARCHAR},
#{item.relationId,jdbcType=VARCHAR}, #{item.relationType,jdbcType=INTEGER}, 1,
now(), now()) now(), now())
</foreach> </foreach>
......
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