Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bme-access-upload
Project
Project
Details
Activity
Releases
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
李洪明
bme-access-upload
Commits
fd706256
Commit
fd706256
authored
Jul 08, 2025
by
李洪明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加登录
parent
886d3d88
Pipeline
#1274
canceled with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletion
+41
-1
HttpUtils.java
src/main/java/com/bme/access/upload/common/HttpUtils.java
+15
-1
HeartBeatJob.java
src/main/java/com/bme/access/upload/job/HeartBeatJob.java
+26
-0
No files found.
src/main/java/com/bme/access/upload/common/HttpUtils.java
View file @
fd706256
...
...
@@ -340,7 +340,7 @@ public class HttpUtils {
return
httpClient
.
execute
(
request
);
}
public
static
HttpResponse
send
(
String
host
,
String
path
,
Map
<
String
,
String
>
querys
,
Map
<
String
,
Object
>
bodys
)
throws
Exception
{
public
static
HttpResponse
send
Post
(
String
host
,
String
path
,
Map
<
String
,
String
>
querys
,
Map
<
String
,
Object
>
bodys
)
throws
Exception
{
HttpClient
httpClient
=
wrapClient
(
host
);
HttpPost
request
=
new
HttpPost
(
buildUrl
(
host
,
path
,
querys
));
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
...
...
@@ -356,6 +356,20 @@ public class HttpUtils {
return
httpClient
.
execute
(
request
);
}
public
static
HttpResponse
sendGet
(
String
host
,
String
path
,
Map
<
String
,
String
>
querys
)
throws
Exception
{
HttpClient
httpClient
=
wrapClient
(
host
);
HttpGet
request
=
new
HttpGet
(
buildUrl
(
host
,
path
,
querys
));
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
"X-Access-Token"
,
LoginConfig
.
token
);
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
request
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
return
httpClient
.
execute
(
request
);
}
}
\ No newline at end of file
src/main/java/com/bme/access/upload/job/HeartBeatJob.java
0 → 100644
View file @
fd706256
package
com
.
bme
.
access
.
upload
.
job
;
import
com.bme.access.upload.common.HttpUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
@Component
@EnableScheduling
@Slf4j
public
class
HeartBeatJob
{
private
final
static
String
HEART_BEAT_URL
=
"https://dctapi.soszyzg.com/dct/heartbeat"
;
@Scheduled
(
cron
=
"0 0/30 * * * ?"
)
public
void
heartBeat
()
{
try
{
HttpResponse
response
=
HttpUtils
.
sendGet
(
HEART_BEAT_URL
,
null
,
null
);
String
str
=
EntityUtils
.
toString
(
response
.
getEntity
());
}
catch
(
Exception
e
)
{
log
.
error
(
"心跳协议(每半个小时调用一次): {}"
,
e
);
}
}
}
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