Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haoban3.0
haoban-manage3.0
Commits
8dda3e04
Commit
8dda3e04
authored
May 24, 2021
by
fudahua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
批量处理关联关系
parent
e10a5b4c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
26 deletions
+28
-26
StoreRangeServiceImpl.java
...an/manage/service/service/impl/StoreRangeServiceImpl.java
+13
-14
ServiceTest.java
haoban-manage3-service/src/test/java/ServiceTest.java
+15
-12
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/StoreRangeServiceImpl.java
View file @
8dda3e04
...
...
@@ -113,15 +113,16 @@ public class StoreRangeServiceImpl implements StoreRangeService {
return
true
;
}
String
enterpriseId
=
list
.
get
(
0
).
getEnterpriseId
();
//导购绑定列表 容错处理
List
<
StaffClerkRelationDTO
>
staffClerkRelationDTOS
=
staffClerkRelationService
.
listBindStoreIdByEnterpriseId
(
enterpriseId
);
Map
<
String
,
Set
<
String
>>
oldStaffStoreIdByWxEidMap
=
staffClerkRelationDTOS
.
stream
().
collect
(
Collectors
.
groupingBy
(
StaffClerkRelationDTO:
:
getWxEnterpriseId
,
Collectors
.
mapping
(
dto
->
dto
.
getStoreId
(),
Collectors
.
toSet
())));
//更新前绑定门店列表
List
<
TabStoreRelation
>
storeRelations
=
tabHaobanStoreRelationMapper
.
listStoreRange
(
enterpriseId
);
Map
<
String
,
Set
<
String
>>
oldStoreIdByMap
=
storeRelations
.
stream
().
collect
(
Collectors
.
groupingBy
(
TabStoreRelation:
:
getWxEnterpriseId
,
Collectors
.
mapping
(
dto
->
dto
.
getStoreId
(),
Collectors
.
toSet
())));
//根据wxEnterpriseId 分组
Map
<
String
,
Set
<
String
>>
newStoreIdBywxEnterpriseMap
=
list
.
stream
().
collect
(
Collectors
.
groupingBy
(
TabStoreRelation:
:
getWxEnterpriseId
,
Collectors
.
mapping
(
dto
->
dto
.
getStoreId
(),
Collectors
.
toSet
())));
//所有就的门店old绑定列表
Map
<
String
,
Set
<
String
>>
oldStoreIdBywxEnterpriseMap
=
getOldStoreIdsByWxEnterpriseId
(
enterpriseId
,
oldSt
affStoreIdByWxEid
Map
);
Map
<
String
,
Set
<
String
>>
oldStoreIdBywxEnterpriseMap
=
getOldStoreIdsByWxEnterpriseId
(
enterpriseId
,
oldSt
oreIdBy
Map
);
//需要解绑门店
Set
<
String
>
needUnBindStoreIds
=
new
HashSet
<>();
...
...
@@ -141,7 +142,7 @@ public class StoreRangeServiceImpl implements StoreRangeService {
needUnBindStoreIds
.
addAll
(
mid
);
//需要新增
Set
<
String
>
old
=
oldSt
affStoreIdByWxEid
Map
.
get
(
wxEid
);
Set
<
String
>
old
=
oldSt
oreIdBy
Map
.
get
(
wxEid
);
if
(
CollectionUtils
.
isEmpty
(
old
))
{
needAddStoreIds
.
addAll
(
newStoreIds
);
return
;
...
...
@@ -176,8 +177,6 @@ public class StoreRangeServiceImpl implements StoreRangeService {
tabHaobanStoreRelationMapper
.
deleteStoreRalationByStoreIds
(
enterpriseId
,
delStoreIds
);
}
if
(
CollectionUtils
.
isNotEmpty
(
addStoreIds
))
{
insertStoreRelationBatch
(
storeRelations
);
}
else
{
List
<
TabStoreRelation
>
adds
=
storeRelations
.
stream
().
filter
(
dto
->
addStoreIds
.
contains
(
dto
.
getStoreId
())).
collect
(
Collectors
.
toList
());
//批量插入
insertStoreRelationBatch
(
adds
);
...
...
@@ -208,20 +207,20 @@ public class StoreRangeServiceImpl implements StoreRangeService {
* @param enterpriseId
* @return
*/
private
Map
<
String
,
Set
<
String
>>
getOldStoreIdsByWxEnterpriseId
(
String
enterpriseId
,
Map
<
String
,
Set
<
String
>>
oldSt
affStoreIdByWxEid
Map
)
{
private
Map
<
String
,
Set
<
String
>>
getOldStoreIdsByWxEnterpriseId
(
String
enterpriseId
,
Map
<
String
,
Set
<
String
>>
oldSt
oreIdBywxEnterprise
Map
)
{
Map
<
String
,
Set
<
String
>>
ret
=
new
HashMap
<>();
Set
<
String
>
wxEnterpriseIds
=
new
HashSet
<>();
//更新前绑定门店列表
List
<
TabStoreRelation
>
storeRelations
=
tabHaobanStoreRelationMapper
.
listStoreRange
(
enterpriseId
);
Map
<
String
,
Set
<
String
>>
oldStoreIdBywxEnterpriseMap
=
storeRelations
.
stream
().
collect
(
Collectors
.
groupingBy
(
TabStoreRelation:
:
getWxEnterpriseId
,
Collectors
.
mapping
(
dto
->
dto
.
getStoreId
(),
Collectors
.
toSet
())));
if
(
CollectionUtils
.
isNotEmpty
(
storeRelations
)
)
{
//
//更新前绑定门店列表
//
List<TabStoreRelation> storeRelations = tabHaobanStoreRelationMapper.listStoreRange(enterpriseId);
//
Map<String, Set<String>> oldStoreIdBywxEnterpriseMap = storeRelations.stream().collect(Collectors.groupingBy(TabStoreRelation::getWxEnterpriseId, Collectors.mapping(dto -> dto.getStoreId(), Collectors.toSet())));
if
(
oldStoreIdBywxEnterpriseMap
!=
null
&&
oldStoreIdBywxEnterpriseMap
.
size
()
>
0
)
{
wxEnterpriseIds
.
addAll
(
oldStoreIdBywxEnterpriseMap
.
keySet
());
}
//导购绑定列表
//
List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationService.listBindStoreIdByEnterpriseId(enterpriseId);
//
Map<String, Set<String>> oldStaffStoreIdByWxEidMap = staffClerkRelationDTOS.stream().collect(Collectors.groupingBy(StaffClerkRelationDTO::getWxEnterpriseId, Collectors.mapping(dto -> dto.getStoreId(), Collectors.toSet())));
List
<
StaffClerkRelationDTO
>
staffClerkRelationDTOS
=
staffClerkRelationService
.
listBindStoreIdByEnterpriseId
(
enterpriseId
);
Map
<
String
,
Set
<
String
>>
oldStaffStoreIdByWxEidMap
=
staffClerkRelationDTOS
.
stream
().
collect
(
Collectors
.
groupingBy
(
StaffClerkRelationDTO:
:
getWxEnterpriseId
,
Collectors
.
mapping
(
dto
->
dto
.
getStoreId
(),
Collectors
.
toSet
())));
if
(
oldStaffStoreIdByWxEidMap
!=
null
&&
oldStaffStoreIdByWxEidMap
.
size
()
>
0
)
{
wxEnterpriseIds
.
addAll
(
oldStaffStoreIdByWxEidMap
.
keySet
());
}
...
...
haoban-manage3-service/src/test/java/ServiceTest.java
View file @
8dda3e04
...
...
@@ -59,18 +59,21 @@ public class ServiceTest {
@Test
public
void
test11
()
{
FlushStoreMqDTO
flushStoreMqDTO
=
new
FlushStoreMqDTO
();
flushStoreMqDTO
.
setEnterpriseId
(
"testEnteroriseId"
);
int
i
=
2
;
while
(
i
--
>
0
)
{
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
wxEnterpriseRelatedApiService
.
flushBindStoreByEnterpriseId
(
"ff8080815dacd3a2015dacd3ef5c0000"
,
"-1"
,
"-1"
,
ChannelCodeEnum
.
SYNC_UNBIND
.
getCode
());
}
// FlushStoreMqDTO flushStoreMqDTO = new FlushStoreMqDTO();
// flushStoreMqDTO.setEnterpriseId("testEnteroriseId");
// int i = 2;
// while (i-- > 0) {
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// wxEnterpriseRelatedApiService.flushBindStoreByEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000",
// "-1", "-1", ChannelCodeEnum.SYNC_UNBIND.getCode());
// }
wxEnterpriseRelatedApiService
.
flushBindStoreByEnterpriseId
(
"ff808081593917d90159398ec6340012"
,
"ca66a01b79474c40b3e7c7f93daf1a3b"
,
"-1"
,
ChannelCodeEnum
.
SYNC_UNBIND
.
getCode
());
// List<String> ids = new ArrayList<>();
// ids.add("8f5ddb9df0a54332acfa2d5804e90c64");
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment