Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
baihang-report
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
data-spider
baihang-report
Commits
4aeb8643
Commit
4aeb8643
authored
Mar 12, 2020
by
郝彦辉
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
百行每天的重新报送优化成定时任务
parent
29d0decb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
ManualToolController.java
...cn/quantgroup/report/controller/ManualToolController.java
+36
-0
No files found.
src/main/java/cn/quantgroup/report/controller/ManualToolController.java
View file @
4aeb8643
...
@@ -11,6 +11,10 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -11,6 +11,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.net.Inet4Address
;
import
java.net.InetAddress
;
import
java.net.NetworkInterface
;
import
java.util.Enumeration
;
import
java.util.Map
;
import
java.util.Map
;
@Slf4j
@Slf4j
...
@@ -214,4 +218,36 @@ public class ManualToolController {
...
@@ -214,4 +218,36 @@ public class ManualToolController {
}
}
@RequestMapping
(
"/getIp"
)
public
String
getIp
(){
try
{
return
getServerIp
();
}
catch
(
Exception
e
){
return
"获取本地ip异常"
;
}
}
private
String
getServerIp
()
{
try
{
Enumeration
<
NetworkInterface
>
allNetInterfaces
=
NetworkInterface
.
getNetworkInterfaces
();
while
(
allNetInterfaces
.
hasMoreElements
())
{
NetworkInterface
netInterface
=
(
NetworkInterface
)
allNetInterfaces
.
nextElement
();
Enumeration
<
InetAddress
>
addresses
=
netInterface
.
getInetAddresses
();
while
(
addresses
.
hasMoreElements
())
{
InetAddress
ip
=
(
InetAddress
)
addresses
.
nextElement
();
if
(
ip
!=
null
&&
ip
instanceof
Inet4Address
&&
!
ip
.
isLoopbackAddress
()
/* loopback地址即本机地址,IPv4的loopback范围是127.0.0.0 ~ 127.255.255.255 */
&&
ip
.
getHostAddress
().
indexOf
(
":"
)
==
-
1
)
{
System
.
out
.
println
(
"本机的IP = "
+
ip
.
getHostAddress
());
return
ip
.
getHostAddress
();
}
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"获取本地ip异常"
,
e
);
}
return
null
;
}
}
}
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