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 25d7bfad
authored
Dec 26, 2021
by
danmo
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
群发同步接口优化
1 parent
3092d0aa
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
22 deletions
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeGroupMessageTask.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeGroupMessageTemplate.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/vo/WeGroupMessageDetailVo.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeGroupMessageSendResultServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeGroupMessageTemplateServiceImpl.java
linkwe-wecom/src/main/resources/mapper/wecom/WeGroupMessageSendResultMapper.xml
linkwe-wecom/src/main/resources/mapper/wecom/WeGroupMessageTaskMapper.xml
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeGroupMessageTask.java
View file @
25d7bfa
...
...
@@ -77,4 +77,14 @@ public class WeGroupMessageTask extends BaseEntity{
@ApiModelProperty
(
"企业服务人员名称"
)
@TableField
(
exist
=
false
)
private
String
userName
;
@ApiModelProperty
(
value
=
"待发送客户"
,
hidden
=
true
)
@TableField
(
exist
=
false
)
private
String
toBeCustomerName
;
@ApiModelProperty
(
value
=
"已发送客户"
,
hidden
=
true
)
@TableField
(
exist
=
false
)
private
String
alreadyCustomerName
;
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeGroupMessageTemplate.java
View file @
25d7bfa
...
...
@@ -77,4 +77,11 @@ public class WeGroupMessageTemplate extends BaseEntity {
*/
@ApiModelProperty
(
"来源 0 群发 1 其他"
)
private
Integer
source
;
/**
* 刷新时间
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
"刷新时间"
)
private
Date
refreshTime
;
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/vo/WeGroupMessageDetailVo.java
View file @
25d7bfa
...
...
@@ -28,6 +28,10 @@ public class WeGroupMessageDetailVo {
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
sendTime
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty
(
"刷新时间"
)
private
Date
refreshTime
;
@ApiModelProperty
(
"附件"
)
private
List
<
WeGroupMessageAttachments
>
attachments
;
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeGroupMessageSendResultServiceImpl.java
View file @
25d7bfa
...
...
@@ -81,12 +81,16 @@ public class WeGroupMessageSendResultServiceImpl extends ServiceImpl<WeGroupMess
sendResultList
.
forEach
(
item
->
{
LambdaQueryWrapper
<
WeGroupMessageSendResult
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
WeGroupMessageSendResult:
:
getMsgId
,
item
.
getMsgId
())
.
eq
(
WeGroupMessageSendResult:
:
getExternalUserid
,
item
.
getExternalUserid
())
.
eq
(
WeGroupMessageSendResult:
:
getUserId
,
item
.
getUserId
())
.
eq
(
WeGroupMessageSendResult:
:
getChatId
,
item
.
getChatId
());
.
eq
(
WeGroupMessageSendResult:
:
getUserId
,
item
.
getUserId
());
if
(
item
.
getMsgTemplateId
()
!=
null
){
wrapper
.
eq
(
WeGroupMessageSendResult:
:
getMsgTemplateId
,
item
.
getMsgTemplateId
());
}
if
(
item
.
getExternalUserid
()
!=
null
){
wrapper
.
eq
(
WeGroupMessageSendResult:
:
getExternalUserid
,
item
.
getExternalUserid
());
}
if
(
item
.
getChatId
()
!=
null
){
wrapper
.
eq
(
WeGroupMessageSendResult:
:
getChatId
,
item
.
getChatId
());
}
if
(!
this
.
update
(
item
,
wrapper
))
{
this
.
save
(
item
);
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeGroupMessageTemplateServiceImpl.java
View file @
25d7bfa
...
...
@@ -93,30 +93,30 @@ public class WeGroupMessageTemplateServiceImpl extends ServiceImpl<WeGroupMessag
WeGroupMessageDetailVo
detailVo
=
new
WeGroupMessageDetailVo
();
detailVo
.
setChatType
(
msgTemplate
);
detailVo
.
setRefreshTime
(
weGroupMessageTemplate
.
getRefreshTime
());
detailVo
.
setSendTime
(
weGroupMessageTemplate
.
getSendTime
());
detailVo
.
setContent
(
weGroupMessageTemplate
.
getContent
());
List
<
WeGroupMessageListVo
>
groupMsgDetail
=
weGroupMessageListService
.
getGroupMsgDetail
(
id
);
if
(
CollectionUtil
.
isNotEmpty
(
groupMsgDetail
))
{
detailVo
.
setAttachments
(
groupMsgDetail
.
get
(
0
).
getAttachments
());
//待发送人员列表
L
ist
<
WeGroupMessageTask
>
toBeSent
=
groupMsgDetail
.
stream
().
map
(
WeGroupMessageListVo:
:
getSenders
)
.
flatMap
(
Collection:
:
stream
).
filter
(
item
->
ObjectUtil
.
equal
(
0
,
item
.
getStatus
())).
co
llect
(
Collectors
.
toList
()
);
L
ong
toBeSent
=
groupMsgDetail
.
stream
().
map
(
WeGroupMessageListVo:
:
getSenders
)
.
flatMap
(
Collection:
:
stream
).
filter
(
item
->
ObjectUtil
.
equal
(
0
,
item
.
getStatus
())).
co
unt
(
);
detailVo
.
setToBeSendNum
(
toBeSent
.
intValue
());
//已发送人员列表
L
ist
<
WeGroupMessageTask
>
alreadySent
=
groupMsgDetail
.
stream
().
map
(
WeGroupMessageListVo:
:
getSenders
)
.
flatMap
(
Collection:
:
stream
).
filter
(
item
->
ObjectUtil
.
equal
(
2
,
item
.
getStatus
())).
co
llect
(
Collectors
.
toList
()
);
L
ong
alreadySent
=
groupMsgDetail
.
stream
().
map
(
WeGroupMessageListVo:
:
getSenders
)
.
flatMap
(
Collection:
:
stream
).
filter
(
item
->
ObjectUtil
.
equal
(
2
,
item
.
getStatus
())).
co
unt
(
);
detailVo
.
setAlreadySendNum
(
alreadySent
.
intValue
());
//未发送客户数
Long
toBeCustomerNum
=
groupMsgDetail
.
stream
().
map
(
WeGroupMessageListVo:
:
getExtralInfos
).
flatMap
(
Collection:
:
stream
)
.
filter
(
item
->
ObjectUtil
.
equal
(
0
,
item
.
getStatus
())).
count
();
detailVo
.
setToBeSendCustomerNum
(
toBeCustomerNum
.
intValue
());
//已发送客户数
Long
alreadyCustomerNum
=
groupMsgDetail
.
stream
().
map
(
WeGroupMessageListVo:
:
getExtralInfos
).
flatMap
(
Collection:
:
stream
)
.
filter
(
item
->
!
ObjectUtil
.
equal
(
1
,
item
.
getStatus
())).
count
();
.
filter
(
item
->
ObjectUtil
.
equal
(
1
,
item
.
getStatus
())).
count
();
detailVo
.
setAlreadySendCustomerNum
(
alreadyCustomerNum
.
intValue
());
//未发送查询每个人员对应客户信息
if
(
CollectionUtil
.
isNotEmpty
(
toBeSent
))
{
/*
if (CollectionUtil.isNotEmpty(toBeSent)) {
List<WeGroupMessageTaskVo> toBeSentList = toBeSent.stream().map(userInfo -> {
WeGroupMessageTaskVo weGroupMessageTaskVo = new WeGroupMessageTaskVo();
weGroupMessageTaskVo.setUserId(userInfo.getUserId());
...
...
@@ -138,9 +138,9 @@ public class WeGroupMessageTemplateServiceImpl extends ServiceImpl<WeGroupMessag
}).collect(Collectors.toList());
detailVo.setToBeSendList(toBeSentList);
detailVo.setToBeSendNum(toBeSentList.size());
}
}
*/
//已发送查询每个人员对应客户信息
if
(
CollectionUtil
.
isNotEmpty
(
alreadySent
))
{
/*
if (CollectionUtil.isNotEmpty(alreadySent)) {
List<WeGroupMessageTaskVo> alreadySentList = alreadySent.stream().map(userInfo -> {
WeGroupMessageTaskVo weGroupMessageTaskVo = new WeGroupMessageTaskVo();
weGroupMessageTaskVo.setUserId(userInfo.getUserId());
...
...
@@ -163,7 +163,7 @@ public class WeGroupMessageTemplateServiceImpl extends ServiceImpl<WeGroupMessag
}).collect(Collectors.toList());
detailVo.setAlreadySendList(alreadySentList);
detailVo.setAlreadySendNum(alreadySentList.size());
}
}
*/
}
return
detailVo
;
}
...
...
@@ -309,6 +309,9 @@ public class WeGroupMessageTemplateServiceImpl extends ServiceImpl<WeGroupMessag
@Async
@Override
public
void
syncGroupMsgSendResultByIds
(
List
<
Long
>
asList
)
{
WeGroupMessageTemplate
template
=
new
WeGroupMessageTemplate
();
template
.
setRefreshTime
(
new
Date
());
this
.
update
(
template
,
new
LambdaQueryWrapper
<
WeGroupMessageTemplate
>().
in
(
WeGroupMessageTemplate:
:
getId
,
asList
));
List
<
WeGroupMessageList
>
weGroupMessageLists
=
weGroupMessageListService
.
list
(
new
LambdaQueryWrapper
<
WeGroupMessageList
>()
.
in
(
WeGroupMessageList:
:
getMsgTemplateId
,
asList
));
List
<
WeGroupMessageTask
>
taskList
=
new
ArrayList
<>();
...
...
linkwe-wecom/src/main/resources/mapper/wecom/WeGroupMessageSendResultMapper.xml
View file @
25d7bfa
...
...
@@ -47,13 +47,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and wgmsr.status = #{status}
</if>
<if
test=
"customerName != null and customerName != ''"
>
and wc.name like concat('%', #{customerName}, '%')
and exists
(select 1 from we_customer wc where
wc.external_userid = wgmsr.external_userid
and wc.name like concat('%', #{customerName}, '%'))
</if>
<if
test=
"userName != null and userName != ''"
>
and wu.user_name like concat('%', #{userName}, '%')
and exists
(select 1 from we_user wu where
wu.user_id = wgmsr.user_id
and wu.user_name like concat('%', #{userName}, '%'))
</if>
<if
test=
"chatName != null and chatName != ''"
>
and wg.group_name like concat('%', #{chatName}, '%')
and exists
(select 1 from we_group wg where wg.chat_id = wgmsr.chat_id
and wg.group_name like concat('%', #{chatName}, '%'))
</if>
<if
test=
"beginTime != null and beginTime != ''"
>
<!-- 开始时间检索 -->
AND date_format(wgmsr.send_time,'%y%m%d')
>
= date_format(#{beginTime},'%y%m%d')
...
...
linkwe-wecom/src/main/resources/mapper/wecom/WeGroupMessageTaskMapper.xml
View file @
25d7bfa
...
...
@@ -10,6 +10,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"msgId"
column=
"msg_id"
/>
<result
property=
"userId"
column=
"user_id"
/>
<result
property=
"userName"
column=
"user_name"
/>
<result
property=
"toBeCustomerName"
column=
"to_be_customer_name"
/>
<result
property=
"alreadyCustomerName"
column=
"already_customer_name"
/>
<result
property=
"status"
column=
"status"
/>
<result
property=
"sendTime"
column=
"send_time"
/>
</resultMap>
...
...
@@ -19,11 +21,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wgmt.msg_template_id,
wgmt.msg_id,
wgmt.user_id,
wu.
user_name,
(select wu.user_name from we_user wu where wu.user_id = wgmt.user_id limit 1) as
user_name,
wgmt.status,
wgmt.send_time
wgmt.send_time,
(select group_concat((select wc.name from we_customer wc where wc.external_userid = wgmsr.external_userid limit 1)) as customer_name
from we_group_message_send_result wgmsr where wgmsr.user_id = wgmt.user_id and wgmsr.status = 0) as to_be_customer_name ,
(select group_concat((select wc.name from we_customer wc where wc.external_userid = wgmsr.external_userid limit 1)) as customer_name
from we_group_message_send_result wgmsr where wgmsr.user_id = wgmt.user_id and wgmsr.status = 1) as already_customer_name,
from we_group_message_task wgmt
left join we_user wu on wu.user_id = wgmt.user_id
<where>
<if
test=
"id != null"
>
and wgmt.id = #{id}
...
...
@@ -35,7 +40,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and wgmt.msg_template_id = #{msgTemplateId}
</if>
<if
test=
"userName != null and userName != ''"
>
and wu.user_name like concat('%', #{userName}, '%')
and exists
(select 1 from we_user wu where wu.user_id = wgmt.user_id and wu.user_name like concat('%', #{userName}, '%'))
</if>
<if
test=
"status != null"
>
and wgmt.status = #{status}
...
...
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