Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
data-sending
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
data-sending
Commits
2ea33e36
提交
2ea33e36
authored
3月 21, 2023
作者:
Matrix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
first commit
上级
全部展开
显示空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
747 行增加
和
0 行删除
+747
-0
.gitignore
.gitignore
+33
-0
hs_err_pid26845.log
hs_err_pid26845.log
+0
-0
hs_err_pid31430.log
hs_err_pid31430.log
+0
-0
pom.xml
pom.xml
+79
-0
App.java
src/main/java/com/example/datasending/App.java
+112
-0
LineChartFx.java
src/main/java/com/example/datasending/LineChartFx.java
+39
-0
SendController.java
src/main/java/com/example/datasending/SendController.java
+79
-0
TerminalData.java
src/main/java/com/example/datasending/TerminalData.java
+235
-0
DataCollector.java
...ava/com/example/datasending/collectors/DataCollector.java
+42
-0
DataCollectorScheduler.java
...xample/datasending/collectors/DataCollectorScheduler.java
+25
-0
DataRecord.java
...n/java/com/example/datasending/collectors/DataRecord.java
+28
-0
DataRecordService.java
...com/example/datasending/collectors/DataRecordService.java
+13
-0
DataRecordServiceImpl.java
...example/datasending/collectors/DataRecordServiceImpl.java
+16
-0
DataRecordMapper.java
...ample/datasending/collectors/mapper/DataRecordMapper.java
+18
-0
application.properties
src/main/resources/application.properties
+15
-0
DataSendingApplicationTests.java
.../com/example/datasending/DataSendingApplicationTests.java
+13
-0
没有找到文件。
.gitignore
0 → 100644
浏览文件 @
2ea33e36
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
hs_err_pid26845.log
0 → 100644
浏览文件 @
2ea33e36
差异被折叠。
点击展开。
hs_err_pid31430.log
0 → 100644
浏览文件 @
2ea33e36
差异被折叠。
点击展开。
pom.xml
0 → 100644
浏览文件 @
2ea33e36
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 https://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.3.1.RELEASE
</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>
com.example
</groupId>
<artifactId>
data-sending
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<name>
data-sending
</name>
<description>
data-sending
</description>
<properties>
<java.version>
1.8
</java.version>
</properties>
<dependencies>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
3.5.3.1
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<version>
5.8.12
</version>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
1.18.24
</version>
</dependency>
<dependency>
<groupId>
org.json
</groupId>
<artifactId>
json
</artifactId>
<version>
20210307
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
src/main/java/com/example/datasending/App.java
0 → 100644
浏览文件 @
2ea33e36
package
com
.
example
.
datasending
;
import
javafx.animation.AnimationTimer
;
import
javafx.application.Application
;
import
javafx.scene.Scene
;
import
javafx.scene.chart.CategoryAxis
;
import
javafx.scene.chart.LineChart
;
import
javafx.scene.chart.NumberAxis
;
import
javafx.scene.chart.XYChart
;
import
javafx.scene.control.Button
;
import
javafx.scene.control.TextField
;
import
javafx.scene.layout.VBox
;
import
javafx.stage.Stage
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URL
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Scanner
;
public
class
App
extends
Application
{
@Override
public
void
start
(
Stage
primaryStage
)
{
primaryStage
.
setTitle
(
"Real-time Chart"
);
CategoryAxis
xAxis
=
new
CategoryAxis
();
xAxis
.
setLabel
(
"Time (HH:mm:ss)"
);
NumberAxis
yAxis
=
new
NumberAxis
();
yAxis
.
setLabel
(
"sc"
);
LineChart
<
String
,
Number
>
lineChart
=
new
LineChart
<>(
xAxis
,
yAxis
);
XYChart
.
Series
<
String
,
Number
>
fgSeries
=
new
XYChart
.
Series
<>();
fgSeries
.
setName
(
"FG"
);
lineChart
.
getData
().
add
(
fgSeries
);
XYChart
.
Series
<
String
,
Number
>
dsmSeries
=
new
XYChart
.
Series
<>();
dsmSeries
.
setName
(
"DSM"
);
lineChart
.
getData
().
add
(
dsmSeries
);
Button
startButton
=
new
Button
(
"Start"
);
Button
stopButton
=
new
Button
(
"Stop"
);
TextField
freqTextField
=
new
TextField
(
"5"
);
freqTextField
.
setPromptText
(
"Freq (s)"
);
VBox
vbox
=
new
VBox
(
10
,
startButton
,
stopButton
,
freqTextField
,
lineChart
);
primaryStage
.
setScene
(
new
Scene
(
vbox
,
800
,
600
));
primaryStage
.
show
();
long
[]
lastUpdate
=
{
0
};
long
[]
interval
=
{
5_000_000_000L
};
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
AnimationTimer
timer
=
new
AnimationTimer
()
{
@Override
public
void
handle
(
long
now
)
{
if
(
now
-
lastUpdate
[
0
]
>=
interval
[
0
])
{
lastUpdate
[
0
]
=
now
;
String
currentTime
=
sdf
.
format
(
new
Date
());
try
{
JSONObject
jsonObject
=
fetchData
();
JSONArray
rankList
=
jsonObject
.
getJSONArray
(
"rankList"
);
for
(
int
i
=
0
;
i
<
rankList
.
length
();
i
++)
{
JSONObject
dataObject
=
rankList
.
getJSONObject
(
i
);
int
rid
=
dataObject
.
getInt
(
"rid"
);
int
sc
=
dataObject
.
getInt
(
"sc"
);
if
(
rid
==
9999
)
{
fgSeries
.
getData
().
add
(
new
XYChart
.
Data
<>(
currentTime
,
sc
));
}
else
if
(
rid
==
606118
)
{
dsmSeries
.
getData
().
add
(
new
XYChart
.
Data
<>(
currentTime
,
sc
));
}
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
};
startButton
.
setOnAction
(
event
->
{
interval
[
0
]
=
(
long
)
(
Double
.
parseDouble
(
freqTextField
.
getText
())
*
1_000_000_000L
);
timer
.
start
();
});
stopButton
.
setOnAction
(
event
->
timer
.
stop
());
}
private
JSONObject
fetchData
()
throws
IOException
{
String
apiUrl
=
"http://43.138.103.253:9999/test"
;
try
(
InputStream
is
=
new
URL
(
apiUrl
).
openStream
();
Scanner
scanner
=
new
Scanner
(
is
,
"UTF-8"
))
{
String
jsonText
=
scanner
.
useDelimiter
(
"\\A"
).
next
();
JSONObject
jsonObject
=
new
JSONObject
(
jsonText
);
return
jsonObject
.
getJSONObject
(
"data"
).
getJSONObject
(
"data"
);
}
}
public
static
void
main
(
String
[]
args
)
{
launch
();
}
}
src/main/java/com/example/datasending/LineChartFx.java
0 → 100644
浏览文件 @
2ea33e36
package
com
.
example
.
datasending
;
import
cn.hutool.log.Log
;
import
com.example.datasending.collectors.DataRecord
;
import
com.example.datasending.collectors.DataRecordService
;
import
javafx.application.Application
;
import
javafx.application.Platform
;
import
javafx.collections.FXCollections
;
import
javafx.collections.ObservableList
;
import
javafx.geometry.Pos
;
import
javafx.scene.Scene
;
import
javafx.scene.chart.CategoryAxis
;
import
javafx.scene.chart.LineChart
;
import
javafx.scene.chart.NumberAxis
;
import
javafx.scene.chart.XYChart
;
import
javafx.scene.control.Button
;
import
javafx.scene.layout.BorderPane
;
import
javafx.scene.layout.VBox
;
import
javafx.stage.Stage
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@EnableScheduling
@SpringBootApplication
public
class
LineChartFx
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
LineChartFx
.
class
,
args
);
}
}
src/main/java/com/example/datasending/SendController.java
0 → 100644
浏览文件 @
2ea33e36
package
com
.
example
.
datasending
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
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
;
/**
* SendController.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2023/2/21 at 15:02
* Suffering is the most powerful teacher of life.
*/
@Slf4j
@RestController
@RequestMapping
(
"/sending"
)
public
class
SendController
{
private
boolean
flag
=
false
;
private
String
ip
=
"http://192.168.102.68:82/schedule/terminal"
;
// private String ip = "http://127.0.0.1:82/schedule/terminal";
/**
* 开始循环发送数据,每30秒发送一次
*/
@GetMapping
(
"/start"
)
public
ResponseEntity
sendTerminal
()
{
flag
=
true
;
log
.
info
(
"[模拟消息发送] 开始循环发送消息"
);
//使用hutool 向 http://192.168.102.68:82/schedule/terminal 发送Post TerminalData数据
TerminalData
terminalData
=
new
TerminalData
().
initTerminalData
();
// 开一个新的线程 循环发送数据
new
Thread
(()
->
{
while
(
true
)
{
try
{
if
(
flag
)
{
RestTemplate
restTemplate
=
new
RestTemplate
();
//创建请求头
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
HttpEntity
<
TerminalData
>
entity
=
new
HttpEntity
<
TerminalData
>(
terminalData
,
headers
);
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
postForEntity
(
ip
,
entity
,
String
.
class
);
// HttpUtil.post(ip, );
log
.
info
(
"[模拟消息发送] 发送地址 {},模拟数据 {}"
,
ip
,
new
ObjectMapper
().
writeValueAsString
(
terminalData
));
Thread
.
sleep
(
30000
);
}
}
catch
(
InterruptedException
|
JsonProcessingException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}).
start
();
return
ResponseEntity
.
ok
(
"发送成功"
);
}
/**
* 停止循环发送数据
*/
@GetMapping
(
"/stop"
)
public
ResponseEntity
stopSendTerminal
()
{
flag
=
false
;
return
ResponseEntity
.
ok
(
"停止发送"
);
}
}
src/main/java/com/example/datasending/TerminalData.java
0 → 100644
浏览文件 @
2ea33e36
package
com
.
example
.
datasending
;
import
cn.hutool.core.util.RandomUtil
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.math.RoundingMode
;
import
java.util.ArrayList
;
import
java.util.List
;
@NoArgsConstructor
@Data
@AllArgsConstructor
public
class
TerminalData
{
@JsonProperty
(
"hardware_detection"
)
private
HardwareDetectionDTO
hardwareDetection
;
@JsonProperty
(
"task_manager"
)
private
TaskManagerDTO
taskManager
;
//初始化终端发送数据
public
TerminalData
initTerminalData
()
{
this
.
hardwareDetection
=
new
HardwareDetectionDTO
().
initHardware
();
this
.
taskManager
=
new
TaskManagerDTO
().
initTask
();
return
this
;
}
@NoArgsConstructor
@Data
@AllArgsConstructor
public
static
class
HardwareDetectionDTO
{
@JsonProperty
(
"computer_model"
)
private
String
computerModel
;
@JsonProperty
(
"operating_system"
)
private
String
operatingSystem
;
@JsonProperty
(
"computer_manufacture"
)
private
String
computerManufacture
;
@JsonProperty
(
"cpu_model"
)
private
String
cpuModel
;
@JsonProperty
(
"computer_base_board_model"
)
private
String
computerBaseBoardModel
;
@JsonProperty
(
"bios_model"
)
private
String
biosModel
;
@JsonProperty
(
"uuid"
)
private
String
uuid
;
@JsonProperty
(
"agent"
)
private
AgentDTO
agent
;
// 初始化内容合理的硬件主板信息
public
HardwareDetectionDTO
initHardware
()
{
this
.
computerModel
=
"ThinkPad T480"
;
this
.
operatingSystem
=
"Windows 10"
;
this
.
computerManufacture
=
"Lenovo"
;
this
.
cpuModel
=
"Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz"
;
this
.
computerBaseBoardModel
=
"20L5CTO1WW"
;
this
.
biosModel
=
"LENOVO N2JET45W (1.29 )"
;
this
.
uuid
=
"B4D27E1F-2E6A-11EB-9B1D-AC1F6B0D9C0D"
;
this
.
agent
=
new
AgentDTO
().
initAgent
();
return
this
;
}
@NoArgsConstructor
@Data
@AllArgsConstructor
public
static
class
AgentDTO
{
@JsonProperty
(
"id"
)
private
String
id
;
@JsonProperty
(
"type"
)
private
String
type
;
@JsonProperty
(
"start_time"
)
private
String
startTime
;
@JsonProperty
(
"version"
)
private
String
version
;
@JsonProperty
(
"mac_address"
)
private
String
macAddress
;
@JsonProperty
(
"ipv4_address"
)
private
String
ipv4Address
;
//初始化Agent对象
public
AgentDTO
initAgent
()
{
this
.
id
=
RandomUtil
.
randomString
(
10
);
this
.
type
=
"server"
;
this
.
startTime
=
"2020-12-01 00:00:00"
;
this
.
version
=
"1.0.0"
;
this
.
macAddress
=
"08:00:20:0A:8C:6D"
;
this
.
ipv4Address
=
"192.168.55.55"
;
return
this
;
}
}
}
@NoArgsConstructor
@Data
@AllArgsConstructor
public
static
class
TaskManagerDTO
{
@JsonProperty
(
"process"
)
private
ProcessDTO
process
;
@JsonProperty
(
"performance"
)
private
PerformanceDTO
performance
;
//初始化Task对象,使用子对象的初始化方法
public
TaskManagerDTO
initTask
()
{
this
.
process
=
new
ProcessDTO
().
initProcess
();
this
.
performance
=
new
PerformanceDTO
().
initPerformance
();
return
this
;
}
@NoArgsConstructor
@Data
@AllArgsConstructor
public
static
class
ProcessDTO
{
@JsonProperty
(
"process_number"
)
private
Integer
processNumber
;
//初始化处理器数量 4核
public
ProcessDTO
initProcess
()
{
this
.
processNumber
=
4
;
return
this
;
}
}
@NoArgsConstructor
@Data
@AllArgsConstructor
public
static
class
PerformanceDTO
{
@JsonProperty
(
"cpu"
)
private
CpuDTO
cpu
;
@JsonProperty
(
"ram"
)
private
RamDTO
ram
;
@JsonProperty
(
"disk"
)
private
DiskDTO
disk
;
@JsonProperty
(
"net_card"
)
private
NetCardDTO
netCard
;
//初始化性能数值,使用子对象的初始化方法
public
PerformanceDTO
initPerformance
()
{
this
.
cpu
=
new
CpuDTO
().
initCpu
();
this
.
ram
=
new
RamDTO
().
initRam
();
this
.
disk
=
new
DiskDTO
().
initDisk
();
this
.
netCard
=
new
NetCardDTO
().
initNetCard
();
return
this
;
}
@NoArgsConstructor
@Data
@AllArgsConstructor
public
static
class
CpuDTO
{
@JsonProperty
(
"cpu_usage"
)
private
Integer
cpuUsage
;
@JsonProperty
(
"cpu_per_usage"
)
private
List
<
Double
>
cpuPerUsage
;
//初始化合理数值的cpu使用率数据
public
CpuDTO
initCpu
()
{
this
.
cpuUsage
=
RandomUtil
.
randomInt
(
50
,
90
);
this
.
cpuPerUsage
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
this
.
cpuPerUsage
.
add
(
RandomUtil
.
randomDouble
(
50
,
90
,
RoundingMode
.
CEILING
));
}
return
this
;
}
}
@NoArgsConstructor
@Data
@AllArgsConstructor
public
static
class
RamDTO
{
@JsonProperty
(
"ram_usage"
)
private
Integer
ramUsage
;
@JsonProperty
(
"ram_total"
)
private
String
ramTotal
;
@JsonProperty
(
"ram_used"
)
private
String
ramUsed
;
@JsonProperty
(
"ram_free"
)
private
String
ramFree
;
//初始化合理数值的内存数据 单位是MB
public
RamDTO
initRam
()
{
this
.
ramTotal
=
RandomUtil
.
randomInt
(
100_000
,
200_000
)
+
"MB"
;
this
.
ramUsed
=
RandomUtil
.
randomInt
(
50_000
,
100_000
)
+
"MB"
;
this
.
ramFree
=
RandomUtil
.
randomInt
(
10_000
,
50_000
)
+
"MB"
;
this
.
ramUsage
=
RandomUtil
.
randomInt
(
50
,
90
);
return
this
;
}
}
@NoArgsConstructor
@Data
@AllArgsConstructor
public
static
class
DiskDTO
{
@JsonProperty
(
"disk_usage"
)
private
Double
diskUsage
;
@JsonProperty
(
"disk_total"
)
private
String
diskTotal
;
@JsonProperty
(
"disk_used"
)
private
String
diskUsed
;
@JsonProperty
(
"disk_free"
)
private
String
diskFree
;
//初始化磁盘数据 单位是MB 数值要合理
public
DiskDTO
initDisk
()
{
this
.
diskTotal
=
RandomUtil
.
randomInt
(
100_000
,
200_000
)
+
"MB"
;
this
.
diskUsed
=
RandomUtil
.
randomInt
(
50_000
,
100_000
)
+
"MB"
;
this
.
diskFree
=
RandomUtil
.
randomInt
(
10_000
,
50_000
)
+
"MB"
;
this
.
diskUsage
=
RandomUtil
.
randomDouble
(
0.5
,
0.9
);
return
this
;
}
}
@NoArgsConstructor
@Data
@AllArgsConstructor
public
static
class
NetCardDTO
{
@JsonProperty
(
"net_card_flow_in"
)
private
Long
netCardFlowIn
;
@JsonProperty
(
"net_card_flow_out"
)
private
Long
netCardFlowOut
;
//初始化流量数据
public
NetCardDTO
initNetCard
()
{
this
.
netCardFlowIn
=
RandomUtil
.
randomLong
(
100_000L
,
1_000_000L
);
this
.
netCardFlowOut
=
RandomUtil
.
randomLong
(
1_000_000L
,
2_000_000L
);
return
this
;
}
}
}
}
}
\ No newline at end of file
src/main/java/com/example/datasending/collectors/DataCollector.java
0 → 100644
浏览文件 @
2ea33e36
package
com
.
example
.
datasending
.
collectors
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.Date
;
@Slf4j
@Service
public
class
DataCollector
{
@Resource
private
DataRecordService
dataRecordService
;
public
void
collectData
()
{
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
HttpUtil
.
get
(
"http://43.138.103.253:9999/test"
));
JSONArray
rankList
=
jsonObject
.
getJSONObject
(
"data"
).
getJSONObject
(
"data"
).
getJSONArray
(
"rankList"
);
for
(
int
i
=
0
;
i
<
rankList
.
size
();
i
++)
{
JSONObject
dataObject
=
rankList
.
getJSONObject
(
i
);
int
rid
=
dataObject
.
getInt
(
"rid"
);
int
sc
=
dataObject
.
getInt
(
"sc"
);
if
(
rid
==
9999
||
rid
==
606118
)
{
DataRecord
dataRecord
=
new
DataRecord
();
dataRecord
.
setRid
(
rid
);
dataRecord
.
setSc
(
sc
);
dataRecord
.
setTimestamp
(
new
Date
());
log
.
info
(
"[采集数据] {}"
,
dataRecord
);
dataRecordService
.
save
(
dataRecord
);
}
}
}
}
src/main/java/com/example/datasending/collectors/DataCollectorScheduler.java
0 → 100644
浏览文件 @
2ea33e36
package
com
.
example
.
datasending
.
collectors
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
/**
* DataCollectorScheduler.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2023/3/21 at 11:51
* Suffering is the most powerful teacher of life.
*/
@Component
public
class
DataCollectorScheduler
{
@Resource
private
DataCollector
dataCollector
;
@Scheduled
(
fixedRate
=
5000
)
public
void
collectData
()
{
dataCollector
.
collectData
();
}
}
src/main/java/com/example/datasending/collectors/DataRecord.java
0 → 100644
浏览文件 @
2ea33e36
package
com
.
example
.
datasending
.
collectors
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* DataRecord.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2023/3/21 at 11:43
* Suffering is the most powerful teacher of life.
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public
class
DataRecord
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
Long
id
;
private
Integer
rid
;
private
Integer
sc
;
private
Date
timestamp
;
}
src/main/java/com/example/datasending/collectors/DataRecordService.java
0 → 100644
浏览文件 @
2ea33e36
package
com
.
example
.
datasending
.
collectors
;
import
com.baomidou.mybatisplus.extension.service.IService
;
/**
* DataRecordService.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2023/3/21 at 11:48
* Suffering is the most powerful teacher of life.
*/
public
interface
DataRecordService
extends
IService
<
DataRecord
>
{
}
src/main/java/com/example/datasending/collectors/DataRecordServiceImpl.java
0 → 100644
浏览文件 @
2ea33e36
package
com
.
example
.
datasending
.
collectors
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.example.datasending.collectors.mapper.DataRecordMapper
;
import
org.springframework.stereotype.Service
;
/**
* DataRecordServiceImpl.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2023/3/21 at 11:48
* Suffering is the most powerful teacher of life.
*/
@Service
public
class
DataRecordServiceImpl
extends
ServiceImpl
<
DataRecordMapper
,
DataRecord
>
implements
DataRecordService
{
}
src/main/java/com/example/datasending/collectors/mapper/DataRecordMapper.java
0 → 100644
浏览文件 @
2ea33e36
package
com
.
example
.
datasending
.
collectors
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.example.datasending.collectors.DataRecord
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.springframework.stereotype.Repository
;
/**
* DataRecordMapper.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2023/3/21 at 11:47
* Suffering is the most powerful teacher of life.
*/
@Repository
@Mapper
public
interface
DataRecordMapper
extends
BaseMapper
<
DataRecord
>
{
}
src/main/resources/application.properties
0 → 100644
浏览文件 @
2ea33e36
server.port
=
9999
# ?????
spring.datasource.url
=
jdbc:mysql://localhost:3306/fgnb?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
spring.datasource.username
=
root
spring.datasource.password
=
ldf3291369
spring.datasource.driver-class-name
=
com.mysql.cj.jdbc.Driver
mybatis-plus.mapper-locations
=
classpath*:com/example/datasending/**/mapping/*.xml, classpath:/META-INF/modeler-mybatis-mappings/*.xml
mybatis-plus.configuration.map-underscore-to-camel-case
=
true
mybatis-plus.configuration.cache-enabled
=
true
mybatis-plus.configuration.lazy-loading-enabled
=
true
mybatis-plus.configuration.multiple-result-sets-enabled
=
true
mybatis-plus.configuration.log-impl
=
org.apache.ibatis.logging.nologging.NoLoggingImpl
src/test/java/com/example/datasending/DataSendingApplicationTests.java
0 → 100644
浏览文件 @
2ea33e36
package
com
.
example
.
datasending
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
@SpringBootTest
class
DataSendingApplicationTests
{
@Test
void
contextLoads
()
{
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论