Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
haikang-client
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
杨立
haikang-client
Commits
a3ada020
提交
a3ada020
authored
9月 15, 2021
作者:
wangqiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rest test
上级
6114ea97
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
128 行增加
和
72 行删除
+128
-72
ApqClientApplication.java
...lient/src/main/java/com/priusis/ApqClientApplication.java
+2
-2
HaikangClientApplicationTests.java
.../test/java/com/priusis/HaikangClientApplicationTests.java
+0
-13
RestTest.java
apq-pc-client/src/test/java/com/priusis/RestTest.java
+0
-54
pom.xml
apq-pc-control/pom.xml
+18
-3
ApqControlApplication.java
...trol/src/main/java/com/priusis/ApqControlApplication.java
+17
-0
RestTemplateConfig.java
.../src/main/java/com/priusis/config/RestTemplateConfig.java
+30
-0
MqttRpcDataMessage.java
...trol/src/main/java/com/priusis/vo/MqttRpcDataMessage.java
+23
-0
application.yml
apq-pc-control/src/main/resources/application.yml
+4
-0
RestTest.java
apq-pc-control/src/test/java/com/priusis/RestTest.java
+34
-0
没有找到文件。
apq-pc-client/src/main/java/com/priusis/
Haikang
ClientApplication.java
→
apq-pc-client/src/main/java/com/priusis/
Apq
ClientApplication.java
浏览文件 @
a3ada020
...
...
@@ -8,10 +8,10 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
,
SecurityAutoConfiguration
.
class
})
public
class
Haikang
ClientApplication
{
public
class
Apq
ClientApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
Haikang
ClientApplication
.
class
,
args
);
SpringApplication
.
run
(
Apq
ClientApplication
.
class
,
args
);
}
}
apq-pc-client/src/test/java/com/priusis/HaikangClientApplicationTests.java
deleted
100644 → 0
浏览文件 @
6114ea97
package
com
.
priusis
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
@SpringBootTest
class
HaikangClientApplicationTests
{
@Test
void
contextLoads
()
{
}
}
apq-pc-client/src/test/java/com/priusis/RestTest.java
deleted
100644 → 0
浏览文件 @
6114ea97
package
com
.
priusis
;
import
cn.hutool.core.io.unit.DataSizeUtil
;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.system.oshi.OshiUtil
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.web.client.RestTemplate
;
import
oshi.hardware.NetworkIF
;
import
java.net.InetAddress
;
import
java.net.NetworkInterface
;
import
java.util.Map
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
RestTest
{
@Autowired
private
RestTemplate
restTemplate
;
@Test
public
void
test1
()
throws
Exception
{
/*Map<String, Object> data = new HashMap<>();
// {
// "device": "101",
// "lat": "210.2",
// "lng": "11.21"
//}
data.put("device", "101");
data.put("lat", 210.2);
data.put("lng", 11.21);*/
InetAddress
inetAddress
=
InetAddress
.
getLocalHost
();
NetworkIF
networkIF
=
new
NetworkIF
();
networkIF
.
setNetworkInterface
(
NetworkInterface
.
getByInetAddress
(
inetAddress
));
Map
<
String
,
Object
>
data
=
MapUtil
.<
String
,
Object
>
builder
()
.
put
(
"operatingSystem"
,
OshiUtil
.
getOs
().
toString
())
.
put
(
"mac"
,
networkIF
.
getMacaddr
())
.
put
(
"baseboard"
,
OshiUtil
.
getSystem
().
getBaseboard
().
getManufacturer
()
+
" "
+
OshiUtil
.
getSystem
().
getBaseboard
().
getVersion
())
.
put
(
"ip"
,
inetAddress
.
getHostAddress
())
.
put
(
"cpuModel"
,
OshiUtil
.
getCpuInfo
(
0
).
getCpuModel
())
.
put
(
"cpuTemp"
,
OshiUtil
.
getSensors
().
getCpuTemperature
())
.
put
(
"memoryCap"
,
DataSizeUtil
.
format
(
OshiUtil
.
getMemory
().
getTotal
()))
.
put
(
"diskModel"
,
OshiUtil
.
getHardware
().
getDiskStores
()[
0
].
getModel
())
.
put
(
"diskCap"
,
DataSizeUtil
.
format
(
OshiUtil
.
getHardware
().
getDiskStores
()[
0
].
getSize
()))
.
build
();
Map
map
=
restTemplate
.
postForObject
(
"http://localhost:9090/uplink/oc-client"
,
data
,
Map
.
class
);
System
.
out
.
println
(
map
);
}
}
apq-pc-control/pom.xml
浏览文件 @
a3ada020
...
...
@@ -3,7 +3,12 @@
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.4.10
</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>
com.priusis
</groupId>
<artifactId>
apq-pc-control
</artifactId>
<version>
1.0-SNAPSHOT
</version>
...
...
@@ -30,13 +35,23 @@
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
<version>
2.2.0.RELEASE
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<
version>
${lombok.version}
</version
>
<
optional>
true
</optional
>
</dependency>
<dependency>
...
...
apq-pc-control/src/main/java/com/priusis/ApqControlApplication.java
0 → 100644
浏览文件 @
a3ada020
package
com
.
priusis
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
@EnableScheduling
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
,
SecurityAutoConfiguration
.
class
})
public
class
ApqControlApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
ApqControlApplication
.
class
,
args
);
}
}
apq-pc-control/src/main/java/com/priusis/config/RestTemplateConfig.java
0 → 100644
浏览文件 @
a3ada020
package
com
.
priusis
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.client.ClientHttpRequestFactory
;
import
org.springframework.http.client.SimpleClientHttpRequestFactory
;
import
org.springframework.http.converter.StringHttpMessageConverter
;
import
org.springframework.web.client.RestTemplate
;
import
java.nio.charset.Charset
;
@Configuration
public
class
RestTemplateConfig
{
@Bean
public
RestTemplate
restTemplate
(
ClientHttpRequestFactory
factory
)
{
RestTemplate
restTemplate
=
new
RestTemplate
(
factory
);
// 支持中文编码
restTemplate
.
getMessageConverters
().
set
(
1
,
new
StringHttpMessageConverter
(
Charset
.
forName
(
"UTF-8"
)));
return
restTemplate
;
}
@Bean
public
ClientHttpRequestFactory
simpleClientHttpRequestFactory
()
{
SimpleClientHttpRequestFactory
factory
=
new
SimpleClientHttpRequestFactory
();
factory
.
setReadTimeout
(
5000
);
//单位为ms
factory
.
setConnectTimeout
(
5000
);
//单位为ms
return
factory
;
}
}
apq-pc-control/src/main/java/com/priusis/vo/MqttRpcDataMessage.java
0 → 100644
浏览文件 @
a3ada020
package
com
.
priusis
.
vo
;
import
lombok.Data
;
import
java.io.Serializable
;
@Data
public
class
MqttRpcDataMessage
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
3133461476074777891L
;
private
int
requestId
;
private
String
method
;
private
String
params
;
@Override
public
String
toString
()
{
return
"{requestId="
+
requestId
+
", method="
+
method
+
", params="
+
params
+
'}'
;
}
}
apq-pc-control/src/main/resources/application.yml
0 → 100644
浏览文件 @
a3ada020
server
:
# Server bind address
address
:
"
0.0.0.0"
port
:
${random.int[20000,29999]}
apq-pc-control/src/test/java/com/priusis/RestTest.java
0 → 100644
浏览文件 @
a3ada020
package
com
.
priusis
;
import
com.priusis.vo.MqttRpcDataMessage
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.HashMap
;
import
java.util.Map
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
RestTest
{
@Autowired
private
RestTemplate
restTemplate
;
@Test
public
void
test1
()
throws
Exception
{
// 获取硬件监控配置 params == data
ResponseEntity
<
MqttRpcDataMessage
>
forEntity
=
restTemplate
.
getForEntity
(
"http://localhost:8765/rpc_cmd/info"
,
MqttRpcDataMessage
.
class
);
System
.
out
.
println
(
forEntity
.
getBody
().
getMethod
());
System
.
out
.
println
(
forEntity
.
getBody
().
getParams
());
// 上报硬件监控数据
Map
mapRequest
=
new
HashMap
();
Map
map
=
restTemplate
.
postForObject
(
"http://localhost:8765/uplink/oc-client"
,
mapRequest
,
Map
.
class
);
System
.
out
.
println
(
map
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论