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 96816ce9
authored
Dec 09, 2021
by
linkwechat8856@163.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
相关bug修复
1 parent
9303401b
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
137 additions
and
28 deletions
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerController.java
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeGroupController.java
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeMomentsController.java
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTagGroupController.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/aspectj/SynchRecordAop.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/constants/SynchRecordConstants.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeGroupServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeMaterialServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeMomentsServiceImpl.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeTagGroupServiceImpl.java
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerController.java
View file @
96816ce
...
@@ -8,6 +8,7 @@ import com.linkwechat.common.core.controller.BaseController;
...
@@ -8,6 +8,7 @@ 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.TableDataInfo
;
import
com.linkwechat.common.core.page.TableDataInfo
;
import
com.linkwechat.common.enums.BusinessType
;
import
com.linkwechat.common.enums.BusinessType
;
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.*
;
...
@@ -93,7 +94,12 @@ public class WeCustomerController extends BaseController
...
@@ -93,7 +94,12 @@ public class WeCustomerController extends BaseController
@GetMapping
(
"/synchWeCustomer"
)
@GetMapping
(
"/synchWeCustomer"
)
public
AjaxResult
synchWeCustomer
()
{
public
AjaxResult
synchWeCustomer
()
{
try
{
weCustomerService
.
synchWeCustomer
();
weCustomerService
.
synchWeCustomer
();
}
catch
(
CustomException
e
){
return
AjaxResult
.
error
(
e
.
getMessage
());
}
return
AjaxResult
.
success
(
WeConstans
.
SYNCH_TIP
);
return
AjaxResult
.
success
(
WeConstans
.
SYNCH_TIP
);
...
...
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeGroupController.java
View file @
96816ce
...
@@ -5,6 +5,7 @@ import com.linkwechat.common.constant.WeConstans;
...
@@ -5,6 +5,7 @@ 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.TableDataInfo
;
import
com.linkwechat.common.core.page.TableDataInfo
;
import
com.linkwechat.common.exception.CustomException
;
import
com.linkwechat.wecom.constants.SynchRecordConstants
;
import
com.linkwechat.wecom.constants.SynchRecordConstants
;
import
com.linkwechat.wecom.domain.WeGroup
;
import
com.linkwechat.wecom.domain.WeGroup
;
import
com.linkwechat.wecom.domain.WeGroupMember
;
import
com.linkwechat.wecom.domain.WeGroupMember
;
...
@@ -87,7 +88,12 @@ public class WeGroupController extends BaseController {
...
@@ -87,7 +88,12 @@ public class WeGroupController extends BaseController {
// @PreAuthorize("@ss.hasPermi('customerManage:group:sync')")
// @PreAuthorize("@ss.hasPermi('customerManage:group:sync')")
@GetMapping
({
"/synchWeGroup"
})
@GetMapping
({
"/synchWeGroup"
})
public
AjaxResult
synchWeGroup
(){
public
AjaxResult
synchWeGroup
(){
try
{
weGroupService
.
synchWeGroup
();
weGroupService
.
synchWeGroup
();
}
catch
(
CustomException
e
){
return
AjaxResult
.
error
(
e
.
getMessage
());
}
return
AjaxResult
.
success
(
WeConstans
.
SYNCH_TIP
);
return
AjaxResult
.
success
(
WeConstans
.
SYNCH_TIP
);
}
}
...
...
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeMomentsController.java
View file @
96816ce
...
@@ -4,6 +4,7 @@ import com.linkwechat.common.constant.WeConstans;
...
@@ -4,6 +4,7 @@ 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.TableDataInfo
;
import
com.linkwechat.common.core.page.TableDataInfo
;
import
com.linkwechat.common.exception.CustomException
;
import
com.linkwechat.wecom.client.WeMomentsClient
;
import
com.linkwechat.wecom.client.WeMomentsClient
;
import
com.linkwechat.wecom.constants.SynchRecordConstants
;
import
com.linkwechat.wecom.constants.SynchRecordConstants
;
import
com.linkwechat.wecom.domain.WeMoments
;
import
com.linkwechat.wecom.domain.WeMoments
;
...
@@ -90,11 +91,17 @@ public class WeMomentsController extends BaseController {
...
@@ -90,11 +91,17 @@ public class WeMomentsController extends BaseController {
@GetMapping
(
"/synchMoments"
)
@GetMapping
(
"/synchMoments"
)
public
AjaxResult
synchMoments
(
@RequestParam
(
defaultValue
=
"0"
)
Integer
filterType
){
public
AjaxResult
synchMoments
(
@RequestParam
(
defaultValue
=
"0"
)
Integer
filterType
){
try
{
if
(
filterType
.
equals
(
new
Integer
(
0
))){
if
(
filterType
.
equals
(
new
Integer
(
0
))){
iWeMomentsService
.
synchEnterpriseMoments
(
filterType
);
iWeMomentsService
.
synchEnterpriseMoments
(
filterType
);
}
else
if
(
filterType
.
equals
(
new
Integer
(
1
))){
}
else
if
(
filterType
.
equals
(
new
Integer
(
1
))){
iWeMomentsService
.
synchPersonMoments
(
filterType
);
iWeMomentsService
.
synchPersonMoments
(
filterType
);
}
}
}
catch
(
CustomException
e
){
return
AjaxResult
.
error
(
e
.
getMessage
());
}
return
AjaxResult
.
success
(
WeConstans
.
SYNCH_TIP
);
return
AjaxResult
.
success
(
WeConstans
.
SYNCH_TIP
);
}
}
...
...
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTagGroupController.java
View file @
96816ce
...
@@ -9,8 +9,11 @@ import com.linkwechat.common.core.controller.BaseController;
...
@@ -9,8 +9,11 @@ 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.TableDataInfo
;
import
com.linkwechat.common.core.page.TableDataInfo
;
import
com.linkwechat.common.enums.BusinessType
;
import
com.linkwechat.common.enums.BusinessType
;
import
com.linkwechat.common.exception.CustomException
;
import
com.linkwechat.common.utils.Threads
;
import
com.linkwechat.common.utils.Threads
;
import
com.linkwechat.wecom.constants.SynchRecordConstants
;
import
com.linkwechat.wecom.domain.WeTag
;
import
com.linkwechat.wecom.domain.WeTag
;
import
com.linkwechat.wecom.service.IWeSynchRecordService
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.core.context.SecurityContext
;
import
org.springframework.security.core.context.SecurityContext
;
...
@@ -41,6 +44,9 @@ public class WeTagGroupController extends BaseController
...
@@ -41,6 +44,9 @@ public class WeTagGroupController extends BaseController
@Autowired
@Autowired
private
IWeTagGroupService
weTagGroupService
;
private
IWeTagGroupService
weTagGroupService
;
@Autowired
private
IWeSynchRecordService
iWeSynchRecordService
;
/**
/**
* 查询标签组列表(分页)
* 查询标签组列表(分页)
*/
*/
...
@@ -49,9 +55,13 @@ public class WeTagGroupController extends BaseController
...
@@ -49,9 +55,13 @@ public class WeTagGroupController extends BaseController
public
TableDataInfo
list
(
WeTagGroup
weTagGroup
)
public
TableDataInfo
list
(
WeTagGroup
weTagGroup
)
{
{
startPage
();
startPage
();
return
getDataTable
(
weTagGroupService
.
selectWeTagGroupList
(
weTagGroup
)
TableDataInfo
dataTable
=
getDataTable
(
weTagGroupService
.
selectWeTagGroupList
(
weTagGroup
));
);
dataTable
.
setLastSyncTime
(
iWeSynchRecordService
.
findUpdateLatestTime
(
SynchRecordConstants
.
SYNCH_CUSTOMER
)
);
//最近同步时间
return
dataTable
;
}
}
...
@@ -126,16 +136,12 @@ public class WeTagGroupController extends BaseController
...
@@ -126,16 +136,12 @@ public class WeTagGroupController extends BaseController
@GetMapping
(
"/synchWeTags"
)
@GetMapping
(
"/synchWeTags"
)
public
AjaxResult
synchWeTags
(){
public
AjaxResult
synchWeTags
(){
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
try
{
//异步同步一下标签库,解决标签不同步问题
Threads
.
SINGLE_THREAD_POOL
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
SecurityContextHolder
.
setContext
(
securityContext
);
weTagGroupService
.
synchWeTags
();
weTagGroupService
.
synchWeTags
();
}
catch
(
CustomException
e
){
return
AjaxResult
.
error
(
e
.
getMessage
());
}
}
});
return
AjaxResult
.
success
(
WeConstans
.
SYNCH_TIP
);
return
AjaxResult
.
success
(
WeConstans
.
SYNCH_TIP
);
}
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/aspectj/SynchRecordAop.java
View file @
96816ce
...
@@ -2,6 +2,7 @@ package com.linkwechat.wecom.aspectj;
...
@@ -2,6 +2,7 @@ package com.linkwechat.wecom.aspectj;
import
cn.hutool.core.collection.CollectionUtil
;
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.exception.CustomException
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.wecom.annotation.SynchRecord
;
import
com.linkwechat.wecom.annotation.SynchRecord
;
import
com.linkwechat.wecom.domain.WeSynchRecord
;
import
com.linkwechat.wecom.domain.WeSynchRecord
;
...
@@ -41,10 +42,12 @@ public class SynchRecordAop {
...
@@ -41,10 +42,12 @@ public class SynchRecordAop {
if
(
null
!=
annotationLog
){
if
(
null
!=
annotationLog
){
List
<
WeSynchRecord
>
weSynchRecords
=
iWeSynchRecordService
.
list
(
new
LambdaQueryWrapper
<
WeSynchRecord
>()
List
<
WeSynchRecord
>
weSynchRecords
=
iWeSynchRecordService
.
list
(
new
LambdaQueryWrapper
<
WeSynchRecord
>()
.
eq
(
WeSynchRecord:
:
getSynchType
,
annotationLog
.
synchType
())
.
eq
(
WeSynchRecord:
:
getSynchType
,
annotationLog
.
synchType
())
.
apply
(
"date_format (synch_time,'%Y-%m-%d HH:mm:ss') >= date_format('"
+
DateUtils
.
getBeforeByHourTime
(
2
)
+
"','%Y-%m-%d HH:mm:ss')"
)
.
between
(
WeSynchRecord:
:
getSynchTime
,
DateUtils
.
getBeforeByHourTime
(
2
)
.
apply
(
"date_format (synch_time,'%Y-%m-%d HH:mm:ss') <= date_format('"
+
DateUtils
.
getBeforeByHourTime
(
0
)
+
"','%Y-%m-%d HH:mm:ss')"
));
,
DateUtils
.
getBeforeByHourTime
(
0
)
));
if
(
CollectionUtil
.
isEmpty
(
weSynchRecords
)||
weSynchRecords
.
size
()<=
1
){
if
(
CollectionUtil
.
isEmpty
(
weSynchRecords
)||
weSynchRecords
.
size
()<=
1
){
joinPoint
.
proceed
();
joinPoint
.
proceed
();
}
else
{
throw
new
CustomException
(
"由于企业微信开放平台的限制,两小时内不得重复同步操作"
);
}
}
}
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/constants/SynchRecordConstants.java
View file @
96816ce
...
@@ -10,4 +10,5 @@ public class SynchRecordConstants {
...
@@ -10,4 +10,5 @@ public class SynchRecordConstants {
public
static
final
int
SYNCH_CUSTOMER_GROUP
=
3
;
//客户群同步
public
static
final
int
SYNCH_CUSTOMER_GROUP
=
3
;
//客户群同步
public
static
final
int
SYNCH_CUSTOMER_PERSON_MOMENTS
=
4
;
//个人朋友圈
public
static
final
int
SYNCH_CUSTOMER_PERSON_MOMENTS
=
4
;
//个人朋友圈
public
static
final
int
SYNCH_CUSTOMER_ENTERPRISE_MOMENTS
=
5
;
//企业朋友圈
public
static
final
int
SYNCH_CUSTOMER_ENTERPRISE_MOMENTS
=
5
;
//企业朋友圈
public
static
final
int
SYNCH_CUSTOMER_TAG
=
6
;
//企业标签同步
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerServiceImpl.java
View file @
96816ce
...
@@ -11,6 +11,7 @@ import com.linkwechat.common.enums.TrajectorySceneType;
...
@@ -11,6 +11,7 @@ import com.linkwechat.common.enums.TrajectorySceneType;
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
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.common.utils.Threads
;
import
com.linkwechat.common.utils.bean.BeanUtils
;
import
com.linkwechat.common.utils.bean.BeanUtils
;
import
com.linkwechat.wecom.annotation.SynchRecord
;
import
com.linkwechat.wecom.annotation.SynchRecord
;
import
com.linkwechat.wecom.client.WeCustomerClient
;
import
com.linkwechat.wecom.client.WeCustomerClient
;
...
@@ -21,12 +22,15 @@ import com.linkwechat.wecom.domain.dto.AllocateWeCustomerDto;
...
@@ -21,12 +22,15 @@ import com.linkwechat.wecom.domain.dto.AllocateWeCustomerDto;
import
com.linkwechat.wecom.domain.dto.WeCustomerDto
;
import
com.linkwechat.wecom.domain.dto.WeCustomerDto
;
import
com.linkwechat.wecom.domain.dto.WeWelcomeMsg
;
import
com.linkwechat.wecom.domain.dto.WeWelcomeMsg
;
import
com.linkwechat.wecom.domain.dto.customer.*
;
import
com.linkwechat.wecom.domain.dto.customer.*
;
import
com.linkwechat.wecom.domain.dto.tag.WeCropGroupTagListDto
;
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.mapper.WeCustomerMapper
;
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.security.core.context.SecurityContext
;
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.*
;
...
@@ -92,10 +96,18 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
...
@@ -92,10 +96,18 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
* @return
* @return
*/
*/
@Override
@Override
@Async
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@SynchRecord
(
synchType
=
SynchRecordConstants
.
SYNCH_CUSTOMER
)
@SynchRecord
(
synchType
=
SynchRecordConstants
.
SYNCH_CUSTOMER
)
public
void
synchWeCustomer
()
{
public
void
synchWeCustomer
()
{
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
//异步同步一下标签库,解决标签不同步问题
Threads
.
SINGLE_THREAD_POOL
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
SecurityContextHolder
.
setContext
(
securityContext
);
//获取所有可以添加客户的企业员工
//获取所有可以添加客户的企业员工
FollowUserList
followUserList
=
weCustomerClient
.
getFollowUserList
();
FollowUserList
followUserList
=
weCustomerClient
.
getFollowUserList
();
if
(
WeConstans
.
WE_SUCCESS_CODE
.
equals
(
followUserList
.
getErrcode
())
if
(
WeConstans
.
WE_SUCCESS_CODE
.
equals
(
followUserList
.
getErrcode
())
...
@@ -107,7 +119,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
...
@@ -107,7 +119,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
getByUser
(
follow_user
,
null
,
externalUserDetails
);
getByUser
(
follow_user
,
null
,
externalUserDetails
);
if
(
CollectionUtil
.
isNotEmpty
(
externalUserDetails
)){
if
(
CollectionUtil
.
isNotEmpty
(
externalUserDetails
)){
this
.
weFlowerCustomerHandle
(
weFlowerCustomerHandle
(
externalUserDetails
externalUserDetails
);
);
}
}
...
@@ -115,6 +127,10 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
...
@@ -115,6 +127,10 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
}
}
}
}
});
}
/**
/**
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeGroupServiceImpl.java
View file @
96816ce
...
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.utils.StringUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.common.utils.Threads
;
import
com.linkwechat.wecom.annotation.SynchRecord
;
import
com.linkwechat.wecom.annotation.SynchRecord
;
import
com.linkwechat.wecom.client.WeCustomerClient
;
import
com.linkwechat.wecom.client.WeCustomerClient
;
import
com.linkwechat.wecom.client.WeCustomerGroupClient
;
import
com.linkwechat.wecom.client.WeCustomerGroupClient
;
...
@@ -17,9 +18,7 @@ import com.linkwechat.wecom.domain.WeCustomerAddGroup;
...
@@ -17,9 +18,7 @@ import com.linkwechat.wecom.domain.WeCustomerAddGroup;
import
com.linkwechat.wecom.domain.WeGroup
;
import
com.linkwechat.wecom.domain.WeGroup
;
import
com.linkwechat.wecom.domain.WeGroupMember
;
import
com.linkwechat.wecom.domain.WeGroupMember
;
import
com.linkwechat.wecom.domain.dto.AllocateWeGroupDto
;
import
com.linkwechat.wecom.domain.dto.AllocateWeGroupDto
;
import
com.linkwechat.wecom.domain.dto.customer.CustomerGroupDetail
;
import
com.linkwechat.wecom.domain.dto.customer.*
;
import
com.linkwechat.wecom.domain.dto.customer.CustomerGroupList
;
import
com.linkwechat.wecom.domain.dto.customer.CustomerGroupMember
;
import
com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo
;
import
com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo
;
import
com.linkwechat.wecom.mapper.WeGroupMapper
;
import
com.linkwechat.wecom.mapper.WeGroupMapper
;
import
com.linkwechat.wecom.service.IWeAllocateGroupService
;
import
com.linkwechat.wecom.service.IWeAllocateGroupService
;
...
@@ -27,6 +26,8 @@ import com.linkwechat.wecom.service.IWeGroupMemberService;
...
@@ -27,6 +26,8 @@ import com.linkwechat.wecom.service.IWeGroupMemberService;
import
com.linkwechat.wecom.service.IWeGroupService
;
import
com.linkwechat.wecom.service.IWeGroupService
;
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.security.core.context.SecurityContext
;
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
;
...
@@ -118,11 +119,18 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper, WeGroup> impl
...
@@ -118,11 +119,18 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper, WeGroup> impl
* 客户群同步
* 客户群同步
*/
*/
@Override
@Override
@Async
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@SynchRecord
(
synchType
=
SynchRecordConstants
.
SYNCH_CUSTOMER_GROUP
)
@SynchRecord
(
synchType
=
SynchRecordConstants
.
SYNCH_CUSTOMER_GROUP
)
public
void
synchWeGroup
()
{
public
void
synchWeGroup
()
{
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
//异步同步一下标签库,解决标签不同步问题
Threads
.
SINGLE_THREAD_POOL
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
SecurityContextHolder
.
setContext
(
securityContext
);
CustomerGroupList
customerGroupList
=
CustomerGroupList
customerGroupList
=
weCustomerGroupClient
.
groupChatLists
(
new
CustomerGroupList
().
new
Params
());
weCustomerGroupClient
.
groupChatLists
(
new
CustomerGroupList
().
new
Params
());
if
(
customerGroupList
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
)
if
(
customerGroupList
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
)
...
@@ -180,6 +188,12 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper, WeGroup> impl
...
@@ -180,6 +188,12 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper, WeGroup> impl
insertBatchGroupAndMember
(
weGroups
,
weGroupMembers
);
insertBatchGroupAndMember
(
weGroups
,
weGroupMembers
);
}
}
}
});
}
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeMaterialServiceImpl.java
View file @
96816ce
...
@@ -267,8 +267,8 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
...
@@ -267,8 +267,8 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
};
};
try
{
try
{
WeMaterialFileVO
weMaterialFileVO
=
this
.
uploadWeMaterialFile
(
file1
,
fileType
);
return
this
.
uploadWeMaterialFile
(
file1
,
fileType
).
getMaterialUrl
();
return
weMaterialFileVO
.
getMaterialUrl
()+
weMaterialFileVO
.
getMaterialName
();
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
log
.
error
(
"朋友圈资源获取失败:"
+
e
.
getMessage
());
log
.
error
(
"朋友圈资源获取失败:"
+
e
.
getMessage
());
}
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeMomentsServiceImpl.java
View file @
96816ce
...
@@ -12,6 +12,7 @@ import com.linkwechat.common.enums.MediaType;
...
@@ -12,6 +12,7 @@ import com.linkwechat.common.enums.MediaType;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.common.utils.Threads
;
import
com.linkwechat.wecom.annotation.SynchRecord
;
import
com.linkwechat.wecom.annotation.SynchRecord
;
import
com.linkwechat.wecom.client.WeMomentsClient
;
import
com.linkwechat.wecom.client.WeMomentsClient
;
import
com.linkwechat.wecom.constants.SynchRecordConstants
;
import
com.linkwechat.wecom.constants.SynchRecordConstants
;
...
@@ -20,6 +21,8 @@ import com.linkwechat.wecom.domain.WeMomentsInteracte;
...
@@ -20,6 +21,8 @@ import com.linkwechat.wecom.domain.WeMomentsInteracte;
import
com.linkwechat.wecom.domain.WeUser
;
import
com.linkwechat.wecom.domain.WeUser
;
import
com.linkwechat.wecom.domain.dto.WeMediaDto
;
import
com.linkwechat.wecom.domain.dto.WeMediaDto
;
import
com.linkwechat.wecom.domain.dto.WeResultDto
;
import
com.linkwechat.wecom.domain.dto.WeResultDto
;
import
com.linkwechat.wecom.domain.dto.customer.ExternalUserDetail
;
import
com.linkwechat.wecom.domain.dto.customer.FollowUserList
;
import
com.linkwechat.wecom.domain.dto.moments.*
;
import
com.linkwechat.wecom.domain.dto.moments.*
;
import
com.linkwechat.wecom.mapper.WeMomentsMapper
;
import
com.linkwechat.wecom.mapper.WeMomentsMapper
;
import
com.linkwechat.wecom.service.IWeMaterialService
;
import
com.linkwechat.wecom.service.IWeMaterialService
;
...
@@ -28,6 +31,8 @@ import com.linkwechat.wecom.service.IWeUserService;
...
@@ -28,6 +31,8 @@ import com.linkwechat.wecom.service.IWeUserService;
import
com.linkwechat.wecom.service.WeMomentsInteracteService
;
import
com.linkwechat.wecom.service.WeMomentsInteracteService
;
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.security.core.context.SecurityContext
;
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
;
...
@@ -258,11 +263,13 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
...
@@ -258,11 +263,13 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
* @param filterType
* @param filterType
*/
*/
@Override
@Override
@Async
@Transactional
@Transactional
@SynchRecord
(
synchType
=
SynchRecordConstants
.
SYNCH_CUSTOMER_PERSON_MOMENTS
)
@SynchRecord
(
synchType
=
SynchRecordConstants
.
SYNCH_CUSTOMER_PERSON_MOMENTS
)
public
void
synchPersonMoments
(
Integer
filterType
)
{
public
void
synchPersonMoments
(
Integer
filterType
)
{
this
.
synchMoments
(
filterType
);
this
.
synchMoments
(
filterType
);
}
}
...
@@ -271,7 +278,6 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
...
@@ -271,7 +278,6 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
* @param filterType
* @param filterType
*/
*/
@Override
@Override
@Async
@Transactional
@Transactional
@SynchRecord
(
synchType
=
SynchRecordConstants
.
SYNCH_CUSTOMER_ENTERPRISE_MOMENTS
)
@SynchRecord
(
synchType
=
SynchRecordConstants
.
SYNCH_CUSTOMER_ENTERPRISE_MOMENTS
)
public
void
synchEnterpriseMoments
(
Integer
filterType
)
{
public
void
synchEnterpriseMoments
(
Integer
filterType
)
{
...
@@ -296,8 +302,17 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
...
@@ -296,8 +302,17 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
private
void
synchMoments
(
Integer
filterType
)
{
private
void
synchMoments
(
Integer
filterType
)
{
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
//异步同步一下标签库,解决标签不同步问题
Threads
.
SINGLE_THREAD_POOL
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
SecurityContextHolder
.
setContext
(
securityContext
);
List
<
MomentsListDetailResultDto
.
Moment
>
moments
=
new
ArrayList
<>();
List
<
MomentsListDetailResultDto
.
Moment
>
moments
=
new
ArrayList
<>();
this
.
getByMoment
(
null
,
moments
,
filterType
);
getByMoment
(
null
,
moments
,
filterType
);
if
(
CollectionUtil
.
isNotEmpty
(
moments
)){
if
(
CollectionUtil
.
isNotEmpty
(
moments
)){
...
@@ -360,6 +375,7 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
...
@@ -360,6 +375,7 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
WeMoments
weMoment
=
WeMoments
.
builder
()
WeMoments
weMoment
=
WeMoments
.
builder
()
.
type
(
moment
.
getCreate_type
())
.
type
(
moment
.
getCreate_type
())
.
scopeType
(
moment
.
getVisible_type
())
.
scopeType
(
moment
.
getVisible_type
())
.
createTime
(
moment
.
getCreate_time
())
.
addUser
(
moment
.
getCreator
())
.
addUser
(
moment
.
getCreator
())
.
momentId
(
moment
.
getMoment_id
())
.
momentId
(
moment
.
getMoment_id
())
.
creator
(
moment
.
getCreator
())
.
creator
(
moment
.
getCreator
())
...
@@ -377,15 +393,19 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
...
@@ -377,15 +393,19 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
//文本
//文本
Optional
.
ofNullable
(
moment
.
getText
()).
ifPresent
(
k
->{
Optional
.
ofNullable
(
moment
.
getText
()).
ifPresent
(
k
->{
if
(
StringUtils
.
isNotEmpty
(
k
.
getContent
())){
weMoment
.
setContent
(
k
.
getContent
());
weMoment
.
setContent
(
k
.
getContent
());
weMoment
.
setContentType
(
MediaType
.
TEXT
.
getMediaType
());
weMoment
.
setContentType
(
MediaType
.
TEXT
.
getMediaType
());
}
});
});
List
<
WeMoments
.
OtherContent
>
otherContents
=
new
ArrayList
<>();
List
<
WeMoments
.
OtherContent
>
otherContents
=
new
ArrayList
<>();
//图片
//图片
Optional
.
ofNullable
(
moment
.
getImage
()).
ifPresent
(
k
->{
Optional
.
ofNullable
(
moment
.
getImage
()).
ifPresent
(
k
->{
if
(
CollectionUtil
.
isNotEmpty
(
k
)){
k
.
stream
().
forEach
(
image
->{
k
.
stream
().
forEach
(
image
->{
if
(
StringUtils
.
isNotEmpty
(
weMoment
.
getContent
())){
if
(
StringUtils
.
isNotEmpty
(
weMoment
.
getContent
())){
...
@@ -400,6 +420,9 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
...
@@ -400,6 +420,9 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
);
);
});
});
weMoment
.
setContentType
(
MediaType
.
IMAGE
.
getMediaType
());
weMoment
.
setContentType
(
MediaType
.
IMAGE
.
getMediaType
());
}
});
});
//视频
//视频
...
@@ -450,7 +473,7 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
...
@@ -450,7 +473,7 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
});
});
this
.
saveOrUpdateBatch
(
weMoments
);
saveOrUpdateBatch
(
weMoments
);
if
(
CollectionUtil
.
isNotEmpty
(
interactes
)){
if
(
CollectionUtil
.
isNotEmpty
(
interactes
)){
weMomentsInteracteService
.
batchAddOrUpdate
(
interactes
);
weMomentsInteracteService
.
batchAddOrUpdate
(
interactes
);
}
}
...
@@ -459,6 +482,12 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
...
@@ -459,6 +482,12 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
}
}
}
}
});
}
/**
/**
...
@@ -509,6 +538,7 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
...
@@ -509,6 +538,7 @@ public class WeMomentsServiceImpl extends ServiceImpl<WeMomentsMapper, WeMoments
MomentsListDetailResultDto
moment_list
=
weMomentsClient
.
get_moment_list
(
MomentsListDetailParamDto
.
builder
()
MomentsListDetailResultDto
moment_list
=
weMomentsClient
.
get_moment_list
(
MomentsListDetailParamDto
.
builder
()
.
start_time
(
startTime
)
.
start_time
(
startTime
)
.
end_time
(
endTime
)
.
end_time
(
endTime
)
.
cursor
(
nextCursor
)
.
filter_type
(
filterType
)
.
filter_type
(
filterType
)
.
build
());
.
build
());
if
(
WeConstans
.
WE_SUCCESS_CODE
.
equals
(
moment_list
.
getErrcode
())
if
(
WeConstans
.
WE_SUCCESS_CODE
.
equals
(
moment_list
.
getErrcode
())
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeTagGroupServiceImpl.java
View file @
96816ce
...
@@ -9,7 +9,10 @@ import com.linkwechat.common.constant.Constants;
...
@@ -9,7 +9,10 @@ import com.linkwechat.common.constant.Constants;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.common.utils.Threads
;
import
com.linkwechat.wecom.annotation.SynchRecord
;
import
com.linkwechat.wecom.client.WeCropTagClient
;
import
com.linkwechat.wecom.client.WeCropTagClient
;
import
com.linkwechat.wecom.constants.SynchRecordConstants
;
import
com.linkwechat.wecom.domain.WeTag
;
import
com.linkwechat.wecom.domain.WeTag
;
import
com.linkwechat.wecom.domain.WeTagGroup
;
import
com.linkwechat.wecom.domain.WeTagGroup
;
import
com.linkwechat.wecom.domain.dto.tag.*
;
import
com.linkwechat.wecom.domain.dto.tag.*
;
...
@@ -17,6 +20,9 @@ import com.linkwechat.wecom.mapper.WeTagGroupMapper;
...
@@ -17,6 +20,9 @@ import com.linkwechat.wecom.mapper.WeTagGroupMapper;
import
com.linkwechat.wecom.service.IWeTagGroupService
;
import
com.linkwechat.wecom.service.IWeTagGroupService
;
import
com.linkwechat.wecom.service.IWeTagService
;
import
com.linkwechat.wecom.service.IWeTagService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.security.core.context.SecurityContext
;
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
;
...
@@ -253,18 +259,32 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
...
@@ -253,18 +259,32 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
* 同步标签
* 同步标签
*/
*/
@Override
@Override
@Transactional
@Transactional
(
rollbackFor
=
Exception
.
class
)
@SynchRecord
(
synchType
=
SynchRecordConstants
.
SYNCH_CUSTOMER_TAG
)
public
void
synchWeTags
()
{
public
void
synchWeTags
()
{
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
//异步同步一下标签库,解决标签不同步问题
Threads
.
SINGLE_THREAD_POOL
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
SecurityContextHolder
.
setContext
(
securityContext
);
WeCropGroupTagListDto
weCropGroupTagListDto
=
weCropTagClient
.
getAllCorpTagList
();
WeCropGroupTagListDto
weCropGroupTagListDto
=
weCropTagClient
.
getAllCorpTagList
();
if
(
weCropGroupTagListDto
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
))
{
if
(
weCropGroupTagListDto
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
))
{
this
.
batchSaveOrUpdateTagGroupAndTag
(
weCropGroupTagListDto
.
getTag_group
(),
true
);
batchSaveOrUpdateTagGroupAndTag
(
weCropGroupTagListDto
.
getTag_group
(),
true
);
}
}
}
});
}
}
/**
/**
* 来自微信端批量保存或者更新标签组和标签
* 来自微信端批量保存或者更新标签组和标签
*
*
...
...
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