Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
仟微科技
Link Wechat
提交
cac1b401
Link Wechat
项目概览
仟微科技
/
Link Wechat
通知
48
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Link Wechat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cac1b401
编写于
1月 05, 2021
作者:
L
leejoker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
使用并行流和异步处理多线程
上级
c3a1f53d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
18 addition
and
17 deletion
+18
-17
linkwe-admin/src/main/java/com/linkwechat/LinkWeChatApplication.java
...n/src/main/java/com/linkwechat/LinkWeChatApplication.java
+2
-0
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerController.java
...linkwechat/web/controller/wecom/WeCustomerController.java
+6
-10
linkwe-admin/src/main/resources/application.yml
linkwe-admin/src/main/resources/application.yml
+5
-0
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerServiceImpl.java
.../linkwechat/wecom/service/impl/WeCustomerServiceImpl.java
+5
-7
未找到文件。
linkwe-admin/src/main/java/com/linkwechat/LinkWeChatApplication.java
浏览文件 @
cac1b401
...
@@ -6,6 +6,7 @@ import org.mybatis.spring.annotation.MapperScan;
...
@@ -6,6 +6,7 @@ import org.mybatis.spring.annotation.MapperScan;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.scheduling.annotation.EnableAsync
;
/**
/**
* 启动程序
* 启动程序
...
@@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
...
@@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
,
PageHelperAutoConfiguration
.
class
})
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
,
PageHelperAutoConfiguration
.
class
})
@MapperScan
(
"com.linkwechat.*.mapper"
)
@MapperScan
(
"com.linkwechat.*.mapper"
)
@ForestScan
(
basePackages
=
"com.linkwechat.wecom.client"
)
@ForestScan
(
basePackages
=
"com.linkwechat.wecom.client"
)
@EnableAsync
public
class
LinkWeChatApplication
public
class
LinkWeChatApplication
{
{
public
static
void
main
(
String
[]
args
)
public
static
void
main
(
String
[]
args
)
...
...
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerController.java
浏览文件 @
cac1b401
...
@@ -22,7 +22,7 @@ import java.util.List;
...
@@ -22,7 +22,7 @@ import java.util.List;
/**
/**
* 企业微信客户Controller
* 企业微信客户Controller
*
*
* @author ruoyi
* @author ruoyi
* @date 2020-09-13
* @date 2020-09-13
*/
*/
...
@@ -106,16 +106,12 @@ public class WeCustomerController extends BaseController
...
@@ -106,16 +106,12 @@ public class WeCustomerController extends BaseController
@PreAuthorize
(
"@ss.hasPermi('customerManage:customer:sync')"
)
@PreAuthorize
(
"@ss.hasPermi('customerManage:customer:sync')"
)
@Log
(
title
=
"企业微信客户同步接口"
,
businessType
=
BusinessType
.
DELETE
)
@Log
(
title
=
"企业微信客户同步接口"
,
businessType
=
BusinessType
.
DELETE
)
@GetMapping
(
"/synchWeCustomer"
)
@GetMapping
(
"/synchWeCustomer"
)
public
AjaxResult
synchWeCustomer
(){
public
AjaxResult
synchWeCustomer
()
{
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
try
{
try
{
Threads
.
SINGLE_THREAD_POOL
.
execute
(
new
Runnable
()
{
SecurityContext
context
=
SecurityContextHolder
.
getContext
();
@Override
SecurityContextHolder
.
setStrategyName
(
SecurityContextHolder
.
MODE_INHERITABLETHREADLOCAL
);
public
void
run
()
{
SecurityContextHolder
.
setContext
(
context
);
SecurityContextHolder
.
setContext
(
securityContext
);
weCustomerService
.
synchWeCustomer
();
weCustomerService
.
synchWeCustomer
();
}
});
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
linkwe-admin/src/main/resources/application.yml
浏览文件 @
cac1b401
...
@@ -56,6 +56,11 @@ spring:
...
@@ -56,6 +56,11 @@ spring:
max-file-size
:
10MB
max-file-size
:
10MB
# 设置总上传的文件大小
# 设置总上传的文件大小
max-request-size
:
20MB
max-request-size
:
20MB
task
:
execution
:
pool
:
keep-alive
:
10s
thread-name-prefix
:
common-pool-
# 服务模块
# 服务模块
devtools
:
devtools
:
restart
:
restart
:
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerServiceImpl.java
浏览文件 @
cac1b401
...
@@ -26,6 +26,7 @@ import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag;
...
@@ -26,6 +26,7 @@ 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.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
;
...
@@ -121,21 +122,18 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
...
@@ -121,21 +122,18 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
* @return
* @return
*/
*/
@Override
@Override
@Async
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
synchWeCustomer
()
{
public
void
synchWeCustomer
()
{
FollowUserList
followUserList
=
weCustomerClient
.
getFollowUserList
();
FollowUserList
followUserList
=
weCustomerClient
.
getFollowUserList
();
if
(
WeConstans
.
WE_SUCCESS_CODE
.
equals
(
followUserList
.
getErrcode
())
if
(
WeConstans
.
WE_SUCCESS_CODE
.
equals
(
followUserList
.
getErrcode
())
&&
ArrayUtil
.
isNotEmpty
(
followUserList
.
getFollow_user
()))
{
&&
ArrayUtil
.
isNotEmpty
(
followUserList
.
getFollow_user
()))
{
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
Arrays
.
asList
(
followUserList
.
getFollow_user
())
Arrays
.
asList
(
followUserList
.
getFollow_user
())
.
s
tream
().
forEach
(
k
->
{
.
parallelS
tream
().
forEach
(
k
->
{
try
{
try
{
Threads
.
SINGLE_THREAD_POOL
.
execute
(()
->
{
SecurityContextHolder
.
setContext
(
securityContext
);
SecurityContextHolder
.
setContext
(
securityContext
);
weFlowerCustomerHandle
(
k
);
weFlowerCustomerHandle
(
k
);
});
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录