Commit 4eb068c6 by Kim Jinsung

Question #46359 eXFrame 同期エラー

同期・送信処理のパフォーマンス改善
parent 4e8470d2
...@@ -1416,13 +1416,11 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co ...@@ -1416,13 +1416,11 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co
} }
return errorMsg.length() > 0 ? errorMsg.toString() : null; return errorMsg.length() > 0 ? errorMsg.toString() : null;
} }
/** /**
* 作業データ受信 * 作業データ受信
* @param operationId * @param operationId 作業ID
* @param progressCallback * @param progressCallback プログレスバー表示用コールバック
* @return * @return 作業更新日
* @throws NetworkDisconnectedException * @throws NetworkDisconnectedException
* @throws ABVException * @throws ABVException
* @throws IOException * @throws IOException
...@@ -1431,6 +1429,22 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co ...@@ -1431,6 +1429,22 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co
* @throws ZipException * @throws ZipException
*/ */
public Date receptionTaskData(long operationId, Callback progressCallback, StringBuilder errorMsg) throws NetworkDisconnectedException, ABVException, IOException, InterruptedException, NoSuchAlgorithmException, ZipException { public Date receptionTaskData(long operationId, Callback progressCallback, StringBuilder errorMsg) throws NetworkDisconnectedException, ABVException, IOException, InterruptedException, NoSuchAlgorithmException, ZipException {
return receptionTaskData(operationId, progressCallback, errorMsg, null);
}
/**
* 作業データ受信
* @param operationId 作業ID
* @param progressCallback プログレスバー表示用コールバック
* @param taskKey タスクキー
* @return 作業更新日
* @throws NetworkDisconnectedException
* @throws ABVException
* @throws IOException
* @throws InterruptedException
* @throws NoSuchAlgorithmException
* @throws ZipException
*/
public Date receptionTaskData(long operationId, Callback progressCallback, StringBuilder errorMsg, String taskKey) throws NetworkDisconnectedException, ABVException, IOException, InterruptedException, NoSuchAlgorithmException, ZipException {
GetOperationDataParameters param = new GetOperationDataParameters(ABVDataCache.getInstance().getMemberInfo().sid, operationId); GetOperationDataParameters param = new GetOperationDataParameters(ABVDataCache.getInstance().getMemberInfo().sid, operationId);
OperationDto operationDto = mOperationLogic.getOperation(operationId); OperationDto operationDto = mOperationLogic.getOperation(operationId);
OperationContentDto operationContentDto = mOperationContentDao.getOperationMainContent(operationId); OperationContentDto operationContentDto = mOperationContentDao.getOperationMainContent(operationId);
...@@ -1441,17 +1455,24 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co ...@@ -1441,17 +1455,24 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co
OperationDataJSON json = AcmsClient.getInstance(ABVDataCache.getInstance().getUrlPath(), ABVEnvironment.getInstance().networkAdapter).getOpereationData(param); OperationDataJSON json = AcmsClient.getInstance(ABVDataCache.getInstance().getUrlPath(), ABVEnvironment.getInstance().networkAdapter).getOpereationData(param);
//プログレスを40%進行させるための計算 //プログレスを40%進行させるための計算
int progress = 0; float progress = 0;
if (json.taskDtoList.size() != 0) { if (json.taskDtoList.size() != 0) {
progress = 40 / json.taskDtoList.size(); progress = 40f / json.taskDtoList.size();
} }
boolean isRoutineTask = operationDto.reportType == Constant.ReportType.RoutineTask; boolean isRoutineTask = operationDto.reportType == Constant.ReportType.RoutineTask;
List<TaskReportDto> localTaskReportDtoList = null;
if (isRoutineTask) {
localTaskReportDtoList = mTaskReportDao.getTaskReportByOperationId(operationId);
}
float saveProgress = 0;
for (TaskDto serverTaskDto : json.taskDtoList) { for (TaskDto serverTaskDto : json.taskDtoList) {
//報告送信後、そのタスクのみ同期する
if (taskKey != null && !serverTaskDto.taskKey.equals(taskKey)) {
continue;
}
List<TaskReportDto> localTaskReportList = mTaskReportDao.getTaskReportListByTaskKey(serverTaskDto.taskKey); List<TaskReportDto> localTaskReportList = mTaskReportDao.getTaskReportListByTaskKey(serverTaskDto.taskKey);
//報告削除
for (TaskReportDto localTaskReportDto : localTaskReportList) { for (TaskReportDto localTaskReportDto : localTaskReportList) {
if (!isExistsTaskReportInList(serverTaskDto.taskReportDtoList, localTaskReportDto, isRoutineTask)) { if (!isExistsTaskReportInList(serverTaskDto.taskReportDtoList, localTaskReportDto, isRoutineTask)) {
if (isRoutineTask) { if (isRoutineTask) {
...@@ -1467,21 +1488,34 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co ...@@ -1467,21 +1488,34 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co
} }
} }
if (isExistsTaskInList(localTaskList, serverTaskDto)) { //タスク更新・追加
// 作業の報告更新 TaskDto localTaskDto = mOperationLogic.getLocalTaskInList(localTaskList, serverTaskDto.taskKey);
mTaskDao.update(serverTaskDto); if (localTaskDto == null) {
localTaskList.remove(serverTaskDto);
} else {
// 作業の報告登録 // 作業の報告登録
mTaskDao.insert(serverTaskDto); mTaskDao.insert(serverTaskDto);
} else {
// 作業の報告更新
if (mOperationLogic.taskDataSameCheck(localTaskDto, serverTaskDto)) {
mTaskDao.update(serverTaskDto);
}
localTaskList.remove(localTaskDto);
} }
// サーバーからの情報で更新 // サーバーからの情報で更新
//報告更新・追加
for (TaskReportDto serverTaskReportDto : serverTaskDto.taskReportDtoList) { for (TaskReportDto serverTaskReportDto : serverTaskDto.taskReportDtoList) {
String attachedFileName = serverTaskReportDto.attachedFileName; String attachedFileName = serverTaskReportDto.attachedFileName;
TaskReportDto localTaskReportDto; TaskReportDto localTaskReportDto = null;
if (operationDto.reportType == Constant.ReportType.RoutineTask) { if (operationDto.reportType == Constant.ReportType.RoutineTask) {
localTaskReportDto = mTaskReportDao.getRoutineTaskReportUtc(serverTaskReportDto.taskKey, serverTaskReportDto.taskReportId, DateTimeUtil.toString(serverTaskReportDto.reportStartDate, DateTimeFormat.yyyyMMddHHmmss_hyphen)); if (localTaskReportDtoList != null) {
localTaskReportDto = mOperationLogic.getLocalRoutineTaskReportDtoInList(localTaskReportDtoList, serverTaskReportDto.taskKey, serverTaskReportDto.taskReportId, serverTaskReportDto.reportStartDate);
if (localTaskReportDto != null) {
//サーバ側からのデータが変更されているか確認
if (mOperationLogic.taskReportDataSameCheck(localTaskReportDto, serverTaskReportDto)) {
continue;
}
}
}
} else { } else {
localTaskReportDto = mTaskReportDao.selectByTaskKey(serverTaskReportDto.taskKey, serverTaskReportDto.taskReportLevel); localTaskReportDto = mTaskReportDao.selectByTaskKey(serverTaskReportDto.taskKey, serverTaskReportDto.taskReportLevel);
} }
...@@ -1513,6 +1547,9 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co ...@@ -1513,6 +1547,9 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co
if (localTaskReportDto != null) { if (localTaskReportDto != null) {
// 報告データが存在すると作業報告を更新する // 報告データが存在すると作業報告を更新する
mOperationLogic.updateRoutineTaskReport(serverTaskDto.operationId, operationContentDto.contentId, serverTaskReportDto, false, false, localTaskReportDto.localSavedFlg); mOperationLogic.updateRoutineTaskReport(serverTaskDto.operationId, operationContentDto.contentId, serverTaskReportDto, false, false, localTaskReportDto.localSavedFlg);
if (localTaskReportDtoList != null) {
localTaskReportDtoList.remove(localTaskReportDto);
}
} else { } else {
mOperationLogic.insertRoutineTaskReport(serverTaskDto.operationId, operationContentDto.contentId, serverTaskReportDto, false, false); mOperationLogic.insertRoutineTaskReport(serverTaskDto.operationId, operationContentDto.contentId, serverTaskReportDto, false, false);
} }
...@@ -1548,19 +1585,28 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co ...@@ -1548,19 +1585,28 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co
} }
} }
if (progressCallback != null) { if (progressCallback != null) {
progressCallback.callback(new Integer(progress)); if (progress >= 1) {
progressCallback.callback(new Integer((int)progress));
} else {
saveProgress += progress;
if (saveProgress > 1) {
progressCallback.callback(new Integer((int)saveProgress));
saveProgress = 0f;
}
}
} }
} }
// サーバーから取得した作業情報がローカルに存在しないので削除する // サーバーから取得した作業情報がローカルに存在しないので削除する
if (taskKey == null) {
for (TaskDto taskDto : localTaskList) { for (TaskDto taskDto : localTaskList) {
mOperationLogic.deleteTaskFileData(operationId, operationContentDto.contentId, taskDto.taskKey, Constant.TaskReportLevel.ReportType); mOperationLogic.deleteTaskFileData(operationId, operationContentDto.contentId, taskDto.taskKey, Constant.TaskReportLevel.ReportType);
mTaskDao.delete(taskDto); mTaskDao.delete(taskDto);
} }
}
lastEditDate = json.lastEditDate; lastEditDate = json.lastEditDate;
if (progressCallback != null) { if (progressCallback != null) {
progressCallback.callback(new Integer(40)); progressCallback.callback(new Integer(40));
} }
return lastEditDate; return lastEditDate;
} }
......
...@@ -85,6 +85,8 @@ import jp.agentec.adf.util.DateTimeUtil; ...@@ -85,6 +85,8 @@ import jp.agentec.adf.util.DateTimeUtil;
import jp.agentec.adf.util.FileUtil; import jp.agentec.adf.util.FileUtil;
import jp.agentec.adf.util.StringUtil; import jp.agentec.adf.util.StringUtil;
import static jp.agentec.abook.abv.bl.common.Constant.ReportType.RoutineTask;
public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
protected static GroupLogic groupLogic = AbstractLogic.getLogic(GroupLogic.class); protected static GroupLogic groupLogic = AbstractLogic.getLogic(GroupLogic.class);
...@@ -941,7 +943,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -941,7 +943,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
int taskReportId = 0; int taskReportId = 0;
String reportStartDate = ""; String reportStartDate = "";
if (operationDto.reportType == Constant.ReportType.RoutineTask && abookCheckParam.get(ABookKeys.TASK_REPORT_ID) != null && abookCheckParam.get(ABookKeys.REPORT_START_DATE) != null) { if (operationDto.reportType == RoutineTask && abookCheckParam.get(ABookKeys.TASK_REPORT_ID) != null && abookCheckParam.get(ABookKeys.REPORT_START_DATE) != null) {
taskReportId = Integer.parseInt(abookCheckParam.get(ABookKeys.TASK_REPORT_ID)); taskReportId = Integer.parseInt(abookCheckParam.get(ABookKeys.TASK_REPORT_ID));
reportStartDate = abookCheckParam.get(ABookKeys.REPORT_START_DATE); reportStartDate = abookCheckParam.get(ABookKeys.REPORT_START_DATE);
} }
...@@ -963,10 +965,15 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -963,10 +965,15 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
try { try {
if (StringUtil.equalsAny(mCmd, ABookKeys.CMD_INSERT_TASK_REPORT, ABookKeys.CMD_UPDATE_TASK_REPORT)) { if (StringUtil.equalsAny(mCmd, ABookKeys.CMD_INSERT_TASK_REPORT, ABookKeys.CMD_UPDATE_TASK_REPORT)) {
// リソースパターンの適用 // リソースパターンの適用
runOnUiThread(new Runnable() {
@Override
public void run() {
showProgressPopup(PatternStringUtil.patternToString(getApplicationContext(), showProgressPopup(PatternStringUtil.patternToString(getApplicationContext(),
R.string.file_initialization, R.string.file_initialization,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0))); getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
} }
});
}
//連続作業の全削除ボタンタップ時のインジケーター表示 //連続作業の全削除ボタンタップ時のインジケーター表示
if (StringUtil.equalsAny(mCmd, ABookKeys.CMD_DELETE_PROCESS)) { if (StringUtil.equalsAny(mCmd, ABookKeys.CMD_DELETE_PROCESS)) {
showProgressPopup(PatternStringUtil.patternToString(getApplicationContext(), showProgressPopup(PatternStringUtil.patternToString(getApplicationContext(),
...@@ -1013,12 +1020,20 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -1013,12 +1020,20 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
public Object callback(Object ret) { public Object callback(Object ret) {
final boolean isError = (boolean)ret; final boolean isError = (boolean)ret;
closeProgressPopup(); closeProgressPopup();
syncOperation(mOperationId, mReportType, false); //キー項目あり設定時、送信後、同期処理
if (mOperationType == OperationType.LIST) { //リスト作業のみ実行
if (mReportType != RoutineTask) { //定期点検以外
if (mCmd.equals(ABookKeys.CMD_INSERT_TASK_REPORT) || mCmd.equals(ABookKeys.CMD_UPDATE_TASK_REPORT)) {
try { try {
receptionTaskData(mOperationId, null, null, mTaskKey);
mOperationLogic.createJsonForOperationContent(mOperationId, mContentPath, false); mOperationLogic.createJsonForOperationContent(mOperationId, mContentPath, false);
} catch (IOException e) { } catch (Exception e) {
Logger.e(TAG, "createJsonForOperationContent error. " + e);
}
} }
}
}
// 報告・報告(回答)の切り替えボタンタップ、連続作業の全削除ボタンタップ // 報告・報告(回答)の切り替えボタンタップ、連続作業の全削除ボタンタップ
if (mCmd.equals(ABookKeys.CMD_CHANGE_TASK_REPORT) || mCmd.equals(ABookKeys.CMD_DELETE_PROCESS)) { if (mCmd.equals(ABookKeys.CMD_CHANGE_TASK_REPORT) || mCmd.equals(ABookKeys.CMD_DELETE_PROCESS)) {
afterABookCheckApi(mCmd, mTaskKey, 0, "", null, isOperationPdf()); afterABookCheckApi(mCmd, mTaskKey, 0, "", null, isOperationPdf());
......
...@@ -80,7 +80,7 @@ public class ABookCheckWebViewHelper extends ABookHelper { ...@@ -80,7 +80,7 @@ public class ABookCheckWebViewHelper extends ABookHelper {
* @param finishCallback * @param finishCallback
* @param taskReportLevel * @param taskReportLevel
*/ */
public void doABookCheckParam(ABVContentViewActivity context, String cmd, String taskKey, int enableReportHistory, Map<String, String> param, long operationId, String contentPath, long contentId, int reportType, Callback finishCallback, int taskReportLevel) throws IOException { public void doABookCheckParam(ABVContentViewActivity context, final String cmd, final String taskKey, final int enableReportHistory, final Map<String, String> param, final long operationId, final String contentPath, final long contentId, final int reportType, Callback finishCallback,final int taskReportLevel) throws IOException {
int taskReportSendId = 0; int taskReportSendId = 0;
mFinishCallback = finishCallback; mFinishCallback = finishCallback;
...@@ -106,17 +106,25 @@ public class ABookCheckWebViewHelper extends ABookHelper { ...@@ -106,17 +106,25 @@ public class ABookCheckWebViewHelper extends ABookHelper {
// その時に呼び出し元で表示したダイアログが閉じずに、操作不能となったので、 // その時に呼び出し元で表示したダイアログが閉じずに、操作不能となったので、
// mFinishCallBackに、エラーを通知しダイアログを閉じる処理を追加した。 // mFinishCallBackに、エラーを通知しダイアログを閉じる処理を追加した。
// TODO: 失敗するのであれば、データが壊れているわけなので、壊れたデータを削除する必要があるのでは? // TODO: 失敗するのであれば、データが壊れているわけなので、壊れたデータを削除する必要があるのでは?
final ABVContentViewActivity final_context = context;
final String final_processKey = processKey;
final Integer final_phaseNo = phaseNo;
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
try { try {
insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, reportType, taskReportLevel, false); insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, reportType, taskReportLevel, false);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel, final_processKey, final_phaseNo);
sendTaskData(final_context, operationId, taskKey, taskReportLevel, reportType, contentPath);
} catch (Exception e) { } catch (Exception e) {
context.showSimpleAlertDialog(R.string.error, R.string.ERROR); final_context.showSimpleAlertDialog(R.string.error, R.string.ERROR);
Logger.e(TAG,e); Logger.e(TAG, e);
mFinishCallback.callback(true); mFinishCallback.callback(true);
context.closeProgressPopup(); final_context.closeProgressPopup();
throw e; Logger.e(TAG, "doABookCheckParam error", e);
} }
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel, processKey, phaseNo); }
sendTaskData(context, operationId, taskKey, taskReportLevel, reportType, contentPath); });
break; break;
case ABookKeys.CMD_LOCAL_SAVE_TASK_REPORT: // 一時保存 case ABookKeys.CMD_LOCAL_SAVE_TASK_REPORT: // 一時保存
insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, reportType, taskReportLevel, true); insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, reportType, taskReportLevel, true);
...@@ -236,9 +244,14 @@ public class ABookCheckWebViewHelper extends ABookHelper { ...@@ -236,9 +244,14 @@ public class ABookCheckWebViewHelper extends ABookHelper {
}; };
// リソースパターンの適用 // リソースパターンの適用
context.runOnUiThread(new Runnable() {
@Override
public void run() {
context.showProgressView(PatternStringUtil.patternToString(context, context.showProgressView(PatternStringUtil.patternToString(context,
R.string.synchronizing, R.string.synchronizing,
getUserPref(context, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0))); getUserPref(context, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
}
});
CommonExecutor.execute(new Runnable() { CommonExecutor.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
......
...@@ -162,8 +162,6 @@ public class OzdFileHelper { ...@@ -162,8 +162,6 @@ public class OzdFileHelper {
public static final boolean moveTempOzdFileToOzdFile(long contentId, String taskKey, String tempOzFileName, String ozFileName) { public static final boolean moveTempOzdFileToOzdFile(long contentId, String taskKey, String tempOzFileName, String ozFileName) {
String tempOzdFilePath = ABVEnvironment.getInstance().getTempFilePath(contentId, taskKey, tempOzFileName); String tempOzdFilePath = ABVEnvironment.getInstance().getTempFilePath(contentId, taskKey, tempOzFileName);
String ozdFilePath = ABVEnvironment.getInstance().getTempFilePath(contentId, taskKey, ozFileName); String ozdFilePath = ABVEnvironment.getInstance().getTempFilePath(contentId, taskKey, ozFileName);
Logger.i("******** tempOzdFilePath = " + tempOzdFilePath);
Logger.i("******** ozdFilePath = " + ozdFilePath);
if (FileUtil.exists(ozdFilePath)) { if (FileUtil.exists(ozdFilePath)) {
FileUtil.delete(ozdFilePath); FileUtil.delete(ozdFilePath);
} }
......
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