Commit 5887a91f by Yujin Seo

Merge branch 'feature/contract/sato/1.0.300_operation_counts' into 'contract/sato/1.0.300'

件数表示周りの不具合の修正

See merge request !271
parents fe5d22b4 f87bac92
package jp.agentec.abook.abv.bl.data.dao; package jp.agentec.abook.abv.bl.data.dao;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -550,4 +549,61 @@ public class OperationDao extends AbstractDao { ...@@ -550,4 +549,61 @@ public class OperationDao extends AbstractDao {
return sql.toString(); return sql.toString();
} }
private String incrementCount(long operationId, String column) {
StringBuilder sql = new StringBuilder();
sql.append("UPDATE t_operation ");
sql.append(" SET ").append(column).append(" = (").append(column).append(" + 1)");
sql.append(" WHERE operation_id = ").append(operationId);
return sql.toString();
}
private String decrementCount(long operationId, String column) {
StringBuilder sql = new StringBuilder();
sql.append("UPDATE t_operation ");
sql.append(" SET ").append(column).append(" = (").append(column).append(" - 1)");
sql.append(" WHERE operation_id = ").append(operationId);
sql.append(" AND ").append(column).append(" > 0");
return sql.toString();
}
public void countUpCompleted(long operationId) {
beginTransaction();
try {
execSql(decrementCount(operationId, "status_not_started_count"));
execSql(incrementCount(operationId, "status_completed_count"));
commit();
} catch (Throwable e) {
rollback();
Logger.e(TAG, e);
}
}
public void countUpWorking(long operationId) {
beginTransaction();
try {
execSql(decrementCount(operationId, "status_not_started_count"));
execSql(incrementCount(operationId, "status_working_count"));
commit();
} catch (Throwable e) {
rollback();
Logger.e(TAG, e);
}
}
public void coutUpCompletedFromWorking(long operationId) {
beginTransaction();
try {
execSql(decrementCount(operationId, "status_working_count"));
execSql(incrementCount(operationId, "status_completed_count"));
commit();
} catch (Throwable e) {
rollback();
Logger.e(TAG, e);
}
}
} }
...@@ -494,4 +494,40 @@ public class TaskReportDao extends AbstractDao { ...@@ -494,4 +494,40 @@ public class TaskReportDao extends AbstractDao {
public String getRoutineTaskReportAttachedFileName(String taskKey, int taskReportId, String reportStartDate) { public String getRoutineTaskReportAttachedFileName(String taskKey, int taskReportId, String reportStartDate) {
return rawQueryGetString("select local_attached_file_name from t_task_report where task_key=? and task_report_id=? and datetime(report_start_date)=datetime(?, 'utc')", new String[]{ taskKey, "" + taskReportId, reportStartDate }); return rawQueryGetString("select local_attached_file_name from t_task_report where task_key=? and task_report_id=? and datetime(report_start_date)=datetime(?, 'utc')", new String[]{ taskKey, "" + taskReportId, reportStartDate });
} }
public boolean isLocalSaved(String taskKey, int taskReportId, String reportStartDate) {
int count;
StringBuilder sql = new StringBuilder();
sql.append("SELECT count(*) FROM t_task_report");
sql.append(" WHERE local_saved_flg > 0");
if (reportStartDate == null) {
// 報告
sql.append(" AND task_key=?");
count = rawQueryGetInt(sql.toString(), new String[] { taskKey });
} else {
// 点検
sql.append(" AND task_report_id=?");
sql.append(" AND datetime(report_start_date)=datetime(?, 'utc')");
count = rawQueryGetInt(sql.toString(), new String[] { String.valueOf(taskReportId), reportStartDate });
}
return count > 0;
}
public boolean isCompleted(String taskKey, int taskReportId, String reportStartDate) {
int count;
StringBuilder sql = new StringBuilder();
sql.append("SELECT count(*) FROM t_task_report");
sql.append(" WHERE task_report_info_id > 0");
if (reportStartDate == null) {
// 報告
sql.append(" AND task_key=?");
count = rawQueryGetInt(sql.toString(), new String[] { taskKey });
} else {
// 点検
sql.append(" AND task_report_id=?");
sql.append(" AND datetime(report_start_date)=datetime(?, 'utc')");
count = rawQueryGetInt(sql.toString(), new String[] { String.valueOf(taskReportId), reportStartDate });
}
return count > 0;
}
} }
package jp.agentec.abook.abv.bl.data.dao;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jp.agentec.abook.abv.bl.common.db.Cursor;
import jp.agentec.abook.abv.bl.dto.WorkingReportDto;
public class WorkingReportDao extends AbstractDao {
@Override
protected WorkingReportDto convert(Cursor cursor) {
return new WorkingReportDto(
getLongOrNull(cursor, "operation_id"),
getIntOrNull(cursor, "count")
);
}
private Long getLongOrNull(Cursor cursor, String name) {
int column = cursor.getColumnIndex(name);
if (column < 0) {
return null;
} else {
return cursor.getLong(column);
}
}
private Integer getIntOrNull(Cursor cursor, String name) {
int column = cursor.getColumnIndex(name);
if (column < 0) {
return null;
} else {
return cursor.getInt(column);
}
}
public Map<Long, Integer> getWorkingTaskReportCounts() {
StringBuilder sql = new StringBuilder();
sql.append(" SELECT t_operation.operation_id AS operation_id, count(*) AS count FROM t_task_report ");
sql.append(" INNER JOIN t_task ON t_task_report.task_key = t_task.task_key ");
sql.append(" INNER JOIN t_operation ON t_task.operation_id = t_operation.operation_id");
sql.append(" WHERE t_task_report.local_saved_flg > 0");
sql.append(" GROUP BY t_operation.operation_id");
List<WorkingReportDto> list = rawQueryGetDtoList(sql.toString(), null, WorkingReportDto.class);
Map<Long, Integer> map = new HashMap<Long, Integer>();
for (WorkingReportDto dto : list) {
Long id = dto.getOperationId();
Integer cnt = dto.getCount();
if (id != null && cnt != null) {
map.put(id, cnt);
}
}
return map;
}
}
package jp.agentec.abook.abv.bl.dto;
public class WorkingReportDto extends AbstractDto {
private final Long operationId;
private final Integer count;
public WorkingReportDto(Long operationId, Integer count) {
super();
this.operationId = operationId;
this.count = count;
}
@Override
public String[] getKeyValues() {
return new String[0];
}
@Override
public Object[] getInsertValues() {
return new Object[0];
}
public Long getOperationId() {
return operationId;
}
public Integer getCount() {
return count;
}
}
...@@ -47,6 +47,7 @@ import jp.agentec.abook.abv.bl.data.dao.TaskReportItemsDao; ...@@ -47,6 +47,7 @@ import jp.agentec.abook.abv.bl.data.dao.TaskReportItemsDao;
import jp.agentec.abook.abv.bl.data.dao.TaskReportSendDao; import jp.agentec.abook.abv.bl.data.dao.TaskReportSendDao;
import jp.agentec.abook.abv.bl.data.dao.TaskWorkerGroupDao; import jp.agentec.abook.abv.bl.data.dao.TaskWorkerGroupDao;
import jp.agentec.abook.abv.bl.data.dao.WorkerGroupDao; import jp.agentec.abook.abv.bl.data.dao.WorkerGroupDao;
import jp.agentec.abook.abv.bl.data.dao.WorkingReportDao;
import jp.agentec.abook.abv.bl.dto.CategoryContentDto; import jp.agentec.abook.abv.bl.dto.CategoryContentDto;
import jp.agentec.abook.abv.bl.dto.ContentDto; import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.dto.OperationContentDto; import jp.agentec.abook.abv.bl.dto.OperationContentDto;
...@@ -1186,7 +1187,23 @@ public class OperationLogic extends AbstractLogic { ...@@ -1186,7 +1187,23 @@ public class OperationLogic extends AbstractLogic {
* @return 作業情報配列 * @return 作業情報配列
*/ */
public List<OperationDto> getRefreshOperation(String searchWord, String searchStartDateStr, String searchEndDateStr, String reportTypeStr) { public List<OperationDto> getRefreshOperation(String searchWord, String searchStartDateStr, String searchEndDateStr, String reportTypeStr) {
return mOperationDao.getOperations(searchWord, searchStartDateStr, searchEndDateStr, reportTypeStr); List<OperationDto> list = mOperationDao.getOperations(searchWord, searchStartDateStr, searchEndDateStr, reportTypeStr);
WorkingReportDao dao = AbstractDao.getDao(WorkingReportDao.class);
// ローカル保存している分を補正する
Map<Long, Integer> working = dao.getWorkingTaskReportCounts();
for (OperationDto dto : list) {
Integer workingCount = working.get(dto.operationId);
if (workingCount != null) {
if (dto.reportType == 1) {
// 定期点検の場合は、先にレポートが作られるので、その分を差し引く
dto.statusNotStartedCount -= workingCount;
}
dto.statusWorkingCount += workingCount;
}
}
return list;
} }
/** /**
......
Subproject commit 7bcb5bfc6820f6ea7f9dc94d32dc982deaced578 Subproject commit 39a8f243e91a4a70143ef6cfe7ba33807de9cdfb
...@@ -18,6 +18,7 @@ import java.text.SimpleDateFormat; ...@@ -18,6 +18,7 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import jp.agentec.abook.abv.bl.common.ABVEnvironment; import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.Callback; import jp.agentec.abook.abv.bl.common.Callback;
...@@ -27,6 +28,9 @@ import jp.agentec.abook.abv.bl.common.constant.ABookKeys; ...@@ -27,6 +28,9 @@ import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode; import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode;
import jp.agentec.abook.abv.bl.common.exception.AcmsException; import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.dao.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.OperationDao;
import jp.agentec.abook.abv.bl.data.dao.TaskReportDao;
import jp.agentec.abook.abv.bl.dto.OperationDto; import jp.agentec.abook.abv.bl.dto.OperationDto;
import jp.agentec.abook.abv.bl.dto.OperationTaskDto; import jp.agentec.abook.abv.bl.dto.OperationTaskDto;
import jp.agentec.abook.abv.bl.dto.TaskDto; import jp.agentec.abook.abv.bl.dto.TaskDto;
...@@ -44,6 +48,8 @@ import jp.agentec.adf.util.DateTimeUtil; ...@@ -44,6 +48,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.acms.client.json.OperationDataJSON.ReportStartDate;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.TaskReportId;
import static jp.agentec.abook.abv.cl.util.PreferenceUtil.getUserPref; import static jp.agentec.abook.abv.cl.util.PreferenceUtil.getUserPref;
/** /**
...@@ -89,25 +95,51 @@ public class ABookCheckWebViewHelper extends ABookHelper { ...@@ -89,25 +95,51 @@ public class ABookCheckWebViewHelper extends ABookHelper {
switch (cmd) { switch (cmd) {
case ABookKeys.CMD_INSERT_TASK_REPORT: case ABookKeys.CMD_INSERT_TASK_REPORT:
case ABookKeys.CMD_UPDATE_TASK_REPORT: case ABookKeys.CMD_UPDATE_TASK_REPORT: {
// もとから作業中だったかを調べる
TaskReportDao taskReportDao = AbstractDao.getDao(TaskReportDao.class);
int rportId = Integer.parseInt(String.valueOf(param.getOrDefault(TaskReportId, "0")));
String startDate = param.getOrDefault(ReportStartDate, null);
boolean isLocalSaved = taskReportDao.isLocalSaved(taskKey, rportId, startDate);
boolean isCompleted = taskReportDao.isCompleted(taskKey, rportId, startDate);
// 報告書の更新
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); copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
sendTaskData(context, operationId, taskKey, taskReportLevel); sendTaskData(context, operationId, taskKey, taskReportLevel);
// 作業ステータスのカウントを変える
OperationDao operationDao = AbstractDao.getDao(OperationDao.class);
if (isLocalSaved) {
operationDao.coutUpCompletedFromWorking(operationId);
} else if (! isCompleted) {
operationDao.countUpCompleted(operationId);
}
break; break;
}
case ABookKeys.CMD_LOCAL_SAVE_TASK_REPORT: // 一時保存 case ABookKeys.CMD_LOCAL_SAVE_TASK_REPORT: // 一時保存
// もとから作業中だったかを調べる
TaskReportDao taskReportDao = AbstractDao.getDao(TaskReportDao.class);
int rportId = Integer.parseInt(String.valueOf(param.getOrDefault(TaskReportId, "0")));
String startDate = param.getOrDefault(ReportStartDate, null);
boolean isLocalSaved = taskReportDao.isLocalSaved(taskKey, rportId, startDate);
// 報告書の更新
insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, reportType, taskReportLevel, true); insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, reportType, taskReportLevel, true);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel); copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
ABVToastUtil.showMakeText(context, R.string.msg_temp_save_result, Toast.LENGTH_SHORT); ABVToastUtil.showMakeText(context, R.string.msg_temp_save_result, Toast.LENGTH_SHORT);
// 作業ステータスのカウントを変える
if (! isLocalSaved) {
OperationDao operationDao = AbstractDao.getDao(OperationDao.class);
operationDao.countUpWorking(operationId);
}
mFinishCallback.callback(false); mFinishCallback.callback(false);
break; break;
case ABookKeys.CMD_DELETE_TASK_REPORT: case ABookKeys.CMD_DELETE_TASK_REPORT: {
int taskReportId = 0; int taskReportId = 0;
String reportStartDate = ""; String reportStartDate = "";
boolean sendTaskReportDataFlg = false; boolean sendTaskReportDataFlg = false;
if (reportType == Constant.ReportType.RoutineTask) { if (reportType == Constant.ReportType.RoutineTask) {
taskReportId = Integer.valueOf(param.get(ABookKeys.TASK_REPORT_ID)); taskReportId = Integer.valueOf(param.get(ABookKeys.TASK_REPORT_ID));
reportStartDate = param.get(ABookKeys.REPORT_START_DATE).replace("T", " "); reportStartDate = param.get(ABookKeys.REPORT_START_DATE);
mOperationLogic.deleteRoutineTaskReport(operationId, contentId, taskKey, taskReportId, reportStartDate); mOperationLogic.deleteRoutineTaskReport(operationId, contentId, taskKey, taskReportId, reportStartDate);
mOperationLogic.createJsonForOperationContent(operationId, contentPath, true); mOperationLogic.createJsonForOperationContent(operationId, contentPath, true);
copyRoutineTaskReportAttachedMovie(operationId, contentId, taskKey, taskReportId, reportStartDate); copyRoutineTaskReportAttachedMovie(operationId, contentId, taskKey, taskReportId, reportStartDate);
...@@ -128,6 +160,7 @@ public class ABookCheckWebViewHelper extends ABookHelper { ...@@ -128,6 +160,7 @@ public class ABookCheckWebViewHelper extends ABookHelper {
sendTaskData(context, operationId, taskKey, taskReportLevel); sendTaskData(context, operationId, taskKey, taskReportLevel);
break; break;
}
case ABookKeys.CMD_MOVE_HOT_SPOT: case ABookKeys.CMD_MOVE_HOT_SPOT:
mOperationLogic.updateTaskHotspot(taskKey, param); mOperationLogic.updateTaskHotspot(taskKey, param);
mOperationLogic.createHopSpotJson(operationId, contentPath); mOperationLogic.createHopSpotJson(operationId, contentPath);
......
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