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
32e2800b
Commit
32e2800b
authored
Sep 27, 2019
by
luozhenzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
子符串转存储对象
parent
9917ef7a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
3 deletions
+35
-3
Application.java
src/main/java/com/Application.java
+29
-0
DataImportController.java
src/main/java/com/demo/mongodb/DataImportController.java
+5
-3
DeviceService.java
src/main/java/com/demo/service/DeviceService.java
+1
-0
No files found.
src/main/java/com/Application.java
View file @
32e2800b
package
com
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.mongodb.MongoDbFactory
;
import
org.springframework.data.mongodb.core.convert.DbRefResolver
;
import
org.springframework.data.mongodb.core.convert.DefaultDbRefResolver
;
import
org.springframework.data.mongodb.core.convert.MappingMongoConverter
;
import
org.springframework.data.mongodb.core.mapping.MongoMappingContext
;
@Configuration
@ComponentScan
@SpringBootApplication
(
scanBasePackages
=
"com"
)
@EnableAutoConfiguration
public
class
Application
{
@Autowired
public
MongoDbFactory
mongoFactory
;
@Autowired
public
MongoMappingContext
mongoMappingContext
;
@Bean
public
MappingMongoConverter
mongoConverter
()
throws
Exception
{
DbRefResolver
dbRefResolver
=
new
DefaultDbRefResolver
(
mongoFactory
);
MappingMongoConverter
mongoConverter
=
new
MappingMongoConverter
(
dbRefResolver
,
mongoMappingContext
);
//this is my customization
mongoConverter
.
setMapKeyDotReplacement
(
"#"
);
mongoConverter
.
afterPropertiesSet
();
return
mongoConverter
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SpringApplication
.
run
(
Application
.
class
,
args
);
}
...
...
src/main/java/com/demo/mongodb/DataImportController.java
View file @
32e2800b
...
...
@@ -308,8 +308,9 @@ public class DataImportController {
"\t\t}\n"
+
"\t],\n"
+
"\"period\":1800,"
+
"\"heart_period\":30"
+
"}"
;
"\"heart_period\":30,"
+
"\"sensor_period\":3"
+
"}"
;
str
=
str
.
replaceAll
(
"\n"
,
""
);
str
=
str
.
replaceAll
(
"\t"
,
""
);
...
...
@@ -749,7 +750,8 @@ public class DataImportController {
"\"key\":\"5662e7c3d61fd5e0e67acd8bace6d1b0\""
+
"},"
+
"\"period\":1800,"
+
"\"heart_period\":30"
+
"\"heart_period\":30,"
+
"\"sensor_period\":3"
+
"}"
;
str
=
str
.
replaceAll
(
"\n"
,
""
);
str
=
str
.
replaceAll
(
"\t"
,
""
);
...
...
src/main/java/com/demo/service/DeviceService.java
View file @
32e2800b
...
...
@@ -201,6 +201,7 @@ public class DeviceService {
JSONObject
jsonData
=
JSONObject
.
parseObject
(
dataReal
);
DeviceInfo
deviceInfo
=
new
DeviceInfo
(
osEnum
.
getVal
(),
jsonData
,
reyunIdReal
);
// System.out.println("/deviceid 将要保存的数据:"+JSONObject.toJSONString(deviceInfo));
deviceInfoDao
.
insert
(
deviceInfo
);
JSONObject
result
=
(
JSONObject
)
JSON
.
toJSON
(
reyunIdMap
);
...
...
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