Commit bae657e9 by Kim Jinsung

Merge branch 'contract/sato/1.0.612_62460' into 'contract/sato/1.0.612'

62460:アプリ自動同期仕様変更

See merge request !328
parents 5b70622b 36d31460
...@@ -131,6 +131,11 @@ public class OperationDao extends AbstractDao { ...@@ -131,6 +131,11 @@ public class OperationDao extends AbstractDao {
dto.statusCompletedCount = cursor.getInt(column); dto.statusCompletedCount = cursor.getInt(column);
} }
column = cursor.getColumnIndex("operation_last_sync_date");
if (column != -1) {
dto.operationLastSyncDate = DateTimeUtil.toDate(cursor.getString(column), "UTC", DateTimeFormat.yyyyMMddHHmmss_hyphen);
}
return dto; return dto;
} }
...@@ -205,9 +210,10 @@ public class OperationDao extends AbstractDao { ...@@ -205,9 +210,10 @@ public class OperationDao extends AbstractDao {
+ "status_not_started_count, " + "status_not_started_count, "
+ "status_working_count, " + "status_working_count, "
+ "status_completed_count, " + "status_completed_count, "
+ "quick_report) " + "quick_report, "
+ "operation_last_sync_date) "
+ "values " + "values "
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
dto.getInsertValues()); dto.getInsertValues());
} }
...@@ -232,7 +238,8 @@ public class OperationDao extends AbstractDao { ...@@ -232,7 +238,8 @@ public class OperationDao extends AbstractDao {
+ "status_not_started_count=?, " + "status_not_started_count=?, "
+ "status_working_count=?, " + "status_working_count=?, "
+ "status_completed_count=?, " + "status_completed_count=?, "
+ "quick_report=? " + "quick_report=?, "
+ "operation_last_sync_date=? "
+ "where operation_id=?", + "where operation_id=?",
dto.getUpdateValues()); dto.getUpdateValues());
return count > 0; return count > 0;
...@@ -301,6 +308,7 @@ public class OperationDao extends AbstractDao { ...@@ -301,6 +308,7 @@ public class OperationDao extends AbstractDao {
sql.append(" top.status_not_started_count, "); sql.append(" top.status_not_started_count, ");
sql.append(" top.status_working_count, "); sql.append(" top.status_working_count, ");
sql.append(" top.status_completed_count, "); sql.append(" top.status_completed_count, ");
sql.append(" top.operation_last_sync_date, ");
sql.append(" CASE "); sql.append(" CASE ");
sql.append(" WHEN report_type = 1 THEN ( "); sql.append(" WHEN report_type = 1 THEN ( ");
sql.append(" SELECT strftime('%Y/%m/%d %H:%M', datetime(ttr.report_start_date, 'localtime')) || ' ~ ' || strftime('%Y/%m/%d %H:%M', datetime(ttr.report_end_date, 'localtime')) "); sql.append(" SELECT strftime('%Y/%m/%d %H:%M', datetime(ttr.report_start_date, 'localtime')) || ' ~ ' || strftime('%Y/%m/%d %H:%M', datetime(ttr.report_end_date, 'localtime')) ");
...@@ -466,6 +474,7 @@ public class OperationDao extends AbstractDao { ...@@ -466,6 +474,7 @@ public class OperationDao extends AbstractDao {
sql.append(" top.status_not_started_count, "); sql.append(" top.status_not_started_count, ");
sql.append(" top.status_working_count, "); sql.append(" top.status_working_count, ");
sql.append(" top.status_completed_count, "); sql.append(" top.status_completed_count, ");
sql.append(" top.operation_last_sync_date, ");
sql.append(" CASE "); sql.append(" CASE ");
sql.append(" WHEN report_type = 1 THEN ( "); sql.append(" WHEN report_type = 1 THEN ( ");
sql.append(" SELECT strftime('%Y/%m/%d %H:%M', datetime(ttr.report_start_date, 'localtime')) || ' ~ ' || strftime('%Y/%m/%d %H:%M', datetime(ttr.report_end_date, 'localtime')) "); sql.append(" SELECT strftime('%Y/%m/%d %H:%M', datetime(ttr.report_start_date, 'localtime')) || ' ~ ' || strftime('%Y/%m/%d %H:%M', datetime(ttr.report_end_date, 'localtime')) ");
......
...@@ -47,6 +47,7 @@ public class TOperation extends SQLiteTableScript { ...@@ -47,6 +47,7 @@ public class TOperation extends SQLiteTableScript {
sql.append(" , status_not_started_count INTEGER NOT NULL DEFAULT 0 "); sql.append(" , status_not_started_count INTEGER NOT NULL DEFAULT 0 ");
sql.append(" , status_working_count INTEGER NOT NULL DEFAULT 0 "); sql.append(" , status_working_count INTEGER NOT NULL DEFAULT 0 ");
sql.append(" , status_completed_count INTEGER NOT NULL DEFAULT 0 "); sql.append(" , status_completed_count INTEGER NOT NULL DEFAULT 0 ");
sql.append(" , operation_last_sync_date DATETIME ");
sql.append(" , PRIMARY KEY (operation_id) "); sql.append(" , PRIMARY KEY (operation_id) ");
sql.append(" ) "); sql.append(" ) ");
ddl.add(sql.toString()); ddl.add(sql.toString());
...@@ -67,6 +68,9 @@ public class TOperation extends SQLiteTableScript { ...@@ -67,6 +68,9 @@ public class TOperation extends SQLiteTableScript {
ddl.add(" ALTER TABLE t_operation ADD COLUMN status_working_count INTEGER NOT NULL DEFAULT 0 "); ddl.add(" ALTER TABLE t_operation ADD COLUMN status_working_count INTEGER NOT NULL DEFAULT 0 ");
ddl.add(" ALTER TABLE t_operation ADD COLUMN status_completed_count INTEGER NOT NULL DEFAULT 0 "); ddl.add(" ALTER TABLE t_operation ADD COLUMN status_completed_count INTEGER NOT NULL DEFAULT 0 ");
} }
if (oldVersion < DatabaseVersions.Ver1_0_612) {
ddl.add(" ALTER TABLE t_operation ADD COLUMN operation_last_sync_date DATETIME ");
}
return ddl; return ddl;
} }
......
...@@ -37,6 +37,8 @@ public class OperationDto extends AbstractDto { ...@@ -37,6 +37,8 @@ public class OperationDto extends AbstractDto {
public int statusWorkingCount; //「作業中」数 public int statusWorkingCount; //「作業中」数
public int statusCompletedCount; // 「作業完了」数 public int statusCompletedCount; // 「作業完了」数
public Date operationLastSyncDate;
// 作業担当グループリスト // 作業担当グループリスト
public List<TaskWorkerGroupDto> taskWorkerGroupDtoList; public List<TaskWorkerGroupDto> taskWorkerGroupDtoList;
// 作業種別に紐づく作業Dto // 作業種別に紐づく作業Dto
...@@ -53,12 +55,12 @@ public class OperationDto extends AbstractDto { ...@@ -53,12 +55,12 @@ public class OperationDto extends AbstractDto {
@Override @Override
public Object[] getInsertValues() { public Object[] getInsertValues() {
return new Object[] { operationId, operationName, operationDescriptions, operationStartDate, operationEndDate, operationType, reportType, lastEditDate, contentCreatingFlg, editLockFlg, needSyncFlg, reportCycle, enableReportUpdate, enableReportHistory, enableReportEdit, enableAddReport, statusNotStartedCount, statusWorkingCount, statusCompletedCount, quickReport }; return new Object[] { operationId, operationName, operationDescriptions, operationStartDate, operationEndDate, operationType, reportType, lastEditDate, contentCreatingFlg, editLockFlg, needSyncFlg, reportCycle, enableReportUpdate, enableReportHistory, enableReportEdit, enableAddReport, statusNotStartedCount, statusWorkingCount, statusCompletedCount, quickReport, operationLastSyncDate };
} }
@Override @Override
public Object[] getUpdateValues() { public Object[] getUpdateValues() {
return new Object[] { operationName, operationDescriptions, operationStartDate, operationEndDate, operationType, reportType, lastEditDate, contentCreatingFlg, editLockFlg, needSyncFlg, reportCycle, enableReportUpdate, enableReportHistory, enableReportEdit, enableAddReport, statusNotStartedCount, statusWorkingCount, statusCompletedCount, quickReport, operationId }; return new Object[] { operationName, operationDescriptions, operationStartDate, operationEndDate, operationType, reportType, lastEditDate, contentCreatingFlg, editLockFlg, needSyncFlg, reportCycle, enableReportUpdate, enableReportHistory, enableReportEdit, enableAddReport, statusNotStartedCount, statusWorkingCount, statusCompletedCount, quickReport, operationLastSyncDate, operationId };
} }
@Override @Override
......
...@@ -90,6 +90,7 @@ public class OperationLogic extends AbstractLogic { ...@@ -90,6 +90,7 @@ public class OperationLogic extends AbstractLogic {
private TaskWorkerGroupDao mTaskWorkerGroupDao = AbstractDao.getDao(TaskWorkerGroupDao.class); private TaskWorkerGroupDao mTaskWorkerGroupDao = AbstractDao.getDao(TaskWorkerGroupDao.class);
private static final int FINISHED_STATUS = 999; private static final int FINISHED_STATUS = 999;
private final static int INTERVAL_LAST_EDIT_TIME_MS = 1800000;
public void initializeOperations() throws AcmsException, NetworkDisconnectedException { public void initializeOperations() throws AcmsException, NetworkDisconnectedException {
// 作業グループリスト取得 // 作業グループリスト取得
setWorkingGroupList(); setWorkingGroupList();
...@@ -117,6 +118,7 @@ public class OperationLogic extends AbstractLogic { ...@@ -117,6 +118,7 @@ public class OperationLogic extends AbstractLogic {
if (serverOperationDto.operationId.equals(localProjcetDto.operationId)) { if (serverOperationDto.operationId.equals(localProjcetDto.operationId)) {
//update //update
serverOperationDto.needSyncFlg = serverOperationDto.equalsLastEdit(localProjcetDto) ? localProjcetDto.needSyncFlg : true; serverOperationDto.needSyncFlg = serverOperationDto.equalsLastEdit(localProjcetDto) ? localProjcetDto.needSyncFlg : true;
serverOperationDto.operationLastSyncDate = localProjcetDto.operationLastSyncDate;
List<Long> localOperationContentIds = mOperationContentDao.getContentIds(serverOperationDto.operationId); List<Long> localOperationContentIds = mOperationContentDao.getContentIds(serverOperationDto.operationId);
boolean operationContentFlg = false; boolean operationContentFlg = false;
for (OperationContentDto operationContentDto : serverOperationDto.operationContentDtoList) { for (OperationContentDto operationContentDto : serverOperationDto.operationContentDtoList) {
...@@ -1573,9 +1575,10 @@ public class OperationLogic extends AbstractLogic { ...@@ -1573,9 +1575,10 @@ public class OperationLogic extends AbstractLogic {
* @param operationId * @param operationId
* @param lastEditDate * @param lastEditDate
*/ */
public void finishedSyncOperation(Long operationId, Date lastEditDate) { public void finishedSyncOperation(Long operationId, Date lastEditDate, Date lastSyncDate) {
OperationDto operationDto = mOperationDao.getOperationJoinContent(operationId); OperationDto operationDto = mOperationDao.getOperationJoinContent(operationId);
operationDto.lastEditDate = lastEditDate; operationDto.lastEditDate = lastEditDate;
operationDto.operationLastSyncDate = lastSyncDate;
operationDto.needSyncFlg = false; operationDto.needSyncFlg = false;
mOperationDao.update(operationDto); mOperationDao.update(operationDto);
} }
...@@ -1931,4 +1934,27 @@ public class OperationLogic extends AbstractLogic { ...@@ -1931,4 +1934,27 @@ public class OperationLogic extends AbstractLogic {
} }
return result; return result;
} }
private Boolean isEnableTimeForAutoSync(Date lastEditDateTime) {
Date currentDateTime = DateTimeUtil.getCurrentDate();
if (lastEditDateTime == null) {
return true;
} else {
long diffInMillis = currentDateTime.getTime() - lastEditDateTime.getTime();
if (diffInMillis >= INTERVAL_LAST_EDIT_TIME_MS) {
return true;
}
}
return false;
}
public List<OperationDto> needSyncCheckArray(List<OperationDto> needSyncOperationInfoArray) {
List<OperationDto> needSyncCheckArray = new ArrayList<>();
for (OperationDto operationDto : needSyncOperationInfoArray) {
if (isEnableTimeForAutoSync(operationDto.operationLastSyncDate)) {
needSyncCheckArray.add(operationDto);
}
}
return needSyncCheckArray;
}
} }
...@@ -505,8 +505,9 @@ public class OperationListActivity extends OperationActivity { ...@@ -505,8 +505,9 @@ public class OperationListActivity extends OperationActivity {
} else { } else {
needSyncOperationList.addAll(mOperationDao.getNeedSyncAllOperation()); needSyncOperationList.addAll(mOperationDao.getNeedSyncAllOperation());
} }
if (needSyncOperationList.size() > 0) { List<OperationDto> needSyncCheckArray = mOperationLogic.needSyncCheckArray(needSyncOperationList);
categoryBatchSync(needSyncOperationList); if (needSyncCheckArray.size() > 0) {
categoryBatchSync(needSyncCheckArray);
} else { } else {
// donot need sync // donot need sync
autoSyncOperationDone(true); autoSyncOperationDone(true);
...@@ -966,7 +967,8 @@ public class OperationListActivity extends OperationActivity { ...@@ -966,7 +967,8 @@ public class OperationListActivity extends OperationActivity {
// データの受信時、エラーキャッチのための変数を初期化 // データの受信時、エラーキャッチのための変数を初期化
isSyncGetTaskFileError = false; isSyncGetTaskFileError = false;
if (mOperationLastEditDate != null) { if (mOperationLastEditDate != null) {
mOperationLogic.finishedSyncOperation(operationId, mOperationLastEditDate); Date operationLastSyncDate = DateTimeUtil.getCurrentDate();
mOperationLogic.finishedSyncOperation(operationId, mOperationLastEditDate, operationLastSyncDate);
progressDialogHorizontal.setProgress(100); progressDialogHorizontal.setProgress(100);
} }
mOperationLastEditDate = null; mOperationLastEditDate = null;
......
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