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 a8794518
authored
Nov 15, 2021
by
danmo
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改任务宝群发逻辑
1 parent
8a65cd13
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
56 deletions
linkwe-admin/src/main/resources/application.yml
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeTaskFissionServiceImpl.java
linkwe-admin/src/main/resources/application.yml
View file @
a879451
...
@@ -89,7 +89,7 @@ logging:
...
@@ -89,7 +89,7 @@ logging:
H5
:
H5
:
domainPrefix
:
http://linkwechat.cn/
domainPrefix
:
http://linkwechat.cn/
url
:
http://h5.linkwechat.cn/index.html
url
:
http://h5.linkwechat.cn/index.html
fissionUrl
:
http://h5.linkwechat.cn/index.html
fissionUrl
:
http://h5.linkwechat.cn/index.html
?fissionId={}&fissionTargetId={}&posterId={}
fissionGroupUrl
:
http://h5.linkwechat.cn/fission.html
fissionGroupUrl
:
http://h5.linkwechat.cn/fission.html
# Spring配置
# Spring配置
spring
:
spring
:
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeTaskFissionServiceImpl.java
View file @
a879451
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
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.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.enums.MessageType
;
import
com.linkwechat.common.enums.TaskFissionType
;
import
com.linkwechat.common.enums.TaskFissionType
;
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
;
...
@@ -23,6 +26,7 @@ import com.linkwechat.wecom.domain.dto.WeExternalContactDto;
...
@@ -23,6 +26,7 @@ import com.linkwechat.wecom.domain.dto.WeExternalContactDto;
import
com.linkwechat.wecom.domain.dto.WeTaskFissionPosterDTO
;
import
com.linkwechat.wecom.domain.dto.WeTaskFissionPosterDTO
;
import
com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto
;
import
com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto
;
import
com.linkwechat.wecom.domain.dto.message.LinkMessageDto
;
import
com.linkwechat.wecom.domain.dto.message.LinkMessageDto
;
import
com.linkwechat.wecom.domain.query.WeAddGroupMessageQuery
;
import
com.linkwechat.wecom.domain.vo.WeTaskFissionDailyDataVO
;
import
com.linkwechat.wecom.domain.vo.WeTaskFissionDailyDataVO
;
import
com.linkwechat.wecom.domain.vo.WeTaskFissionProgressVO
;
import
com.linkwechat.wecom.domain.vo.WeTaskFissionProgressVO
;
import
com.linkwechat.wecom.domain.vo.WeTaskFissionStatisticVO
;
import
com.linkwechat.wecom.domain.vo.WeTaskFissionStatisticVO
;
...
@@ -75,6 +79,9 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
...
@@ -75,6 +79,9 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
@Autowired
@Autowired
private
IWeTaskFissionCompleteRecordService
weTaskFissionCompleteRecordService
;
private
IWeTaskFissionCompleteRecordService
weTaskFissionCompleteRecordService
;
@Autowired
private
IWeGroupMessageTemplateService
weGroupMessageTemplateService
;
@Value
(
"${H5.fissionUrl}"
)
@Value
(
"${H5.fissionUrl}"
)
private
String
pageUrl
;
private
String
pageUrl
;
@Value
(
"${H5.fissionGroupUrl}"
)
@Value
(
"${H5.fissionGroupUrl}"
)
...
@@ -197,57 +204,56 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
...
@@ -197,57 +204,56 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
//目标员工id
//目标员工id
String
fissStaffId
=
weTaskFission
.
getFissionTargetId
();
String
fissStaffId
=
weTaskFission
.
getFissionTargetId
();
//H5生成海报页面路径
//H5生成海报页面路径
StringBuilder
pageUrlBuilder
=
new
StringBuilder
(
pageUrl
);
String
pageUrlStr
=
StringUtils
.
format
(
pageUrl
,
id
,
fissStaffId
,
weTaskFission
.
getPostersId
());
pageUrlBuilder
.
append
(
"?"
)
.
append
(
"fissionId="
).
append
(
id
)
.
append
(
"&"
)
WeAddGroupMessageQuery
messageQuery
=
new
WeAddGroupMessageQuery
();
.
append
(
"fissionTargetId="
).
append
(
fissStaffId
)
messageQuery
.
setChatType
(
1
);
.
append
(
"&"
)
WeMessageTemplate
weMessageTemplate
=
new
WeMessageTemplate
();
.
append
(
"posterId="
).
append
(
weTaskFission
.
getPostersId
());
weMessageTemplate
.
setMsgType
(
MessageType
.
LINK
.
getMessageType
());
LinkMessageDto
linkMessageDto
=
new
LinkMessageDto
();
weMessageTemplate
.
setMediaId
(
postersPath
);
linkMessageDto
.
setPicurl
(
postersPath
);
weMessageTemplate
.
setDescription
(
weTaskFission
.
getFissInfo
());
linkMessageDto
.
setDesc
(
weTaskFission
.
getFissInfo
());
weMessageTemplate
.
setLinkUrl
(
pageUrlStr
);
linkMessageDto
.
setTitle
(
weTaskFission
.
getTaskName
());
weMessageTemplate
.
setTitle
(
weTaskFission
.
getTaskName
());
linkMessageDto
.
setUrl
(
pageUrlBuilder
.
toString
());
weMessageTemplate
.
setPicUrl
(
postersPath
);
messageQuery
.
setAttachmentsList
(
ListUtil
.
toList
(
weMessageTemplate
));
CustomerMessagePushDto
customerMessagePushDto
=
new
CustomerMessagePushDto
();
if
(
weTaskFission
.
getStartTime
()
!=
null
&&
weTaskFission
.
getStartTime
().
getTime
()
<=
System
.
currentTimeMillis
())
{
if
(
weTaskFission
.
getStartTime
()
!=
null
&&
weTaskFission
.
getStartTime
().
getTime
()
<=
System
.
currentTimeMillis
())
{
customerMessagePushDto
.
setSendNow
(
true
);
messageQuery
.
setIsTask
(
0
);
customerMessagePushDto
.
setSettingTime
(
null
);
}
else
{
}
else
{
customerMessagePushDto
.
setSendNow
(
false
);
messageQuery
.
setIsTask
(
1
);
customerMessagePushDto
.
setSettingTime
(
DateUtil
.
formatDateTime
(
weTaskFission
.
getStartTime
()
));
messageQuery
.
setSendTime
(
weTaskFission
.
getStartTime
(
));
}
}
customerMessagePushDto
.
setLinkMessage
(
linkMessageDto
);
customerMessagePushDto
.
setPushType
(
"0"
);
customerMessagePushDto
.
setPushRange
(
"1"
);
customerMessagePushDto
.
setMessageType
(
"2"
);
customerMessagePushDto
.
setTag
(
weTaskFission
.
getCustomerTagId
());
//查询发起成员
//查询发起成员
List
<
WeTaskFissionStaff
>
weTaskFissionStaffList
=
weTaskFissionStaffService
.
selectWeTaskFissionStaffByTaskId
(
id
);
List
<
WeTaskFissionStaff
>
weTaskFissionStaffList
=
weTaskFissionStaffService
.
selectWeTaskFissionStaffByTaskId
(
id
);
if
(
CollectionUtil
.
isNotEmpty
(
weTaskFissionStaffList
))
{
//获取部门id
//获取部门id
String
departmentIds
=
Optional
.
ofNullable
(
weTaskFissionStaffList
).
orElseGet
(
ArrayList:
:
new
).
stream
().
filter
(
weTaskFissionStaff
->
String
departmentIds
=
weTaskFissionStaffList
.
stream
().
filter
(
weTaskFissionStaff
->
WeConstans
.
USE_SCOP_BUSINESSID_TYPE_ORG
.
equals
(
weTaskFissionStaff
.
getStaffType
()))
WeConstans
.
USE_SCOP_BUSINESSID_TYPE_ORG
.
equals
(
weTaskFissionStaff
.
getStaffType
()))
.
map
(
WeTaskFissionStaff:
:
getStaffId
).
collect
(
Collectors
.
joining
(
","
));
.
map
(
WeTaskFissionStaff:
:
getStaffId
).
collect
(
Collectors
.
joining
(
","
));
//获取成员id
//获取成员id
String
userIds
=
Optional
.
ofNullable
(
weTaskFissionStaffList
).
orElseGet
(
ArrayList:
:
new
).
stream
().
filter
(
weTaskFissionStaff
->
String
userIds
=
weTaskFissionStaffList
.
stream
().
filter
(
weTaskFissionStaff
->
WeConstans
.
USE_SCOP_BUSINESSID_TYPE_USER
.
equals
(
weTaskFissionStaff
.
getStaffType
()))
WeConstans
.
USE_SCOP_BUSINESSID_TYPE_USER
.
equals
(
weTaskFissionStaff
.
getStaffType
()))
.
map
(
WeTaskFissionStaff:
:
getStaffId
).
collect
(
Collectors
.
joining
(
","
));
.
map
(
WeTaskFissionStaff:
:
getStaffId
).
collect
(
Collectors
.
joining
(
","
));
List
<
WeCustomerList
>
weCustomerList
=
weCustomerService
.
findWeCustomerList
(
WeCustomerList
.
builder
()
customerMessagePushDto
.
setStaffId
(
userIds
);
.
userIds
(
userIds
)
customerMessagePushDto
.
setDepartment
(
departmentIds
);
.
tagIds
(
weTaskFission
.
getCustomerTagId
().
replaceAll
(
"all"
,
""
))
}
.
departmentIds
(
departmentIds
)
try
{
.
build
());
SecurityContext
context
=
SecurityContextHolder
.
getContext
();
if
(
weCustomerList
!=
null
){
SecurityContextHolder
.
setStrategyName
(
SecurityContextHolder
.
MODE_INHERITABLETHREADLOCAL
);
Map
<
String
,
Set
<
String
>>
userAndCustomerMap
=
weCustomerList
.
stream
().
collect
(
Collectors
.
groupingBy
(
WeCustomerList:
:
getFirstUserId
,
Collectors
.
mapping
(
WeCustomerList:
:
getExternalUserid
,
Collectors
.
toSet
())));
SecurityContextHolder
.
setContext
(
context
);
List
<
WeAddGroupMessageQuery
.
SenderInfo
>
senderList
=
new
ArrayList
<>();
weCustomerMessagePushService
.
addWeCustomerMessagePush
(
customerMessagePushDto
);
userAndCustomerMap
.
forEach
((
userId
,
customerIds
)
->{
}
catch
(
JsonProcessingException
|
ParseException
|
CloneNotSupportedException
e
)
{
WeAddGroupMessageQuery
.
SenderInfo
senderInfo
=
new
WeAddGroupMessageQuery
.
SenderInfo
();
e
.
printStackTrace
();
senderInfo
.
setUserId
(
userId
);
log
.
error
(
"发送任务失败》》》》》》》》》》》params:{},ex:{}"
,
JSONObject
.
toJSONString
(
customerMessagePushDto
),
e
);
if
(!
ObjectUtil
.
equal
(
"all"
,
weTaskFission
.
getCustomerTagId
()))
{
senderInfo
.
setCustomerList
(
new
ArrayList
<>(
customerIds
));
}
senderList
.
add
(
senderInfo
);
});
}
}
weGroupMessageTemplateService
.
addGroupMsgTemplate
(
messageQuery
);
}
}
@Override
@Override
...
@@ -315,16 +321,21 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
...
@@ -315,16 +321,21 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
});
});
}
}
}
else
{
}
else
{
// WeTaskFissionRecord weTaskFissionRecord = weTaskFissionRecordService
WeTaskFissionRecord
weTaskFissionRecord
=
weTaskFissionRecordService
// .selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), unionId);
.
selectWeTaskFissionRecordByIdAndCustomerId
(
Long
.
valueOf
(
fissionId
),
unionId
);
// Optional.ofNullable(weTaskFissionRecord).orElseThrow(() -> new WeComException("任务记录信息不存在"));
Optional
.
ofNullable
(
weTaskFissionRecord
).
orElseThrow
(()
->
new
WeComException
(
"任务记录信息不存在"
));
// List<WeFlowerCustomerRel> list = weFlowerCustomerRelService.list(new LambdaQueryWrapper<WeFlowerCustomerRel>()
// .eq(WeFlowerCustomerRel::getState, WeConstans.FISSION_PREFIX + weTaskFissionRecord.getId()));
// List<String> eidList = Optional.ofNullable(list).orElseGet(ArrayList::new).stream()
List
<
WeCustomer
>
weCustomers
=
weCustomerService
.
list
(
new
LambdaQueryWrapper
<
WeCustomer
>()
// .map(WeFlowerCustomerRel::getExternalUserid).collect(Collectors.toList());
.
eq
(
WeCustomer:
:
getState
,
WeConstans
.
FISSION_PREFIX
+
weTaskFissionRecord
.
getId
()));
// if (CollectionUtil.isNotEmpty(eidList)) {
// customerList.addAll(weCustomerService.listByIds(eidList));
// }
List
<
String
>
eidList
=
Optional
.
ofNullable
(
weCustomers
).
orElseGet
(
ArrayList:
:
new
).
stream
()
.
map
(
WeCustomer:
:
getExternalUserid
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtil
.
isNotEmpty
(
eidList
))
{
customerList
.
addAll
(
weCustomerService
.
listByIds
(
eidList
));
}
}
}
return
customerList
;
return
customerList
;
}
}
...
...
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