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 {
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;
}
......@@ -205,9 +210,10 @@ public class OperationDao extends AbstractDao {
+ "status_not_started_count, "
+ "status_working_count, "
+ "status_completed_count, "
+ "quick_report) "
+ "quick_report, "
+ "operation_last_sync_date) "
+ "values "
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
dto.getInsertValues());
}
......@@ -232,7 +238,8 @@ public class OperationDao extends AbstractDao {
+ "status_not_started_count=?, "
+ "status_working_count=?, "
+ "status_completed_count=?, "
+ "quick_report=? "
+ "quick_report=?, "
+ "operation_last_sync_date=? "
+ "where operation_id=?",
dto.getUpdateValues());
return count > 0;
......@@ -301,6 +308,7 @@ public class OperationDao extends AbstractDao {
sql.append(" top.status_not_started_count, ");
sql.append(" top.status_working_count, ");
sql.append(" top.status_completed_count, ");
sql.append(" top.operation_last_sync_date, ");
sql.append(" CASE ");
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')) ");
......@@ -466,6 +474,7 @@ public class OperationDao extends AbstractDao {
sql.append(" top.status_not_started_count, ");
sql.append(" top.status_working_count, ");
sql.append(" top.status_completed_count, ");
sql.append(" top.operation_last_sync_date, ");
sql.append(" CASE ");
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')) ");
......
......@@ -47,6 +47,7 @@ public class TOperation extends SQLiteTableScript {
sql.append(" , status_not_started_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(" , operation_last_sync_date DATETIME ");
sql.append(" , PRIMARY KEY (operation_id) ");
sql.append(" ) ");
ddl.add(sql.toString());
......@@ -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_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;
}
......
......@@ -37,6 +37,8 @@ public class OperationDto extends AbstractDto {
public int statusWorkingCount; //「作業中」数
public int statusCompletedCount; // 「作業完了」数
public Date operationLastSyncDate;
// 作業担当グループリスト
public List<TaskWorkerGroupDto> taskWorkerGroupDtoList;
// 作業種別に紐づく作業Dto
......@@ -53,12 +55,12 @@ public class OperationDto extends AbstractDto {
@Override
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
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
......
......@@ -90,6 +90,7 @@ public class OperationLogic extends AbstractLogic {
private TaskWorkerGroupDao mTaskWorkerGroupDao = AbstractDao.getDao(TaskWorkerGroupDao.class);
private static final int FINISHED_STATUS = 999;
private final static int INTERVAL_LAST_EDIT_TIME_MS = 1800000;
public void initializeOperations() throws AcmsException, NetworkDisconnectedException {
// 作業グループリスト取得
setWorkingGroupList();
......@@ -117,6 +118,7 @@ public class OperationLogic extends AbstractLogic {
if (serverOperationDto.operationId.equals(localProjcetDto.operationId)) {
//update
serverOperationDto.needSyncFlg = serverOperationDto.equalsLastEdit(localProjcetDto) ? localProjcetDto.needSyncFlg : true;
serverOperationDto.operationLastSyncDate = localProjcetDto.operationLastSyncDate;
List<Long> localOperationContentIds = mOperationContentDao.getContentIds(serverOperationDto.operationId);
boolean operationContentFlg = false;
for (OperationContentDto operationContentDto : serverOperationDto.operationContentDtoList) {
......@@ -1573,9 +1575,10 @@ public class OperationLogic extends AbstractLogic {
* @param operationId
* @param lastEditDate
*/
public void finishedSyncOperation(Long operationId, Date lastEditDate) {
public void finishedSyncOperation(Long operationId, Date lastEditDate, Date lastSyncDate) {
OperationDto operationDto = mOperationDao.getOperationJoinContent(operationId);
operationDto.lastEditDate = lastEditDate;
operationDto.operationLastSyncDate = lastSyncDate;
operationDto.needSyncFlg = false;
mOperationDao.update(operationDto);
}
......@@ -1931,4 +1934,27 @@ public class OperationLogic extends AbstractLogic {
}
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 {
} else {
needSyncOperationList.addAll(mOperationDao.getNeedSyncAllOperation());
}
if (needSyncOperationList.size() > 0) {
categoryBatchSync(needSyncOperationList);
List<OperationDto> needSyncCheckArray = mOperationLogic.needSyncCheckArray(needSyncOperationList);
if (needSyncCheckArray.size() > 0) {
categoryBatchSync(needSyncCheckArray);
} else {
// donot need sync
autoSyncOperationDone(true);
......@@ -966,7 +967,8 @@ public class OperationListActivity extends OperationActivity {
// データの受信時、エラーキャッチのための変数を初期化
isSyncGetTaskFileError = false;
if (mOperationLastEditDate != null) {
mOperationLogic.finishedSyncOperation(operationId, mOperationLastEditDate);
Date operationLastSyncDate = DateTimeUtil.getCurrentDate();
mOperationLogic.finishedSyncOperation(operationId, mOperationLastEditDate, operationLastSyncDate);
progressDialogHorizontal.setProgress(100);
}
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