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
4ffce4c0
Commit
4ffce4c0
authored
Jun 02, 2024
by
王祖波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
初始化holo
parent
58b0e702
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
7 deletions
+19
-7
HoloDataSource.java
...anage/service/dao/mapper/content/holo/HoloDataSource.java
+19
-7
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/content/holo/HoloDataSource.java
View file @
4ffce4c0
package
com
.
gic
.
haoban
.
manage
.
service
.
dao
.
mapper
.
content
.
holo
;
package
com
.
gic
.
haoban
.
manage
.
service
.
dao
.
mapper
.
content
.
holo
;
import
cn.hutool.core.date.DateField
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.lang.Pair
;
import
cn.hutool.core.lang.Pair
;
import
cn.hutool.core.lang.TypeReference
;
import
cn.hutool.core.lang.TypeReference
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.http.HttpUtil
;
...
@@ -14,6 +18,7 @@ import org.springframework.beans.factory.DisposableBean;
...
@@ -14,6 +18,7 @@ import org.springframework.beans.factory.DisposableBean;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ScheduledExecutorService
;
...
@@ -29,7 +34,7 @@ import java.util.concurrent.TimeUnit;
...
@@ -29,7 +34,7 @@ import java.util.concurrent.TimeUnit;
@Component
@Component
public
class
HoloDataSource
implements
InitializingBean
,
DisposableBean
{
public
class
HoloDataSource
implements
InitializingBean
,
DisposableBean
{
HoloClient
client
;
private
volatile
HoloClient
client
;
private
final
ScheduledExecutorService
scheduler
=
Executors
.
newScheduledThreadPool
(
1
);
private
final
ScheduledExecutorService
scheduler
=
Executors
.
newScheduledThreadPool
(
1
);
...
@@ -43,9 +48,6 @@ public class HoloDataSource implements InitializingBean, DisposableBean {
...
@@ -43,9 +48,6 @@ public class HoloDataSource implements InitializingBean, DisposableBean {
log
.
info
(
"holo链接初始化获取授权信息失败"
);
log
.
info
(
"holo链接初始化获取授权信息失败"
);
return
;
return
;
}
}
if
(
this
.
client
!=
null
)
{
this
.
client
.
close
();
}
String
holoUserName
=
holoAuth
.
getKey
();
String
holoUserName
=
holoAuth
.
getKey
();
String
holoPassword
=
holoAuth
.
getValue
();
String
holoPassword
=
holoAuth
.
getValue
();
HoloConfig
holoConfig
=
new
HoloConfig
();
HoloConfig
holoConfig
=
new
HoloConfig
();
...
@@ -53,8 +55,13 @@ public class HoloDataSource implements InitializingBean, DisposableBean {
...
@@ -53,8 +55,13 @@ public class HoloDataSource implements InitializingBean, DisposableBean {
holoConfig
.
setUsername
(
holoUserName
);
holoConfig
.
setUsername
(
holoUserName
);
holoConfig
.
setPassword
(
holoPassword
);
holoConfig
.
setPassword
(
holoPassword
);
holoConfig
.
setConnectionMaxIdleMs
(
13000
);
holoConfig
.
setConnectionMaxIdleMs
(
13000
);
this
.
client
=
new
HoloClient
(
holoConfig
);
HoloClient
newClient
=
new
HoloClient
(
holoConfig
);
this
.
client
.
setAsyncCommit
(
false
);
newClient
.
setAsyncCommit
(
false
);
if
(
this
.
client
!=
null
)
{
this
.
client
.
close
();
this
.
client
=
null
;
}
this
.
client
=
newClient
;
log
.
info
(
"holo链接初始化完成"
);
log
.
info
(
"holo链接初始化完成"
);
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
log
.
info
(
"初始化client 异常 >>>"
,
ex
);
log
.
info
(
"初始化client 异常 >>>"
,
ex
);
...
@@ -74,7 +81,12 @@ public class HoloDataSource implements InitializingBean, DisposableBean {
...
@@ -74,7 +81,12 @@ public class HoloDataSource implements InitializingBean, DisposableBean {
if
(
client
==
null
)
{
if
(
client
==
null
)
{
this
.
init
();
this
.
init
();
}
}
scheduler
.
scheduleAtFixedRate
(
this
::
reinitialize
,
12
,
12
,
TimeUnit
.
HOURS
);
DateTime
now
=
DateUtil
.
date
();
Date
todayTwo
=
DateUtil
.
beginOfDay
(
now
).
offset
(
DateField
.
HOUR_OF_DAY
,
2
);
if
(
now
.
after
(
todayTwo
))
{
todayTwo
=
DateUtil
.
offsetDay
(
todayTwo
,
1
);
}
scheduler
.
scheduleAtFixedRate
(
this
::
reinitialize
,
DateUtil
.
between
(
now
,
todayTwo
,
DateUnit
.
SECOND
,
true
),
24
*
60
*
60
,
TimeUnit
.
SECONDS
);
}
}
...
...
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