Commit 728ae416 by Kazuyuki Hida

作業一覧にローカル保存しているデータ数が反映されるようにした。

parent 8d4e25d8
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(
longOrNull(cursor, "operation_id"),
intOrNull(cursor, "count")
);
}
private Long longOrNull(Cursor cursor, String name) {
int column = cursor.getColumnIndex(name);
if (column < 0) {
return null;
} else {
return cursor.getLong(column);
}
}
private Integer intOrNull(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;
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.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.ContentDto;
import jp.agentec.abook.abv.bl.dto.OperationContentDto;
......@@ -1186,7 +1187,23 @@ public class OperationLogic extends AbstractLogic {
* @return 作業情報配列
*/
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;
}
/**
......
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