Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 8e90d663
authored
Jan 11, 2022
by
linkwechat8856@163.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
客户列表索引查询优化
1 parent
222b9edc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
107 additions
and
57 deletions
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerController.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeCustomer.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/mapper/WeCustomerMapper.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMessagePushServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeTaskFissionServiceImpl.java
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerMapper.xml
linkwe-wecom/src/main/resources/mapper/wecom/WeFlowerCustomerTagRelMapper.xml
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerController.java
View file @
8e90d66
package
com
.
linkwechat
.
web
.
controller
.
wecom
;
package
com
.
linkwechat
.
web
.
controller
.
wecom
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.linkwechat.common.annotation.Log
;
import
com.linkwechat.common.annotation.Log
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.core.controller.BaseController
;
import
com.linkwechat.common.core.controller.BaseController
;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.common.core.page.PageDomain
;
import
com.linkwechat.common.core.page.TableDataInfo
;
import
com.linkwechat.common.core.page.TableDataInfo
;
import
com.linkwechat.common.core.page.TableSupport
;
import
com.linkwechat.common.enums.BusinessType
;
import
com.linkwechat.common.enums.BusinessType
;
import
com.linkwechat.common.enums.TrackState
;
import
com.linkwechat.common.enums.TrajectoryType
;
import
com.linkwechat.common.exception.CustomException
;
import
com.linkwechat.common.exception.CustomException
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.wecom.constants.SynchRecordConstants
;
import
com.linkwechat.wecom.constants.SynchRecordConstants
;
import
com.linkwechat.wecom.domain.*
;
import
com.linkwechat.wecom.domain.*
;
import
com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo
;
import
com.linkwechat.wecom.domain.vo.WeMakeCustomerTag
;
import
com.linkwechat.wecom.domain.vo.WeMakeCustomerTag
;
import
com.linkwechat.wecom.domain.vo.WeOnTheJobCustomerVo
;
import
com.linkwechat.wecom.domain.vo.WeOnTheJobCustomerVo
;
import
com.linkwechat.wecom.service.IWeCustomerService
;
import
com.linkwechat.wecom.service.IWeCustomerService
;
...
@@ -25,7 +23,6 @@ import io.swagger.annotations.ApiOperation;
...
@@ -25,7 +23,6 @@ import io.swagger.annotations.ApiOperation;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -57,15 +54,19 @@ public class WeCustomerController extends BaseController
...
@@ -57,15 +54,19 @@ public class WeCustomerController extends BaseController
*********************************************************************************/
*********************************************************************************/
/**
/**
* 查询企业微信客户列表(分页)
* 查询企业微信客户列表(分页)
,优化百万数据分页查询,没有用框架自带分页
*/
*/
@GetMapping
(
"/findWeCustomerList"
)
@GetMapping
(
"/findWeCustomerList"
)
@ApiOperation
(
"查询企业微信客户列表"
)
@ApiOperation
(
"查询企业微信客户列表"
)
public
TableDataInfo
findWeCustomerList
(
WeCustomerList
weCustomerList
)
public
TableDataInfo
findWeCustomerList
(
WeCustomerList
weCustomerList
)
{
{
startPage
();
List
<
WeCustomerList
>
list
=
weCustomerService
.
findWeCustomerList
(
weCustomerList
);
List
<
WeCustomerList
>
list
=
weCustomerService
.
findWeCustomerList
(
weCustomerList
,
TableSupport
.
buildPageRequest
()
);
TableDataInfo
dataTable
=
getDataTable
(
list
);
TableDataInfo
dataTable
=
getDataTable
(
list
);
//设置总条数
dataTable
.
setTotal
(
weCustomerService
.
countWeCustomerList
(
weCustomerList
)
);
dataTable
.
setLastSyncTime
(
dataTable
.
setLastSyncTime
(
iWeSynchRecordService
.
findUpdateLatestTime
(
SynchRecordConstants
.
SYNCH_CUSTOMER
)
iWeSynchRecordService
.
findUpdateLatestTime
(
SynchRecordConstants
.
SYNCH_CUSTOMER
)
);
//最近同步时间
);
//最近同步时间
...
@@ -85,7 +86,7 @@ public class WeCustomerController extends BaseController
...
@@ -85,7 +86,7 @@ public class WeCustomerController extends BaseController
public
AjaxResult
findAllWeCustomerList
(
WeCustomerList
weCustomerList
)
public
AjaxResult
findAllWeCustomerList
(
WeCustomerList
weCustomerList
)
{
{
return
AjaxResult
.
success
(
return
AjaxResult
.
success
(
weCustomerService
.
findWeCustomerList
(
weCustomerList
)
weCustomerService
.
findWeCustomerList
(
weCustomerList
,
null
)
);
);
}
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeCustomer.java
View file @
8e90d66
...
@@ -101,6 +101,11 @@ public class WeCustomer extends BaseEntity {
...
@@ -101,6 +101,11 @@ public class WeCustomer extends BaseEntity {
private
String
takeoverUserId
;
private
String
takeoverUserId
;
private
String
tagIds
;
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/mapper/WeCustomerMapper.java
View file @
8e90d66
...
@@ -3,6 +3,7 @@ package com.linkwechat.wecom.mapper;
...
@@ -3,6 +3,7 @@ package com.linkwechat.wecom.mapper;
import
java.util.List
;
import
java.util.List
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.linkwechat.common.core.page.PageDomain
;
import
com.linkwechat.wecom.domain.*
;
import
com.linkwechat.wecom.domain.*
;
import
com.linkwechat.wecom.domain.vo.CusertomerBelongUserInfo
;
import
com.linkwechat.wecom.domain.vo.CusertomerBelongUserInfo
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
...
@@ -22,10 +23,17 @@ public interface WeCustomerMapper extends BaseMapper<WeCustomer>
...
@@ -22,10 +23,17 @@ public interface WeCustomerMapper extends BaseMapper<WeCustomer>
* @param weCustomerList
* @param weCustomerList
* @return
* @return
*/
*/
List
<
WeCustomerList
>
findWeCustomerList
(
@Param
(
"weCustomerList"
)
WeCustomerList
weCustomerList
);
List
<
WeCustomerList
>
findWeCustomerList
(
@Param
(
"weCustomerList"
)
WeCustomerList
weCustomerList
,
@Param
(
"pageDomain"
)
PageDomain
pageDomain
);
/**
/**
* 客户总数统计
* @param weCustomerList
* @return
*/
long
countWeCustomerList
(
@Param
(
"weCustomerList"
)
WeCustomerList
weCustomerList
);
/**
* 获取客户所在群
* 获取客户所在群
* @param userId
* @param userId
* @return
* @return
...
@@ -77,4 +85,7 @@ public interface WeCustomerMapper extends BaseMapper<WeCustomer>
...
@@ -77,4 +85,7 @@ public interface WeCustomerMapper extends BaseMapper<WeCustomer>
long
noRepeatCountCustomer
(
@Param
(
"weCustomerList"
)
WeCustomerList
weCustomerList
);
long
noRepeatCountCustomer
(
@Param
(
"weCustomerList"
)
WeCustomerList
weCustomerList
);
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerService.java
View file @
8e90d66
package
com
.
linkwechat
.
wecom
.
service
;
package
com
.
linkwechat
.
wecom
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.linkwechat.common.core.page.PageDomain
;
import
com.linkwechat.wecom.domain.*
;
import
com.linkwechat.wecom.domain.*
;
import
com.linkwechat.wecom.domain.dto.WeWelcomeMsg
;
import
com.linkwechat.wecom.domain.dto.WeWelcomeMsg
;
import
com.linkwechat.wecom.domain.vo.WeCustomerDetailVo
;
import
com.linkwechat.wecom.domain.vo.WeCustomerDetailVo
;
import
com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo
;
import
com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo
;
import
com.linkwechat.wecom.domain.vo.WeMakeCustomerTag
;
import
com.linkwechat.wecom.domain.vo.WeMakeCustomerTag
;
import
com.linkwechat.wecom.domain.vo.WeOnTheJobCustomerVo
;
import
com.linkwechat.wecom.domain.vo.WeOnTheJobCustomerVo
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.ExecutionException
;
/**
/**
* 企业微信客户Service接口
* 企业微信客户Service接口
...
@@ -102,7 +105,14 @@ public interface IWeCustomerService extends IService<WeCustomer>
...
@@ -102,7 +105,14 @@ public interface IWeCustomerService extends IService<WeCustomer>
* @param weCustomerList
* @param weCustomerList
* @return
* @return
*/
*/
List
<
WeCustomerList
>
findWeCustomerList
(
WeCustomerList
weCustomerList
);
List
<
WeCustomerList
>
findWeCustomerList
(
WeCustomerList
weCustomerList
,
PageDomain
pageDomain
);
/**
* 客户总数统计
* @param weCustomerList
* @return
*/
long
countWeCustomerList
(
@Param
(
"weCustomerList"
)
WeCustomerList
weCustomerList
);
/**
/**
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerMessagePushServiceImpl.java
View file @
8e90d66
...
@@ -237,7 +237,7 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
...
@@ -237,7 +237,7 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
return
weCustomerService
.
findWeCustomerList
(
WeCustomerList
.
builder
()
return
weCustomerService
.
findWeCustomerList
(
WeCustomerList
.
builder
()
.
userIds
(
staffId
)
.
userIds
(
staffId
)
.
departmentIds
(
department
)
.
departmentIds
(
department
)
.
build
());
.
build
()
,
null
);
}
else
{
}
else
{
...
@@ -250,7 +250,7 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
...
@@ -250,7 +250,7 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
.
userIds
(
staffId
)
.
userIds
(
staffId
)
.
tagIds
(
tag
)
.
tagIds
(
tag
)
.
departmentIds
(
department
)
.
departmentIds
(
department
)
.
build
());
.
build
()
,
null
);
// WeCustomer weCustomer = new WeCustomer();
// WeCustomer weCustomer = new WeCustomer();
// weCustomer.setUserIds(staffId);
// weCustomer.setUserIds(staffId);
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerServiceImpl.java
View file @
8e90d66
...
@@ -5,9 +5,11 @@ import cn.hutool.core.collection.ListUtil;
...
@@ -5,9 +5,11 @@ import cn.hutool.core.collection.ListUtil;
import
cn.hutool.core.util.ArrayUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.google.common.base.Joiner
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.linkwechat.common.constant.Constants
;
import
com.linkwechat.common.constant.Constants
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.core.page.PageDomain
;
import
com.linkwechat.common.enums.*
;
import
com.linkwechat.common.enums.*
;
import
com.linkwechat.common.exception.wecom.WeComException
;
import
com.linkwechat.common.exception.wecom.WeComException
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.DateUtils
;
...
@@ -32,11 +34,15 @@ import com.linkwechat.wecom.mapper.WeCustomerMapper;
...
@@ -32,11 +34,15 @@ import com.linkwechat.wecom.mapper.WeCustomerMapper;
import
com.linkwechat.wecom.service.*
;
import
com.linkwechat.wecom.service.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.security.core.context.SecurityContext
;
import
org.springframework.security.core.context.SecurityContext
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
java.util.stream.Stream
;
...
@@ -80,6 +86,11 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
...
@@ -80,6 +86,11 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
@Autowired
private
ThreadPoolTaskExecutor
taskExecutor
;
/**
/**
* 重构版客户列表
* 重构版客户列表
...
@@ -88,9 +99,20 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
...
@@ -88,9 +99,20 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
* @return
* @return
*/
*/
@Override
@Override
public
List
<
WeCustomerList
>
findWeCustomerList
(
WeCustomerList
weCustomerList
)
{
public
List
<
WeCustomerList
>
findWeCustomerList
(
WeCustomerList
weCustomerList
,
PageDomain
pageDomain
)
{
return
this
.
baseMapper
.
findWeCustomerList
(
weCustomerList
,
pageDomain
);
}
return
this
.
baseMapper
.
findWeCustomerList
(
weCustomerList
);
/**
* 客户总数统计
* @param weCustomerList
* @return
*/
@Override
public
long
countWeCustomerList
(
WeCustomerList
weCustomerList
)
{
return
this
.
baseMapper
.
countWeCustomerList
(
weCustomerList
);
}
}
...
@@ -100,40 +122,40 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
...
@@ -100,40 +122,40 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
* @return
* @return
*/
*/
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@SynchRecord
(
synchType
=
SynchRecordConstants
.
SYNCH_CUSTOMER
)
@SynchRecord
(
synchType
=
SynchRecordConstants
.
SYNCH_CUSTOMER
)
public
void
synchWeCustomer
()
{
@Async
public
void
synchWeCustomer
(){
//获取所有可以添加客户的企业员工
FollowUserList
followUserList
=
weCustomerClient
.
getFollowUserList
();
if
(
WeConstans
.
WE_SUCCESS_CODE
.
equals
(
followUserList
.
getErrcode
())
&&
ArrayUtil
.
isNotEmpty
(
followUserList
.
getFollow_user
()))
{
List
<
List
<
String
>>
partition
=
Lists
.
partition
(
Arrays
.
asList
(
followUserList
.
getFollow_user
()),
100
);
//此处逻辑,根据分片的数据,每片从线程池获取线程,然后启动不同线程处理下面的逻辑
for
(
List
<
String
>
follow_user:
partition
)
{
List
<
ExternalUserDetail
>
externalUserDetails
=
new
ArrayList
<>();
getByUser
(
follow_user
.
stream
().
toArray
(
String
[]::
new
),
null
,
externalUserDetails
);
if
(
CollectionUtil
.
isNotEmpty
(
externalUserDetails
))
{
List
<
List
<
ExternalUserDetail
>>
userDetailPartition
=
Lists
.
partition
(
externalUserDetails
,
1000
);
for
(
List
<
ExternalUserDetail
>
details:
userDetailPartition
){
taskExecutor
.
submit
(()->{
//此处也可多线程数据分片处理
weFlowerCustomerHandle
(
details
,
true
);
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
});
}
}
//异步同步一下标签库,解决标签不同步问题
}
Threads
.
SINGLE_THREAD_POOL
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
SecurityContextHolder
.
setContext
(
securityContext
);
//获取所有可以添加客户的企业员工
FollowUserList
followUserList
=
weCustomerClient
.
getFollowUserList
();
if
(
WeConstans
.
WE_SUCCESS_CODE
.
equals
(
followUserList
.
getErrcode
())
&&
ArrayUtil
.
isNotEmpty
(
followUserList
.
getFollow_user
()))
{
String
[]
follow_user
=
followUserList
.
getFollow_user
();
if
(
ArrayUtil
.
isNotEmpty
(
follow_user
))
{
List
<
ExternalUserDetail
>
externalUserDetails
=
new
ArrayList
<>();
getByUser
(
follow_user
,
null
,
externalUserDetails
);
if
(
CollectionUtil
.
isNotEmpty
(
externalUserDetails
))
{
}
weFlowerCustomerHandle
(
externalUserDetails
,
true
);
}
}
}
}
});
}
}
...
@@ -162,12 +184,14 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
...
@@ -162,12 +184,14 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
weCustomer
.
setFirstUserId
(
followInfo
.
getUserid
());
weCustomer
.
setFirstUserId
(
followInfo
.
getUserid
());
weCustomer
.
setFirstAddTime
(
new
Date
(
followInfo
.
getCreatetime
()
*
1000L
));
weCustomer
.
setFirstAddTime
(
new
Date
(
followInfo
.
getCreatetime
()
*
1000L
));
weCustomer
.
setAddMethod
(
followInfo
.
getAdd_way
());
weCustomer
.
setAddMethod
(
followInfo
.
getAdd_way
());
weCustomerList
.
add
(
weCustomer
);
if
(
isSynchCustomerTagRel
){
if
(
isSynchCustomerTagRel
){
List
<
String
>
tags
=
Stream
.
of
(
followInfo
.
getTag_id
()).
collect
(
Collectors
.
toList
());
List
<
String
>
tags
=
Stream
.
of
(
followInfo
.
getTag_id
()).
collect
(
Collectors
.
toList
());
if
(
CollectionUtil
.
isNotEmpty
(
tags
))
{
if
(
CollectionUtil
.
isNotEmpty
(
tags
))
{
tags
.
stream
().
forEach
(
tag
->
{
//获取标签
weCustomer
.
setTagIds
(
Joiner
.
on
(
","
).
join
(
tags
));
tags
.
stream
().
forEach
(
tag
->
{
weFlowerCustomerTagRels
.
add
(
weFlowerCustomerTagRels
.
add
(
WeFlowerCustomerTagRel
.
builder
()
WeFlowerCustomerTagRel
.
builder
()
.
userId
(
followInfo
.
getUserid
())
.
userId
(
followInfo
.
getUserid
())
...
@@ -181,6 +205,8 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
...
@@ -181,6 +205,8 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
}
}
}
}
weCustomerList
.
add
(
weCustomer
);
});
});
...
@@ -528,11 +554,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
...
@@ -528,11 +554,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
TrajectorySceneType
.
TRAJECTORY_TITLE_GXGRBQ
.
getType
(),
TrajectorySceneType
.
TRAJECTORY_TITLE_GXGRBQ
.
getType
(),
CollectionUtil
.
isNotEmpty
(
lodAddTag
)?
CollectionUtil
.
isNotEmpty
(
lodAddTag
)?
String
.
join
(
","
,
lodAddTag
.
stream
().
map
(
WeTag:
:
getName
).
collect
(
Collectors
.
toList
())):
"暂无标签"
,
null
);
String
.
join
(
","
,
lodAddTag
.
stream
().
map
(
WeTag:
:
getName
).
collect
(
Collectors
.
toList
())):
"暂无标签"
,
null
);
}
}
...
@@ -581,13 +602,12 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
...
@@ -581,13 +602,12 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
weCustomer
.
setState
(
followUser
.
getState
());
weCustomer
.
setState
(
followUser
.
getState
());
weCustomer
.
setFirstAddTime
(
new
Date
(
followUser
.
getCreatetime
()
*
1000L
));
weCustomer
.
setFirstAddTime
(
new
Date
(
followUser
.
getCreatetime
()
*
1000L
));
weCustomer
.
setAddMethod
(
followUser
.
getAddWay
());
weCustomer
.
setAddMethod
(
followUser
.
getAddWay
());
this
.
baseMapper
.
batchAddOrUpdate
(
ListUtil
.
toList
(
weCustomer
)
);
//设置标签
//设置标签
List
<
ExternalUserTag
>
tags
=
followUser
.
getTags
();
List
<
ExternalUserTag
>
tags
=
followUser
.
getTags
();
if
(
CollectionUtil
.
isNotEmpty
(
tags
)){
if
(
CollectionUtil
.
isNotEmpty
(
tags
)){
weCustomer
.
setTagIds
(
Joiner
.
on
(
","
).
join
(
tags
));
List
<
WeFlowerCustomerTagRel
>
tagRels
=
new
ArrayList
<>();
List
<
WeFlowerCustomerTagRel
>
tagRels
=
new
ArrayList
<>();
tags
.
stream
().
forEach
(
k
->{
tags
.
stream
().
forEach
(
k
->{
tagRels
.
add
(
tagRels
.
add
(
...
@@ -602,7 +622,9 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
...
@@ -602,7 +622,9 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
iWeFlowerCustomerTagRelService
.
batchAddOrUpdate
(
tagRels
);
iWeFlowerCustomerTagRelService
.
batchAddOrUpdate
(
tagRels
);
}
}
this
.
baseMapper
.
batchAddOrUpdate
(
ListUtil
.
toList
(
weCustomer
)
);
//生成轨迹
//生成轨迹
iWeCustomerTrajectoryService
.
createTrajectory
(
ListUtil
.
toList
(
iWeCustomerTrajectoryService
.
createTrajectory
(
ListUtil
.
toList
(
...
@@ -705,7 +727,8 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
...
@@ -705,7 +727,8 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
WeCustomerList
.
builder
()
WeCustomerList
.
builder
()
.
externalUserid
(
externalUserid
)
.
externalUserid
(
externalUserid
)
.
delFlag
(
delFlag
)
.
delFlag
(
delFlag
)
.
build
()
.
build
(),
null
);
);
if
(
CollectionUtil
.
isNotEmpty
(
weCustomerList
)){
if
(
CollectionUtil
.
isNotEmpty
(
weCustomerList
)){
BeanUtils
.
copyBeanProp
(
BeanUtils
.
copyBeanProp
(
...
@@ -755,7 +778,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
...
@@ -755,7 +778,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
.
externalUserid
(
externalUserid
)
.
externalUserid
(
externalUserid
)
.
userIds
(
userId
)
.
userIds
(
userId
)
.
delFlag
(
delFlag
)
.
delFlag
(
delFlag
)
.
build
());
.
build
()
,
null
);
if
(
CollectionUtil
.
isNotEmpty
(
weCustomerList
)){
if
(
CollectionUtil
.
isNotEmpty
(
weCustomerList
)){
List
<
WeCustomerDetail
.
CompanyOrPersonTag
>
companyTags
=
new
ArrayList
<>();
List
<
WeCustomerDetail
.
CompanyOrPersonTag
>
companyTags
=
new
ArrayList
<>();
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeTaskFissionServiceImpl.java
View file @
8e90d66
...
@@ -236,7 +236,7 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
...
@@ -236,7 +236,7 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
.
userIds
(
userIds
)
.
userIds
(
userIds
)
.
tagIds
(
weTaskFission
.
getCustomerTagId
().
replaceAll
(
"all"
,
""
))
.
tagIds
(
weTaskFission
.
getCustomerTagId
().
replaceAll
(
"all"
,
""
))
.
departmentIds
(
departmentIds
)
.
departmentIds
(
departmentIds
)
.
build
());
.
build
()
,
null
);
if
(
weCustomerList
!=
null
){
if
(
weCustomerList
!=
null
){
Map
<
String
,
Set
<
String
>>
userAndCustomerMap
=
weCustomerList
.
stream
().
collect
(
Collectors
.
groupingBy
(
WeCustomerList:
:
getFirstUserId
,
Collectors
.
mapping
(
WeCustomerList:
:
getExternalUserid
,
Collectors
.
toSet
())));
Map
<
String
,
Set
<
String
>>
userAndCustomerMap
=
weCustomerList
.
stream
().
collect
(
Collectors
.
groupingBy
(
WeCustomerList:
:
getFirstUserId
,
Collectors
.
mapping
(
WeCustomerList:
:
getExternalUserid
,
Collectors
.
toSet
())));
List
<
WeAddGroupMessageQuery
.
SenderInfo
>
senderList
=
new
ArrayList
<>();
List
<
WeAddGroupMessageQuery
.
SenderInfo
>
senderList
=
new
ArrayList
<>();
...
...
linkwe-wecom/src/main/resources/mapper/wecom/WeCustomerMapper.xml
View file @
8e90d66
This diff is collapsed.
Click to expand it.
linkwe-wecom/src/main/resources/mapper/wecom/WeFlowerCustomerTagRelMapper.xml
View file @
8e90d66
...
@@ -85,9 +85,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -85,9 +85,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
(#{item.userId},#{item.externalUserid},#{item.tagId},NOW(),#{item.isCompanyTag},#{item.delFlag})
(#{item.userId},#{item.externalUserid},#{item.tagId},NOW(),#{item.isCompanyTag},#{item.delFlag})
</foreach>
</foreach>
ON DUPLICATE KEY UPDATE
ON DUPLICATE KEY UPDATE
user_id=IF
(TRIM(VALUES(user_id)) !='',
VALUES(user_id), we_flower_customer_tag_rel.user_id),
user_id=IF
NULL(
VALUES(user_id), we_flower_customer_tag_rel.user_id),
external_userid=IF
(TRIM(VALUES(external_userid)) !='',
VALUES(external_userid), we_flower_customer_tag_rel.external_userid),
external_userid=IF
NULL(
VALUES(external_userid), we_flower_customer_tag_rel.external_userid),
tag_id=IF
(TRIM(VALUES(tag_id)) !='',
VALUES(tag_id), we_flower_customer_tag_rel.tag_id),
tag_id=IF
NULL(
VALUES(tag_id), we_flower_customer_tag_rel.tag_id),
del_flag=IFNULL(VALUES(del_flag),we_flower_customer_tag_rel.del_flag);
del_flag=IFNULL(VALUES(del_flag),we_flower_customer_tag_rel.del_flag);
</insert>
</insert>
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment