Commit 05b337ce by Lee Jaebin

#32825 作業一覧画面改善

parent 1d2780ad
......@@ -73,6 +73,7 @@ import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.dto.GroupDto;
import jp.agentec.abook.abv.bl.dto.MemberInfoDto;
import jp.agentec.abook.abv.bl.dto.ServiceOptionDto;
import jp.agentec.abook.abv.bl.dto.TaskReportDto;
import jp.agentec.adf.net.http.HttpDownloadState;
import jp.agentec.adf.net.http.HttpFileDownloader;
import jp.agentec.adf.net.http.HttpMultipart;
......@@ -513,21 +514,19 @@ public class AcmsClient implements AcmsClientResponseListener {
}
/**
* 作業データ送信
* 作業報告データ送信
* @param sid
* @param operationId
* @param taskKey
* @param delFlag
* @param taskReportLevel
* @param taskHotspotInfo
* @param taskReportInfo
* @param taskReportDto
* @param formFile
* @param taskReportSendSaveDate
* @param isRoutinTask
* @return
* @throws AcmsException
* @throws ABVException
* @throws NetworkDisconnectedException
* @throws IOException
*/
public AcmsMessageJSON sendTaskData(String sid, String operationId, String taskKey, String delFlag, String taskReportLevel, String taskHotspotInfo, String taskReportInfo, File formFile, boolean attachedFileSendFlg, Date taskReportSendSaveDate) throws ABVException, NetworkDisconnectedException, IOException {
public AcmsMessageJSON testSendTaskData(String sid, Long operationId, TaskReportDto taskReportDto, File formFile, Date taskReportSendSaveDate, boolean isRoutinTask) throws ABVException, NetworkDisconnectedException, IOException {
if (networkAdapter != null && !networkAdapter.isNetworkConnected()) { // NWのチェック
throw new NetworkDisconnectedException();
}
......@@ -535,39 +534,47 @@ public class AcmsClient implements AcmsClientResponseListener {
String apiUrl = AcmsApis.getApiUrl(env.acmsAddress, urlPath, AcmsApis.ApiSendTaskData);
List<HttpMultipart> HttpMultipartList = new ArrayList<HttpMultipart>();
HttpMultipartList.add(new HttpMultipart(ABookKeys.SID, sid));
HttpMultipartList.add(new HttpMultipart(ABookKeys.OPERATION_ID, operationId));
HttpMultipartList.add(new HttpMultipart(ABookKeys.TASK_KEY, taskKey));
HttpMultipartList.add(new HttpMultipart(ABookKeys.DEL_FLAG, delFlag));
HttpMultipartList.add(new HttpMultipart(ABookKeys.TASK_REPORT_LEVEL, taskReportLevel));
HttpMultipartList.add(new HttpMultipart(ABookKeys.TASK_HOT_SPOT_INFO, taskHotspotInfo));
HttpMultipartList.add(new HttpMultipart(ABookKeys.TASK_REPORT_INFO, taskReportInfo));
HttpMultipartList.add(new HttpMultipart(ABookKeys.ATTACHED_CHANGE_FLAG, attachedFileSendFlg ? "1" : "0"));
HttpMultipartList.add(new HttpMultipart(ABookKeys.OPERATION_ID, StringUtil.toString(operationId)));
HttpMultipartList.add(new HttpMultipart(ABookKeys.TASK_KEY, taskReportDto.taskKey));
HttpMultipartList.add(new HttpMultipart(ABookKeys.DEL_FLAG, taskReportDto.delFlg ? "1" : "0"));
HttpMultipartList.add(new HttpMultipart(ABookKeys.TASK_REPORT_LEVEL, StringUtil.toString(taskReportDto.taskReportLevel)));
HttpMultipartList.add(new HttpMultipart(ABookKeys.TASK_HOT_SPOT_INFO, taskReportDto.taskHotSpotInfo));
HttpMultipartList.add(new HttpMultipart(ABookKeys.TASK_REPORT_INFO, taskReportDto.taskReportInfo));
HttpMultipartList.add(new HttpMultipart(ABookKeys.ATTACHED_CHANGE_FLAG, taskReportDto.attachedFileSendFlg ? "1" : "0"));
// 定期点検用
if (isRoutinTask) {
HttpMultipartList.add(new HttpMultipart(ABookKeys.TASK_REPORT_ID, StringUtil.toString(taskReportDto.taskReportId)));
HttpMultipartList.add(new HttpMultipart(ABookKeys.TASK_REPORT_INFO_ID, StringUtil.toString(taskReportDto.taskReportInfoId)));
HttpMultipartList.add(new HttpMultipart(ABookKeys.REPORT_START_DATE, DateTimeUtil.toStringForCmsGMT(taskReportDto.reportStartDate)));
}
if (formFile != null) {
HttpMultipartList.add(new HttpMultipart(ABookKeys.FORM_FILE, formFile));
}
if (taskReportSendSaveDate != null) {
String sendDate = DateTimeUtil.toStringInTimeZone(taskReportSendSaveDate, DateTimeFormat.yyyyMMddHHmmss_hyphen, "GMT") + ",GMT";
HttpMultipartList.add(new HttpMultipart(ABookKeys.TASK_REPORT_SAVE_DATE, sendDate));
}
HttpMultipartList.add(new HttpMultipart(ABookKeys.TASK_REPORT_SAVE_DATE, DateTimeUtil.toStringForCmsGMT(taskReportSendSaveDate)));
}
result = HttpRequestSender.post(apiUrl, HttpMultipartList.toArray(new HttpMultipart[HttpMultipartList.size()]));
Logger.d(TAG, "[sendTaskData]: operationId=%s, taskKey=%s, delFlag=%s, taskReportLevel=%s, taskHopspotInfo=%s, taskReportInfo=%s, attachedFileSendFlg=%s", operationId, taskKey, delFlag, taskReportLevel, taskHotspotInfo, taskReportInfo, attachedFileSendFlg);
AcmsMessageJSON json = new AcmsMessageJSON(result.httpResponseBody);
Logger.d(TAG, "sendTaskData res: %s", json);
if (json.errorMessage != null) {
if (json.errorMessage[0].equals("P003")) {
throw new ABVException(ABVExceptionCode.P_E_ACMS_P003);
} else if (json.errorMessage[0].equals("P004")) {
throw new ABVException(ABVExceptionCode.P_E_ACMS_P004);
} else if (json.errorMessage[0].equals("P005")) {
throw new ABVException(ABVExceptionCode.P_E_ACMS_P005);
}
}
if (json.httpStatus != 200) {
throw new AcmsException(ABVExceptionCode.S_E_ACMS_0001, json);
}
return json;
}
......
......@@ -71,12 +71,13 @@ public class OperationDataJSON extends AcmsCommonJSON {
TaskReportDto taskReportDto = new TaskReportDto();
JSONObject taskReportJson = taskReportList.getJSONObject(j);
taskReportDto.taskKey = dto.taskKey;
taskReportDto.taskReportLevel = taskReportJson.getInt(TaskReportLevel);
taskReportDto.enableReport = taskReportJson.getInt(EnableReport);
if (taskReportJson.has(TaskReportInfoId)) {
// 定期点検の場合
taskReportDto.taskReportInfoId = taskReportJson.getLong(TaskReportInfoId);
taskReportDto.taskReportInfoId = taskReportJson.getInt(TaskReportInfoId);
}
if (taskReportJson.has(ReportStartDate)) {
taskReportDto.reportStartDate = DateTimeUtil.toDate(taskReportJson.getString(ReportStartDate), DateTimeFormat.yyyyMMddHHmmss_hyphen);
......
......@@ -6,12 +6,11 @@ import org.json.adf.JSONObject;
import java.util.ArrayList;
import java.util.List;
import jp.agentec.abook.abv.bl.acms.client.json.AcmsCommonJSON;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.dto.OperationContentDto;
import jp.agentec.abook.abv.bl.dto.OperationDto;
import jp.agentec.abook.abv.bl.dto.PushMessageDto;
import jp.agentec.abook.abv.bl.dto.WorkingGroupDto;
import jp.agentec.abook.abv.bl.dto.TaskWorkerGroupDto;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
......@@ -37,6 +36,9 @@ public class OperationListJSON extends AcmsCommonJSON {
public static final String EnableReportHistory = "enableReportHistory";
// 作業編集可能区分
public static final String EnableReportEdit = "enableReportEdit";
// 作業担当グループリスト
public static final String WorkingGroupList = "workingGroupList";
public static final String ReportLevel = "reportLevel"; // 報告階層
......@@ -68,7 +70,7 @@ public class OperationListJSON extends AcmsCommonJSON {
JSONObject operationJson = operations.getJSONObject(i);
OperationDto dto = new OperationDto();
dto.operationContentDtoList = new ArrayList<OperationContentDto>();
dto.workingGroupDtoList = new ArrayList<WorkingGroupDto>();
dto.taskWorkerGroupDtoList = new ArrayList<TaskWorkerGroupDto>();
dto.operationId = operationJson.getLong(OperationId);
dto.operationType = operationJson.getInt(OperationType);
dto.operationName = operationJson.getString(OperationName);
......@@ -77,13 +79,13 @@ public class OperationListJSON extends AcmsCommonJSON {
dto.operationEndDate = DateTimeUtil.toDate(operationJson.getString(OperationEndDate), "UTC", DateTimeFormat.yyyyMMdd_hyphen);
dto.reportType = operationJson.getInt(ReportType); // 作業報告タイプ
dto.enableReportHistory = operationJson.getInt(EnableReportHistory); // 報告履歴管理
dto.enableReportEdit = operationJson.has(EnableReportEdit) ? operationJson.getInt(EnableReportEdit) : 0; // 作業編集区分
// 作業終了更新日
if (operationJson.has(OperationLastEditDate)) {
dto.lastEditDate = DateTimeUtil.toDate(operationJson.getString(OperationLastEditDate), "UTC", DateTimeFormat.yyyyMMddHHmmss_hyphen);
}
if (operationJson.has(ReportCycle)) {
dto.reportCycle = operationJson.getInt(ReportCycle);
}
......@@ -138,14 +140,14 @@ public class OperationListJSON extends AcmsCommonJSON {
break;
}
// 作業担当グループリストセット
WorkingGroupDto workingGroupDto = new WorkingGroupDto();
workingGroupDto.reportLevel = workingGroupJsonArray.getJSONObject(k).getInt(ReportLevel);
workingGroupDto.groupList = new ArrayList<Integer>();
TaskWorkerGroupDto taskWorkerGroupDto = new TaskWorkerGroupDto();
taskWorkerGroupDto.taskReportLevel = workingGroupJsonArray.getJSONObject(k).getInt(ReportLevel);
taskWorkerGroupDto.groupList = new ArrayList<Integer>();
JSONArray workingGroupListArray = workingGroupJsonArray.getJSONObject(k).getJSONArray(GroupList);
for (int j = 0; j < workingGroupListArray.length(); j++) {
workingGroupDto.groupList.add(workingGroupListArray.getJSONObject(j).getInt(GroupId));
taskWorkerGroupDto.groupList.add(workingGroupListArray.getJSONObject(j).getInt(GroupId));
}
dto.workingGroupDtoList.add(workingGroupDto);
dto.taskWorkerGroupDtoList.add(taskWorkerGroupDto);
}
}
......
......@@ -150,4 +150,10 @@ public class Constant {
int Invalid = 0; // 無効
int Enable = 1; // 有効
}
// 作業編集可能区分
public interface EnableReportEdit {
int NO = 0;
int YES = 1;
}
}
......@@ -12,24 +12,17 @@ public class ABookKeys {
public static final String CONTENT_ID = "contentId";
public static final String CONTENT_NAME = "contentName";
public static final String CONTENT_TYPE = "contentType";
public static final String OPERATION_ID = "projectId";
public static final String OPERATION_NAME = "projectName";
public static final String OPERATION_ID = "operationId";
public static final String OPERATION_NAME = "operationName";
// ABOOKCHECK SCHEME
public static final String ABOOK_CHECK_API = "abookcheck-api";
// #32782 指示者テーブル関連削除 start
// TODO TaskDirections 削除処理が必要
public static final String CMD_INSERT_TASK_DIRECTIONS = "insertTaskReportLevel";
public static final String CMD_UPDATE_TASK_DIRECTIONS = "updateTaskReportLevel";
public static final String CMD_DELETE_TASK_DIRECTIONS = "deleteTaskReport";
public static final String CMD_CANCEL_TASK_DIRECTIONS = "cancelTaskDirections";
// #32782 指示者テーブル関連削除 end
public static final String CMD_MOVE_HOT_SPOT = "moveHotspot";
public static final String CMD_SHOW_DIRECTION_OZD = "showDirectionOzd";
public static final String CMD_PREVIEW_DIRECTION_OZD = "previewDirectionOzd";
public static final String CMD_INSERT_TASK_REPORT = "insertTaskReportReplyLevel";
public static final String CMD_UPDATE_TASK_REPORT = "updateTaskReportReplyLevel";
public static final String CMD_DELETE_TASK_REPORT = "deleteTaskReportReply";
public static final String CMD_INSERT_TASK_REPORT = "insertTaskReport";
public static final String CMD_UPDATE_TASK_REPORT = "updateTaskReport";
public static final String CMD_DELETE_TASK_REPORT = "deleteTaskReport";
public static final String CMD_CANCEL_TASK_REPORT = "cancelTaskReport";
public static final String CMD_SHOW_REPORT_OZD = "showReportOzd";
public static final String CMD_PREVIEW_REPORT_OZD = "previewReportOzd";
......
......@@ -255,6 +255,34 @@ public class AbstractDao {
}
}
}
/**
* クエリを実行し、最初の行の最初の列の値をInteger型リストで返します。
*
* @param sql
* @param bindArgs
* @return
*/
public List<Integer> rawQueryGetIntegerList(String sql, String[] bindArgs) {
SQLiteDatabase db = dbConn.getDatabase();
Cursor cursor = null;
try {
List<Integer> list = new ArrayList<Integer>();
if (Logger.isVerboseEnabled()) {
Logger.v(TAG, "%s [%s]", sql, join(bindArgs));
}
cursor = db.rawQuery(sql, bindArgs);
while (cursor.moveToNext()) {
list.add(cursor.getInt(0));
}
return list;
}
finally {
if (cursor != null) {
cursor.close();
}
}
}
/**
* クエリを実行し、最初の行の最初の列の値をLong型リストで返します。
......
......@@ -158,9 +158,10 @@ public class OperationDao extends AbstractDao {
+ "need_sync_flg, "
+ "report_cycle, "
+ "enable_report_update, "
+ "enable_report_history) "
+ "enable_report_history, "
+ "enable_report_edit) "
+ "values "
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
dto.getInsertValues());
}
......@@ -179,13 +180,15 @@ public class OperationDao extends AbstractDao {
+ "need_sync_flg=?, "
+ "report_cycle=?, "
+ "enable_report_update=?, "
+ "enable_report_history=? "
+ "enable_report_history=?, "
+ "enable_report_edit=? "
+ "where operation_id=?",
dto.getUpdateValues());
return count > 0;
}
public void delete(OperationDto dto) {
delete("r_task_worker_group", "operation_id=?", dto.getKeyValues());
delete("r_operation_content", "operation_id=?", dto.getKeyValues());
delete("t_operation", "operation_id=?", dto.getKeyValues());
}
......@@ -200,6 +203,7 @@ public class OperationDao extends AbstractDao {
delete("t_task_report_items", null, null);
delete("t_inspect_task_report", 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) {
......
......@@ -152,74 +152,70 @@ public class RoutineTaskReportDao extends AbstractDao {
return rawQueryGetDto("select * from t_inspect_task_report where task_key=? and task_report_id=? and datetime(report_start_date)=datetime(?, 'utc')", new String[]{ taskKey, "" + taskReportId, reportStartDate }, RoutineTaskReportDto.class);
}
public List<RoutineTaskReportDto> selectRoutineTaskReportByTaskKey(String taskKey) {
return rawQueryGetDtoList("select * from t_inspect_task_report where task_key=?", new String[]{ taskKey }, RoutineTaskReportDto.class);
}
public List<RoutineTaskReportDto> getRoutineTaskReportByOperationId(Long operationId) {
StringBuilder sb = new StringBuilder();
sb.append(" select tr.* ");
sb.append(" from t_inspect_task_report tr ");
sb.append(" inner join ");
sb.append(" t_task tt ");
sb.append(" ON tt.task_key == tr.task_key ");
sb.append(" WHERE tt.del_flg = 0");
sb.append(" AND tt.operation_id = ?");
sb.append(" ORDER BY task_report_id ASC, report_start_date ASC");
return rawQueryGetDtoList(sb.toString(), new String[]{"" + operationId}, RoutineTaskReportDto.class);
}
public List<RoutineTaskReportDto> getSendableRoutineTaskReportData(long operationId) {
StringBuilder sb = new StringBuilder();
sb.append(" select * ");
sb.append(" from t_inspect_task_report tr ");
sb.append(" inner join ");
sb.append(" t_task tt ");
sb.append(" ON tr.task_key == tt.task_key");
sb.append(" WHERE tr.data_send_flag = 1");
sb.append(" AND tt.operation_id = ?");
return rawQueryGetDtoList(sb.toString(), new String[]{ "" + operationId }, RoutineTaskReportDto.class);
}
public List<RoutineTaskReportDto> getSendableRoutineTaskReportData(long operationId, String taskKey) {
StringBuilder sb = new StringBuilder();
sb.append(" select * ");
sb.append(" from t_inspect_task_report tr ");
sb.append(" inner join ");
sb.append(" t_task tt ");
sb.append(" ON tr.task_key == tt.task_key");
sb.append(" WHERE tr.data_send_flag = 1");
sb.append(" AND tt.operation_id = ?");
sb.append(" AND tt.task_key = ?");
return rawQueryGetDtoList(sb.toString(), new String[]{ "" + operationId, "" + taskKey }, RoutineTaskReportDto.class);
}
public boolean isExistSendRoutineTaskData(Long operationId) {
return getSendableRoutineTaskReportData(operationId).size() > 0;
}
public boolean existsToDoRoutineTaskReportData(long operationId) {
String currDate = DateTimeUtil.toString(DateTimeUtil.getCurrentSqlDate(), DateTimeFormat.yyyyMMddHHmmss_hyphen);
StringBuilder sb = new StringBuilder();
sb.append(" select count(*) ");
sb.append(" from t_inspect_task_report tr ");
sb.append(" inner join t_task tt ON tt.task_key == tr.task_key ");
sb.append(" WHERE tt.del_flg = 0 ");
sb.append(" AND tt.operation_id = ? ");
sb.append(" AND datetime(report_end_date) >= datetime(?, 'utc') ");
return rawQueryGetInt(sb.toString(), new String[]{ "" + operationId, currDate }) > 0;
}
public List<RoutineTaskReportDto> geRoutineTaskReportByTaskKey(String taskKey) {
StringBuilder sb = new StringBuilder();
sb.append(" SELECT * ");
sb.append(" FROM t_inspect_task_report ");
sb.append(" WHERE task_key = ? ");
sb.append(" ORDER BY task_report_id, report_start_date ");
return rawQueryGetDtoList(sb.toString(), new String[]{ taskKey }, RoutineTaskReportDto.class);
}
public String getRoutineTaskReportAttachedFileName(String taskKey, int taskReportId, String reportStartDate) {
return rawQueryGetString("select local_attached_file_name from t_inspect_task_report where task_key=? and task_report_id=? and datetime(report_start_date)=datetime(?)", new String[]{ taskKey, "" + taskReportId, reportStartDate });
}
// public List<RoutineTaskReportDto> selectRoutineTaskReportByTaskKey(String taskKey) {
// return rawQueryGetDtoList("select * from t_inspect_task_report where task_key=?", new String[]{ taskKey }, RoutineTaskReportDto.class);
// }
//
// public List<RoutineTaskReportDto> getRoutineTaskReportByOperationId(Long operationId) {
// StringBuilder sb = new StringBuilder();
// sb.append(" select tr.* ");
// sb.append(" from t_inspect_task_report tr ");
// sb.append(" inner join ");
// sb.append(" t_task tt ");
// sb.append(" ON tt.task_key == tr.task_key ");
// sb.append(" WHERE tt.del_flg = 0");
// sb.append(" AND tt.operation_id = ?");
// sb.append(" ORDER BY task_report_id ASC, report_start_date ASC");
// return rawQueryGetDtoList(sb.toString(), new String[]{"" + operationId}, RoutineTaskReportDto.class);
// }
//
// public List<RoutineTaskReportDto> getSendableRoutineTaskReportData(long operationId) {
// StringBuilder sb = new StringBuilder();
// sb.append(" select * ");
// sb.append(" from t_inspect_task_report tr ");
// sb.append(" inner join ");
// sb.append(" t_task tt ");
// sb.append(" ON tr.task_key == tt.task_key");
// sb.append(" WHERE tr.data_send_flag = 1");
// sb.append(" AND tt.operation_id = ?");
// return rawQueryGetDtoList(sb.toString(), new String[]{ "" + operationId }, RoutineTaskReportDto.class);
// }
//
// public List<RoutineTaskReportDto> getSendableRoutineTaskReportData(long operationId, String taskKey) {
// StringBuilder sb = new StringBuilder();
// sb.append(" select * ");
// sb.append(" from t_inspect_task_report tr ");
// sb.append(" inner join ");
// sb.append(" t_task tt ");
// sb.append(" ON tr.task_key == tt.task_key");
// sb.append(" WHERE tr.data_send_flag = 1");
// sb.append(" AND tt.operation_id = ?");
// sb.append(" AND tt.task_key = ?");
// return rawQueryGetDtoList(sb.toString(), new String[]{ "" + operationId, "" + taskKey }, RoutineTaskReportDto.class);
// }
// public boolean existsToDoRoutineTaskReportData(long operationId) {
// String currDate = DateTimeUtil.toString(DateTimeUtil.getCurrentSqlDate(), DateTimeFormat.yyyyMMddHHmmss_hyphen);
// StringBuilder sb = new StringBuilder();
// sb.append(" select count(*) ");
// sb.append(" from t_inspect_task_report tr ");
// sb.append(" inner join t_task tt ON tt.task_key == tr.task_key ");
// sb.append(" WHERE tt.del_flg = 0 ");
// sb.append(" AND tt.operation_id = ? ");
// sb.append(" AND datetime(report_end_date) >= datetime(?, 'utc') ");
// return rawQueryGetInt(sb.toString(), new String[]{ "" + operationId, currDate }) > 0;
// }
//
// public List<RoutineTaskReportDto> geRoutineTaskReportByTaskKey(String taskKey) {
// StringBuilder sb = new StringBuilder();
// sb.append(" SELECT * ");
// sb.append(" FROM t_inspect_task_report ");
// sb.append(" WHERE task_key = ? ");
// sb.append(" ORDER BY task_report_id, report_start_date ");
// return rawQueryGetDtoList(sb.toString(), new String[]{ taskKey }, RoutineTaskReportDto.class);
// }
// public String getRoutineTaskReportAttachedFileName(String taskKey, int taskReportId, String reportStartDate) {
// return rawQueryGetString("select local_attached_file_name from t_inspect_task_report where task_key=? and task_report_id=? and datetime(report_start_date)=datetime(?)", new String[]{ taskKey, "" + taskReportId, reportStartDate });
// }
}
......@@ -5,6 +5,8 @@ import java.util.List;
import jp.agentec.abook.abv.bl.common.db.Cursor;
import jp.agentec.abook.abv.bl.dto.TaskReportDto;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
/**
* Created by leej on 2018/09/10.
......@@ -74,7 +76,7 @@ public class TaskReportDao extends AbstractDao {
+ "task_report_info_id, "
+ "report_start_date, "
+ "report_end_date, "
+ "reported_flag) "
+ "reported_flg) "
+ "values "
+ "(?,?,?,?,?,?,?,?,?,?,?)",
dto.getInsertValues());
......@@ -92,6 +94,7 @@ public class TaskReportDao extends AbstractDao {
return rawQueryGetDtoList(sb.toString(), new String[]{"" + operationId}, TaskReportDto.class);
}
/**
* 作業キーと作業報告タイプで作業報告データ取得
* @param taskKey
......@@ -99,7 +102,7 @@ public class TaskReportDao extends AbstractDao {
* @return
*/
public TaskReportDto getTaskReport(String taskKey, Integer taskReportLevel) {
return rawQueryGetDto("select * from t_task_report where task_key=? AND task_report_level", new String[]{ "" + taskKey, "" + taskReportLevel }, TaskReportDto.class);
return rawQueryGetDto("select * from t_task_report where task_key=? AND task_report_level=?", new String[]{ "" + taskKey, "" + taskReportLevel }, TaskReportDto.class);
}
public boolean update(TaskReportDto dto) {
......@@ -114,44 +117,44 @@ public class TaskReportDao extends AbstractDao {
+ "task_report_info_id=?, "
+ "report_start_date=?, "
+ "report_end_date=?, "
+ "reported_flag=?, "
+ "reported_flg=? "
+ "where task_key=?",
dto.getUpdateValues());
return count > 0;
}
public boolean updateRoutinTask(TaskReportDto dto, boolean reportedFlg) {
long count;
if (reportedFlg) {
dto.reportedFlag = true;
count = update("update t_inspect_task_report "
+ "set "
+ "report_end_date=?, "
+ "attached_file_name=?, "
+ "local_attached_file_name=?, "
+ "json_data=?, "
+ "data_send_flag=?, "
+ "attached_file_send_flag=?, "
+ "reported_flag=? "
+ "where task_key=? and task_report_id=? and datetime(report_start_date)=datetime(?)",
dto.getUpdateValues());
} else {
count = update("update t_inspect_task_report "
+ "set "
+ "report_end_date=?, "
+ "attached_file_name=?, "
+ "local_attached_file_name=?, "
+ "json_data=?, "
+ "data_send_flag=?, "
+ "attached_file_send_flag=? "
+ "where task_key=? and task_report_id=? and datetime(report_start_date)=datetime(?)",
new Object[] { dto.reportEndDate, dto.attachedFileName, dto.localAttachedFileName, dto.jsonData, dto.dataSendFlag, dto.attachedFileSendFlag, dto.taskKey, dto.taskReportId, dto.reportStartDate });
}
return count > 0;
}
}
// public boolean updateRoutinTask(TaskReportDto dto, boolean reportedFlg) {
// long count;
// if (reportedFlg) {
// dto.reportedFlag = true;
//
// count = update("update t_inspect_task_report "
// + "set "
// + "report_end_date=?, "
// + "attached_file_name=?, "
// + "local_attached_file_name=?, "
// + "json_data=?, "
// + "data_send_flag=?, "
// + "attached_file_send_flag=?, "
// + "reported_flag=? "
// + "where task_key=? and task_report_id=? and datetime(report_start_date)=datetime(?)",
// dto.getUpdateValues());
// } else {
// count = update("update t_inspect_task_report "
// + "set "
// + "report_end_date=?, "
// + "attached_file_name=?, "
// + "local_attached_file_name=?, "
// + "json_data=?, "
// + "data_send_flag=?, "
// + "attached_file_send_flag=? "
// + "where task_key=? and task_report_id=? and datetime(report_start_date)=datetime(?)",
// new Object[] { dto.reportEndDate, dto.attachedFileName, dto.localAttachedFileName, dto.jsonData, dto.dataSendFlag, dto.attachedFileSendFlag, dto.taskKey, dto.taskReportId, dto.reportStartDate });
// }
//
// return count > 0;
// }
// }
/**
* 送信フラグのあるデータが存在するか
......@@ -201,20 +204,16 @@ public class TaskReportDao extends AbstractDao {
return rawQueryGetString("select local_attached_file_name from t_task_report where task_key=? AND task_report_level=?", new String[]{"" + taskKey, "" + taskReportLevel});
}
public List<TaskReportDto> selectByTaskKey(String taskKey) {
return rawQueryGetDtoList("select * from t_task_report where task_key=?", new String[]{ taskKey }, TaskReportDto.class);
public List<TaskReportDto> selectByTaskKey(String taskKey, int taskReportLevel) {
return rawQueryGetDtoList("select * from t_task_report where task_key=? and task_report_level", new String[]{ "" + taskKey, "" + taskReportLevel }, TaskReportDto.class);
}
public List<TaskReportDto> selectAll() {
return rawQueryGetDtoList("select * from t_task_report", null, TaskReportDto.class);
}
public void deleteAll() {
delete("t_task_report", null, null);
}
/**
*
* データの存在チェック
* @param taskKey
* @param taskReportLevel
* @return
......@@ -222,4 +221,146 @@ public class TaskReportDao extends AbstractDao {
public boolean isExistTaskReport(String taskKey, Integer taskReportLevel) {
return rawQueryGetInt("select COUNT(*) from t_task_report where task_key=? AND task_report_level=?", new String[]{"" + taskKey, "" + taskReportLevel }) > 0;
}
// 仮定期点検メソッド
public boolean update(TaskReportDto dto, boolean reportedFlg) {
long count;
if (reportedFlg) {
dto.reportedFlag = true;
count = update("update t_inspect_task_report "
+ "set "
+ "report_end_date=?, "
+ "attached_file_name=?, "
+ "local_attached_file_name=?, "
+ "json_data=?, "
+ "data_send_flag=?, "
+ "attached_file_send_flag=?, "
+ "reported_flag=? "
+ "where task_key=? and task_report_id=? and datetime(report_start_date)=datetime(?)",
dto.getUpdateValues());
} else {
count = update("update t_inspect_task_report "
+ "set "
+ "report_end_date=?, "
+ "attached_file_name=?, "
+ "local_attached_file_name=?, "
+ "json_data=?, "
+ "data_send_flag=?, "
+ "attached_file_send_flag=? "
+ "where task_key=? and task_report_id=? and datetime(report_start_date)=datetime(?)",
new Object[] { dto.reportEndDate, dto.attachedFileName, dto.localAttachedFileName, dto.jsonData, dto.dataSendFlg, dto.attachedFileSendFlg, dto.taskKey, dto.taskReportId, dto.reportStartDate });
}
return count > 0;
}
public void delete(TaskReportDto dto) {
delete("t_task_report", "task_key=? and task_report_level=? task_report_id=? and datetime(report_start_date)=datetime(?, 'utc')", new String[] { dto.taskKey, "" + dto.taskReportLevel, "" + dto.taskReportId, DateTimeUtil.toString(dto.reportStartDate, DateTimeFormat.yyyyMMddHHmmss_hyphen) });
}
public TaskReportDto getLastRoutineTaskReportData(long operationId) {
StringBuilder sb = new StringBuilder();
sb.append(" select tr.* ");
sb.append(" from t_inspect_task_report tr ");
sb.append(" inner join ");
sb.append(" t_task tt ");
sb.append(" ON tr.task_key == tt.task_key");
sb.append(" WHERE tt.operation_id = ? ORDER BY tr.report_start_date DESC LIMIT 1");
List<TaskReportDto> dtoList = rawQueryGetDtoList(sb.toString(), new String[]{ "" + operationId }, TaskReportDto.class);
if (dtoList != null && dtoList.size() > 0) {
return dtoList.get(0);
} else {
TaskReportDto dto = new TaskReportDto();
dto.taskReportId = 0;
return dto;
}
}
public TaskReportDto getRoutineTaskReportUtc(String taskKey, int taskReportId, String reportStartDate){
return rawQueryGetDto("select * from t_inspect_task_report where task_key=? and task_report_id=? and datetime(report_start_date)=datetime(?, 'utc')", new String[]{ taskKey, "" + taskReportId, reportStartDate }, TaskReportDto.class);
}
public List<TaskReportDto> selectRoutineTaskReportByTaskKey(String taskKey) {
return rawQueryGetDtoList("select * from t_inspect_task_report where task_key=?", new String[]{ taskKey }, TaskReportDto.class);
}
public List<TaskReportDto> getRoutineTaskReportByOperationId(Long operationId) {
StringBuilder sb = new StringBuilder();
sb.append(" select tr.* ");
sb.append(" from t_inspect_task_report tr ");
sb.append(" inner join ");
sb.append(" t_task tt ");
sb.append(" ON tt.task_key == tr.task_key ");
sb.append(" WHERE tt.del_flg = 0");
sb.append(" AND tt.operation_id = ?");
sb.append(" ORDER BY task_report_id ASC, report_start_date ASC");
return rawQueryGetDtoList(sb.toString(), new String[]{"" + operationId}, TaskReportDto.class);
}
public List<TaskReportDto> getSendableRoutineTaskReportData(long operationId) {
StringBuilder sb = new StringBuilder();
sb.append(" select * ");
sb.append(" from t_inspect_task_report tr ");
sb.append(" inner join ");
sb.append(" t_task tt ");
sb.append(" ON tr.task_key == tt.task_key");
sb.append(" WHERE tr.data_send_flag = 1");
sb.append(" AND tt.operation_id = ?");
return rawQueryGetDtoList(sb.toString(), new String[]{ "" + operationId }, TaskReportDto.class);
}
public List<TaskReportDto> getSendableRoutineTaskReportData(long operationId, String taskKey) {
StringBuilder sb = new StringBuilder();
sb.append(" select * ");
sb.append(" from t_inspect_task_report tr ");
sb.append(" inner join ");
sb.append(" t_task tt ");
sb.append(" ON tr.task_key == tt.task_key");
sb.append(" WHERE tr.data_send_flag = 1");
sb.append(" AND tt.operation_id = ?");
sb.append(" AND tt.task_key = ?");
return rawQueryGetDtoList(sb.toString(), new String[]{ "" + operationId, "" + taskKey }, TaskReportDto.class);
}
public boolean existsToDoRoutineTaskReportData(long operationId) {
String currDate = DateTimeUtil.toString(DateTimeUtil.getCurrentSqlDate(), DateTimeFormat.yyyyMMddHHmmss_hyphen);
StringBuilder sb = new StringBuilder();
sb.append(" select count(*) ");
sb.append(" from t_inspect_task_report tr ");
sb.append(" inner join t_task tt ON tt.task_key == tr.task_key ");
sb.append(" WHERE tt.del_flg = 0 ");
sb.append(" AND tt.operation_id = ? ");
sb.append(" AND datetime(report_end_date) >= datetime(?, 'utc') ");
return rawQueryGetInt(sb.toString(), new String[]{ "" + operationId, currDate }) > 0;
}
public List<TaskReportDto> geRoutineTaskReportByTaskKey(String taskKey) {
StringBuilder sb = new StringBuilder();
sb.append(" SELECT * ");
sb.append(" FROM t_inspect_task_report ");
sb.append(" WHERE task_key = ? ");
sb.append(" ORDER BY task_report_id, report_start_date ");
return rawQueryGetDtoList(sb.toString(), new String[]{ taskKey }, TaskReportDto.class);
}
public String getRoutineTaskReportAttachedFileName(String taskKey, int taskReportId, String reportStartDate) {
return rawQueryGetString("select local_attached_file_name from t_inspect_task_report where task_key=? and task_report_id=? and datetime(report_start_date)=datetime(?)", new String[]{ taskKey, "" + taskReportId, reportStartDate });
}
/**
* 作業キーで作業時間が存在する作業報告データ取得(定期点検)
* @param taskKey
* @return
*/
public List<TaskReportDto> getNotNullStartDateTaskReportByTaskKey(String taskKey) {
return rawQueryGetDtoList("select * from t_task_report where task_key=? AND report_start_date IS NOT NULL", new String[]{ taskKey }, TaskReportDto.class);
}
}
package jp.agentec.abook.abv.bl.data.dao;
import java.util.List;
import jp.agentec.abook.abv.bl.common.db.Cursor;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.TaskWorkerGroupDto;
import jp.agentec.abook.abv.bl.dto.WorkerGroupDto;
/**
* Created by leej on 2019/03/19.
*/
public class TaskWorkerGroupDao extends AbstractDao {
private static final String TAG = "TaskReportDao";
/*package*/ TaskWorkerGroupDao() {
}
@Override
protected TaskWorkerGroupDto convert(Cursor cursor) {
TaskWorkerGroupDto dto = new TaskWorkerGroupDto();
int column = cursor.getColumnIndex("task_report_level");
if (column != -1) {
dto.taskReportLevel = cursor.getInt(column);
}
column = cursor.getColumnIndex("operation_id");
if (column != -1) {
dto.operationId = cursor.getLong(column);
}
column = cursor.getColumnIndex("group_id");
if (column != -1) {
dto.groupId = cursor.getInt(column);
}
column = cursor.getColumnIndex("group_name");
if (column != -1) {
dto.groupName = cursor.getString(column);
}
return dto;
}
public void insert(TaskWorkerGroupDto dto) {
insert("insert into r_task_worker_group "
+ "(task_report_level, "
+ "operation_id, "
+ "group_id ) "
+ "values "
+ "(?,?,?)",
dto.getInsertValues());
}
/**
* 作業に紐づいた作業担当グループを削除
* @param operationId
*/
public void deleteByOperationId(Long operationId) {
delete("r_task_worker_group", "operation_id=?", new String[]{""+ operationId});
}
/**
* 作業IDに紐づいた作業担当グループを取得
* inner joing m_worker_group(作業名取得)
* @param operationId
* @return
*/
public List<TaskWorkerGroupDto> getTaskWorkerGroupByOperationId(Long operationId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT rtwg.task_report_level, rtwg.operation_id, rtwg.group_id, mwg.group_name ");
sql.append(" FROM r_task_worker_group AS rtwg ");
sql.append(" INNER JOIN m_worker_group AS mwg ");
sql.append(" ON rtwg.group_id = mwg.group_id ");
sql.append(" WHERE rtwg.operation_id = ? ");
sql.append(" ORDER BY rtwg.group_id DESC ");
Logger.v(TAG, "sql=%s", sql);
return rawQueryGetDtoList(sql.toString(), new String[]{""+ operationId}, TaskWorkerGroupDto.class);
}
}
......@@ -59,13 +59,44 @@ public class WorkerGroupDao extends AbstractDao {
return count > 0;
}
public boolean delete(WorkerGroupDto dto) {
long ret = delete("m_worker_group", "group_id=?", dto.getKeyValues());
return ret > 0;
/**
* 作業グループ削除
* @param dto
*/
public void delete(WorkerGroupDto dto) {
delete("r_task_worker_group", "group_id=?", dto.getKeyValues());
delete("m_worker_group", "group_id=?", dto.getKeyValues());
}
/**
* グループIDで削除
* @param groupId
* @return
*/
public void deleteById(Integer groupId) {
String[] keyValue = new String[]{""+ groupId};
delete("r_task_worker_group", "group_id=?", keyValue);
delete("m_worker_group", "group_id=?", keyValue);
}
public void deleteAll() {
delete("m_worker_group", null, null);
}
/**
* グループIDで存在チェック
* @param groupId
* @return
*/
public boolean isExist(Integer groupId) {
return rawQueryGetInt("select COUNT(*) from m_worker_group where group_id=?", new String[]{"" + groupId }) > 0;
}
/**
* 全てのグループID取得
* @return
*/
public List<Integer> getAllWorkerGroupId() {
return rawQueryGetIntegerList("select group_id from m_worker_group order by group_id", null);
}
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ public class RTaskWorkerGroup extends SQLiteTableScript {
List<String> ddl = new ArrayList<String>();
StringBuffer sql = new StringBuffer();
sql.append(" CREATE TABLE t_task_worker_group ( ");
sql.append(" CREATE TABLE r_task_worker_group ( ");
sql.append(" task_report_level INTEGER default 0 ");
sql.append(" , operation_id BIGINT NOT NULL ");
sql.append(" , group_id INTEGER NOT NULL ");
......
......@@ -33,10 +33,10 @@ public class TOperation extends SQLiteTableScript {
sql.append(" , edit_lock_flg BOOLEAN NOT NULL DEFAULT 0 ");
sql.append(" , need_sync_flg BOOLEAN NOT NULL DEFAULT 0 ");
sql.append(" , report_type INTEGER NOT NULL DEFAULT 0 ");
sql.append(" , report_cycle INTEGER NOT NULL DEFAULT 0 ");
sql.append(" , enable_report_update INTEGER NOT NULL DEFAULT 0 ");
sql.append(" , enable_report_history SMALLINT NOT NULL DEFAULT 0 ");
sql.append(" , enable_report_edit SMALLINT NOT NULL DEFAULT 0 ");
sql.append(" , PRIMARY KEY (operation_id) ");
sql.append(" ) ");
ddl.add(sql.toString());
......
......@@ -39,6 +39,7 @@ public class TTaskReport extends SQLiteTableScript {
sql.append(" , task_report_info_id INTEGER NOT NULL DEFAULT 0 ");
sql.append(" , enable_report SMALLINT NOT NULL DEFAULT 0 ");
sql.append(" , task_report_level SMALLINT NOT NULL DEFAULT 0 ");
sql.append(" , reported_flg BOOLEAN DEFAULT 0 ");
sql.append(" ) ");
ddl.add(sql.toString());
......
......@@ -28,11 +28,11 @@ public class OperationDto extends AbstractDto {
public int enableReportUpdate; //0:不可 1:可
public String reportPeriod; //定期点検、2018/12/20 08:10:00 ~ 2018/12/21 18:10:00
public int reportCount; //定期点検、作業数
public int enableReportEdit; // 作業編集可能区分
public int enableReportHistory; // 0: 履歴無し, 1: 履歴可
// 作業担当グループリスト
public List<WorkingGroupDto> workingGroupDtoList;
public List<TaskWorkerGroupDto> taskWorkerGroupDtoList;
public boolean equalsLastEdit(OperationDto dto) {
if (dto != null) {
......@@ -45,12 +45,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 };
return new Object[] { operationId, operationName, operationDescriptions, operationStartDate, operationEndDate, operationType, reportType, lastEditDate, contentCreatingFlg, editLockFlg, needSyncFlg, reportCycle, enableReportUpdate, enableReportHistory, enableReportEdit };
}
@Override
public Object[] getUpdateValues() {
return new Object[] { operationName, operationDescriptions, operationStartDate, operationEndDate, operationType, reportType, lastEditDate, contentCreatingFlg, editLockFlg, needSyncFlg, reportCycle, enableReportUpdate, enableReportHistory, operationId };
return new Object[] { operationName, operationDescriptions, operationStartDate, operationEndDate, operationType, reportType, lastEditDate, contentCreatingFlg, editLockFlg, needSyncFlg, reportCycle, enableReportUpdate, enableReportHistory, enableReportEdit, operationId };
}
@Override
......
......@@ -19,7 +19,7 @@ public class TaskReportDto extends AbstractDto {
//  作業報告詳細リスト
public int taskReportLevel; // 作業報告レベル
public int taskReportId; // 作業報告ID
public long taskReportInfoId; // 作業報告情報ID
public int taskReportInfoId; // 作業報告情報ID
public Date reportStartDate; // 作業開始日
public Date reportEndDate; // 作業終了日
public int enableReport; // 報告可能区分
......
package jp.agentec.abook.abv.bl.dto;
import java.util.List;
/**
* Created by leej on 2019/03/19.
*/
public class TaskWorkerGroupDto extends AbstractDto {
public int taskReportLevel;
public long operationId;
public int groupId;
// inner join 用
public String groupName;
// OperationListJSONで取得用
public List<Integer> groupList;
@Override
public Object[] getInsertValues() {
return new Object[] { taskReportLevel, operationId, groupId};
}
@Override
public String[] getKeyValues() {
return new String[] { "" + operationId };
}
}
package jp.agentec.abook.abv.bl.dto;
import java.util.List;
/**
* Created by leej on 2019/03/18.
*/
public class WorkingGroupDto {
public int reportLevel;
public List<Integer> groupList;
}
......@@ -44,6 +44,7 @@ import jp.agentec.abook.abv.bl.data.dao.TaskDao;
import jp.agentec.abook.abv.bl.data.dao.TaskReportDao;
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.dto.CategoryContentDto;
import jp.agentec.abook.abv.bl.dto.ContentDto;
......@@ -55,6 +56,7 @@ import jp.agentec.abook.abv.bl.dto.TaskDto;
import jp.agentec.abook.abv.bl.dto.TaskReportDto;
import jp.agentec.abook.abv.bl.dto.TaskReportItemsDto;
import jp.agentec.abook.abv.bl.dto.TaskReportSendDto;
import jp.agentec.abook.abv.bl.dto.TaskWorkerGroupDto;
import jp.agentec.abook.abv.bl.dto.WorkerGroupDto;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
......@@ -83,11 +85,13 @@ public class OperationLogic extends AbstractLogic {
private PushMessageDao mPushMessageDao = AbstractDao.getDao(PushMessageDao.class);
private TaskWorkerGroupDao mTaskWorkerGroupDao = AbstractDao.getDao(TaskWorkerGroupDao.class);
public void initializeOperations() throws AcmsException, NetworkDisconnectedException {
// 作業グループリスト取得
setWorkingGroupList();
// プロジェクト一覧取得し、登録・更新・削除する
retrieveServerOperation();
// 作業者グループリスト取得
setWorkingGroupList();
}
/**
......@@ -112,7 +116,7 @@ public class OperationLogic extends AbstractLogic {
List<Long> localOperationContentIds = mOperationContentDao.getContentIds(serverOperationDto.operationId);
boolean operationContentFlg = false;
for (OperationContentDto operationContentDto : serverOperationDto.operationContentDtoList) {
if (localOperationContentIds == null) {
if (localOperationContentIds == null || localOperationContentIds.size() == 0) {
// insert
mOperationContentDao.insertOperationContent(operationContentDto);
} else {
......@@ -136,6 +140,7 @@ public class OperationLogic extends AbstractLogic {
if (mOperationContentDao.isExistMainOperationContent(serverOperationDto.operationId)) {
serverOperationDto.contentCreatingFlg = false;
}
mOperationDao.update(serverOperationDto);
// 更新することで登録フラグをfalseにセット
insertFlg = false;
......@@ -163,8 +168,18 @@ public class OperationLogic extends AbstractLogic {
for (OperationContentDto operationContentDto : serverOperationDto.operationContentDtoList) {
mOperationContentDao.insertOperationContent(operationContentDto);
}
}
// 作業担当グループ登録
mTaskWorkerGroupDao.deleteByOperationId(serverOperationDto.operationId);
for (TaskWorkerGroupDto taskWorkerGroupDto : serverOperationDto.taskWorkerGroupDtoList) {
taskWorkerGroupDto.operationId = serverOperationDto.operationId;
for (Integer groupId : taskWorkerGroupDto.groupList) {
taskWorkerGroupDto.groupId = groupId;
mTaskWorkerGroupDao.insert(taskWorkerGroupDto);
}
}
for (PushMessageDto dto : serverOperationDto.pushMessageList) {
mPushMessageDao.insert(dto);
}
......@@ -207,9 +222,19 @@ public class OperationLogic extends AbstractLogic {
private void setWorkingGroupList() throws NetworkDisconnectedException, AcmsException {
AcmsParameters param = new AcmsParameters(cache.getMemberInfo().sid);
WorkerGroupJSON json = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).getWorkingGroupList(param);
mWorkerGroupDao.deleteAll();
List<Integer> localWorkerGroupIdList = mWorkerGroupDao.getAllWorkerGroupId();
for (WorkerGroupDto dto : json.workerGroupList) {
mWorkerGroupDao.insert(dto);
if (mWorkerGroupDao.isExist(dto.groupId)) {
localWorkerGroupIdList.remove(dto.groupId);
mWorkerGroupDao.update(dto);
} else {
mWorkerGroupDao.insert(dto);
}
}
// 削除
for (Integer groupId : localWorkerGroupIdList) {
mWorkerGroupDao.deleteById(groupId);
}
}
......@@ -225,10 +250,8 @@ public class OperationLogic extends AbstractLogic {
* @param dataSendFlg
* @throws IOException
*/
public void insertTaskReportLevel(String taskKey, long operationId, long contentId, JSONObject taskDirectionsJson, String hotSpotInfo, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
// #32782 指示者テーブル関連削除 start
public void insertTaskReport(String taskKey, long operationId, long contentId, JSONObject taskDirectionsJson, String hotSpotInfo, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
// TODO Delete
TaskDto taskDto = new TaskDto();
TaskReportDto taskReportDto = new TaskReportDto();
JSONObject taskJson = taskDirectionsJson.getJSONObject("task");
......@@ -287,7 +310,6 @@ public class OperationLogic extends AbstractLogic {
if (result) {
FileUtil.delete(tempDirPath);
}
// #32782 指示者テーブル関連削除 end
}
/**
......@@ -302,7 +324,7 @@ public class OperationLogic extends AbstractLogic {
* @param dataSendFlg
* @throws IOException
*/
public void updateTaskReportLevel(String taskKey, long operationId, long contentId, JSONObject taskReportJson, String hotSpotInfo, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
public void updateTaskReport(String taskKey, long operationId, long contentId, JSONObject taskReportJson, String hotSpotInfo, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
TaskDto taskDto = mTaskDao.getTaskByTaskKey(taskKey);
if (taskDto == null) {
// ignore
......@@ -405,10 +427,9 @@ public class OperationLogic extends AbstractLogic {
* @param localAttachedFileName
* @param attachedChangeFlag
* @param dataSendFlg
* @param taskReportLevel
* @throws IOException
*/
public void insertTaskReportReplyLevel(String taskKey, long operationId, int taskReportLevel, long contentId, JSONObject taskReportJson, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
public void insertTaskReportReply(String taskKey, long operationId, long contentId, JSONObject taskReportJson, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
TaskDto taskDto = mTaskDao.getTaskByTaskKey(taskKey);
if (taskDto == null) {
//TODO error
......@@ -421,7 +442,7 @@ public class OperationLogic extends AbstractLogic {
while (taskKeys.hasNext()) {
TaskReportItemsDto taskReportItemsDto = new TaskReportItemsDto();
String itemKey = (String) taskKeys.next();
if (itemKey.startsWith("q_2_")) {
if (itemKey.startsWith("q_3_")) {
taskDto.taskStatus = taskJson.getInt(itemKey);
}
taskReportItemsDto.taskKey = taskKey;
......@@ -440,18 +461,19 @@ public class OperationLogic extends AbstractLogic {
taskReportDto.attachedFileSendFlg = attachedChangeFlag;
// 削除の時、deleteではなく、jsonDataを空にして、データが残っているので、updateする
List<TaskReportDto> taskReport = mTaskReportDao.selectByTaskKey(taskReportDto.taskKey);
List<TaskReportDto> taskReport = mTaskReportDao.selectByTaskKey(taskReportDto.taskKey, Constant.TaskReportLevel.ReportReplyType);
if (taskReport.size() > 0) {
mTaskReportDao.update(taskReportDto);
} else {
mTaskReportDao.insert(taskReportDto);
}
mTaskDao.update(taskDto);
//添付ファイル変更の場合、以下の処理を行う
String tempDirPath = ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey);
// #32926 作業報告画面改善 start
String operationDrectionOrReportDirPath = ABVEnvironment.getInstance().getOperationTaskReportLevelDirPath(operationId, taskKey, taskReportLevel);
String operationDrectionOrReportDirPath = ABVEnvironment.getInstance().getOperationTaskReportLevelDirPath(operationId, taskKey, Constant.TaskReportLevel.ReportReplyType);
// #32926 作業報告画面改善 end
JSONObject attachedListJson = taskReportJson.getJSONObject("attached");
......@@ -470,24 +492,24 @@ public class OperationLogic extends AbstractLogic {
* 定期点検データ新規
* @param operationId
* @param contentId
* @param routineTaskReportDto
* @param taskReportDto
* @param attachedChangeFlag
* @param dataSendFlg
* @throws IOException
*/
public void insertRoutineTaskReport(long operationId, long contentId, RoutineTaskReportDto routineTaskReportDto, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
routineTaskReportDto.attachedFileSendFlag = attachedChangeFlag;
routineTaskReportDto.dataSendFlag = dataSendFlg;
mRoutineTaskReportDao.insert(routineTaskReportDto);
public void insertRoutineTaskReport(long operationId, long contentId, TaskReportDto taskReportDto, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
taskReportDto.attachedFileSendFlg = attachedChangeFlag;
taskReportDto.dataSendFlg = dataSendFlg;
mTaskReportDao.insert(taskReportDto);
if (!StringUtil.isNullOrEmpty(routineTaskReportDto.jsonData)) {
JSONObject taskReportJson = new JSONObject(routineTaskReportDto.jsonData);
if (!StringUtil.isNullOrEmpty(taskReportDto.jsonData)) {
JSONObject taskReportJson = new JSONObject(taskReportDto.jsonData);
JSONObject taskJson = taskReportJson.getJSONObject("task");
Iterator taskKeys = taskJson.keys();
while (taskKeys.hasNext()) {
TaskReportItemsDto taskReportItemsDto = new TaskReportItemsDto();
String itemKey = (String) taskKeys.next();
taskReportItemsDto.taskKey = routineTaskReportDto.taskKey;
taskReportItemsDto.taskKey = taskReportDto.taskKey;
taskReportItemsDto.itemKey = itemKey;
try {
taskReportItemsDto.inputValue = taskJson.getString(itemKey);
......@@ -500,16 +522,12 @@ public class OperationLogic extends AbstractLogic {
}
//添付ファイル変更の場合、以下の処理を行う
String strReportStartDate = DateTimeUtil.toString_yyyyMMddHHmmss_none(routineTaskReportDto.reportStartDate);
String tempDirPath = ABVEnvironment.getInstance().getTempTaskDirPath(contentId, routineTaskReportDto.taskKey);
// #32926 作業報告画面改善 start
// TODO routineTaskReportDto -> taskReportDto
// String routineTaskReportDirPath = ABVEnvironment.getInstance().getRoutineTaskReportDirFilePath(operationId, routineTaskReportDto.taskKey, routineTaskReportDto.taskReportId, strReportStartDate, routineTaskReportDto.taskReportLevel);
String routineTaskReportDirPath = ABVEnvironment.getInstance().getRoutineTaskReportDirFilePath(operationId, routineTaskReportDto.taskKey, routineTaskReportDto.taskReportId, strReportStartDate, 0);
// #32926 作業報告画面改善 end
String strReportStartDate = DateTimeUtil.toString_yyyyMMddHHmmss_none(taskReportDto.reportStartDate);
String tempDirPath = ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskReportDto.taskKey);
String routineTaskReportDirPath = ABVEnvironment.getInstance().getRoutineTaskReportDirFilePath(operationId, taskReportDto.taskKey, taskReportDto.taskReportId, strReportStartDate, 0);
if (!StringUtil.isNullOrEmpty(routineTaskReportDto.jsonData)) {
JSONObject attachedListJson = (new JSONObject(routineTaskReportDto.jsonData)).getJSONObject("attached");
if (!StringUtil.isNullOrEmpty(taskReportDto.jsonData)) {
JSONObject attachedListJson = (new JSONObject(taskReportDto.jsonData)).getJSONObject("attached");
List<String> attachedFileNames = JSONObject.getValues(attachedListJson);
// コピー元のファイルで、添付ファイルとして使用しないファイル削除
deleteDifferentialFile(tempDirPath, attachedFileNames);
......@@ -522,12 +540,12 @@ public class OperationLogic extends AbstractLogic {
}
}
public void updateTaskReportReplyLevel(String taskKey, int taskReportLevel, long operationId, long contentId, JSONObject taskReport, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
TaskReportDto taskReportDto = mTaskReportDao.getTaskReport(taskKey, taskReportLevel);
public void updateTaskReportReplyLevel(String taskKey, long operationId, long contentId, 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
insertTaskReportReplyLevel(taskKey, operationId, taskReportLevel, contentId, taskReport, localAttachedFileName, attachedChangeFlag, dataSendFlg);
insertTaskReportReply(taskKey, operationId, contentId, taskReport, localAttachedFileName, attachedChangeFlag, dataSendFlg);
// #32926 作業報告画面改善 end
return;
}
......@@ -542,7 +560,7 @@ public class OperationLogic extends AbstractLogic {
taskReportItemsDto.inputValue = newValue;
mTaskReportItemsDao.updateTaskReportItems(taskReportItemsDto);
}
if (taskReportItemsDto.itemKey.startsWith("q_2_")) {
if (taskReportItemsDto.itemKey.startsWith("q_3_")) {
// 値が異なるため、作業コードの入力値を変更する
taskDto.taskStatus = Integer.parseInt(taskReportItemsDto.inputValue);
}
......@@ -562,7 +580,7 @@ public class OperationLogic extends AbstractLogic {
mTaskDao.update(taskDto);
String tempDirPath = ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey);
// #32926 作業報告画面改善 start
String operationDrectionOrReportDirPath = ABVEnvironment.getInstance().getOperationTaskReportLevelDirPath(operationId, taskKey, taskReportLevel);
String operationDrectionOrReportDirPath = ABVEnvironment.getInstance().getOperationTaskReportLevelDirPath(operationId, taskKey, Constant.TaskReportLevel.ReportReplyType);
// #32926 作業報告画面改善 end
if (taskReportDto.attachedFileSendFlg) {
//添付ファイル変更の場合、以下の処理を行う
......@@ -585,20 +603,20 @@ public class OperationLogic extends AbstractLogic {
* 定期点検データ更新
* @param operationId
* @param contentId
* @param routineTaskReportDto
* @param taskReportDto
* @param attachedChangeFlag
* @param dataSendFlg
* @param insertFlg
* @param reportedFlg
* @throws IOException
*/
public void updateRoutineTaskReport(long operationId, long contentId, RoutineTaskReportDto routineTaskReportDto, boolean attachedChangeFlag, boolean dataSendFlg, boolean insertFlg, boolean reportedFlg) throws IOException {
routineTaskReportDto.attachedFileSendFlag = attachedChangeFlag;
routineTaskReportDto.dataSendFlag = dataSendFlg;
mRoutineTaskReportDao.update(routineTaskReportDto, reportedFlg);
public void updateRoutineTaskReport(long operationId, long contentId, TaskReportDto taskReportDto, boolean attachedChangeFlag, boolean dataSendFlg, boolean insertFlg, boolean reportedFlg) throws IOException {
taskReportDto.attachedFileSendFlg = attachedChangeFlag;
taskReportDto.dataSendFlg = dataSendFlg;
mTaskReportDao.update(taskReportDto, reportedFlg);
if (!StringUtil.isNullOrEmpty(routineTaskReportDto.jsonData)) {
JSONObject taskReportJson = new JSONObject(routineTaskReportDto.jsonData);
if (!StringUtil.isNullOrEmpty(taskReportDto.jsonData)) {
JSONObject taskReportJson = new JSONObject(taskReportDto.jsonData);
JSONObject taskJson = taskReportJson.getJSONObject("task");
if (insertFlg) {
......@@ -606,7 +624,7 @@ public class OperationLogic extends AbstractLogic {
while (taskKeys.hasNext()) {
TaskReportItemsDto taskReportItemsDto = new TaskReportItemsDto();
String itemKey = (String) taskKeys.next();
taskReportItemsDto.taskKey = routineTaskReportDto.taskKey;
taskReportItemsDto.taskKey = taskReportDto.taskKey;
taskReportItemsDto.itemKey = itemKey;
taskReportItemsDto.taskReportLevel = Constant.TaskReportLevel.ReportType;
try {
......@@ -618,7 +636,7 @@ public class OperationLogic extends AbstractLogic {
mTaskReportItemsDao.insertTaskReportItems(taskReportItemsDto);
}
} else {
List<TaskReportItemsDto> taskReportItemsDaoList = mTaskReportItemsDao.getTaskReportItemByTaskKey(routineTaskReportDto.taskKey, Constant.TaskReportLevel.ReportType);
List<TaskReportItemsDto> taskReportItemsDaoList = mTaskReportItemsDao.getTaskReportItemByTaskKey(taskReportDto.taskKey, Constant.TaskReportLevel.ReportType);
for (TaskReportItemsDto taskReportItemsDto : taskReportItemsDaoList) {
try {
String newValue = taskJson.getString(taskReportItemsDto.itemKey);
......@@ -635,17 +653,15 @@ public class OperationLogic extends AbstractLogic {
}
}
String strReportStartDate = DateTimeUtil.toString_yyyyMMddHHmmss_none(routineTaskReportDto.reportStartDate);
String tempDirPath = ABVEnvironment.getInstance().getTempTaskDirPath(contentId, routineTaskReportDto.taskKey);
// #32926 作業報告画面改善 start
// TODO routineTaskReportDto -> taskReportDto
// String routineTaskReportDirPath = ABVEnvironment.getInstance().getRoutineTaskReportDirFilePath(operationId, routineTaskReportDto.taskKey, routineTaskReportDto.taskReportId, strReportStartDate, taskReportDto.taskReportLevel);
String routineTaskReportDirPath = ABVEnvironment.getInstance().getRoutineTaskReportDirFilePath(operationId, routineTaskReportDto.taskKey, routineTaskReportDto.taskReportId, strReportStartDate, 0);
// #32926 作業報告画面改善 end
String strReportStartDate = DateTimeUtil.toString_yyyyMMddHHmmss_none(taskReportDto.reportStartDate);
String tempDirPath = ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskReportDto.taskKey);
String routineTaskReportDirPath = ABVEnvironment.getInstance().getRoutineTaskReportDirFilePath(operationId, taskReportDto.taskKey, taskReportDto.taskReportId, strReportStartDate, taskReportDto.taskReportLevel);
if (insertFlg) {
if (!StringUtil.isNullOrEmpty(routineTaskReportDto.jsonData)) {
JSONObject attachedListJson = (new JSONObject(routineTaskReportDto.jsonData)).getJSONObject("attached");
if (!StringUtil.isNullOrEmpty(taskReportDto.jsonData)) {
JSONObject attachedListJson = (new JSONObject(taskReportDto.jsonData)).getJSONObject("attached");
List<String> attachedFileNames = JSONObject.getValues(attachedListJson);
// コピー元のファイルで、添付ファイルとして使用しないファイル削除
deleteDifferentialFile(tempDirPath, attachedFileNames);
......@@ -657,11 +673,11 @@ public class OperationLogic extends AbstractLogic {
FileUtil.delete(tempDirPath);
}
} else {
if (routineTaskReportDto.attachedFileSendFlag) {
if (taskReportDto.attachedFileSendFlg) {
if (StringUtil.isNullOrEmpty(routineTaskReportDto.jsonData)) {
if (StringUtil.isNullOrEmpty(taskReportDto.jsonData)) {
//添付ファイル変更の場合、以下の処理を行う
JSONObject attachedListJson = (new JSONObject(routineTaskReportDto.jsonData)).getJSONObject("attached");
JSONObject attachedListJson = (new JSONObject(taskReportDto.jsonData)).getJSONObject("attached");
List<String> attachedFileNames = JSONObject.getValues(attachedListJson);
// コピー元のファイルで、添付ファイルとして使用しないファイル削除
deleteDifferentialFile(tempDirPath, attachedFileNames);
......@@ -753,8 +769,14 @@ public class OperationLogic extends AbstractLogic {
return mTaskReportSendDao.getLastTaskReportSendId(taskKey);
}
public void deleteTaskReportReply(long operationId, long contentId, String taskKey, int taskReportLevel) {
TaskReportDto taskReportDto = mTaskReportDao.getTaskReport(taskKey, taskReportLevel);
/**
* 報告回答を削除
* @param operationId
* @param contentId
* @param taskKey
*/
public void deleteTaskReportReply(long operationId, long contentId, String taskKey) {
TaskReportDto taskReportDto = mTaskReportDao.getTaskReport(taskKey, Constant.TaskReportLevel.ReportReplyType);
if(taskReportDto != null) {
taskReportDto.dataSendFlg = true;
taskReportDto.attachedFileSendFlg = false;
......@@ -772,7 +794,7 @@ public class OperationLogic extends AbstractLogic {
FileUtil.delete(ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey));
// #32926 作業報告画面改善 start
FileUtil.delete(ABVEnvironment.getInstance().getOperationTaskReportLevelDirPath(operationId, taskKey, taskReportLevel));
FileUtil.delete(ABVEnvironment.getInstance().getOperationTaskReportLevelDirPath(operationId, taskKey, Constant.TaskReportLevel.ReportReplyType));
// #32926 作業報告画面改善 end
}
......@@ -782,12 +804,8 @@ public class OperationLogic extends AbstractLogic {
* @param contentId
* @param dto
*/
// #32926 作業報告画面改善 start
// TODO RoutineTaskReportDto -> TaskReportDto
// public void deleteRoutineTaskReport(long operationId, long contentId, TaskReportDto dto) {
public void deleteRoutineTaskReport(long operationId, long contentId, RoutineTaskReportDto dto) {
// #32926 作業報告画面改善 end
mRoutineTaskReportDao.delete(dto);
public void deleteTaskReport(long operationId, long contentId, TaskReportDto dto) {
mTaskReportDao.delete(dto);
String reportStartDate = DateTimeUtil.toString(dto.reportStartDate, DateTimeFormat.yyyyMMddHHmmss_hyphen);
mTaskReportSendDao.deleteByTaskKeyIdDate(dto.taskKey, dto.taskReportId, reportStartDate);
......@@ -796,16 +814,10 @@ public class OperationLogic extends AbstractLogic {
// 作業報告のディレクトリ削除
FileUtil.delete(ABVEnvironment.getInstance().getTempTaskDirPath(contentId, dto.taskKey));
// #32926 作業報告画面改善 start
// TODO routineTaskReportDto -> taskReportDto
// FileUtil.delete(ABVEnvironment.getInstance().getRoutineTaskReportDirFilePath(operationId, dto.taskKey, dto.taskReportId, reportStartDate, dto.taskReportLevel));
FileUtil.delete(ABVEnvironment.getInstance().getRoutineTaskReportDirFilePath(operationId, dto.taskKey, dto.taskReportId, reportStartDate, 0));
// 作業報告送信のディレクトリ削除
// TODO routineTaskReportDto -> taskReportDto
// FileUtil.delete(ABVEnvironment.getInstance().getRoutineTaskReportSendDirFilePath(operationId, dto.taskKey, dto.taskReportId, reportStartDate, dto.taskReportLevel));
FileUtil.delete(ABVEnvironment.getInstance().getRoutineTaskReportSendDirFilePath(operationId, dto.taskKey, dto.taskReportId, reportStartDate, 0));
// #32926 作業報告画面改善 end
}
/**
......@@ -840,12 +852,12 @@ public class OperationLogic extends AbstractLogic {
}
public RoutineTaskReportDto getRoutineTaskReportUtc(String taskKey, int taskReportId, String reportStartDate) {
return mRoutineTaskReportDao.getRoutineTaskReportUtc(taskKey, taskReportId, reportStartDate);
public TaskReportDto getRoutineTaskReportUtc(String taskKey, int taskReportId, String reportStartDate) {
return mTaskReportDao.getRoutineTaskReportUtc(taskKey, taskReportId, reportStartDate);
}
public List<RoutineTaskReportDto> getRoutineTaskReportByTaskKey(String taskKey) {
return mRoutineTaskReportDao.geRoutineTaskReportByTaskKey(taskKey);
public List<TaskReportDto> getRoutineTaskReportByTaskKey(String taskKey) {
return mTaskReportDao.geRoutineTaskReportByTaskKey(taskKey);
}
/**
......@@ -869,11 +881,10 @@ public class OperationLogic extends AbstractLogic {
* ホットスポットの更新
* @param taskKey
* @param param
* @param taskReportLevel
*/
public void updateTaskHotspot(String taskKey, Map<String, String> param, int taskReportLevel) {
public void updateTaskHotspot(String taskKey, Map<String, String> param) {
TaskDto taskDto = mTaskDao.getTaskByTaskKey(taskKey);
TaskReportDto taskReportDto = mTaskReportDao.getTaskReport(taskKey, taskReportLevel);
TaskReportDto taskReportDto = mTaskReportDao.getTaskReport(taskKey, Constant.TaskReportLevel.ReportType);
taskReportDto.dataSendFlg = true;
taskDto.taskHotSpotInfo = param.get(ABookKeys.HOT_SPOT);
mTaskReportDao.update(taskReportDto);
......@@ -903,19 +914,6 @@ public class OperationLogic extends AbstractLogic {
mTaskDao.update(taskDto);
}
/**
* 作業指示、作業報告用のjsonファイル
* taskReport.jsonとtaskReportSuggest.jsonとhotspot.jsonを作成
*
* @param operationId
* @param contentPath
* @throws IOException
*/
public void createJsonForOperationContent(Long operationId, String contentPath) throws IOException {
createJsonForOperationContent(operationId, contentPath, false);
}
/**
* 作業指示、作業報告用のjsonファイル
* taskReport.jsonとtaskReportSuggest.jsonとhotspot.jsonを作成
......@@ -1005,8 +1003,8 @@ public class OperationLogic extends AbstractLogic {
List<JSONObject> workerGroupJsonList = new ArrayList<JSONObject>();
JSONObject taskGroupJson = new JSONObject();
List<WorkerGroupDto> workerGroupDtoList = mWorkerGroupDao.getAllWorkerGroup();
for (WorkerGroupDto dto : workerGroupDtoList) {
List<TaskWorkerGroupDto> taskWorkerGroupDtoList = mTaskWorkerGroupDao.getTaskWorkerGroupByOperationId(operationId);
for (TaskWorkerGroupDto dto : taskWorkerGroupDtoList) {
JSONObject workerGroupJson = new JSONObject();
workerGroupJson.put(ABookKeys.GROUP_ID, dto.groupId);
workerGroupJson.put(ABookKeys.GROUP_NAME, dto.groupName);
......@@ -1021,9 +1019,9 @@ public class OperationLogic extends AbstractLogic {
}
taskGroupJson.put("taskGroup", workerGroupJsonList);
Logger.d(TAG, "createWorkerGroupJson : " + taskGroupJson.toString());
Logger.d(TAG,contentPath + "/workerGroup.json");
Logger.d(TAG,contentPath + "/workingGroup.json");
// #32926 作業報告画面改善 end
FileUtil.createFile(contentPath + "/workerGroup.json", taskGroupJson.toString());
FileUtil.createFile(contentPath + "/workingGroup.json", taskGroupJson.toString());
}
/**
......@@ -1061,17 +1059,13 @@ public class OperationLogic extends AbstractLogic {
public void createTaskReportJson(Long operationId, String contentPath) throws IOException {
List<JSONObject> taskReportJsonList = new ArrayList<JSONObject>();
JSONObject taskReportJson = new JSONObject();
JSONObject taskReportJsonRow;
List<TaskReportDto> taskReportDtoList = mTaskReportDao.getTaskReportByOperationId(operationId);
// #32926 作業報告画面改善 start
int taskReportLevel = 0;
for (TaskReportDto dto : taskReportDtoList) {
taskReportJsonRow = new JSONObject();
taskReportLevel = dto.taskReportLevel;
if(dto.jsonData != null && dto.jsonData.length() > 0) {
taskReportJsonRow.put(ABookKeys.HAS_AUTHORITY, dto.enableReport);
taskReportJsonList.add(new JSONObject(dto.jsonData));
taskReportJsonList.add(taskReportJsonRow);
taskReportJsonList.add(new JSONObject(dto.jsonData).put(ABookKeys.HAS_AUTHORITY, dto.enableReport));
}
}
taskReportJson.put(String.format("taskReport_%d", taskReportLevel), taskReportJsonList);
......@@ -1283,7 +1277,7 @@ public class OperationLogic extends AbstractLogic {
* @param taskKey
* @throws Exception
*/
public void sendTaskReportSendData(long operationId, String taskKey, Callback progressCallback) throws Exception {
public boolean sendTaskReportSendData(long operationId, String taskKey, boolean isRoutinTask, Callback progressCallback) throws Exception {
List<TaskReportDto> taskReportDtoList = null;
int maxProgress = 0;
if (taskKey == null) {
......@@ -1301,8 +1295,17 @@ public class OperationLogic extends AbstractLogic {
int progress = maxProgress / allSendCount;
for (TaskReportDto taskReportDto : taskReportDtoList) {
List<TaskReportSendDto> taskReportSendDtoList = mTaskReportSendDao.getSendableTaskReportSendData(taskReportDto.taskKey);
int lastTaskReportSendId = mTaskReportSendDao.getLastTaskReportSendId(taskReportDto.taskKey);
List<TaskReportSendDto> taskReportSendDtoList;
int lastTaskReportSendId;
if (isRoutinTask) {
// 定期点検
String reportStartDateStr = DateTimeUtil.toString(taskReportDto.reportStartDate, DateTimeFormat.yyyyMMddHHmmss_hyphen);
taskReportSendDtoList = mTaskReportSendDao.getSendableTaskReportSendData(taskReportDto.taskKey, taskReportDto.taskReportId, reportStartDateStr);
lastTaskReportSendId = mTaskReportSendDao.getLastTaskReportSendId(taskReportDto.taskKey, taskReportDto.taskReportId, reportStartDateStr);
} else {
taskReportSendDtoList = mTaskReportSendDao.getSendableTaskReportSendData(taskReportDto.taskKey);
lastTaskReportSendId = mTaskReportSendDao.getLastTaskReportSendId(taskReportDto.taskKey);
}
for (TaskReportSendDto taskReportSendDto : taskReportSendDtoList) {
// 履歴なし:元のattachedFileSendFlg
......@@ -1313,10 +1316,11 @@ public class OperationLogic extends AbstractLogic {
}
File zipFile = null;
String strReportStartDate = DateTimeUtil.toString_yyyyMMddHHmmss_none(taskReportDto.reportStartDate);
if (taskReportDto.attachedFileSendFlg) {
String fileName = null;
zipFile = createAttachedFileForSend(operationId, taskReportDto.taskKey, taskReportSendDto.taskReportSendId, false, 0, "", taskReportDto.taskReportLevel);
zipFile = createAttachedFileForSend(operationId, taskReportDto.taskKey, taskReportSendDto.taskReportSendId, isRoutinTask, taskReportDto.taskReportId, strReportStartDate, taskReportDto.taskReportLevel);
if (zipFile != null) {
fileName = FileUtil.getFilenameWithoutExt(zipFile.getName());
}
......@@ -1324,23 +1328,29 @@ public class OperationLogic extends AbstractLogic {
}
try {
AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).sendTaskData(
AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).testSendTaskData(
cache.getMemberInfo().sid,
String.valueOf(operationId),
taskReportDto.taskKey,
taskReportDto.delFlg ? "1" : "0",
String.valueOf(taskReportDto.taskReportLevel),
taskReportDto.taskHotSpotInfo,
taskReportSendDto.jsonData,
operationId,
taskReportDto,
zipFile,
taskReportDto.attachedFileSendFlg,
taskReportSendDto.saveDate
taskReportSendDto.saveDate,
isRoutinTask
);
progressCallback.callback(new Integer(progress));
mTaskReportSendDao.deleteBySendId(taskReportSendDto.taskReportSendId);
// #32926 作業報告画面改善 start
FileUtil.delete(ABVEnvironment.getInstance().getOperationTaskReportSendDirFilePath(operationId, taskReportSendDto.taskKey, taskReportSendDto.taskReportSendId, taskReportDto.taskReportLevel));
// #32926 作業報告画面改善 end
if (isRoutinTask) {
// 定期点検
FileUtil.delete(ABVEnvironment.getInstance().getRoutineTaskReportSendDirFilePath(operationId, taskReportSendDto.taskKey, taskReportSendDto.taskReportId, strReportStartDate, taskReportSendDto.taskReportSendId, taskReportDto.taskReportLevel));
} else {
FileUtil.delete(ABVEnvironment.getInstance().getOperationTaskReportSendDirFilePath(operationId, taskReportSendDto.taskKey, taskReportSendDto.taskReportSendId, taskReportDto.taskReportLevel));
}
} catch (ABVException ex) {
if (ex.getCode() == ABVExceptionCode.P_E_ACMS_P005) {
mTaskReportSendDao.deleteBySendId(taskReportSendDto.taskReportSendId);
FileUtil.delete(ABVEnvironment.getInstance().getRoutineTaskReportSendDirFilePath(operationId, taskReportSendDto.taskKey, taskReportSendDto.taskReportId, strReportStartDate, taskReportSendDto.taskReportSendId, taskReportDto.taskReportLevel));
return true;
}
} catch (Exception ex) {
throw ex;
} finally {
......@@ -1360,105 +1370,7 @@ public class OperationLogic extends AbstractLogic {
}
}
}
}
/**
* 定期点検用、作業報告履歴データ送信
* @param operationId
* @param taskKey
* @throws Exception
*/
public int sendRoutineTaskReportSendData(long operationId, String taskKey, Callback progressCallback) throws Exception {
List<RoutineTaskReportDto> routineTaskReportDtoList = null;
int sendErrorCnt = 0;
int maxProgress = 0;
if (taskKey == null) {
routineTaskReportDtoList = mRoutineTaskReportDao.getSendableRoutineTaskReportData(operationId);
maxProgress = 40;
} else {
routineTaskReportDtoList = mRoutineTaskReportDao.getSendableRoutineTaskReportData(operationId, taskKey);
maxProgress = 100;
}
if (routineTaskReportDtoList != null && routineTaskReportDtoList.size() > 0) {
OperationDto operationDto = mOperationDao.getOperation(operationId);
int allSendCount = mTaskReportSendDao.getSendableTaskReportSendDataCount(operationId, taskKey);
int progress = maxProgress / allSendCount;
for (RoutineTaskReportDto routineTaskReportDto : routineTaskReportDtoList) {
String reportStartDate = DateTimeUtil.toString(routineTaskReportDto.reportStartDate, DateTimeFormat.yyyyMMddHHmmss_hyphen);
List<TaskReportSendDto> taskReportSendDtoList = mTaskReportSendDao.getSendableTaskReportSendData(routineTaskReportDto.taskKey, routineTaskReportDto.taskReportId, reportStartDate);
int lastTaskReportSendId = mTaskReportSendDao.getLastTaskReportSendId(routineTaskReportDto.taskKey, routineTaskReportDto.taskReportId, reportStartDate);
for (TaskReportSendDto taskReportSendDto : taskReportSendDtoList) {
// 履歴なし:元のattachedFileSendFlg
// 履歴追加:古い履歴はtrue
// 履歴更新:true、ファイルに変更が無くてもzipファイル作成
if (taskReportSendDto.taskReportSendId < lastTaskReportSendId || operationDto.enableReportHistory == Constant.EnableReportHistory.Enable) {
routineTaskReportDto.attachedFileSendFlag = true;
}
File zipFile = null;
String strReportStartDate = DateTimeUtil.toString_yyyyMMddHHmmss_none(routineTaskReportDto.reportStartDate);
if (routineTaskReportDto.attachedFileSendFlag) {
String fileName = null;
// #32926 作業報告画面改善 start
// TODO routineTaskReportDto -> taskReportDto
// zipFile = createAttachedFileForSend(operationId, routineTaskReportDto.taskKey, taskReportSendDto.taskReportSendId, true, routineTaskReportDto.taskReportId, strReportStartDate, taskReportDto.taskReportLevel);
zipFile = createAttachedFileForSend(operationId, routineTaskReportDto.taskKey, taskReportSendDto.taskReportSendId, true, routineTaskReportDto.taskReportId, strReportStartDate, 0);
// #32926 作業報告画面改善 end
if (zipFile != null) {
fileName = FileUtil.getFilenameWithoutExt(zipFile.getName());
}
routineTaskReportDto.localAttachedFileName = fileName != null ? SecurityUtil.getMd5Hash(fileName) : null;
}
try {
AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).sendRoutineTaskReportData(
cache.getMemberInfo().sid,
operationId,
routineTaskReportDto.taskReportId,
routineTaskReportDto.taskReportInfoId,
routineTaskReportDto.reportStartDate,
taskReportSendDto.jsonData,
zipFile,
routineTaskReportDto.attachedFileSendFlag,
taskReportSendDto.saveDate
);
progressCallback.callback(new Integer(progress));
mTaskReportSendDao.deleteBySendId(taskReportSendDto.taskReportSendId);
// #32926 作業報告画面改善 start
// TODO routineTaskReportDto -> taskReportDto
// FileUtil.delete(ABVEnvironment.getInstance().getRoutineTaskReportSendDirFilePath(operationId, taskReportSendDto.taskKey, routineTaskReportDto.taskReportId, strReportStartDate, taskReportSendDto.taskReportSendId, taskReportDto.taskReportLevel));
FileUtil.delete(ABVEnvironment.getInstance().getRoutineTaskReportSendDirFilePath(operationId, taskReportSendDto.taskKey, routineTaskReportDto.taskReportId, strReportStartDate, taskReportSendDto.taskReportSendId, 0));
// #33926 作業報告画面改善 end
} catch (ABVException ex) {
if (ex.getCode() == ABVExceptionCode.P_E_ACMS_P005) {
mTaskReportSendDao.deleteBySendId(taskReportSendDto.taskReportSendId);
// #32926 作業報告画面改善 start
// TODO routineTaskReportDto -> taskReportDto
// FileUtil.delete(ABVEnvironment.getInstance().getRoutineTaskReportSendDirFilePath(operationId, taskReportSendDto.taskKey, routineTaskReportDto.taskReportId, strReportStartDate, taskReportSendDto.taskReportSendId, taskReportDto.taskReportLevel));
FileUtil.delete(ABVEnvironment.getInstance().getRoutineTaskReportSendDirFilePath(operationId, taskReportSendDto.taskKey, routineTaskReportDto.taskReportId, strReportStartDate, taskReportSendDto.taskReportSendId, 0));
// #32926 作業報告画面改善 end
sendErrorCnt++;
}
} catch (Exception ex) {
throw ex;
} finally {
if (zipFile != null) {
zipFile.delete();
}
}
}
routineTaskReportDto.dataSendFlag = false;
routineTaskReportDto.attachedFileSendFlag = false;
mRoutineTaskReportDao.update(routineTaskReportDto, false);
}
}
return sendErrorCnt;
return false;
}
/**
......@@ -1697,4 +1609,14 @@ public class OperationLogic extends AbstractLogic {
}
return null;
}
/**
* 作業報告の取得
* @param taskKey
* @param taskReportlevel
* @return
*/
public TaskReportDto getTaskReport(String taskKey, int taskReportlevel) {
return mTaskReportDao.getTaskReport(taskKey, taskReportlevel);
}
}
......@@ -855,13 +855,10 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
mCmd = abookCheckParam.get(ABookKeys.CMD);
mTaskKey = abookCheckParam.get(ABookKeys.TASK_KEY);
// #32926 作業報告画面改善 start
int taskReportLevel = 0; // 作業報告レベル(0:報告、1:報告(回答)、2:報告(回答))
if (abookCheckParam.containsKey(ABookKeys.TASK_REPORT_LEVEL)) {
taskReportLevel = Integer.parseInt(abookCheckParam.get(ABookKeys.TASK_REPORT_LEVEL)); // 作業報告レベル
}
// #32926 作業報告画面改善 end
int taskReportId = 0;
String reportStartDate = "";
......@@ -870,9 +867,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
reportStartDate = abookCheckParam.get(ABookKeys.REPORT_START_DATE);
}
if (StringUtil.equalsAny(mCmd, ABookKeys.CMD_INSERT_TASK_DIRECTIONS, ABookKeys.CMD_UPDATE_TASK_DIRECTIONS, ABookKeys.CMD_DELETE_TASK_DIRECTIONS, ABookKeys.CMD_CANCEL_TASK_DIRECTIONS,
ABookKeys.CMD_MOVE_HOT_SPOT, ABookKeys.CMD_INSERT_TASK_REPORT, ABookKeys.CMD_UPDATE_TASK_REPORT, ABookKeys.CMD_DELETE_TASK_REPORT, ABookKeys.CMD_CANCEL_TASK_REPORT,
ABookKeys.CMD_LOCAL_SAVE_TASK_REPORT)) {
if (StringUtil.equalsAny(mCmd, ABookKeys.CMD_MOVE_HOT_SPOT, ABookKeys.CMD_INSERT_TASK_REPORT, ABookKeys.CMD_UPDATE_TASK_REPORT,
ABookKeys.CMD_DELETE_TASK_REPORT, ABookKeys.CMD_CANCEL_TASK_REPORT, ABookKeys.CMD_LOCAL_SAVE_TASK_REPORT)) {
boolean isError = false;
try {
......@@ -881,19 +877,15 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
}
if (isOperationPdf && operationTaskDto != null && StringUtil.equalsAny(mCmd,
ABookKeys.CMD_INSERT_TASK_DIRECTIONS,
ABookKeys.CMD_UPDATE_TASK_DIRECTIONS,
ABookKeys.CMD_INSERT_TASK_REPORT,
ABookKeys.CMD_UPDATE_TASK_REPORT,
ABookKeys.CMD_MOVE_HOT_SPOT,
ABookKeys.CMD_LOCAL_SAVE_TASK_REPORT)) {
String taskCode = "";
// #32781 start
// TODO TASK_DIRECTIONSの削除され、TASK_REPORTに変更する
if (abookCheckParam.get(ABookKeys.TASK_DIRECTIONS) != null) {
JSONObject direction = new JSONObject(abookCheckParam.get(ABookKeys.TASK_DIRECTIONS));
JSONObject taskJson = direction.getJSONObject(ABookKeys.TASK);
if (abookCheckParam.get(ABookKeys.TASK_REPORT) != null) {
JSONObject tastReportJson = new JSONObject(abookCheckParam.get(ABookKeys.TASK_REPORT));
JSONObject taskJson = tastReportJson.getJSONObject(ABookKeys.TASK);
Iterator taskKeys = taskJson.keys();
while (taskKeys.hasNext()) {
String itemKey = (String) taskKeys.next();
......@@ -902,7 +894,6 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
}
}
}
// #32781 end
if (abookCheckParam.get(ABookKeys.HOT_SPOT) != null) {
JSONObject hotSpot = new JSONObject(abookCheckParam.get(ABookKeys.HOT_SPOT));
......@@ -930,12 +921,12 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
return null;
}
};
// #32926 作業報告画面改善 start
ABookCheckWebViewHelper.getInstance().doABookCheckParam(ABVContentViewActivity.this,
mCmd, mTaskKey, enableReportHistory, abookCheckParam, mOperationId, mContentPath, getContentId(),
operationDto.reportType == Constant.ReportType.Routine, finishCallback,
operationDto.reportType, finishCallback,
taskReportLevel);
// #32926 作業報告画面改善 end
} catch(Exception e) {
Logger.e(TAG, "doABookCheckParam error", e);
}
......
......@@ -9,7 +9,6 @@ import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.SparseBooleanArray;
......@@ -52,11 +51,9 @@ import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON;
import jp.agentec.abook.abv.bl.acms.client.json.RoutineTaskDataJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetOperationDataParameters;
import jp.agentec.abook.abv.bl.acms.type.DownloadStatusType;
import jp.agentec.abook.abv.bl.acms.type.OperationAuthLevel;
......@@ -620,7 +617,7 @@ public class OperationListActivity extends ABVUIActivity {
Intent intent = new Intent();
intent.putExtra(ABookKeys.CONTENT_ID, operationDto.contentId);
intent.putExtra(ABookKeys.OPERATION_ID, operationDto.operationId);
intent.putExtra(Constant.ABookCheck.XWALK_OPEN_TYPE, mOperationAuthLevel == OperationAuthLevel.OPERATION_INSTRUCTOR ? Constant.XWalkOpenType.TASK_DERECTION : Constant.XWalkOpenType.TASK_REPORT);
intent.putExtra(Constant.ABookCheck.XWALK_OPEN_TYPE, Constant.XWalkOpenType.TASK_REPORT);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
if(operationDto.operationType == OperationType.PDF) {
......@@ -700,14 +697,10 @@ public class OperationListActivity extends ABVUIActivity {
}
};
if (reportType == OperationReportType.ROUTINE_TASK) {
// 定期点検
if (mOperationLogic.sendRoutineTaskReportSendData(operationId, null, progressCallback) > 0) {
handleErrorMessageToast(R.string.P005);
}
} else {
// 報告送信
mOperationLogic.sendTaskReportSendData(operationId, null, progressCallback);
// 報告送信
if (mOperationLogic.sendTaskReportSendData(operationId, null, reportType == OperationReportType.ROUTINE_TASK, progressCallback)) {
// 作業報告タイプが定期点検且つ、P005のエラーの場合、以下のエラーをトーストメッセージで表示
handleErrorMessageToast(R.string.P005);
}
progressDialogHorizontal.setProgress(60);
......@@ -722,7 +715,7 @@ public class OperationListActivity extends ABVUIActivity {
if (!StringUtil.isNullOrEmpty(avilableDateStr)) {
// 利用可能メッセージ
dialogMsg = String.format(getString(R.string.msg_routineTask_report_available_from), avilableDateStr);
} else if (!mRoutineTaskReportDao.existsToDoRoutineTaskReportData(operationId)) {
} else if (!mTaskReportDao.existsToDoRoutineTaskReportData(operationId)) {
// 作業データが存在しないメッセージ
dialogMsg = getString(R.string.msg_no_report_data);
}
......@@ -837,141 +830,124 @@ public class OperationListActivity extends ABVUIActivity {
List<RoutineTaskReportDto> localRoutineTaskReportList;
Date lastEditDate;
if (operationDto.reportType == Constant.OperationReportType.ROUTINE_TASK) {
RoutineTaskDataJSON json = AcmsClient.getInstance(ABVDataCache.getInstance().getUrlPath(), ABVEnvironment.getInstance().networkAdapter).getRoutineTaskData(param);
OperationDataJSON json = AcmsClient.getInstance(ABVDataCache.getInstance().getUrlPath(), ABVEnvironment.getInstance().networkAdapter).getOpereationData(param);
//プログレスを40%進行させるための計算
int progress = 0;
if (json.taskDtoList.size() != 0) {
progress = 40 / json.taskDtoList.size();
}
//プログレスを40%進行させるための計算
int progress = 0;
if (json.taskDtoList.size() != 0) {
progress = 40 / json.taskDtoList.size();
JSONObject taskReportJson;
for (TaskDto serverTaskDto : json.taskDtoList) {
if (operationDto.reportType == Constant.ReportType.Routine) {
if (isExistsTaskInList(localTaskList, serverTaskDto)) {
mTaskDao.update(serverTaskDto);
} else {
mTaskDao.insert(serverTaskDto);
}
for (TaskDto serverTaskDto : json.taskDtoList) {
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
for (TaskReportDto localTaskReportDto : localTaskReportList) {
if (!isExistsRoutinTaskReportInList(serverTaskDto.taskReportDtoList, localTaskReportDto)) {
mOperationLogic.deleteTaskReport(operationId, operationContentDto.contentId, localTaskReportDto);
localRemove.add(localTaskReportDto);
}
}
localTaskReportList.removeAll(localRemove);
localRoutineTaskReportList = mRoutineTaskReportDao.selectRoutineTaskReportByTaskKey(serverTaskDto.taskKey);
List<RoutineTaskReportDto> localRemove = new ArrayList();
// サーバーからの情報で更新
for (TaskReportDto taskReportDto : serverTaskDto.taskReportDtoList) {
String reportAttachedFileName = taskReportDto.attachedFileName;
taskReportDto.taskKey = serverTaskDto.taskKey;
// 先にローカルにしか存在しない事を削除 : DB, files
for (RoutineTaskReportDto routineTaskDto : localRoutineTaskReportList) {
if (!isExistsRoutineTaskReportInList(serverTaskDto.RoutineTaskReportList, routineTaskDto)) {
mOperationLogic.deleteRoutineTaskReport(operationDto.operationId, operationContentDto.contentId, routineTaskDto);
localRemove.add(routineTaskDto);
// 添付ファイルが存在する場合、取得して解凍する。
refreshRoutineTaskFile(operationId, operationContentDto.contentId, serverTaskDto.taskId, serverTaskDto.taskKey, taskReportDto.taskReportId, taskReportDto.taskReportInfoId, taskReportDto.reportStartDate, reportAttachedFileName);
if (isSyncGetTaskFileError) {
return null;
}
if (isExistsRoutinTaskReportInList(localTaskReportList, taskReportDto)) {
// 報告データが存在すると作業報告を更新する
if (taskReportDto.jsonData != null) {
mOperationLogic.updateRoutineTaskReport(serverTaskDto.operationId, operationContentDto.contentId, taskReportDto, false, false, false, false);
}
} else {
if (taskReportDto.jsonData != null) {
mOperationLogic.insertRoutineTaskReport(serverTaskDto.operationId, operationContentDto.contentId, taskReportDto, false, false);
}
}
}
localRoutineTaskReportList.removeAll(localRemove);
// サーバーからの情報で更新
for (RoutineTaskReportDto routineTaskDto : serverTaskDto.RoutineTaskReportList) {
String reportAttachedFileName = routineTaskDto.attachedFileName;
routineTaskDto.taskKey = serverTaskDto.taskKey;
} else {
if (isExistsTaskInList(localTaskList, serverTaskDto)) {
// 更新
for (TaskReportDto taskReportDto : serverTaskDto.taskReportDtoList) {
String attachedFileName = taskReportDto.attachedFileName;
if (isExistsRoutineTaskReportInList(localRoutineTaskReportList, routineTaskDto)) {
// 添付ファイルが存在する場合、取得して解凍する。
refreshRoutineTaskFile(operationId, operationContentDto.contentId, serverTaskDto.taskId, serverTaskDto.taskKey, routineTaskDto.taskReportId, routineTaskDto.taskReportInfoId, routineTaskDto.reportStartDate, reportAttachedFileName);
if (isSyncGetTaskFileError) {
return null;
}
// 添付ファイルが存在する場合、取得して解凍する。
try {
refreshTaskFile(operationId, taskReportDto.taskReportLevel, operationContentDto.contentId, serverTaskDto.taskId, serverTaskDto.taskKey, taskReportDto.attachedFileName);
} catch (Exception e) {
return null;
}
// 報告データが存在すると作業報告を更新する
if (routineTaskDto.jsonData != null) {
mOperationLogic.updateRoutineTaskReport(serverTaskDto.operationId, operationContentDto.contentId, routineTaskDto, false, false, false, false);
}
if (taskReportDto.taskReportLevel == Constant.TaskReportLevel.ReportType) {
taskReportJson = new JSONObject(taskReportDto.jsonData);
taskReportJson.put(ABookKeys.TASK_STATUS, serverTaskDto.taskStatus);
// 作業報告を更新
// update
mOperationLogic.updateTaskReport(serverTaskDto.taskKey, serverTaskDto.operationId, operationContentDto.contentId,
taskReportJson, serverTaskDto.taskHotSpotInfo, attachedFileName, false, false);
} else {
// 添付ファイルが存在する場合、取得して解凍する。
refreshRoutineTaskFile(operationId, operationContentDto.contentId, serverTaskDto.taskId, serverTaskDto.taskKey, routineTaskDto.taskReportId, routineTaskDto.taskReportInfoId, routineTaskDto.reportStartDate, reportAttachedFileName);
if (isSyncGetTaskFileError) {
return null;
}
if (routineTaskDto.jsonData != null) {
mOperationLogic.insertRoutineTaskReport(operationContentDto.operationId, operationContentDto.contentId, routineTaskDto, false, false);
// 作業報告(回答)
if (taskReportDto.jsonData != null) {
mOperationLogic.updateTaskReportReplyLevel(serverTaskDto.taskKey, serverTaskDto.operationId, operationContentDto.contentId,
new JSONObject(taskReportDto.jsonData), attachedFileName, false, false);
}
}
// 更新済みの場合、localTaskListから削除
localTaskList.remove(serverTaskDto);
}
progressCallback.callback(new Integer(progress));
}
lastEditDate = json.lastEditDate;
} else {
OperationDataJSON json = AcmsClient.getInstance(ABVDataCache.getInstance().getUrlPath(), ABVEnvironment.getInstance().networkAdapter).getOpereationData(param);
//プログレスを40%進行させるための計算
int progress = 0;
if (json.taskDtoList.size() != 0) {
progress = 40 / json.taskDtoList.size();
}
JSONObject taskReportJson;
for (TaskDto taskDto : json.taskDtoList) {
if (isExistsTaskInList(localTaskList, taskDto)) {
// 更新
for (TaskReportDto taskReportDto : taskDto.taskReportDtoList) {
String attachedFileName = taskReportDto.attachedFileName;
// 添付ファイルが存在する場合、取得して解凍する。
try {
refreshTaskFile(operationId, taskReportDto.taskReportLevel, operationContentDto.contentId, taskDto.taskId, taskDto.taskKey, taskReportDto.attachedFileName);
} catch (Exception e) {
return null;
}
} else {
// 登録
for (TaskReportDto taskReportDto : serverTaskDto.taskReportDtoList) {
String attachedFileName = taskReportDto.attachedFileName;
if (taskReportDto.taskReportLevel == Constant.TaskReportLevel.ReportType) {
taskReportJson = new JSONObject(taskReportDto.jsonData);
taskReportJson.put(ABookKeys.TASK_STATUS, taskDto.taskStatus);
// 作業報告を更新
// update
mOperationLogic.updateTaskReportLevel(taskDto.taskKey, taskDto.operationId, operationContentDto.contentId,
taskReportJson, taskDto.taskHotSpotInfo, attachedFileName, false, false);
} else {
// 作業報告(回答)
if (taskReportDto.jsonData != null) {
mOperationLogic.updateTaskReportReplyLevel(taskDto.taskKey, taskReportDto.taskReportLevel, taskDto.operationId, operationContentDto.contentId,
new JSONObject(taskReportDto.jsonData), attachedFileName, false, false);
}
}
// 更新済みの場合、localTaskListから削除
localTaskList.remove(taskDto);
// 添付ファイルが存在する場合、取得して解凍する。
try {
refreshTaskFile(operationId, taskReportDto.taskReportLevel, operationContentDto.contentId, serverTaskDto.taskId, serverTaskDto.taskKey, taskReportDto.attachedFileName);
} catch (Exception e) {
return null;
}
} else {
// 登録
for (TaskReportDto taskReportDto : taskDto.taskReportDtoList) {
String attachedFileName = taskReportDto.attachedFileName;
// 添付ファイルが存在する場合、取得して解凍する。
try {
refreshTaskFile(operationId, taskReportDto.taskReportLevel, operationContentDto.contentId, taskDto.taskId, taskDto.taskKey, taskReportDto.attachedFileName);
} catch (Exception e) {
return null;
}
if (taskReportDto.taskReportLevel == Constant.TaskReportLevel.ReportType) {
taskReportJson = new JSONObject(taskReportDto.jsonData);
taskReportJson.put(ABookKeys.TASK_STATUS, taskDto.taskStatus);
if (taskReportDto.taskReportLevel == Constant.TaskReportLevel.ReportType) {
taskReportJson = new JSONObject(taskReportDto.jsonData);
taskReportJson.put(ABookKeys.TASK_STATUS, serverTaskDto.taskStatus);
mOperationLogic.insertTaskReportLevel(taskDto.taskKey, operationContentDto.operationId, operationContentDto.contentId,
taskReportJson, taskDto.taskHotSpotInfo, attachedFileName, false, false);
} else {
if (taskReportDto.jsonData != null) {
mOperationLogic.insertTaskReportReplyLevel(taskDto.taskKey, operationContentDto.operationId, taskReportDto.taskReportLevel, operationContentDto.contentId,
new JSONObject(taskReportDto.jsonData), attachedFileName, false, false);
}
mOperationLogic.insertTaskReport(serverTaskDto.taskKey, operationContentDto.operationId, operationContentDto.contentId,
taskReportJson, serverTaskDto.taskHotSpotInfo, attachedFileName, false, false);
} else {
if (taskReportDto.jsonData != null) {
mOperationLogic.insertTaskReportReply(serverTaskDto.taskKey, operationContentDto.operationId, operationContentDto.contentId,
new JSONObject(taskReportDto.jsonData), attachedFileName, false, false);
}
}
}
progressCallback.callback(new Integer(progress));
}
// サーバーから取得した作業情報がローカルに存在しないので削除する
for (TaskDto taskDto : localTaskList) {
mOperationLogic.deleteTaskFileData(operationId, operationContentDto.contentId, taskDto.taskKey);
mTaskDao.delete(taskDto);
}
lastEditDate = json.lastEditDate;
}
progressCallback.callback(new Integer(progress));
}
// サーバーから取得した作業情報がローカルに存在しないので削除する
for (TaskDto taskDto : localTaskList) {
mOperationLogic.deleteTaskFileData(operationId, operationContentDto.contentId, taskDto.taskKey);
mTaskDao.delete(taskDto);
}
lastEditDate = json.lastEditDate;
progressCallback.callback(new Integer(40));
return lastEditDate;
......@@ -1033,48 +1009,27 @@ public class OperationListActivity extends ABVUIActivity {
// 既存の添付ディレクトリ削除
FileUtil.delete(ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey));
String reportLocalAttachedFileName = mRoutineTaskReportDao.getRoutineTaskReportAttachedFileName(taskKey, taskReportId, reportStartDateHypn);
int count = 0;
String reportLocalAttachedFileName = mTaskReportDao.getRoutineTaskReportAttachedFileName(taskKey, taskReportId, reportStartDateHypn);
boolean getReportFileFlg = !StringUtil.isNullOrEmpty(reportAttachedFileName) && !reportAttachedFileName.equals(reportLocalAttachedFileName);
if (mOperationAuthLevel == OperationAuthLevel.WORKER && getReportFileFlg) {
count++;
}
// 同期させるタスクの数をコンストラクタで渡す
final CountDownLatch latch = new CountDownLatch(count);
if (mOperationAuthLevel == OperationAuthLevel.WORKER && getReportFileFlg) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
Logger.i(TAG, "[Get Task Report Files] operationId=%s, taskKey=%s, taskId=%s, attachedFileName=%s", operationId, taskKey, taskId, reportAttachedFileName);
// #32926 start
int taskReportLevel = 0;
FileUtil.delete(ABVEnvironment.getInstance().getRoutineTaskReportDirFilePath(operationId, taskKey, taskReportId, reportStartDateNone, taskReportLevel));
// #32926 end
String outputFilePath = mOperationLogic.getRoutineTaskReportFile(operationId, taskKey, taskId, taskReportId, taskReportInfoId, reportStartDateNone, reportAttachedFileName);
// #32926 start
ContentFileExtractor.getInstance().extractZipFile(contentId, outputFilePath,
ABVEnvironment.getInstance().getRoutineTaskReportDirFilePath(operationId, taskKey, taskReportId, reportStartDateNone, taskReportLevel), null, true);
// #32926 end
} catch (Exception e) {
Logger.e(TAG, e);
ABVToastUtil.showMakeText(getApplicationContext(), R.string.msg_error_task_report_receiving_failed, Toast.LENGTH_LONG);
isSyncGetTaskFileError = true;
}
return null;
}
@Override
protected void onPostExecute(Void v) {
super.onPostExecute(v);
latch.countDown();
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
if (getReportFileFlg) {
try {
Logger.i(TAG, "[Get Task Report Files] operationId=%s, taskKey=%s, taskId=%s, attachedFileName=%s", operationId, taskKey, taskId, reportAttachedFileName);
// #32926 start
int taskReportLevel = 0;
FileUtil.delete(ABVEnvironment.getInstance().getRoutineTaskReportDirFilePath(operationId, taskKey, taskReportId, reportStartDateNone, taskReportLevel));
// #32926 end
String outputFilePath = mOperationLogic.getRoutineTaskReportFile(operationId, taskKey, taskId, taskReportId, taskReportInfoId, reportStartDateNone, reportAttachedFileName);
// #32926 start
ContentFileExtractor.getInstance().extractZipFile(contentId, outputFilePath,
ABVEnvironment.getInstance().getRoutineTaskReportDirFilePath(operationId, taskKey, taskReportId, reportStartDateNone, taskReportLevel), null, true);
// #32926 end
} catch (Exception e) {
Logger.e(TAG, e);
ABVToastUtil.showMakeText(getApplicationContext(), R.string.msg_error_task_report_receiving_failed, Toast.LENGTH_LONG);
isSyncGetTaskFileError = true;
}
}
// 上記の非同期の処理が終了するまで、待つ
latch.await();
}
/**
......@@ -1602,8 +1557,8 @@ public class OperationListActivity extends ABVUIActivity {
* @param rDto
* @return
*/
private boolean isExistsRoutineTaskReportInList(List<RoutineTaskReportDto> listDto, RoutineTaskReportDto rDto) {
for(RoutineTaskReportDto lDto:listDto) {
private boolean isExistsRoutinTaskReportInList(List<TaskReportDto> listDto, TaskReportDto rDto) {
for (TaskReportDto lDto : listDto) {
if (lDto.taskKey.equals(rDto.taskKey) &&
lDto.taskReportId == rDto.taskReportId &&
lDto.reportStartDate.equals(rDto.reportStartDate)) {
......
......@@ -143,7 +143,7 @@ public class OperationListAdapter extends AbstractOperationAdapter {
holder.lyPanoEditLayout.setVisibility(View.INVISIBLE);
}
if(mOperationAuthLevel == OperationAuthLevel.WORKER) {
if(operationDto.enableReportEdit == Constant.EnableReportEdit.NO) {
holder.lyPanoEditLayout.setVisibility(View.GONE);
}
......
......@@ -18,16 +18,12 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import jp.agentec.abook.abv.bl.acms.type.OperationAuthLevel;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.Callback;
import jp.agentec.abook.abv.bl.common.CommonExecutor;
import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.exception.ABVException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.ABVDataCache;
import jp.agentec.abook.abv.bl.dto.RoutineTaskReportDto;
import jp.agentec.abook.abv.bl.dto.OperationDto;
import jp.agentec.abook.abv.bl.dto.OperationTaskDto;
import jp.agentec.abook.abv.bl.dto.TaskDto;
......@@ -69,271 +65,107 @@ public class ABookCheckWebViewHelper extends ABookHelper {
* @param param
* @param operationId プロジェクトID
* @param contentPath
* @param routineTaskReportFlg
* @param reportType
* @param finishCallback
* @param taskReportLevel
*/
public void doABookCheckParam(ABVContentViewActivity context, String cmd, String taskKey, int enableReportHistory, Map<String, String> param, long operationId, String contentPath, long contentId, boolean routineTaskReportFlg, Callback finishCallback, int taskReportLevel) throws IOException {
public void doABookCheckParam(ABVContentViewActivity context, String cmd, String taskKey, int enableReportHistory, Map<String, String> param, long operationId, String contentPath, long contentId, int reportType, Callback finishCallback, int taskReportLevel) throws IOException {
int taskReportSendId = 0;
mFinishCallback = finishCallback;
// #32782 指示者テーブル関連削除 start
// TODO append
// int mOperationAuthLevel = ABVDataCache.getInstance().getMemberInfo().operationAuthLevel;
// #32782 指示者テーブル関連削除 end
// #32782 指示者テーブル関連削除 start
// TODO change
/*
switch (cmd) {
case ABookKeys.CMD_INSERT_TASK_DIRECTIONS:
// #32782 指示者テーブル関連削除 start
// TODO TASK_DIRECTIONS の削除
case ABookKeys.CMD_INSERT_TASK_REPORT:
insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, true, routineTaskReportFlg);
if (mOperationAuthLevel == OperationAuthLevel.OPERATION_INSTRUCTOR) {
copyTaskAttachedMovie(operationId, contentId, taskKey, String.valueOf(taskReportLevel));
sendTaskReportData(context, operationId, taskKey, -1, true);
} else {
sendTaskReportData(context, operationId, taskKey, enableReportHistory, false);
}
// #32782 指示者テーブル関連削除 end
insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, true, reportType, taskReportLevel);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
sendTaskData(context, operationId, taskKey, taskReportLevel);
break;
// TODO TASK_DIRECTIONS の削除
case ABookKeys.CMD_UPDATE_TASK_DIRECTIONS:
case ABookKeys.CMD_UPDATE_TASK_REPORT:
insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, false, routineTaskReportFlg);
if (mOperationAuthLevel == OperationAuthLevel.OPERATION_INSTRUCTOR) {
copyTaskAttachedMovie(operationId, contentId, taskKey, String.valueOf(taskReportLevel));
sendTaskReportData(context, operationId, taskKey, -1, true);
} else {
sendTaskReportData(context, operationId, taskKey, enableReportHistory, false);
}
insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, false, reportType, taskReportLevel);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
sendTaskData(context, operationId, taskKey, taskReportLevel);
break;
// #32782 指示者テーブル関連削除 start
case ABookKeys.CMD_DELETE_TASK_DIRECTIONS:
// TODO TASK_DIRECTIONS の削除
case ABookKeys.CMD_DELETE_TASK_REPORT:
int taskReportId = 0;
String reportStartDate = "";
boolean sendTaskReportDataFlg = false;
if (mOperationAuthLevel == OperationAuthLevel.OPERATION_INSTRUCTOR) {
mOperationLogic.deleteTaskReportReply(operationId, contentId, taskKey);
mOperationLogic.createJsonForOperationContent(operationId, enableReportHistory, contentPath, false);
copyTaskAttachedMovie(operationId, contentId, taskKey, String.valueOf(taskReportLevel));
sendTaskReportData(context, operationId, taskKey, -1, true);
} else {
if (routineTaskReportFlg) {
// TODO検討
// copyTaskAttachedMovie(operationId, contentId, taskKey, String.valueOf(taskReportLevel));
if (reportType == Constant.ReportType.Routine) {
taskReportId = Integer.valueOf(param.get(ABookKeys.TASK_REPORT_ID));
reportStartDate = param.get(ABookKeys.REPORT_START_DATE);
reportStartDate = reportStartDate.replace("T", " ");
reportStartDate = param.get(ABookKeys.REPORT_START_DATE).replace("T", " ");
mOperationLogic.deleteRoutineTaskReport(operationId, contentId, taskKey, taskReportId, reportStartDate);
mOperationLogic.createJsonForOperationContent(operationId, enableReportHistory, contentPath, false);
mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
copyRoutineTaskReportAttachedMovie(operationId, contentId, taskKey, taskReportId, reportStartDate);
RoutineTaskReportDto routineTaskTaskReportDto = mOperationLogic.getRoutineTaskReportUtc(taskKey, taskReportId, reportStartDate);
if (routineTaskTaskReportDto != null && enableReportHistory != Constant.OperationUpdateType.HISTORY_ADD) {
sendTaskReportDataFlg = true;
}
} else {
mOperationLogic.deleteTaskReportReply(operationId, contentId, taskKey);
mOperationLogic.createJsonForOperationContent(operationId, enableReportHistory, contentPath, false);
copyTaskAttachedMovie(operationId, contentId, taskKey, String.valueOf(taskReportLevel));
mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
}
TaskReportDto taskReportDto = mOperationLogic.getTaskReport(taskKey);
if (taskReportDto != null && enableReportHistory != Constant.OperationUpdateType.HISTORY_ADD) {
sendTaskReportDataFlg = true;
}
if (enableReportHistory == Constant.EnableReportHistory.Invalid) {
taskReportSendId = mOperationLogic.getLastTaskReportSendId(taskKey);
mOperationLogic.updateTaskReportSend(taskKey, taskReportId, reportStartDate, null, true);
deleteReportTaskSendFiles(operationId, taskKey, taskReportSendId, taskReportLevel);
} else if (enableReportHistory == Constant.EnableReportHistory.Enable) {
mOperationLogic.insertTaskReportSend(taskKey, taskReportId, reportStartDate, null, true);
}
if (sendTaskReportDataFlg) {
if (enableReportHistory == Constant.OperationUpdateType.HISTORY_NO) {
taskReportSendId = mOperationLogic.getLastTaskReportSendId(taskKey);
mOperationLogic.updateTaskReportSend(taskKey, taskReportId, reportStartDate, null, true);
deleteReportTaskSendFiles(operationId, taskKey, taskReportSendId);
} else if (enableReportHistory == Constant.OperationUpdateType.HISTORY_UPDATE) {
mOperationLogic.insertTaskReportSend(taskKey, taskReportId, reportStartDate, null, true);
}
sendTaskData(context, operationId, taskKey);
sendTaskReportData(context, operationId, taskKey, enableReportHistory, false);
} else {
mFinishCallback.callback(false);
}
}
break;
// #32782 指示者テーブル関連削除 end
case ABookKeys.CMD_MOVE_HOT_SPOT:
mOperationLogic.updateTaskHotspot(taskKey, param);
mOperationLogic.createHopSpotJson(operationId, contentPath);
break;
case ABookKeys.CMD_CANCEL_TASK_DIRECTIONS:
// case ABookKeys.CMD_CANCEL_TASK_DIRECTIONS:
case ABookKeys.CMD_CANCEL_TASK_REPORT:
FileUtil.delete(ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey));
mFinishCallback.callback(false);
break;
}
*/
switch (cmd) {
case ABookKeys.CMD_INSERT_TASK_DIRECTIONS:
insertOrUpdateTaskDirections(taskKey, operationId, contentId, param, contentPath, true);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
// sendTaskDirectionsData(context, operationId, taskKey);
break;
case ABookKeys.CMD_UPDATE_TASK_DIRECTIONS:
insertOrUpdateTaskDirections(taskKey, operationId, contentId, param, contentPath, false);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
// sendTaskDirectionsData(context, operationId, taskKey);
break;
case ABookKeys.CMD_DELETE_TASK_DIRECTIONS:
mOperationLogic.deleteTaskReport(operationId, contentId, taskKey);
// mOperationLogic.createJsonForOperationContent(operationId, contentPath, true);
mOperationLogic.createJsonForOperationContent(operationId, contentPath);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
// sendTaskDirectionsData(context, operationId, taskKey);
break;
case ABookKeys.CMD_MOVE_HOT_SPOT:
// #32926 作業報告画面改善 start
mOperationLogic.updateTaskHotspot(taskKey, param, taskReportLevel);
// #32926 作業報告画面改善 end
mOperationLogic.createHopSpotJson(operationId, contentPath);
break;
case ABookKeys.CMD_INSERT_TASK_REPORT:
insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, true, routineTaskReportFlg, taskReportLevel);
sendTaskReportData(context, operationId, taskKey, enableReportHistory);
break;
case ABookKeys.CMD_UPDATE_TASK_REPORT:
insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, false, routineTaskReportFlg, taskReportLevel);
sendTaskReportData(context, operationId, taskKey, enableReportHistory);
break;
// #32861 作業情報追加 start
// 一時保存処理
case ABookKeys.CMD_LOCAL_SAVE_TASK_REPORT:
insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, false, routineTaskReportFlg, taskReportLevel);
context.handleErrorMessageToast(R.string.msg_temp_save_result);
break;
// #32861 作業情報追加 end
case ABookKeys.CMD_DELETE_TASK_REPORT:
int taskReportId = 0;
String reportStartDate = "";
if (routineTaskReportFlg) {
taskReportId = Integer.valueOf(param.get(ABookKeys.TASK_REPORT_ID));
reportStartDate = param.get(ABookKeys.REPORT_START_DATE);
reportStartDate = reportStartDate.replace("T", " ");
mOperationLogic.deleteRoutineTaskReport(operationId, contentId, taskKey, taskReportId, reportStartDate);
// mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
mOperationLogic.createJsonForOperationContent(operationId, contentPath);
copyRoutineTaskReportAttachedMovie(operationId, contentId, taskKey, taskReportId, reportStartDate, taskReportLevel);
} else {
mOperationLogic.deleteTaskReportReply(operationId, contentId, taskKey, taskReportLevel);
// mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
mOperationLogic.createJsonForOperationContent(operationId, contentPath);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
}
if (enableReportHistory == Constant.EnableReportHistory.Invalid) {
taskReportSendId = mOperationLogic.getLastTaskReportSendId(taskKey);
mOperationLogic.updateTaskReportSend(taskKey, taskReportId, reportStartDate, null, true);
deleteReportTaskSendFiles(operationId, taskKey, taskReportSendId, taskReportLevel);
} else if (enableReportHistory == Constant.EnableReportHistory.Enable) {
mOperationLogic.insertTaskReportSend(taskKey, taskReportId, reportStartDate, null, true);
}
sendTaskReportData(context, operationId, taskKey, enableReportHistory);
break;
case ABookKeys.CMD_CANCEL_TASK_DIRECTIONS:
case ABookKeys.CMD_CANCEL_TASK_REPORT:
// #32926 作業報告画面改善 start
FileUtil.delete(ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey));
// #32926 作業報告画面改善 end
mFinishCallback.callback(false);
break;
}
// #32782 指示者テーブル関連削除 end
}
/**
* 作業指示データ送信処理
*
* @param context ABVContentViewActivity
* @param operationId プロジェクトID
* @param taskKey タスクキー
*/
private void sendTaskDirectionsData(final ABVContentViewActivity context, final long operationId, final String taskKey) {
// #32782 指示者テーブル関連削除 start
// TODO Delete mothod
Logger.d(TAG, "[sendTaskDirectionsData] operationId=%s, taskKey=%s", operationId, taskKey);
//作業指示送信時には「enableReportHistory」値が必要ではないので、「-1」に設定
sendTaskData(context, operationId, taskKey, -1, true);
// #32782 指示者テーブル関連削除 end
}
/**
* 作業報告データ送信処理
* @param context ABVContentViewActivity
* @param operationId プロジェクトID
* @param taskKey タスクキー
* @param reportUpdateType 作業履歴タイプ
*/
// #32782 指示者テーブル関連削除 start
// TODO change
/*
private void sendTaskReportData(final ABVContentViewActivity context, final long operationId, final String taskKey, final int enableReportHistory, final boolean isDirection) {
Logger.d(TAG, "[sendTaskReportData] operationId=%s, taskKey=%s", operationId, taskKey);
sendTaskData(context, operationId, taskKey, enableReportHistory, isDirection);
}
*/
private void sendTaskReportData(final ABVContentViewActivity context, final long operationId, final String taskKey, final int reportUpdateType) {
Logger.d(TAG, "[sendTaskReportData] operationId=%s, taskKey=%s", operationId, taskKey);
sendTaskData(context, operationId, taskKey, reportUpdateType, false);
}
// #32782 指示者テーブル関連削除 end
/**
* 作業報告・指示データ送信処理(共通)
* @param context ABVContentViewActivity
* @param operationId プロジェクトID
* @param taskKey タスクキー
* @param reportUpdateType 作業履歴タイプ
* @param isDirections 作業指示:true, 作業報告:false
*/
private void sendTaskData(final ABVContentViewActivity context, final long operationId, final String taskKey, final int reportUpdateType, final boolean isDirections) {
private void sendTaskData(final ABVContentViewActivity context, final long operationId, final String taskKey, final int taskReportLevel) {
// TODO 以下の処理見直し
// // ネットワーク通信チェック
// if (!ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
// mFinishCallback.callback(false);
// return;
// }
//
// final Callback progressCallback = new Callback() {
// @Override
// public Object callback(Object ret) {
// final int progress = (int)ret;
// context.runOnUiThread(new Runnable() {
// @Override
// public void run() {
// context.progressDialogHorizontal.setProgress(context.progressDialogHorizontal.getProgress() + progress);
// }
// });
// return null;
// }
// };
//
// context.showProgressView(context.getString(R.string.synchronizing));
// CommonExecutor.execute(new Runnable() {
// @Override
// public void run() {
// boolean isError = false;
// ネットワーク通信チェック
if (!ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
mFinishCallback.callback(false);
return;
}
final Callback progressCallback = new Callback() {
@Override
public Object callback(Object ret) {
final int progress = (int)ret;
context.runOnUiThread(new Runnable() {
@Override
public void run() {
context.progressDialogHorizontal.setProgress(context.progressDialogHorizontal.getProgress() + progress);
}
});
return null;
}
};
context.showProgressView(context.getString(R.string.synchronizing));
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
boolean isError = false;
// try {
// if (isDirections) {
// if (taskReportLevel == Constant.TaskReportLevel.ReportType) {
// // #32782 指示者テーブル関連削除 start
// // TODO change
//// mOperationLogic.sendTaskReportSendData(operationId, taskKey, progressCallback);
// mOperationLogic.sendTaskDirectionsData(operationId, taskKey, progressCallback);
// mOperationLogic.sendTaskReportSendData(operationId, taskKey, taskReportLevel, progressCallback);
// // #32782 指示者テーブル関連削除 end
// mOperationLogic.updateSyncOperation(operationId, true);
// } else {
......@@ -368,8 +200,8 @@ public class ABookCheckWebViewHelper extends ABookHelper {
// mFinishCallback.callback(isError);
// context.closeProgressPopup();
// }
// }
// });
}
});
}
public void doABookCheckParamPdf(long operationId, OperationTaskDto operationTaskDto, String contentPath) {
......@@ -461,13 +293,11 @@ public class ABookCheckWebViewHelper extends ABookHelper {
JSONObject taskDirectionsJson = new JSONObject(taskDirections);
String taskHotSpotInfo = param.get(ABookKeys.HOT_SPOT);
if (insertFlg) {
mOperationLogic.insertTaskReportLevel(taskKey, operationId, contentId, taskDirectionsJson, taskHotSpotInfo, null, attachedChangeFlag, true);
// mOperationLogic.createJsonForOperationContent(operationId, contentPath, true);
mOperationLogic.createJsonForOperationContent(operationId, contentPath);
mOperationLogic.insertTaskReport(taskKey, operationId, contentId, taskDirectionsJson, taskHotSpotInfo, null, attachedChangeFlag, true);
mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
} else {
mOperationLogic.updateTaskReportLevel(taskKey, operationId, contentId, taskDirectionsJson, taskHotSpotInfo, null, attachedChangeFlag, true);
// mOperationLogic.createJsonForOperationContent(operationId, contentPath, true);
mOperationLogic.createJsonForOperationContent(operationId, contentPath);
mOperationLogic.updateTaskReport(taskKey, operationId, contentId, taskDirectionsJson, taskHotSpotInfo, null, attachedChangeFlag, true);
mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
}
// #32782 指示者テーブル関連削除 end
}
......@@ -500,7 +330,7 @@ public class ABookCheckWebViewHelper extends ABookHelper {
// 指示者の場合下記の処理を行わない
if (mOperationAuthLevel == OperationAuthLevel.OPERATION_INSTRUCTOR) {
if (insertFlg) {
mOperationLogic.insertTaskReportReplyLevel(taskKey, operationId, contentId, taskReportJson, null, attachedChangeFlag, true, taskHotSpotInfo);
mOperationLogic.insertTaskReportReply(taskKey, operationId, contentId, taskReportJson, null, attachedChangeFlag, true, taskHotSpotInfo);
mOperationLogic.createJsonForOperationContent(operationId, enableReportHistory, contentPath, false);
} else {
mOperationLogic.updateTaskReportReplyLevel(taskKey, operationId, contentId, taskReportJson, null, attachedChangeFlag, true, taskHotSpotInfo);
......@@ -519,7 +349,7 @@ public class ABookCheckWebViewHelper extends ABookHelper {
mOperationLogic.updateRoutineTaskReport(operationId, contentId, routineTaskTaskReportDto, attachedChangeFlag, true, insertFlg, true);
} else {
if (insertFlg) {
mOperationLogic.insertTaskReportReplyLevel(taskKey, operationId, contentId, taskReportJson, null, attachedChangeFlag, true, taskHotSpotInfo);
mOperationLogic.insertTaskReportReply(taskKey, operationId, contentId, taskReportJson, null, attachedChangeFlag, true, taskHotSpotInfo);
} else {
mOperationLogic.updateTaskReportReplyLevel(taskKey, operationId, contentId, taskReportJson, null, attachedChangeFlag, true, taskHotSpotInfo);
}
......@@ -560,7 +390,7 @@ public class ABookCheckWebViewHelper extends ABookHelper {
}
}
*/
private void insertOrUpdateTaskReport(String taskKey, int reportUpdateType, long operationId, long contentId, Map<String, String> param, String contentPath, boolean insertFlg, boolean routineTaskReportFlg, int taskReportLevel) throws IOException {
private void insertOrUpdateTaskReport(String taskKey, int reportUpdateType, long operationId, long contentId, Map<String, String> param, String contentPath, boolean insertFlg, int reportType, int taskReportLevel) throws IOException {
int taskReportSendId = 0;
boolean attachedChangeFlag = param.get(ABookKeys.ATTACHED_CHANGE_FLAG).equals("1") ? true : false;
String taskReport = param.get(ABookKeys.TASK_REPORT);
......@@ -568,33 +398,39 @@ public class ABookCheckWebViewHelper extends ABookHelper {
int taskReportId = 0;
String reportStartDate = "";
if (routineTaskReportFlg) {
if (reportType == Constant.ReportType.Routine) {
taskReportId = Integer.valueOf(param.get(ABookKeys.TASK_REPORT_ID));
reportStartDate = param.get(ABookKeys.REPORT_START_DATE);
reportStartDate = reportStartDate.replace("T", " ");
//reportStartDate = DateTimeUtil.toString(DateTimeUtil.toDate(reportStartDate, "UTC", DateTimeFormat.yyyyMMddHHmmss_hyphen), DateTimeFormat.yyyyMMddHHmmss_hyphen);
RoutineTaskReportDto routineTaskTaskReportDto = mOperationLogic.getRoutineTaskReportUtc(taskKey, taskReportId, reportStartDate);
routineTaskTaskReportDto.jsonData = taskReport;
TaskReportDto taskReportDto = mOperationLogic.getRoutineTaskReportUtc(taskKey, taskReportId, reportStartDate);
taskReportDto.jsonData = taskReport;
mOperationLogic.updateRoutineTaskReport(operationId, contentId, routineTaskTaskReportDto, attachedChangeFlag, true, insertFlg, true);
mOperationLogic.updateRoutineTaskReport(operationId, contentId, taskReportDto, attachedChangeFlag, true, insertFlg, true);
} else {
if (insertFlg) {
// #32926 作業報告画面改善 start
mOperationLogic.insertTaskReportReplyLevel(taskKey, operationId, taskReportLevel, contentId, taskReportJson, null, attachedChangeFlag, true);
// #32926 作業報告画面改善 end
} else {
mOperationLogic.updateTaskReportReplyLevel(taskKey, taskReportLevel, operationId, contentId, taskReportJson, null, attachedChangeFlag, true);
}
if (taskReportLevel == Constant.TaskReportLevel.ReportType) {
String hotSpotInfo = param.get(ABookKeys.HOT_SPOT);
if (insertFlg) {
mOperationLogic.insertTaskReport(taskKey, operationId, contentId, taskReportJson, hotSpotInfo, null, attachedChangeFlag, true);
} else {
mOperationLogic.updateTaskReport(taskKey, operationId, contentId, taskReportJson, hotSpotInfo, null, attachedChangeFlag, true);
}
} else {
if (insertFlg) {
mOperationLogic.insertTaskReportReply(taskKey, operationId, contentId, taskReportJson, null, attachedChangeFlag, true);
} else {
mOperationLogic.updateTaskReportReplyLevel(taskKey, operationId, contentId, taskReportJson, null, attachedChangeFlag, true);
}
}
}
if (routineTaskReportFlg) {
// mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
mOperationLogic.createJsonForOperationContent(operationId, contentPath);
copyRoutineTaskReportAttachedMovie(operationId, contentId, taskKey, taskReportId, reportStartDate, taskReportLevel);
if (reportType == Constant.ReportType.Routine) {
mOperationLogic.createJsonForOperationContent(operationId, contentPath, true);
copyRoutineTaskReportAttachedMovie(operationId, contentId, taskKey, taskReportId, reportStartDate);
} else {
// mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
mOperationLogic.createJsonForOperationContent(operationId, contentPath);
mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
}
......@@ -606,7 +442,7 @@ public class ABookCheckWebViewHelper extends ABookHelper {
}
// #32926 作業報告画面改善 start
copyReportTaskSendFiles(operationId, taskKey, taskReportSendId, routineTaskReportFlg, taskReportId, reportStartDate, taskReportLevel);
copyReportTaskSendFiles(operationId, taskKey, taskReportSendId, reportType == Constant.ReportType.Routine, taskReportId, reportStartDate, taskReportLevel);
// #32926 作業報告画面改善 end
if (reportUpdateType == Constant.EnableReportHistory.Enable) {
......@@ -625,9 +461,9 @@ public class ABookCheckWebViewHelper extends ABookHelper {
List<TaskDto> taskDtoList = mOperationLogic.getOperationTask(operationId);
for (TaskDto taskDto : taskDtoList) {
if (operationDto.reportType == Constant.OperationReportType.ROUTINE_TASK) {
List<RoutineTaskReportDto> listRoutineTaskReport = mOperationLogic.getRoutineTaskReportByTaskKey(taskDto.taskKey);
for (RoutineTaskReportDto routineTaskDto : listRoutineTaskReport) {
copyRoutineTaskReportAttachedMovie(operationId, contentId, routineTaskDto.taskKey, routineTaskDto.taskReportId, routineTaskDto.reportStartDate, 0);
List<TaskReportDto> listRoutineTaskReport = mOperationLogic.getRoutineTaskReportByTaskKey(taskDto.taskKey);
for (TaskReportDto routineTaskDto : listRoutineTaskReport) {
copyRoutineTaskReportAttachedMovie(operationId, contentId, routineTaskDto.taskKey, routineTaskDto.taskReportId, routineTaskDto.reportStartDate);
}
} else {
// #32926 作業報告画面改善 start
......@@ -651,7 +487,7 @@ public class ABookCheckWebViewHelper extends ABookHelper {
* @param objReportStartDate
* @throws IOException
*/
public void copyRoutineTaskReportAttachedMovie(long operationId, long contentId, String taskKey, int taskReportId, Object objReportStartDate, int taskReportLevel) throws IOException {
public void copyRoutineTaskReportAttachedMovie(long operationId, long contentId, String taskKey, int taskReportId, Object objReportStartDate) throws IOException {
String reportStartDate;
if (objReportStartDate instanceof String) {
reportStartDate = DateTimeUtil.toString_yyyyMMddHHmmss_none(DateTimeUtil.toDate((String)objReportStartDate, DateTimeFormat.yyyyMMddHHmmss_hyphen));
......@@ -661,7 +497,7 @@ public class ABookCheckWebViewHelper extends ABookHelper {
return;
}
String taskKeyPath = ABVEnvironment.getInstance().getRoutineTaskReportDirFilePath(operationId, taskKey, taskReportId, reportStartDate, taskReportLevel);
String taskKeyPath = ABVEnvironment.getInstance().getRoutineTaskReportDirFilePath(operationId, taskKey, taskReportId, reportStartDate, 0);
File taskKeyFile = new File(taskKeyPath);
// 作業報告書の添付ファイル(mp4,mov拡張子のみ)コピー
......@@ -702,21 +538,21 @@ public class ABookCheckWebViewHelper extends ABookHelper {
}
}
}
// 作業報告書の添付ファイル(mp4,mov拡張子のみ)コピー
if (ABVDataCache.getInstance().getMemberInfo().operationAuthLevel == OperationAuthLevel.WORKER) {
taskKeyPath = ABVEnvironment.getInstance().getOperationDirectionOrReportDirPath(operationId, taskKey, taskReportLevel);
taskKeyFile = new File(taskKeyPath);
if (taskKeyFile.exists()) {
String attachedMoviesFilePath = ABVEnvironment.getInstance().getAttachedDirectionOrReportDirPath(contentId, taskKey, taskReportLevel);
FileUtil.delete(attachedMoviesFilePath);
FileUtil.createNewDirectory(attachedMoviesFilePath);
for (String taskAttachedFile : taskKeyFile.list()) {
if (StringUtil.endsWithAny(taskAttachedFile.toLowerCase(), "mov", "mp4")) {
FileUtil.copy(taskKeyPath + "/" + taskAttachedFile, attachedMoviesFilePath + "/" + taskAttachedFile, true);
}
}
}
}
// // 作業報告書の添付ファイル(mp4,mov拡張子のみ)コピー
// if (ABVDataCache.getInstance().getMemberInfo().operationAuthLevel == OperationAuthLevel.WORKER) {
// taskKeyPath = ABVEnvironment.getInstance().getOperationDirectionOrReportDirPath(operationId, taskKey, taskReportLevel);
// taskKeyFile = new File(taskKeyPath);
// if (taskKeyFile.exists()) {
// String attachedMoviesFilePath = ABVEnvironment.getInstance().getAttachedDirectionOrReportDirPath(contentId, taskKey, taskReportLevel);
// FileUtil.delete(attachedMoviesFilePath);
// FileUtil.createNewDirectory(attachedMoviesFilePath);
// for (String taskAttachedFile : taskKeyFile.list()) {
// if (StringUtil.endsWithAny(taskAttachedFile.toLowerCase(), "mov", "mp4")) {
// FileUtil.copy(taskKeyPath + "/" + taskAttachedFile, attachedMoviesFilePath + "/" + taskAttachedFile, true);
// }
// }
// }
// }
}
/**
......
......@@ -4954,14 +4954,10 @@ public class ContentViewActivity extends ABVContentViewActivity {
String cmd = checkParam.get(ABookKeys.CMD);
switch (cmd) {
case ABookKeys.CMD_INSERT_TASK_DIRECTIONS: // 作業指示の登録
case ABookKeys.CMD_UPDATE_TASK_DIRECTIONS: // 作業指示の更新
case ABookKeys.CMD_DELETE_TASK_DIRECTIONS: // 作業指示の削除
case ABookKeys.CMD_INSERT_TASK_REPORT: // 作業報告の登録
case ABookKeys.CMD_UPDATE_TASK_REPORT: // 作業報告の更新
case ABookKeys.CMD_DELETE_TASK_REPORT: // 作業報告の削除
getTaskHotspotJSON();
case ABookKeys.CMD_CANCEL_TASK_DIRECTIONS: // 作業指示のキャンセル
case ABookKeys.CMD_CANCEL_TASK_REPORT: // 作業報告のキャンセル
if(operationTaskDto != null) {
updateOperationTaskPosition(operationTaskDto.pdfX, operationTaskDto.pdfY);
......@@ -5183,8 +5179,6 @@ public class ContentViewActivity extends ABVContentViewActivity {
if (operationTaskLayout.currentLayout != null && !StringUtil.isNullOrEmpty(taskKey)) {
switch(cmd){
case ABookKeys.CMD_INSERT_TASK_DIRECTIONS:
case ABookKeys.CMD_UPDATE_TASK_DIRECTIONS:
// #32782 指示者テーブル関連削除 start
case ABookKeys.CMD_INSERT_TASK_REPORT:
case ABookKeys.CMD_UPDATE_TASK_REPORT:
......@@ -5204,10 +5198,10 @@ public class ContentViewActivity extends ABVContentViewActivity {
}
// #32782 指示者テーブル関連削除 end
break;
case ABookKeys.CMD_DELETE_TASK_DIRECTIONS:
operationTaskLayout.setIconStatus(taskKey, true);
//hideOperationTaskLayout();
break;
// case ABookKeys.CMD_DELETE_TASK_DIRECTIONS:
// operationTaskLayout.setIconStatus(taskKey, true);
// //hideOperationTaskLayout();
// break;
default:
operationTaskLayout.setIconStatus(taskKey, 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