Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
haikang-client
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
杨立
haikang-client
Commits
6c622901
提交
6c622901
authored
10月 18, 2021
作者:
wangqiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
install service
上级
73d2dcb6
显示空白字符变更
内嵌
并排
正在显示
17 个修改的文件
包含
287 行增加
和
17 行删除
+287
-17
pom.xml
apq-pc-client/pom.xml
+0
-0
ApqClientApplication.java
...lient/src/main/java/com/priusis/ApqClientApplication.java
+0
-0
DeviceInfoController.java
...ain/java/com/priusis/controller/DeviceInfoController.java
+15
-3
ApqInfoDataVo.java
...pc-client/src/main/java/com/priusis/vo/ApqInfoDataVo.java
+14
-0
MqttRpcDataMessage.java
...ient/src/main/java/com/priusis/vo/MqttRpcDataMessage.java
+23
-0
install.bat
apq-pc-client/src/main/scripts/windows/install.bat
+1
-1
install2.bat
apq-pc-client/src/main/scripts/windows/install2.bat
+1
-1
ApqControlApplication.java
...trol/src/main/java/com/priusis/ApqControlApplication.java
+20
-2
application.yml
apq-pc-control/src/main/resources/application.yml
+3
-1
InfoController.java
.../src/main/java/com/priusis/controller/InfoController.java
+159
-0
R.java
apq-pc-info/src/main/java/com/priusis/lib/R.java
+40
-0
application.yml
apq-pc-info/src/main/resources/application.yml
+2
-1
ApqRegisterApplication.java
...ter/src/main/java/com/priusis/ApqRegisterApplication.java
+4
-5
application.yml
apq-pc-register/src/main/resources/application.yml
+3
-1
apq-client.iss
tools/install-package/boot/apq-client/apq-client.iss
+1
-1
启动服务S.bat
tools/install-package/boot/apq-client/bak/启动服务S.bat
+1
-1
没有可用的文件名
+0
-0
没有找到文件。
apq-pc-client/pom.xml
浏览文件 @
6c622901
apq-pc-client/src/main/java/com/priusis/ApqClientApplication.java
浏览文件 @
6c622901
apq-pc-client/src/main/java/com/priusis/controller/DeviceInfoController.java
浏览文件 @
6c622901
...
...
@@ -48,8 +48,10 @@ public class DeviceInfoController {
JSONObject
diskModel
=
null
;
JSONObject
diskCap
=
null
;
JSONObject
diskFree
=
null
;
HWDiskStore
[]
diskStores
=
null
;
try
{
diskModel
=
JSONUtil
.
parseObj
(
Arrays
.
stream
(
OshiUtil
.
getHardware
().
getDiskStores
())
diskStores
=
OshiUtil
.
getHardware
().
getDiskStores
();
diskModel
=
JSONUtil
.
parseObj
(
Arrays
.
stream
(
diskStores
)
.
map
(
store
->
Arrays
.
stream
(
store
.
getPartitions
())
.
map
(
HWPartition:
:
getMountPoint
)
.
filter
(
StrUtil:
:
isNotBlank
)
...
...
@@ -58,14 +60,14 @@ public class DeviceInfoController {
.
collect
(
Collectors
.
joining
(
","
)))
.
filter
(
StrUtil:
:
isNotBlank
)
.
collect
(
Collectors
.
joining
(
","
,
"{"
,
"}"
)));
diskCap
=
JSONUtil
.
parseObj
(
Arrays
.
stream
(
OshiUtil
.
getHardware
().
getDiskStores
())
diskCap
=
JSONUtil
.
parseObj
(
Arrays
.
stream
(
diskStores
)
.
map
(
HWDiskStore:
:
getPartitions
)
.
flatMap
(
Arrays:
:
stream
)
.
filter
(
partition
->
StrUtil
.
isNotBlank
(
partition
.
getMountPoint
()))
.
map
(
partition
->
"\""
+
StrUtil
.
removeSuffix
(
partition
.
getMountPoint
(),
":\\"
)
+
"盘\":\""
+
DataSizeUtil
.
format
(
partition
.
getSize
())
+
"\""
)
.
collect
(
Collectors
.
joining
(
","
,
"{"
,
"}"
)));
diskFree
=
JSONUtil
.
parseObj
(
Arrays
.
stream
(
OshiUtil
.
getHardware
().
getDiskStores
())
diskFree
=
JSONUtil
.
parseObj
(
Arrays
.
stream
(
diskStores
)
.
map
(
HWDiskStore:
:
getPartitions
)
.
flatMap
(
Arrays:
:
stream
)
.
filter
(
partition
->
StrUtil
.
isNotBlank
(
partition
.
getMountPoint
()))
...
...
@@ -74,6 +76,16 @@ public class DeviceInfoController {
.
collect
(
Collectors
.
joining
(
","
,
"{"
,
"}"
)));
}
catch
(
Exception
e
)
{
log
.
error
(
"硬盘数据获取失败"
,
e
);
if
(
null
!=
diskStores
)
{
for
(
HWDiskStore
diskStore
:
diskStores
)
{
HWPartition
[]
partitions
=
diskStore
.
getPartitions
();
if
(
null
!=
partitions
)
{
for
(
HWPartition
partition
:
partitions
)
{
log
.
error
(
"硬盘数据获取失败: {}"
,
partition
.
getMountPoint
());
}
}
}
}
}
info
=
MapUtil
.<
String
,
Object
>
builder
()
.
put
(
"operatingSystem"
,
OshiUtil
.
getOs
().
toString
())
...
...
apq-pc-client/src/main/java/com/priusis/vo/ApqInfoDataVo.java
0 → 100644
浏览文件 @
6c622901
package
com
.
priusis
.
vo
;
import
lombok.Data
;
import
java.io.Serializable
;
@Data
public
class
ApqInfoDataVo
implements
Serializable
{
private
String
code
;
private
String
name
;
private
int
frequency
;
}
apq-pc-client/src/main/java/com/priusis/vo/MqttRpcDataMessage.java
0 → 100644
浏览文件 @
6c622901
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-client/src/main/scripts/windows/install.bat
浏览文件 @
6c622901
...
...
@@ -70,7 +70,7 @@ IF "%JRE_PATH2%" == "" GOTO JAVA_NOT_INSTALLED
@ECHO Java 1.8 found!
@ECHO Installing apq-pc-client ...
%~dp0apq-pc-client.exe install
@ECHO run
ing apq-pc-client ...
@ECHO run
ning apq-pc-client ...
%~dp0apq-pc-client.exe start
@ECHO DONE.
...
...
apq-pc-client/src/main/scripts/windows/install2.bat
浏览文件 @
6c622901
...
...
@@ -70,7 +70,7 @@ IF "%JRE_PATH2%" == "" GOTO JAVA_NOT_INSTALLED
@ECHO Java 1.8 found!
@ECHO Installing apq-pc-client ...
%~dp0apq-pc-client.exe install
@ECHO run
ing apq-pc-client ...
@ECHO run
ning apq-pc-client ...
%~dp0apq-pc-client.exe start
@ECHO DONE.
...
...
apq-pc-control/src/main/java/com/priusis/ApqControlApplication.java
浏览文件 @
6c622901
...
...
@@ -8,7 +8,6 @@ import com.priusis.utils.IHwPortController;
import
com.priusis.vo.MqttRpcDataMessage
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
...
...
@@ -16,7 +15,6 @@ import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfi
import
org.springframework.http.ResponseEntity
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.web.client.RestClientException
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.HashMap
;
...
...
@@ -42,6 +40,10 @@ public class ApqControlApplication {
@Scheduled
(
fixedDelay
=
60000L
)
protected
void
controlProgramTask
()
{
log
.
info
(
"硬件监控上报================="
);
// todo
//testUsb();
// 获取硬件监控配置 params == data
ResponseEntity
<
MqttRpcDataMessage
>
forEntity
=
null
;
try
{
...
...
@@ -199,4 +201,20 @@ public class ApqControlApplication {
//log.info("APQ_HWPORT_Uninitialize ret:{}", result2);
}
}
public
void
testUsb
()
{
// 初始化硬件接口管理模块
int
result
=
IHwPortController
.
instanceDll
.
APQ_HWPORT_Initialize
();
log
.
info
(
"APQ_HWPORT_Initialize ret:{}"
,
result
);
// APQ_HWPORT_STORAGE_PERM_ALLOW APQ_HWPORT_STORAGE_PERM_DENY
int
result32
=
IHwPortController
.
instanceDll
.
APQ_HWPORT_set_storage_device_permit
(
IHwPortController
.
HwportStorageDevidEnum
.
APQ_HWPORT_STORAGE_DEVID_UDISK
.
getCode
(),
IHwPortController
.
HwportStoragePermEnum
.
APQ_HWPORT_STORAGE_PERM_ALLOW
.
getCode
(),
null
);
log
.
info
(
"APQ_HWPORT_set_storage_device_permit ret:{}"
,
result32
);
//应用硬件接口管理模块的配置内容
int
result5
=
IHwPortController
.
instanceDll
.
APQ_HWPORT_Apply
();
log
.
info
(
"APQ_HWPORT_Apply ret:{}"
,
result5
);
int
result2
=
IHwPortController
.
instanceDll
.
APQ_HWPORT_Uninitialize
();
log
.
info
(
"APQ_HWPORT_Uninitialize ret:{}"
,
result2
);
}
}
apq-pc-control/src/main/resources/application.yml
浏览文件 @
6c622901
...
...
@@ -5,4 +5,5 @@ spring:
server
:
# Server bind address
address
:
"
0.0.0.0"
port
:
${random.int[10000,19999]}
# port: ${random.int[10000,19999]}
port
:
8762
\ No newline at end of file
apq-pc-info/src/main/java/com/priusis/controller/InfoController.java
0 → 100644
浏览文件 @
6c622901
package
com
.
priusis
.
controller
;
import
cn.hutool.core.io.unit.DataSizeUtil
;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.system.oshi.CpuInfo
;
import
cn.hutool.system.oshi.OshiUtil
;
import
com.priusis.lib.R
;
import
com.priusis.util.MacAddrUtil
;
import
com.priusis.vo.ApqInfoDataVo
;
import
com.priusis.vo.MqttRpcDataMessage
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.client.RestTemplate
;
import
oshi.hardware.HWDiskStore
;
import
oshi.hardware.HWPartition
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.InetAddress
;
import
java.text.DecimalFormat
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @author yangli
* @since 2021/09/10
*/
@Slf4j
@Validated
@RestController
@RequestMapping
(
value
=
"info"
)
public
class
InfoController
{
@Autowired
private
RestTemplate
restTemplate
;
@GetMapping
(
value
=
"read_post"
)
public
R
<
Map
<
String
,
Object
>>
getDownloadPath
()
throws
IOException
{
boolean
isNoneEven
=
false
;
// 获取采集配置,数据上报频率 params == data
ResponseEntity
<
MqttRpcDataMessage
>
forEntity
=
null
;
Map
<
String
,
Integer
>
mapParams
=
null
;
try
{
forEntity
=
restTemplate
.
getForEntity
(
"http://localhost:8765/rpc_cmd/info"
,
MqttRpcDataMessage
.
class
);
if
(
null
!=
forEntity
)
{
MqttRpcDataMessage
body
=
forEntity
.
getBody
();
String
params
=
body
.
getParams
();
if
(
StrUtil
.
isNotBlank
(
params
))
{
List
<
ApqInfoDataVo
>
apqInfoDataVos
=
JSONUtil
.
toList
(
params
,
ApqInfoDataVo
.
class
);
mapParams
=
new
HashMap
<>();
for
(
ApqInfoDataVo
apqInfoDataVo
:
apqInfoDataVos
)
{
mapParams
.
put
(
apqInfoDataVo
.
getCode
(),
apqInfoDataVo
.
getFrequency
());
}
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"采集数据异常"
,
e
);
}
String
operatingSystem
=
"operatingSystem"
;
String
mac
=
"mac"
;
String
baseboard
=
"baseboard"
;
String
ip
=
"ip"
;
String
cpuModel
=
"cpuModel"
;
String
cpuLoad
=
"cpuLoad"
;
String
cpuTemp
=
"cpuTemp"
;
String
memoryCap
=
"memoryCap"
;
String
memoryAvailable
=
"memoryAvailable"
;
String
diskModel
=
"diskModel"
;
String
diskCap
=
"diskCap"
;
String
diskFree
=
"diskFree"
;
Map
<
String
,
Object
>
data
=
null
;
try
{
// 上报PC实时信息
String
collect
=
null
;
String
collect1
=
null
;
String
collect2
=
null
;
try
{
collect
=
Arrays
.
stream
(
OshiUtil
.
getHardware
().
getDiskStores
())
.
map
(
HWDiskStore:
:
getPartitions
)
.
flatMap
(
Arrays:
:
stream
)
.
filter
(
partition
->
StrUtil
.
isNotBlank
(
partition
.
getMountPoint
()))
.
map
(
partition
->
"\""
+
StrUtil
.
removeSuffix
(
partition
.
getMountPoint
(),
":\\"
)
+
"盘\":\""
+
DataSizeUtil
.
format
(
partition
.
getSize
())
+
"\""
)
.
collect
(
Collectors
.
joining
(
","
,
"{"
,
"}"
));
collect1
=
Arrays
.
stream
(
OshiUtil
.
getHardware
().
getDiskStores
())
.
map
(
store
->
Arrays
.
stream
(
store
.
getPartitions
())
.
map
(
HWPartition:
:
getMountPoint
)
.
filter
(
StrUtil:
:
isNotBlank
)
.
map
(
s
->
"\""
+
StrUtil
.
removeSuffix
(
s
,
":\\"
)
+
"盘\":\""
+
StrUtil
.
removeSuffix
(
store
.
getModel
(),
" (标准磁盘驱动器)"
)
+
"\""
)
.
collect
(
Collectors
.
joining
(
","
)))
.
filter
(
StrUtil:
:
isNotBlank
)
.
collect
(
Collectors
.
joining
(
","
,
"{"
,
"}"
));
collect2
=
Arrays
.
stream
(
OshiUtil
.
getHardware
().
getDiskStores
())
.
map
(
HWDiskStore:
:
getPartitions
)
.
flatMap
(
Arrays:
:
stream
)
.
filter
(
partition
->
StrUtil
.
isNotBlank
(
partition
.
getMountPoint
()))
.
map
(
partition
->
"\""
+
StrUtil
.
removeSuffix
(
partition
.
getMountPoint
(),
":\\"
)
+
"盘\":\""
+
new
DecimalFormat
(
"#.00"
).
format
(
100
d
*
new
File
(
partition
.
getMountPoint
()).
getFreeSpace
()
/
partition
.
getSize
())
+
"%\""
)
.
collect
(
Collectors
.
joining
(
","
,
"{"
,
"}"
));
}
catch
(
Exception
e
)
{
log
.
error
(
"硬盘数据获取失败"
,
e
);
}
data
=
MapUtil
.<
String
,
Object
>
builder
()
.
put
(
isNeedCollection
(
isNoneEven
,
operatingSystem
,
mapParams
),
operatingSystem
,
OshiUtil
.
getOs
().
toString
())
.
put
(
isNeedCollection
(
isNoneEven
,
mac
,
mapParams
),
mac
,
MacAddrUtil
.
get
())
.
put
(
isNeedCollection
(
isNoneEven
,
baseboard
,
mapParams
),
baseboard
,
OshiUtil
.
getSystem
().
getBaseboard
().
getManufacturer
()
+
" "
+
OshiUtil
.
getSystem
().
getBaseboard
().
getVersion
())
.
put
(
isNeedCollection
(
isNoneEven
,
ip
,
mapParams
),
ip
,
InetAddress
.
getLocalHost
().
getHostAddress
())
.
put
(
isNeedCollection
(
isNoneEven
,
cpuModel
,
mapParams
),
cpuModel
,
OshiUtil
.
getCpuInfo
(
0
).
getCpuModel
())
.
put
(
isNeedCollection
(
isNoneEven
,
cpuTemp
,
mapParams
),
cpuTemp
,
Double
.
parseDouble
(
new
DecimalFormat
(
"#.00"
).
format
(
OshiUtil
.
getSensors
().
getCpuTemperature
())))
.
put
(
isNeedCollection
(
isNoneEven
,
cpuLoad
,
mapParams
),
cpuLoad
,
getCpuUsed
())
.
put
(
isNeedCollection
(
isNoneEven
,
memoryCap
,
mapParams
),
memoryCap
,
DataSizeUtil
.
format
(
OshiUtil
.
getMemory
().
getTotal
()))
.
put
(
isNeedCollection
(
isNoneEven
,
memoryAvailable
,
mapParams
),
memoryAvailable
,
DataSizeUtil
.
format
(
OshiUtil
.
getMemory
().
getAvailable
()))
.
put
(
isNeedCollection
(
isNoneEven
,
diskModel
,
mapParams
),
diskModel
,
collect1
)
.
put
(
isNeedCollection
(
isNoneEven
,
diskCap
,
mapParams
),
diskCap
,
collect
)
.
put
(
isNeedCollection
(
isNoneEven
,
diskFree
,
mapParams
),
diskFree
,
collect2
)
.
build
();
log
.
info
(
"采集数据,上报属性: mapData:{}"
,
data
);
Map
mapR
=
restTemplate
.
postForObject
(
"http://localhost:8765/uplink/oc-client"
,
data
,
Map
.
class
);
log
.
info
(
"采集数据,上报属性: ret:{}"
,
mapR
);
}
catch
(
Exception
e
)
{
log
.
error
(
"采集数据异常"
,
e
);
data
=
MapUtil
.<
String
,
Object
>
builder
().
put
(
"ERROR"
,
e
.
getMessage
()).
build
();
}
return
R
.
success
(
data
);
}
private
boolean
isNeedCollection
(
boolean
isNoneEven
,
String
key
,
Map
<
String
,
Integer
>
mapParams
)
{
if
(
null
!=
mapParams
&&
mapParams
.
containsKey
(
key
))
{
return
(!
isNoneEven
||
mapParams
.
get
(
key
)
!=
30
);
}
else
{
return
isNoneEven
;
}
}
public
static
double
getCpuUsed
()
{
CpuInfo
cpuInfo
=
OshiUtil
.
getCpuInfo
(
100
);
double
used
=
Double
.
parseDouble
(
new
DecimalFormat
(
"#.00"
).
format
(
100
-
cpuInfo
.
getFree
()));
return
Math
.
min
(
Math
.
max
(
used
,
0
),
100
);
}
}
apq-pc-info/src/main/java/com/priusis/lib/R.java
0 → 100644
浏览文件 @
6c622901
package
com
.
priusis
.
lib
;
import
lombok.Getter
;
@Getter
public
class
R
<
T
>
{
private
final
int
code
;
private
final
String
msg
;
private
final
T
data
;
private
R
(
int
code
,
String
msg
,
T
data
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
this
.
data
=
data
;
}
public
static
<
T
>
R
<
T
>
success
(
T
data
)
{
return
new
R
<>(
0
,
"SUCCESS"
,
data
);
}
public
static
<
T
>
R
<
T
>
success
()
{
return
success
(
null
);
}
public
static
<
T
>
R
<
T
>
error
(
int
code
,
String
msg
,
T
data
)
{
return
new
R
<>(
code
,
msg
,
data
);
}
public
static
<
T
>
R
<
T
>
error
(
int
code
,
String
msg
)
{
return
error
(
code
,
msg
,
null
);
}
public
static
<
T
>
R
<
T
>
error
(
String
msg
)
{
return
error
(
500
,
msg
);
}
public
static
<
T
>
R
<
T
>
error
()
{
return
error
(
"系统异常"
);
}
}
apq-pc-info/src/main/resources/application.yml
浏览文件 @
6c622901
...
...
@@ -5,4 +5,5 @@ spring:
server
:
# Server bind address
address
:
"
0.0.0.0"
port
:
${random.int[10000,19999]}
# port: ${random.int[10000,19999]}
port
:
8764
apq-pc-register/src/main/java/com/priusis/ApqRegisterApplication.java
浏览文件 @
6c622901
...
...
@@ -46,11 +46,10 @@ public class ApqRegisterApplication {
@Scheduled
(
fixedDelay
=
30000L
)
protected
void
registerProgramTask
()
{
log
.
info
(
"软件检测上报================="
);
/*
log.info("===================");
try {
WinExecuteUtils.killProc("Postman.exe");
} catch (Exception e) {
/* try {
WinExecuteUtils.killProc("TIM.exe");
} catch (IOException e) {
log.error("杀进程异常", e);
}*/
...
...
apq-pc-register/src/main/resources/application.yml
浏览文件 @
6c622901
...
...
@@ -5,4 +5,5 @@ spring:
server
:
# Server bind address
address
:
"
0.0.0.0"
port
:
${random.int[30000,39999]}
# port: ${random.int[30000,39999]}
port
:
8763
\ No newline at end of file
tools/install-package/boot/apq-client/apq-client.iss
浏览文件 @
6c622901
...
...
@@ -17,7 +17,7 @@
; Tell Windows Explorer to reload the environment
ChangesEnvironment=yes
DisableDirPage=no
AlwaysRestart=yes
; AlwaysRestart=yes
AppId={{1394783A-5D3C-48CD-0000-E2DFBB844E42}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
...
...
tools/install-package/boot/apq-client/bak/启动服务S.bat
浏览文件 @
6c622901
...
...
@@ -4,7 +4,7 @@ setlocal ENABLEEXTENSIONS
@ECHO Installing apq-client ...
"%~dp0apq-client-service.exe" install
@ECHO run
ing apq-client ...
@ECHO run
ning apq-client ...
"%~dp0apq-client-service.exe" start
@ECHO DONE.
...
...
浏览文件 @
6c622901
No preview for this file type
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论