Commit 880b65ad by onuma

オブジェクトを毎回生成していたのを修正。アフターバーナーライブラリを追加。

parent f3029c25
...@@ -16,6 +16,8 @@ dependencies { ...@@ -16,6 +16,8 @@ dependencies {
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.10.8' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.10.8'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.9.10' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.9.10'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-afterburner
implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-afterburner', version: '2.9.10'
} }
sourceSets { sourceSets {
......
...@@ -84,6 +84,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature; ...@@ -84,6 +84,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationConfig; import com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.module.afterburner.AfterburnerModule;
/** /**
* Created by leej on 2018/08/17. * Created by leej on 2018/08/17.
...@@ -1522,12 +1523,18 @@ public class OperationLogic extends AbstractLogic { ...@@ -1522,12 +1523,18 @@ public class OperationLogic extends AbstractLogic {
public void createRoutineTaskReportJsonByJackson(Long operationId, String contentPath) throws IOException { public void createRoutineTaskReportJsonByJackson(Long operationId, String contentPath) throws IOException {
List<TaskReport> taskReportList = new ArrayList<TaskReport>(); List<TaskReport> taskReportList = new ArrayList<TaskReport>();
List<TaskReportDto> routineTaskReportDtoList = mTaskReportDao.getTaskReportByOperationId(operationId); List<TaskReportDto> routineTaskReportDtoList = mTaskReportDao.getTaskReportByOperationId(operationId);
ObjectMapper hogetaskMapper = new ObjectMapper();
hogetaskMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // null を無視
hogetaskMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); // 空を許可。例) "task": {}
hogetaskMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false); // 定義していないプロパティも出力
// 現在の作業タイプは定期点検の場合 // 現在の作業タイプは定期点検の場合
for (TaskReportDto dto : routineTaskReportDtoList) { for (TaskReportDto dto : routineTaskReportDtoList) {
ObjectMapper mapper = new ObjectMapper(); //ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // null を無視 //mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // null を無視
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); // 空を許可。例) "task": {} //mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); // 空を許可。例) "task": {}
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false); // 定義していないプロパティも出力 //mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false); // 定義していないプロパティも出力
TaskReport taskReport = new TaskReport(); TaskReport taskReport = new TaskReport();
taskReport.taskReportInfoId = dto.taskReportInfoId; taskReport.taskReportInfoId = dto.taskReportInfoId;
...@@ -1536,10 +1543,6 @@ public class OperationLogic extends AbstractLogic { ...@@ -1536,10 +1543,6 @@ public class OperationLogic extends AbstractLogic {
taskReport.reportEndDate = DateTimeUtil.toStringInTimeZone(dto.reportEndDate, DateTimeFormat.yyyyMMddHHmmss_hyphen, DateTimeUtil.getLocalTimeZone()); taskReport.reportEndDate = DateTimeUtil.toStringInTimeZone(dto.reportEndDate, DateTimeFormat.yyyyMMddHHmmss_hyphen, DateTimeUtil.getLocalTimeZone());
if (!StringUtil.isNullOrEmpty(dto.jsonData)) { if (!StringUtil.isNullOrEmpty(dto.jsonData)) {
ObjectMapper hogetaskMapper = new ObjectMapper();
hogetaskMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // null を無視
hogetaskMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); // 空を許可。例) "task": {}
hogetaskMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false); // 定義していないプロパティも出力
HogeTask hogeTask1 = hogetaskMapper.readValue(dto.jsonData,HogeTask.class); HogeTask hogeTask1 = hogetaskMapper.readValue(dto.jsonData,HogeTask.class);
...@@ -1564,12 +1567,13 @@ public class OperationLogic extends AbstractLogic { ...@@ -1564,12 +1567,13 @@ public class OperationLogic extends AbstractLogic {
root.taskReportId = lastRoutineTaskReportDto.taskReportId; root.taskReportId = lastRoutineTaskReportDto.taskReportId;
root.taskReport_0 = taskReportList; root.taskReport_0 = taskReportList;
ObjectMapper lastMapper = new ObjectMapper(); //ObjectMapper lastMapper = new ObjectMapper();
lastMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // null を無視 //lastMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // null を無視
lastMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); // 空を許可。例) "task": {} //lastMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); // 空を許可。例) "task": {}
lastMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false); // 定義していないプロパティも出力 //lastMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false); // 定義していないプロパティも出力
//lastMapper.registerModule(new AfterburnerModule());
//long start = System.currentTimeMillis(); //long start = System.currentTimeMillis();
lastMapper.writeValue(new File(contentPath + "/" + ABookKeys.TASK_REPORT + ".json"), root); hogetaskMapper.writeValue(new File(contentPath + "/" + ABookKeys.TASK_REPORT + ".json"), root);
//long end = System.currentTimeMillis(); //long end = System.currentTimeMillis();
//Logger.i(TAG,"Jackson file write time. %s" , (end-start)); //Logger.i(TAG,"Jackson file write time. %s" , (end-start));
} }
......
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