Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
O2OA_plugin_demo
Overview
Overview
Details
Activity
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
周田
O2OA_plugin_demo
Commits
75d5329b
Commit
75d5329b
authored
Dec 08, 2023
by
周田
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 正常获取时间
parent
991beeb7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
25 deletions
+36
-25
Main.java
TDengineDemo/src/main/java/org/linkor/Main.java
+15
-13
QueryDemo.java
TDengineDemo/src/main/java/org/linkor/QueryDemo.java
+11
-3
Modbus.java
TDengineDemo/src/main/java/org/linkor/entities/Modbus.java
+10
-9
No files found.
TDengineDemo/src/main/java/org/linkor/Main.java
View file @
75d5329b
...
@@ -48,22 +48,23 @@ public class Main {
...
@@ -48,22 +48,23 @@ public class Main {
// util.insert("t", new HashMap<>(Map.of(
// util.insert("t", new HashMap<>(Map.of(
// "ss", "123"
// "ss", "123"
// )));
// )));
util
.
insert
(
//
util.insert(
"s"
,
//
"s",
new
HashMap
<>(
Map
.
of
(
//
new HashMap<>(Map.of(
"ts"
,
new
Date
(),
//
"ts", new Date(),
"st"
,
true
,
//
"st", true,
"temperature"
,
1
,
//
"temperature", 1,
"press"
,
2
//
"press", 2
))
//
))
);
//
);
//
List
<
Modbus
>
list
=
util
.
getList
(
"select * from power.s;"
,
Modbus
.
class
);
List
<
Modbus
>
list
=
util
.
getList
(
"select * from power.s;"
,
Modbus
.
class
);
list
.
forEach
(
e
->
System
.
out
.
println
(
e
.
toString
()));
list
.
forEach
(
e
->
System
.
out
.
println
(
e
.
toString
()));
// System.out.println("===============");
System
.
out
.
println
(
"==============="
);
// Modbus m = util.getOne("select * from power.s;", Modbus.class);
Modbus
m
=
util
.
getOne
(
"select * from power.s;"
,
// System.out.println(m.toString());
Modbus
.
class
);
System
.
out
.
println
(
m
.
toString
());
}
}
}
}
\ No newline at end of file
TDengineDemo/src/main/java/org/linkor/QueryDemo.java
View file @
75d5329b
...
@@ -18,7 +18,12 @@ public class QueryDemo {
...
@@ -18,7 +18,12 @@ public class QueryDemo {
System
.
out
.
print
(
value
);
System
.
out
.
print
(
value
);
System
.
out
.
print
(
"\t"
);
System
.
out
.
print
(
"\t"
);
}
}
System
.
out
.
println
();
System
.
out
.
println
();
for
(
int
i
=
1
;
i
<=
meta
.
getColumnCount
();
i
++)
{
System
.
out
.
print
(
rs
.
getString
(
i
).
getClass
().
getName
());
System
.
out
.
print
(
"\t"
);
}
}
}
private
static
void
printColName
(
ResultSet
rs
)
throws
SQLException
{
private
static
void
printColName
(
ResultSet
rs
)
throws
SQLException
{
...
@@ -28,20 +33,23 @@ public class QueryDemo {
...
@@ -28,20 +33,23 @@ public class QueryDemo {
System
.
out
.
print
(
colLabel
);
System
.
out
.
print
(
colLabel
);
System
.
out
.
print
(
"\t"
);
System
.
out
.
print
(
"\t"
);
}
}
System
.
out
.
println
();
System
.
out
.
println
();
}
}
private
static
void
processResult
(
ResultSet
rs
)
throws
SQLException
{
private
static
void
processResult
(
ResultSet
rs
)
throws
SQLException
{
printColName
(
rs
);
printColName
(
rs
);
while
(
rs
.
next
())
{
// while (rs.next()) {
// printRow(rs);
// }
rs
.
next
();
printRow
(
rs
);
printRow
(
rs
);
}
}
}
private
static
void
queryData
()
throws
SQLException
{
private
static
void
queryData
()
throws
SQLException
{
try
(
Connection
conn
=
getConnection
())
{
try
(
Connection
conn
=
getConnection
())
{
try
(
Statement
stmt
=
conn
.
createStatement
())
{
try
(
Statement
stmt
=
conn
.
createStatement
())
{
ResultSet
rs
=
stmt
.
executeQuery
(
"SELECT
AVG(voltage) FROM meters GROUP BY location
"
);
ResultSet
rs
=
stmt
.
executeQuery
(
"SELECT
* FROM power.s
"
);
processResult
(
rs
);
processResult
(
rs
);
}
}
}
}
...
...
TDengineDemo/src/main/java/org/linkor/entities/Modbus.java
View file @
75d5329b
package
org
.
linkor
.
entities
;
package
org
.
linkor
.
entities
;
import
java.util.Date
;
import
java.sql.Date
;
/**
/**
* modbus 数据类
* modbus 数据类
*/
*/
public
class
Modbus
{
public
class
Modbus
{
Date
time
;
String
ts
;
boolean
st
;
boolean
st
;
int
temperature
;
int
temperature
;
int
press
;
int
press
;
...
@@ -14,19 +15,19 @@ public class Modbus {
...
@@ -14,19 +15,19 @@ public class Modbus {
public
Modbus
()
{
public
Modbus
()
{
}
}
public
Modbus
(
Date
time
,
boolean
st
,
int
temperature
,
int
press
)
{
public
Modbus
(
String
ts
,
boolean
st
,
int
temperature
,
int
press
)
{
this
.
t
ime
=
time
;
this
.
t
s
=
ts
;
this
.
st
=
st
;
this
.
st
=
st
;
this
.
temperature
=
temperature
;
this
.
temperature
=
temperature
;
this
.
press
=
press
;
this
.
press
=
press
;
}
}
public
Date
getTime
()
{
public
String
getTs
()
{
return
t
ime
;
return
t
s
;
}
}
public
void
setT
ime
(
Date
time
)
{
public
void
setT
s
(
String
ts
)
{
this
.
t
ime
=
time
;
this
.
t
s
=
ts
;
}
}
public
boolean
isSt
()
{
public
boolean
isSt
()
{
...
@@ -56,7 +57,7 @@ public class Modbus {
...
@@ -56,7 +57,7 @@ public class Modbus {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"Modbus{"
+
return
"Modbus{"
+
"t
ime="
+
time
+
"t
s='"
+
ts
+
'\''
+
", st="
+
st
+
", st="
+
st
+
", temperature="
+
temperature
+
", temperature="
+
temperature
+
", press="
+
press
+
", press="
+
press
+
...
...
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