Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
deviceCheat
Project
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
luozhenzhen
deviceCheat
Commits
178f4418
Commit
178f4418
authored
Sep 20, 2019
by
luozhenzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加转义字符替换
parent
56dd266f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
15 deletions
+21
-15
DeviceInfo.java
src/main/java/com/demo/entity/po/DeviceInfo.java
+6
-6
DeviceService.java
src/main/java/com/demo/service/DeviceService.java
+4
-0
FileEncryptor.java
src/main/java/com/demo/util/FileEncryptor.java
+11
-9
No files found.
src/main/java/com/demo/entity/po/DeviceInfo.java
View file @
178f4418
...
@@ -10,7 +10,7 @@ public class DeviceInfo {
...
@@ -10,7 +10,7 @@ public class DeviceInfo {
private
String
os
;
private
String
os
;
private
String
info
;
private
String
info
;
private
String
reyunId
;
private
String
reyunId
;
private
Long
timestamp
s
;
private
Long
timestamp
;
public
DeviceInfo
()
{
public
DeviceInfo
()
{
}
}
...
@@ -19,7 +19,7 @@ public class DeviceInfo {
...
@@ -19,7 +19,7 @@ public class DeviceInfo {
this
.
os
=
os
;
this
.
os
=
os
;
this
.
info
=
info
;
this
.
info
=
info
;
this
.
reyunId
=
reyunId
;
this
.
reyunId
=
reyunId
;
timestamp
s
=
new
Date
().
getTime
();
timestamp
=
new
Date
().
getTime
();
}
}
public
String
getOs
()
{
public
String
getOs
()
{
...
@@ -46,11 +46,11 @@ public class DeviceInfo {
...
@@ -46,11 +46,11 @@ public class DeviceInfo {
this
.
reyunId
=
reyunId
;
this
.
reyunId
=
reyunId
;
}
}
public
Long
getTimestamp
s
()
{
public
Long
getTimestamp
()
{
return
timestamp
s
;
return
timestamp
;
}
}
public
void
setTimestamp
s
(
Long
timestamps
)
{
public
void
setTimestamp
(
Long
timestamps
)
{
this
.
timestamp
s
=
timestamps
;
this
.
timestamp
=
timestamps
;
}
}
}
}
src/main/java/com/demo/service/DeviceService.java
View file @
178f4418
...
@@ -194,6 +194,8 @@ public class DeviceService {
...
@@ -194,6 +194,8 @@ public class DeviceService {
reyunIdMap
.
put
(
"reyunId"
,
reyunId
);
reyunIdMap
.
put
(
"reyunId"
,
reyunId
);
//区分系统保存数据
//区分系统保存数据
//去掉转义字符
data
=
StringUtils
.
isEmpty
(
data
)
?
data
:
data
.
replaceAll
(
"\\\\"
,
""
);
DeviceInfo
deviceInfo
=
new
DeviceInfo
(
osEnum
.
getVal
(),
data
,
reyunId
);
DeviceInfo
deviceInfo
=
new
DeviceInfo
(
osEnum
.
getVal
(),
data
,
reyunId
);
deviceInfoDao
.
insert
(
deviceInfo
);
deviceInfoDao
.
insert
(
deviceInfo
);
...
@@ -317,6 +319,8 @@ public class DeviceService {
...
@@ -317,6 +319,8 @@ public class DeviceService {
//保存数据
//保存数据
String
reyunId
=
dataObject
.
getString
(
"reyunId"
);
String
reyunId
=
dataObject
.
getString
(
"reyunId"
);
//去掉转义字符
data
=
StringUtils
.
isEmpty
(
data
)
?
data
:
data
.
replaceAll
(
"\\\\"
,
""
);
SensorInfo
sensorInfo
=
new
SensorInfo
(
reyunId
,
new
Date
().
getTime
(),
data
,
osEnum
.
getVal
());
SensorInfo
sensorInfo
=
new
SensorInfo
(
reyunId
,
new
Date
().
getTime
(),
data
,
osEnum
.
getVal
());
sensorInfoDao
.
insert
(
sensorInfo
);
sensorInfoDao
.
insert
(
sensorInfo
);
return
true
;
return
true
;
...
...
src/main/java/com/demo/util/FileEncryptor.java
View file @
178f4418
...
@@ -55,10 +55,8 @@ public class FileEncryptor {
...
@@ -55,10 +55,8 @@ public class FileEncryptor {
byte
[]
data
=
inputStreamToByte
(
in
);
byte
[]
data
=
inputStreamToByte
(
in
);
//base64
//base64
// char[] aesData = DeformedBase64.encode(data);
char
[]
aesData
=
DeformedBase64
.
encode
(
data
);
// ByteArrayInputStream cin = StringToInputStream(getBytes(aesData));
ByteArrayInputStream
cin
=
StringToInputStream
(
getBytes
(
aesData
));
ByteArrayInputStream
cin
=
StringToInputStream
(
data
);
// byte[] aesData = SpecialSecret.aes256EncodeB(data, key.getBytes());
// byte[] aesData = SpecialSecret.aes256EncodeB(data, key.getBytes());
// ByteArrayInputStream cin = StringToInputStream(aesData);
// ByteArrayInputStream cin = StringToInputStream(aesData);
...
@@ -89,7 +87,7 @@ public class FileEncryptor {
...
@@ -89,7 +87,7 @@ public class FileEncryptor {
}
}
public
static
byte
[]
inputStreamToByte
(
InputStream
input
)
throws
IOException
{
public
static
byte
[]
inputStreamToByte
(
InputStream
input
)
throws
IOException
{
byte
[]
b
=
new
byte
[
input
.
available
()
];
byte
[]
b
=
new
byte
[
4096
];
for
(
int
n
;
(
n
=
input
.
read
(
b
))
!=
-
1
;)
{
for
(
int
n
;
(
n
=
input
.
read
(
b
))
!=
-
1
;)
{
}
}
return
b
;
return
b
;
...
@@ -188,12 +186,16 @@ public class FileEncryptor {
...
@@ -188,12 +186,16 @@ public class FileEncryptor {
if
(
sourceFile
.
exists
()
&&
sourceFile
.
isFile
())
{
if
(
sourceFile
.
exists
()
&&
sourceFile
.
isFile
())
{
FileInputStream
in
=
new
FileInputStream
(
sourceFile
);
FileInputStream
in
=
new
FileInputStream
(
sourceFile
);
byte
[]
data
=
inputStreamToByte
(
in
);
char
[]
aesData
=
DeformedBase64
.
encode
(
data
);
ByteArrayInputStream
cin
=
StringToInputStream
(
getBytes
(
aesData
));
out
=
resp
.
getOutputStream
();
out
=
resp
.
getOutputStream
();
// byte[] cache = new byte[CACHE_SIZE];
// int nRead = 0;
// while ((nRead = in.read(cache)) != -1) {
// out.write(cache, 0, nRead);
// out.flush();
// }
int
nRead
=
0
;
int
nRead
=
0
;
while
((
nRead
=
c
in
.
read
())
!=
-
1
)
{
while
((
nRead
=
in
.
read
())
!=
-
1
)
{
out
.
write
(
nRead
);
out
.
write
(
nRead
);
out
.
flush
();
out
.
flush
();
}
}
...
...
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