Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haoban3.0
haoban-manage3.0
Commits
18a62e2d
Commit
18a62e2d
authored
Sep 06, 2023
by
jinxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
会员标签同步
parent
d4fb5c83
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
27 deletions
+74
-27
pom.xml
haoban-manage3-api/pom.xml
+1
-1
ExternalClerkRelatedApiService.java
...an/manage/api/service/ExternalClerkRelatedApiService.java
+2
-1
pom.xml
haoban-manage3-service/pom.xml
+6
-0
ExternalClerkRelatedApiServiceImpl.java
.../service/out/impl/ExternalClerkRelatedApiServiceImpl.java
+65
-25
No files found.
haoban-manage3-api/pom.xml
View file @
18a62e2d
...
@@ -48,7 +48,7 @@
...
@@ -48,7 +48,7 @@
<dependency>
<dependency>
<groupId>
com.gic
</groupId>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-app-customer-api
</artifactId>
<artifactId>
haoban-app-customer-api
</artifactId>
<version>
3.0-SNAPSHOT
</version>
<version>
${haoban-app-customer-api}
</version>
<scope>
compile
</scope>
<scope>
compile
</scope>
</dependency>
</dependency>
</dependencies>
</dependencies>
...
...
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/ExternalClerkRelatedApiService.java
View file @
18a62e2d
...
@@ -6,6 +6,7 @@ import com.gic.haoban.base.api.common.BasePageInfo;
...
@@ -6,6 +6,7 @@ import com.gic.haoban.base.api.common.BasePageInfo;
import
com.gic.haoban.base.api.common.ServiceResponse
;
import
com.gic.haoban.base.api.common.ServiceResponse
;
import
com.gic.haoban.manage.api.dto.*
;
import
com.gic.haoban.manage.api.dto.*
;
import
java.sql.SQLException
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -322,5 +323,5 @@ public interface ExternalClerkRelatedApiService {
...
@@ -322,5 +323,5 @@ public interface ExternalClerkRelatedApiService {
*/
*/
com
.
gic
.
api
.
base
.
commons
.
ServiceResponse
<
String
>
getMemberIdByExternalId
(
String
wxEnterpriseId
,
String
externalUserId
);
com
.
gic
.
api
.
base
.
commons
.
ServiceResponse
<
String
>
getMemberIdByExternalId
(
String
wxEnterpriseId
,
String
externalUserId
);
void
listMemberIdByEnterpriseId
(
QywxTagSyncInfoDTO
dto
);
void
listMemberIdByEnterpriseId
(
QywxTagSyncInfoDTO
dto
)
throws
SQLException
;
}
}
haoban-manage3-service/pom.xml
View file @
18a62e2d
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
<properties>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<libraryVersion>
3.0-SNAPSHOT
</libraryVersion>
<libraryVersion>
3.0-SNAPSHOT
</libraryVersion>
<gic-private-db>
3.0-SNAPSHOT
</gic-private-db>
</properties>
</properties>
<dependencyManagement>
<dependencyManagement>
<dependencies>
<dependencies>
...
@@ -207,6 +208,11 @@
...
@@ -207,6 +208,11 @@
<artifactId>
gic-operating-api
</artifactId>
<artifactId>
gic-operating-api
</artifactId>
<version>
${gic-operating-api}
</version>
<version>
${gic-operating-api}
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-private-db
</artifactId>
<version>
${gic-private-db}
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/ExternalClerkRelatedApiServiceImpl.java
View file @
18a62e2d
package
com
.
gic
.
haoban
.
manage
.
service
.
service
.
out
.
impl
;
package
com
.
gic
.
haoban
.
manage
.
service
.
service
.
out
.
impl
;
import
cn.hutool.core.collection.CollUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.dto.SubscribeMessageDTO
;
import
com.gic.api.base.dto.SubscribeMessageDTO
;
import
com.gic.clerk.api.dto.ClerkDTO
;
import
com.gic.clerk.api.dto.ClerkDTO
;
...
@@ -60,6 +62,10 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -60,6 +62,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.ExecutorService
;
...
@@ -796,7 +802,7 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
...
@@ -796,7 +802,7 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
}
}
@Override
@Override
public
void
listMemberIdByEnterpriseId
(
QywxTagSyncInfoDTO
dto
)
{
public
void
listMemberIdByEnterpriseId
(
QywxTagSyncInfoDTO
dto
)
throws
SQLException
{
if
(
null
==
dto
){
if
(
null
==
dto
){
log
.
info
(
"参数不能为空"
);
log
.
info
(
"参数不能为空"
);
return
;
return
;
...
@@ -812,36 +818,70 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
...
@@ -812,36 +818,70 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
return
;
return
;
}
}
dto
.
setTotalCount
(
totalCount
);
dto
.
setTotalCount
(
totalCount
);
Integer
round
=
size
/
totalCount
+
1
;
Connection
conn
=
null
;
ResultSet
rs
=
null
;
PreparedStatement
pstat
=
null
;
List
<
String
>
result
=
new
LinkedList
<>();
List
<
String
>
result
=
new
LinkedList
<>();
// 程序计数器
try
{
final
CountDownLatch
count
=
new
CountDownLatch
(
round
);
String
excelDb
=
"devDs"
;
// 创建线程
String
schema
=
"haoban3"
;
ExecutorService
executor
=
Executors
.
newFixedThreadPool
(
availableProcessor
);
if
(
isProd
())
{
// 分配数据
excelDb
=
"haobanDs"
;
for
(
int
i
=
0
;
i
<
round
;
i
++)
{
schema
=
"haoban3.0"
;
//该线程的查询开始值
}
int
startLen
=
i
*
size
;
conn
=
com
.
gic
.
privatedb
.
util
.
ConnectionUtil
.
createConnection
(
excelDb
,
schema
);
executor
.
execute
(
new
Runnable
()
{
StringBuilder
sqlBuilder
=
new
StringBuilder
(
"select "
);
@Override
sqlBuilder
.
append
(
"member_id memberId"
)
public
void
run
()
{
.
append
(
" from tab_haoban_external_clerk_related where wx_enterprise_id ='"
)
List
<
String
>
memberIdList
=
tabHaobanExternalClerkRelatedMapper
.
getMemberIdList
(
wxEnterpriseId
,
enterpriseId
,
startLen
,
size
);
.
append
(
wxEnterpriseId
).
append
(
"'"
)
dto
.
setMemberIds
(
memberIdList
);
.
append
(
" and enterprise_id ='"
).
append
(
enterpriseId
).
append
(
"'"
)
.
append
(
" and status_flag = 1"
);
String
sql
=
sqlBuilder
.
toString
();
log
.
info
(
"查询会员id执行的sql语句:{}"
,
sql
);
pstat
=
conn
.
prepareStatement
(
sql
,
ResultSet
.
TYPE_FORWARD_ONLY
,
ResultSet
.
CONCUR_READ_ONLY
);
pstat
.
setFetchSize
(
Integer
.
MIN_VALUE
);
pstat
.
setFetchDirection
(
ResultSet
.
FETCH_REVERSE
);
rs
=
pstat
.
executeQuery
();
while
(
rs
.
next
())
{
String
memberId
=
rs
.
getString
(
"memberId"
);
result
.
add
(
memberId
);
if
(
result
.
size
()
==
size
){
dto
.
setMemberIds
(
result
);
qywxTagSyncApiService
.
tagSync
(
dto
);
qywxTagSyncApiService
.
tagSync
(
dto
);
// 计数器 -1(唤醒阻塞线程)
result
.
clear
();
count
.
countDown
();
}
}
}
});
if
(
CollUtil
.
isNotEmpty
(
result
)){
dto
.
setMemberIds
(
result
);
qywxTagSyncApiService
.
tagSync
(
dto
);
result
.
clear
();
}
}
}
catch
(
Exception
e
){
log
.
warn
(
"异常"
,
e
);
}
finally
{
try
{
try
{
// 阻塞线程(主线程等待所有子线程 一起执行业务)
if
(
null
!=
rs
)
{
count
.
await
();
rs
.
close
();
}
catch
(
Exception
e
)
{
rs
=
null
;
}
if
(
null
!=
pstat
)
{
pstat
.
close
();
pstat
=
null
;
}
if
(
null
!=
conn
)
{
conn
.
close
();
conn
=
null
;
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
finally
{
// 终止线程池
// 启动一次顺序关闭,执行以前提交的任务,但不接受新任务。若已经关闭,则调用没有其他作用。
executor
.
shutdown
();
}
}
}
}
}
private
boolean
isProd
()
{
com
.
ctrip
.
framework
.
apollo
.
Config
config
=
ConfigService
.
getConfig
(
"COMMON.gic-properties"
);
String
env
=
config
.
getProperty
(
"environment.value"
,
""
)
;
log
.
info
(
"feile env={}"
,
env
);
return
"prod"
.
equals
(
env
)
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment