Commit 3493050a by Lee Jaebin

#32825 作業一覧画面改善

parent fcc8f297
......@@ -62,6 +62,15 @@ public class OperationContentDao extends AbstractDao {
return rawQueryGetLongList("select content_id from r_operation_content where operation_id=?", new String[]{""+ operationId});
}
/**
* 資料IDに紐づいた作業が存在しないと資料を削除する判定
* @param contentId
* @return
*/
public boolean isDeleteContent (Long contentId) {
return rawQueryGetInt("select COUNT(*) from r_operation_content where content_id=?", new String[]{"" + contentId }) == 0;
}
public boolean insertOperationContent(OperationContentDto dto) {
StringBuffer sql = new StringBuffer();
......
......@@ -211,13 +211,13 @@ public class OperationDao extends AbstractDao {
public void deleteAll() {
delete("t_push_message", null, null);
delete("r_operation_content", null, null);
delete("r_task_worker_group", null, null);
delete("t_operation", null, null);
delete("t_task", null, null);
delete("t_task_report", null, null);
delete("t_task_report_send", null, null);
delete("t_task_report_items", null, null);
delete("m_worker_group", null, null);
delete("r_task_worker_group", null, null);
}
public List<OperationDto> getOperations(String searchOperationName, String searchStartDateStr, String searchEndDateStr, String reportTypeStr) {
......
......@@ -247,6 +247,14 @@ public class TaskReportDao extends AbstractDao {
}
/**
* テーブル物理削除
* @param dto
*/
public void delete(TaskReportDto dto) {
delete("t_task_report", "task_key=? and task_report_level=?", new String[] { dto.taskKey, "" + dto.taskReportLevel });
}
/**
* テーブル物理削除(定期点検専用)
* @param dto
*/
......
......@@ -77,6 +77,8 @@ public class OperationLogic extends AbstractLogic {
private TaskReportSendDao mTaskReportSendDao = AbstractDao.getDao(TaskReportSendDao.class);
private TaskReportItemsDao mTaskReportItemsDao = AbstractDao.getDao(TaskReportItemsDao.class);
private ContentLogic mContentLogic = AbstractLogic.getLogic(ContentLogic.class);
private PushMessageDao mPushMessageDao = AbstractDao.getDao(PushMessageDao.class);
private TaskWorkerGroupDao mTaskWorkerGroupDao = AbstractDao.getDao(TaskWorkerGroupDao.class);
......@@ -196,12 +198,21 @@ public class OperationLogic extends AbstractLogic {
// サーバーから取得したプロジェクト情報がローカルに存在しないので削除する
for (OperationDto deleteOperationDto : deleteListDtoArray) {
List<TaskDto> taskDtoList = mTaskDao.selectAllTaskByOperationId(deleteOperationDto.operationId);
List<Long> contentIds = mOperationContentDao.getContentIds(deleteOperationDto.operationId);
for(TaskDto taskDto : taskDtoList) {
mTaskDao.delete(taskDto);
}
mPushMessageDao.delete(deleteOperationDto.operationId);
mOperationDao.delete(deleteOperationDto);
// 作業削除時、紐づいた資料を削除
for (Long contentId : contentIds) {
if (mOperationContentDao.isDeleteContent(contentId)) {
ContentDto contentDto = mContentDao.getContent(contentId);
mContentLogic.deleteContent(contentDto, true);
}
}
String operationTaskDirPath = ABVEnvironment.getInstance().getOperationDirFile(deleteOperationDto.operationId);
FileUtil.delete(operationTaskDirPath);
}
......@@ -394,7 +405,7 @@ public class OperationLogic extends AbstractLogic {
}
/**
* 作業指示の削除
* 作業報告の削除
*
* @param operationId
* @param contentId
......@@ -428,13 +439,15 @@ public class OperationLogic extends AbstractLogic {
* @param dataSendFlg
* @throws IOException
*/
public void insertTaskReportReply(String taskKey, long operationId, long contentId, JSONObject taskReportJson, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
public void insertTaskReportReply(String taskKey, long operationId, long contentId, int enableReport, JSONObject taskReportJson, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
TaskDto taskDto = mTaskDao.getTaskByTaskKey(taskKey);
if (taskDto == null) {
//TODO error
return;
}
TaskReportDto taskReportDto = new TaskReportDto();
// taskReportJsonがnullではない場合のみ以下の処理を行う
if (taskReportJson != null) {
JSONObject taskJson = taskReportJson.getJSONObject("task");
Iterator taskKeys = taskJson.keys();
......@@ -454,11 +467,15 @@ public class OperationLogic extends AbstractLogic {
}
mTaskReportItemsDao.insertTaskReportItems(taskReportItemsDto);
}
taskReportDto.taskKey = taskKey;
taskReportDto.jsonData = taskReportJson.toString();
} else {
taskReportDto.jsonData = "";
}
taskReportDto.taskKey = taskKey;
taskReportDto.dataSendFlg = dataSendFlg;
taskReportDto.attachedFileSendFlg = attachedChangeFlag;
taskReportDto.taskReportLevel = Constant.TaskReportLevel.ReportReplyType;
taskReportDto.enableReport = enableReport;
// 削除の時、deleteではなく、jsonDataを空にして、データが残っているので、updateする
List<TaskReportDto> taskReport = mTaskReportDao.selectByTaskKey(taskReportDto.taskKey, Constant.TaskReportLevel.ReportReplyType);
......@@ -470,11 +487,10 @@ public class OperationLogic extends AbstractLogic {
mTaskDao.update(taskDto);
if (taskReportJson != null) {
//添付ファイル変更の場合、以下の処理を行う
String tempDirPath = ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey);
// #32926 作業報告画面改善 start
String operationDrectionOrReportDirPath = ABVEnvironment.getInstance().getOperationTaskReportLevelDirPath(operationId, taskKey, Constant.TaskReportLevel.ReportReplyType);
// #32926 作業報告画面改善 end
JSONObject attachedListJson = taskReportJson.getJSONObject("attached");
List<String> attachedFileNames = JSONObject.getValues(attachedListJson);
......@@ -483,10 +499,11 @@ public class OperationLogic extends AbstractLogic {
// 添付ディレクトリの移動
boolean result = FileUtil.copy(tempDirPath, operationDrectionOrReportDirPath, true);
if(result) {
if (result) {
FileUtil.delete(tempDirPath);
}
}
}
/**
* 定期点検データ新規
......@@ -540,12 +557,12 @@ public class OperationLogic extends AbstractLogic {
}
}
public void updateTaskReportReplyLevel(String taskKey, long operationId, long contentId, JSONObject taskReport, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
public void updateTaskReportReply(String taskKey, long operationId, long contentId, int enableReport, JSONObject taskReport, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
TaskReportDto taskReportDto = mTaskReportDao.getTaskReport(taskKey, Constant.TaskReportLevel.ReportReplyType);
if (taskReportDto == null) {
Logger.w(TAG, "taskReportDto is null");
// #32926 作業報告画面改善 start
insertTaskReportReply(taskKey, operationId, contentId, taskReport, localAttachedFileName, attachedChangeFlag, dataSendFlg);
insertTaskReportReply(taskKey, operationId, contentId, enableReport, taskReport, localAttachedFileName, attachedChangeFlag, dataSendFlg);
// #32926 作業報告画面改善 end
return;
}
......@@ -576,6 +593,11 @@ public class OperationLogic extends AbstractLogic {
taskReportDto.attachedFileSendFlg = attachedChangeFlag;
}
// 作業報告階層
taskReportDto.taskReportLevel = Constant.TaskReportLevel.ReportReplyType;
// 報告可能区分
taskReportDto.enableReport = enableReport;
mTaskReportDao.update(taskReportDto);
mTaskDao.update(taskDto);
String tempDirPath = ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey);
......@@ -792,11 +814,7 @@ public class OperationLogic extends AbstractLogic {
}
// 作業報告のディレクトリ削除
FileUtil.delete(ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey));
// #32926 作業報告画面改善 start
FileUtil.delete(ABVEnvironment.getInstance().getOperationTaskReportLevelDirPath(operationId, taskKey, Constant.TaskReportLevel.ReportReplyType));
// #32926 作業報告画面改善 end
deleteTaskReportReplyFileData(operationId, contentId, taskKey);
}
/**
......@@ -973,30 +991,31 @@ public class OperationLogic extends AbstractLogic {
* @param contentPath
* @throws IOException
*/
// #32926 作業報告画面改善 start
// 現在作業タイプを確認用のparameter追加
private void createWorkerGroupJson(Long operationId, String contentPath) throws IOException {
// #32926 作業報告画面改善 end
int level = 0;
int listCount = 0;
List<JSONObject> workerGroupJsonList = new ArrayList<JSONObject>();
JSONObject taskGroupJson = new JSONObject();
List<TaskWorkerGroupDto> taskWorkerGroupDtoList = mTaskWorkerGroupDao.getTaskWorkerGroupByOperationId(operationId);
// 報告と報告(回答)のデータの区分が必要なので、「taskGroup_0」と「taskGroup_1」で形式で作成
for (TaskWorkerGroupDto dto : taskWorkerGroupDtoList) {
listCount++;
listCount++; // 最後のインデックスの判定のため
if (level != dto.taskReportLevel) {
taskGroupJson.put(String.format("taskReport_%s", String.valueOf(level)), workerGroupJsonList);
workerGroupJsonList = new ArrayList<JSONObject>();
level++;
}
JSONObject workerGroupJson = new JSONObject();
if (level == dto.taskReportLevel) {
workerGroupJson.put(ABookKeys.GROUP_ID, dto.groupId);
workerGroupJson.put(ABookKeys.GROUP_NAME, dto.groupName);
workerGroupJsonList.add(workerGroupJson);
} else {
level++;
}
if (level != dto.taskReportLevel || taskWorkerGroupDtoList.size() == listCount) {
taskGroupJson.put(String.format("taskGroup_%s", String.valueOf(dto.taskReportLevel)), workerGroupJsonList);
workerGroupJsonList = new ArrayList<JSONObject>();
// 最後の時、taskReport_{level}でセット
if (listCount == taskWorkerGroupDtoList.size()) {
taskGroupJson.put(String.format("taskGroup_%s", String.valueOf(level)), workerGroupJsonList);
}
}
......@@ -1053,14 +1072,17 @@ public class OperationLogic extends AbstractLogic {
if(dto.jsonData != null && dto.jsonData.length() > 0) {
taskReportJsonList.add(new JSONObject(dto.jsonData).put(ABookKeys.HAS_AUTHORITY, dto.enableReport));
} else {
JSONObject emptyTaskReportJson = new JSONObject();
emptyTaskReportJson.put(ABookKeys.TASK_KEY, dto.taskKey);
emptyTaskReportJson.put(ABookKeys.HAS_AUTHORITY, dto.enableReport);
taskReportJsonList.add(emptyTaskReportJson);
}
// 最後の時、taskReport_{level}でセット
if (listCount == taskReportDtoList.size()) {
taskReportJson.put(String.format("taskReport_%s", String.valueOf(level)), taskReportJsonList);
}
level = dto.taskReportLevel;
}
// データが存在しない場合、
......@@ -1397,8 +1419,19 @@ public class OperationLogic extends AbstractLogic {
* @param taskKey
*/
public void deleteTaskFileData(long operationId, long contentId, String taskKey) {
FileUtil.delete(ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey));
FileUtil.delete(ABVEnvironment.getInstance().getOperationTaskDirFilePath(operationId, taskKey));
}
/**
* 作業報告(回答)関連ディレクトリ削除
* @param operationId
* @param contentId
* @param taskKey
*/
public void deleteTaskReportReplyFileData(long operationId, long contentId, String taskKey) {
FileUtil.delete(ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey));
FileUtil.delete(ABVEnvironment.getInstance().getOperationTaskReportLevelDirPath(operationId, taskKey, Constant.TaskReportLevel.ReportReplyType));
}
/**
......
......@@ -77,7 +77,6 @@ import jp.agentec.abook.abv.bl.download.ContentFileExtractor;
import jp.agentec.abook.abv.bl.download.ContentZipDownloadNotification;
import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.dto.FixPushMessageDto;
import jp.agentec.abook.abv.bl.dto.RoutineTaskReportDto;
import jp.agentec.abook.abv.bl.dto.OperationContentDto;
import jp.agentec.abook.abv.bl.dto.OperationDto;
import jp.agentec.abook.abv.bl.dto.PushMessageDto;
......@@ -825,6 +824,7 @@ public class OperationListActivity extends ABVUIActivity {
OperationDto operationDto = mOperationLogic.getOperation(operationId);
OperationContentDto operationContentDto = mOperationContentDao.getOperationMainContent(operationId);
List<TaskDto> localTaskList = mTaskDao.selectAllTaskByOperationId(operationId);
Date lastEditDate;
OperationDataJSON json = AcmsClient.getInstance(ABVDataCache.getInstance().getUrlPath(), ABVEnvironment.getInstance().networkAdapter).getOpereationData(param);
......@@ -835,26 +835,35 @@ public class OperationListActivity extends ABVUIActivity {
progress = 40 / json.taskDtoList.size();
}
boolean isRoutineTask = operationDto.reportType == Constant.ReportType.Routine;
JSONObject taskReportJson;
for (TaskDto serverTaskDto : json.taskDtoList) {
if (operationDto.reportType == Constant.ReportType.Routine) {
if (isExistsTaskInList(localTaskList, serverTaskDto)) {
mTaskDao.update(serverTaskDto);
} else {
mTaskDao.insert(serverTaskDto);
}
List<TaskReportDto> localTaskReportList = mTaskReportDao.getNotNullStartDateTaskReportByTaskKey(serverTaskDto.taskKey);
List<TaskReportDto> localRemove = new ArrayList();
// 先にローカルにしか存在しない事を削除 : DB, files
List<TaskReportDto> localTaskReportList = mTaskReportDao.getTaskReportListByTaskKey(serverTaskDto.taskKey);
for (TaskReportDto localTaskReportDto : localTaskReportList) {
if (!isExistsRoutinTaskReportInList(serverTaskDto.taskReportDtoList, localTaskReportDto)) {
if (!isExistsTaskReportInList(serverTaskDto.taskReportDtoList, localTaskReportDto, isRoutineTask)) {
if (isRoutineTask) {
mOperationLogic.deleteRoutineTaskReport(operationId, operationContentDto.contentId, localTaskReportDto);
localRemove.add(localTaskReportDto);
} else {
// taskDtoが存在するとtaskReportLevel 0 (作業報告)が存在しないことはないので、報告(回答)のみチェックして削除
if (localTaskReportDto.taskReportLevel == Constant.TaskReportLevel.ReportReplyType) {
// 作業報告のディレクトリ削除
mOperationLogic.deleteTaskReportReplyFileData(operationId, operationContentDto.contentId, serverTaskDto.taskKey);
mTaskReportDao.delete(localTaskReportDto);
}
}
localTaskReportList.remove(localTaskReportDto);
}
}
localTaskReportList.removeAll(localRemove);
if (operationDto.reportType == Constant.ReportType.Routine) {
if (isExistsTaskInList(localTaskList, serverTaskDto)) {
mTaskDao.update(serverTaskDto);
} else {
mTaskDao.insert(serverTaskDto);
}
// サーバーからの情報で更新
for (TaskReportDto taskReportDto : serverTaskDto.taskReportDtoList) {
......@@ -866,7 +875,7 @@ public class OperationListActivity extends ABVUIActivity {
if (isSyncGetTaskFileError) {
return null;
}
if (isExistsRoutinTaskReportInList(localTaskReportList, taskReportDto)) {
if (isExistsTaskReportInList(localTaskReportList, taskReportDto, true)) {
// 報告データが存在すると作業報告を更新する
if (taskReportDto.jsonData != null) {
mOperationLogic.updateRoutineTaskReport(serverTaskDto.operationId, operationContentDto.contentId, taskReportDto, false, false, false, false);
......@@ -901,8 +910,13 @@ public class OperationListActivity extends ABVUIActivity {
} else {
// 作業報告(回答)
if (taskReportDto.jsonData != null) {
mOperationLogic.updateTaskReportReplyLevel(serverTaskDto.taskKey, serverTaskDto.operationId, operationContentDto.contentId,
// データの更新
mOperationLogic.updateTaskReportReply(serverTaskDto.taskKey, serverTaskDto.operationId, operationContentDto.contentId, taskReportDto.enableReport,
new JSONObject(taskReportDto.jsonData), attachedFileName, false, false);
} else {
// jsonDataがない場合
mOperationLogic.insertTaskReportReply(serverTaskDto.taskKey, operationContentDto.operationId, operationContentDto.contentId, taskReportDto.enableReport,
null, attachedFileName, false, false);
}
}
// 更新済みの場合、localTaskListから削除
......@@ -928,8 +942,12 @@ public class OperationListActivity extends ABVUIActivity {
taskReportJson, serverTaskDto.taskHotSpotInfo, attachedFileName, false, false);
} else {
if (taskReportDto.jsonData != null) {
mOperationLogic.insertTaskReportReply(serverTaskDto.taskKey, operationContentDto.operationId, operationContentDto.contentId,
mOperationLogic.insertTaskReportReply(serverTaskDto.taskKey, operationContentDto.operationId, operationContentDto.contentId, taskReportDto.enableReport,
new JSONObject(taskReportDto.jsonData), attachedFileName, false, false);
} else {
// jsonDataがない場合
mOperationLogic.insertTaskReportReply(serverTaskDto.taskKey, operationContentDto.operationId, operationContentDto.contentId, taskReportDto.enableReport,
null, attachedFileName, false, false);
}
}
}
......@@ -1549,18 +1567,27 @@ public class OperationListActivity extends ABVUIActivity {
}
/**
* 定期点検の報告存在チェック
* 報告存在チェック
* @param listDto
* @param rDto
* @return
*/
private boolean isExistsRoutinTaskReportInList(List<TaskReportDto> listDto, TaskReportDto rDto) {
private boolean isExistsTaskReportInList(List<TaskReportDto> listDto, TaskReportDto rDto, boolean isRoutineTask) {
for (TaskReportDto lDto : listDto) {
if (isRoutineTask) {
// 定期点検の場合、taskKey,taskReportId,reportStartDateで判定
if (lDto.taskKey.equals(rDto.taskKey) &&
lDto.taskReportId == rDto.taskReportId &&
lDto.reportStartDate.equals(rDto.reportStartDate)) {
return true;
}
} else {
// taskKeyと作業報告階層で判定
if (lDto.taskKey.equals(rDto.taskKey) &&
lDto.taskReportLevel == rDto.taskReportLevel) {
return true;
}
}
}
return false;
}
......
......@@ -97,7 +97,11 @@ public class ABookCheckWebViewHelper extends ABookHelper {
mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
copyRoutineTaskReportAttachedMovie(operationId, contentId, taskKey, taskReportId, reportStartDate);
} else {
if (taskReportLevel == Constant.TaskReportLevel.ReportType) {
mOperationLogic.deleteTaskReport(operationId, contentId, taskKey);
} else {
mOperationLogic.deleteTaskReportReply(operationId, contentId, taskKey);
}
mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
}
......@@ -301,9 +305,9 @@ public class ABookCheckWebViewHelper extends ABookHelper {
}
} else {
if (insertFlg) {
mOperationLogic.insertTaskReportReply(taskKey, operationId, contentId, taskReportJson, null, attachedChangeFlag, true);
mOperationLogic.insertTaskReportReply(taskKey, operationId, contentId, Constant.EnableReport.YES, taskReportJson, null, attachedChangeFlag, true);
} else {
mOperationLogic.updateTaskReportReplyLevel(taskKey, operationId, contentId, taskReportJson, null, attachedChangeFlag, true);
mOperationLogic.updateTaskReportReply(taskKey, operationId, contentId, Constant.EnableReport.YES, taskReportJson, null, attachedChangeFlag, true);
}
}
mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
......
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