Commit 32e2800b by luozhenzhen

子符串转存储对象

parent 9917ef7a
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);
}
......
......@@ -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","");
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment