Commit aefef9c5 by Lee Jaebin

#32777 報告・報告(回答)の登録・更新・削除処理のまとめ

parent d17f9d1c
......@@ -257,6 +257,36 @@ public class AbstractDao {
}
/**
* クエリを実行し、最初の行の最初の列の値をlong型で返します。
*
* stmt.simpleQueryForLong()と同じ
*
* @param sql
* @param bindArgs
* @return
* @throws Exception
*/
public long rawQueryGetLong(String sql, String[] bindArgs) {
SQLiteDatabase db = dbConn.getDatabase();
Cursor cursor = null;
try {
if (Logger.isVerboseEnabled()) {
Logger.v(TAG, "%s [%s]", sql, join(bindArgs));
}
cursor = db.rawQuery(sql, bindArgs);
if (cursor.moveToNext()) {
return cursor.getLong(0);
}
return 0;
}
finally {
if (cursor != null) {
cursor.close();
}
}
}
/**
* クエリを実行し、最初の行の最初の列の値をInteger型リストで返します。
*
* @param sql
......
......@@ -56,9 +56,9 @@ public class TaskReportDao extends AbstractDao {
if (column != -1) {
dto.delFlg = toBool(cursor.getInt(column));
}
column = cursor.getColumnIndex("reported_flag");
column = cursor.getColumnIndex("reported_flg");
if (column != -1) {
dto.reportedFlag = toBool(cursor.getInt(column));
dto.reportedFlg = toBool(cursor.getInt(column));
}
column = cursor.getColumnIndex("enable_report");
......@@ -70,6 +70,17 @@ public class TaskReportDao extends AbstractDao {
if (column != -1) {
dto.taskReportLevel = cursor.getInt(column);
}
column = cursor.getColumnIndex("report_start_date");
if (column != -1) {
dto.reportStartDate = DateTimeUtil.toDate(cursor.getString(column), "UTC", DateTimeFormat.yyyyMMddHHmmss_hyphen);
}
column = cursor.getColumnIndex("report_end_date");
if (column != -1) {
dto.reportEndDate = DateTimeUtil.toDate(cursor.getString(column), "UTC", DateTimeFormat.yyyyMMddHHmmss_hyphen);
}
return dto;
}
......@@ -208,8 +219,14 @@ 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, int taskReportLevel) {
return rawQueryGetDtoList("select * from t_task_report where task_key=? and task_report_level=?", new String[]{ "" + taskKey, "" + taskReportLevel }, TaskReportDto.class);
/**
* 報告キー、報告担当レベルでt_task_Reportデータ取得
* @param taskKey
* @param taskReportLevel
* @return
*/
public TaskReportDto selectByTaskKey(String taskKey, int taskReportLevel) {
return rawQueryGetDto("select * from t_task_report where task_key=? and task_report_level=?", new String[]{ "" + taskKey, "" + taskReportLevel }, TaskReportDto.class);
}
public List<TaskReportDto> selectAll() {
......@@ -238,11 +255,11 @@ public class TaskReportDao extends AbstractDao {
+ "attached_file_name=?, "
+ "local_attached_file_name=?, "
+ "json_data=?, "
+ "data_send_flag=?, "
+ "attached_file_send_flag=? "
+ "reported_flag=? "
+ "data_send_flg=?, "
+ "attached_file_send_flg=? "
+ "reported_flg=? "
+ "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.reportedFlag, dto.taskKey, dto.taskReportId, dto.reportStartDate});
new Object[]{dto.reportEndDate, dto.attachedFileName, dto.localAttachedFileName, dto.jsonData, dto.dataSendFlg, dto.attachedFileSendFlg, dto.reportedFlg, dto.taskKey, dto.taskReportId, dto.reportStartDate});
return count > 0;
}
......
......@@ -48,6 +48,17 @@ public class TaskReportItemsDao extends AbstractDao {
return rawQueryGetDtoList("select * from t_task_report_items where task_key=? and task_report_level=?", new String[]{"" + taskKey, "" + taskReportLevel}, TaskReportItemsDto.class);
}
/**
* 報告キー、報告担当レベル、itemKeyでデータ取得
* @param taskKey
* @param taskReportLevel
* @param itemKey
* @return
*/
public TaskReportItemsDto getTaskReportItem(String taskKey, int taskReportLevel, String itemKey) {
return rawQueryGetDto("SELECT * FROM t_task_report_items WHERE task_key=? AND task_report_level=? AND item_key=?", new String[]{"" + taskKey, "" + taskReportLevel, "" + itemKey}, TaskReportItemsDto.class);
}
public List<TaskReportItemsDto> getTaskReportItemByOperationId(Long operationId) {
StringBuilder sb = new StringBuilder();
sb.append(" select distinct ttri.* ");
......
......@@ -24,6 +24,7 @@ public class TTaskReportItems extends SQLiteTableScript {
sql.append(" CREATE TABLE t_task_report_items ( ");
sql.append(" task_key TEXT NOT NULL ");
sql.append(" , task_report_level INTEGER default 0 ");
sql.append(" , item_key VARCHAR(64) ");
sql.append(" , input_value VARCHAR(64) ");
sql.append(" ) ");
......
......@@ -23,7 +23,7 @@ public class OperationDto extends AbstractDto {
public List<OperationContentDto> operationContentDtoList;
public List<TaskDto> taskDtoList;
public List<PushMessageDto> pushMessageList;
public int reportType; //0:通常 1:定期点検
public int reportType; // 報告タイプ 0 : 報告 1 : 定期点検 2 : 報告(回答)
public int reportCycle; //0:日次 1:月次 2:年次
public int enableReportUpdate; //0:不可 1:可
public String reportPeriod; //定期点検、2018/12/20 08:10:00 ~ 2018/12/21 18:10:00
......
......@@ -25,16 +25,16 @@ public class TaskReportDto extends AbstractDto {
public int enableReport; // 報告可能区分
public String attachedFileName;
public String taskReportInfo;
public boolean reportedFlag; // 定期点検用
public boolean reportedFlg; // 定期点検用
@Override
public Object[] getInsertValues() {
return new Object[] { taskKey, jsonData, attachedFileName, localAttachedFileName, attachedFileSendFlg, dataSendFlg, taskReportId, taskReportInfoId, reportStartDate, reportEndDate, enableReport, reportedFlag, taskReportLevel};
return new Object[] { taskKey, jsonData, attachedFileName, localAttachedFileName, attachedFileSendFlg, dataSendFlg, taskReportId, taskReportInfoId, reportStartDate, reportEndDate, enableReport, reportedFlg, taskReportLevel};
}
@Override
public Object[] getUpdateValues() {
return new Object[] { jsonData, attachedFileName, localAttachedFileName, attachedFileSendFlg, dataSendFlg, taskReportId, taskReportInfoId, reportStartDate, reportEndDate, enableReport, reportedFlag, taskReportLevel, taskKey, taskReportLevel };
return new Object[] { jsonData, attachedFileName, localAttachedFileName, attachedFileSendFlg, dataSendFlg, taskReportId, taskReportInfoId, reportStartDate, reportEndDate, enableReport, reportedFlg, taskReportLevel, taskKey, taskReportLevel };
}
@Override
......
......@@ -248,69 +248,51 @@ public class OperationLogic extends AbstractLogic {
*
* @param taskKey
* @param operationId
* @param contentId
* @param taskDirectionsJson
* @param hotSpotInfo
* @param attachedChangeFlag
* @param dataSendFlg
* @throws IOException
*/
public void insertTaskReport(String taskKey, long operationId, long contentId, int enableReport, JSONObject taskDirectionsJson, String hotSpotInfo, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
public void insertTaskReport(String taskKey, long operationId, long contentId, int reportLevel, int enableReport, JSONObject taskReportJson, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
TaskDto taskDto = mTaskDao.getTaskByTaskKey(taskKey);
if (taskDto == null) {
//TODO error
return;
}
TaskDto taskDto = new TaskDto();
TaskReportDto taskReportDto = new TaskReportDto();
JSONObject suggestJson = taskDirectionsJson.getJSONObject("suggest");
taskDto.taskKey = taskKey;
taskDto.operationId = operationId;
taskDto.taskHotSpotInfo = hotSpotInfo;
taskReportDto.taskKey = taskKey;
Iterator taskKeys = suggestJson.keys();
while (taskKeys.hasNext()) {
TaskReportItemsDto taskReportItemsDto = new TaskReportItemsDto();
String itemKey = (String) taskKeys.next();
if (itemKey.startsWith("q_1_")) {
taskDto.taskCode = suggestJson.getString(itemKey);
}
taskReportItemsDto.taskKey = taskKey;
taskReportItemsDto.itemKey = itemKey;
taskReportItemsDto.taskReportLevel = Constant.TaskReportLevel.ReportType;
try {
taskReportItemsDto.inputValue = suggestJson.getString(itemKey);
} catch (JSONException e) {
// 値がStringではない場合、無視する
continue;
}
mTaskReportItemsDao.insertTaskReportItems(taskReportItemsDto);
if (taskReportJson != null) {
// suggest登録・更新処理
registTaskReportItem(taskKey, reportLevel, taskReportJson.getJSONObject("suggest"));
taskReportDto.jsonData = taskReportJson.toString();
} else {
// taskJsonがnullの場合、jsonDataに空でセット
taskReportDto.jsonData = "";
}
taskReportDto.taskKey = taskKey;
taskReportDto.jsonData = taskDirectionsJson.toString();
taskReportDto.dataSendFlg = dataSendFlg;
taskReportDto.attachedFileSendFlg = attachedChangeFlag;
// 作業報告
taskReportDto.taskReportLevel = Constant.TaskReportLevel.ReportType;
taskReportDto.taskReportLevel = reportLevel;
// 報告可能区分
taskReportDto.enableReport = enableReport;
if (localAttachedFileName != null) {
taskReportDto.localAttachedFileName = localAttachedFileName;
}
if (taskDirectionsJson.has(ABookKeys.TASK_STATUS)) {
taskDto.taskStatus = taskDirectionsJson.getInt(ABookKeys.TASK_STATUS);
}
mTaskReportDao.insert(taskReportDto);
mTaskDao.insert(taskDto);
if (taskReportJson != null) {
String tempDirPath = ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey);
//添付ファイル変更の場合、以下の処理を行う
JSONObject attachedListJson = taskDirectionsJson.getJSONObject("attached");
JSONObject attachedListJson = taskReportJson.getJSONObject("attached");
List<String> attachedFileNames = JSONObject.getValues(attachedListJson);
// コピー元のファイルで、添付ファイルとして使用しないファイル削除
deleteDifferentialFile(tempDirPath, attachedFileNames);
String operationDrectionOrReportDirPath = ABVEnvironment.getInstance().getOperationDirectionOrReportDirPath(operationId, taskKey, Constant.TaskReportLevel.ReportType);
String operationDrectionOrReportDirPath = ABVEnvironment.getInstance().getOperationDirectionOrReportDirPath(operationId, taskKey, reportLevel);
// 添付ディレクトリの移動
boolean result = FileUtil.copy(tempDirPath, operationDrectionOrReportDirPath, true);
......@@ -318,53 +300,31 @@ public class OperationLogic extends AbstractLogic {
FileUtil.delete(tempDirPath);
}
}
}
/**
* 作業報告を更新
* @param taskKey
* @param operationId
* @param contentId
* @param taskReportJson
* @param hotSpotInfo
* @param localAttachedFileName
* @param attachedChangeFlag
* @param dataSendFlg
* @throws IOException
*/
public void updateTaskReport(String taskKey, long operationId, long contentId, int enableReport, JSONObject taskReportJson, String hotSpotInfo, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
TaskDto taskDto = mTaskDao.getTaskByTaskKey(taskKey);
if (taskDto == null) {
// ignore
Logger.w(TAG, "taskDto is null");
public void updateTaskReport(String taskKey, long operationId, long contentId, int taskReportLevel, int enableReport, JSONObject taskReportJson, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
TaskReportDto taskReportDto = mTaskReportDao.getTaskReport(taskKey, taskReportLevel);
if (taskReportDto == null) {
//TODO error?
return;
}
TaskReportDto taskReportDto = mTaskReportDao.getTaskReport(taskKey, Constant.TaskReportLevel.ReportType);
taskDto.operationId = operationId;
taskDto.taskHotSpotInfo = hotSpotInfo;
JSONObject suggestJson = taskReportJson.getJSONObject("suggest");
// suggest登録・更新処理
registTaskReportItem(taskKey, taskReportLevel, taskReportJson.getJSONObject("suggest"));
List<TaskReportItemsDto> taskReportItemsDtoList = mTaskReportItemsDao.getTaskReportItemByTaskKey(taskKey, Constant.TaskReportLevel.ReportType);
for (TaskReportItemsDto taskReportItemsDto : taskReportItemsDtoList) {
try {
String newValue = suggestJson.getString(taskReportItemsDto.itemKey);
if (!newValue.equals(taskReportItemsDto.inputValue)) {
// 値が異なる場合のみ、更新する
taskReportItemsDto.inputValue = newValue;
if (taskReportItemsDto.itemKey.startsWith("q_1_")) {
// 値が異なるため、作業コードの入力値を変更する
taskDto.taskCode = taskReportItemsDto.inputValue;
}
mTaskReportItemsDao.updateTaskReportItems(taskReportItemsDto);
}
} catch (JSONException e) {
// 値がStringではない場合、無視する
continue;
}
}
taskReportDto.jsonData = taskReportJson.toString();
taskReportDto.dataSendFlg = dataSendFlg;
// 作業報告階層
taskReportDto.taskReportLevel = Constant.TaskReportLevel.ReportType;
taskReportDto.taskReportLevel = taskReportLevel;
// 報告可能区分
taskReportDto.enableReport = enableReport;
......@@ -376,15 +336,11 @@ public class OperationLogic extends AbstractLogic {
taskReportDto.localAttachedFileName = localAttachedFileName;
}
if (taskReportJson.has(ABookKeys.TASK_STATUS)) {
taskDto.taskStatus = taskReportJson.getInt(ABookKeys.TASK_STATUS);
}
mTaskReportDao.update(taskReportDto);
mTaskDao.update(taskDto);
String tempDirPath = ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey);
String operationDrectionOrReportDirPath = ABVEnvironment.getInstance().getOperationDirectionOrReportDirPath(operationId, taskKey, Constant.TaskReportLevel.ReportType);
String operationDrectionOrReportDirPath = ABVEnvironment.getInstance().getOperationDirectionOrReportDirPath(operationId, taskKey, taskReportLevel);
if (taskReportDto.attachedFileSendFlg) {
//添付ファイル変更の場合、以下の処理を行う
JSONObject attachedListJson = taskReportJson.getJSONObject("attached");
......@@ -404,110 +360,40 @@ public class OperationLogic extends AbstractLogic {
}
/**
* 作業報告の削除
* 作業報告/作業報告(回答)の削除
*
* @param operationId
* @param contentId
* @param taskKey
*/
public void deleteTaskReport(long operationId, long contentId, String taskKey) {
public void deleteTaskReport(long operationId, long contentId, String taskKey, int taskReportLevel) {
TaskDto taskDto = mTaskDao.getTaskByTaskKey(taskKey);
if (taskDto == null) {
return;
}
TaskReportDto taskReportDto = mTaskReportDao.getTaskReport(taskKey, Constant.TaskReportLevel.ReportType);
TaskReportDto taskReportDto = mTaskReportDao.getTaskReport(taskKey, taskReportLevel);
if (taskReportDto != null) {
taskReportDto.dataSendFlg = true;
taskReportDto.attachedFileSendFlg = false;
if (taskReportDto.taskReportLevel == Constant.TaskReportLevel.ReportType) {
// 報告
taskDto.delFlg = true;
mTaskReportDao.update(taskReportDto);
mTaskDao.update(taskDto);
// プロジェクトの作業データディレクトリ削除
deleteTaskFileData(operationId, contentId, taskKey);
}
/**
* 作業報告(回答)の登録
* @param taskKey
* @param operationId
* @param contentId
* @param taskReportJson
* @param localAttachedFileName
* @param attachedChangeFlag
* @param dataSendFlg
* @throws IOException
*/
public void insertTaskReportReply(String taskKey, long operationId, long contentId, int enableReport, JSONObject taskReportJson, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
TaskDto taskDto = mTaskDao.getTaskByTaskKey(taskKey);
if (taskDto == null) {
//TODO error
return;
}
TaskReportDto taskReportDto = new TaskReportDto();
// taskReportJsonがnullではない場合のみ以下の処理を行う
if (taskReportJson != null) {
JSONObject suggestJson = taskReportJson.getJSONObject("suggest");
Iterator taskKeys = suggestJson.keys();
while (taskKeys.hasNext()) {
TaskReportItemsDto taskReportItemsDto = new TaskReportItemsDto();
String itemKey = (String) taskKeys.next();
if (itemKey.startsWith("q_3_")) {
taskDto.taskStatus = suggestJson.getInt(itemKey);
}
taskReportItemsDto.taskKey = taskKey;
taskReportItemsDto.itemKey = itemKey;
try {
taskReportItemsDto.inputValue = suggestJson.getString(itemKey);
} catch (JSONException e) {
// 値がStringではない場合、無視する
continue;
}
mTaskReportItemsDao.insertTaskReportItems(taskReportItemsDto);
}
taskReportDto.jsonData = taskReportJson.toString();
} else {
// 報告(回答)
taskReportDto.jsonData = "";
taskDto.taskStatus = 0;
}
taskReportDto.taskKey = taskKey;
taskReportDto.dataSendFlg = dataSendFlg;
taskReportDto.attachedFileSendFlg = attachedChangeFlag;
taskReportDto.taskReportLevel = Constant.TaskReportLevel.ReportReplyType;
taskReportDto.enableReport = enableReport;
// 削除の時、deleteではなく、jsonDataを空にして、データが残っているので、updateする
List<TaskReportDto> taskReport = mTaskReportDao.selectByTaskKey(taskReportDto.taskKey, Constant.TaskReportLevel.ReportReplyType);
if (taskReport.size() > 0) {
mTaskReportDao.update(taskReportDto);
} else {
mTaskReportDao.insert(taskReportDto);
}
mTaskDao.update(taskDto);
if (taskReportJson != null) {
//添付ファイル変更の場合、以下の処理を行う
String tempDirPath = ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey);
String operationDrectionOrReportDirPath = ABVEnvironment.getInstance().getOperationTaskReportLevelDirPath(operationId, taskKey, Constant.TaskReportLevel.ReportReplyType);
JSONObject attachedListJson = taskReportJson.getJSONObject("attached");
List<String> attachedFileNames = JSONObject.getValues(attachedListJson);
// コピー元のファイルで、添付ファイルとして使用しないファイル削除
deleteDifferentialFile(tempDirPath, attachedFileNames);
// 添付ディレクトリの移動
boolean result = FileUtil.copy(tempDirPath, operationDrectionOrReportDirPath, true);
if (result) {
FileUtil.delete(tempDirPath);
}
// プロジェクトの作業データディレクトリ削除
deleteTaskFileData(operationId, contentId, taskKey, taskReportLevel);
}
}
/**
* 定期点検データ新規
* @param operationId
* @param contentId
* @param taskReportDto
* @param attachedChangeFlag
* @param dataSendFlg
......@@ -539,6 +425,7 @@ public class OperationLogic extends AbstractLogic {
//添付ファイル変更の場合、以下の処理を行う
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);
......@@ -556,74 +443,9 @@ public class OperationLogic extends AbstractLogic {
}
}
public void updateTaskReportReply(String taskKey, long operationId, long contentId, int enableReport, JSONObject taskReport, String localAttachedFileName, boolean attachedChangeFlag, boolean dataSendFlg) throws IOException {
TaskReportDto taskReportDto = mTaskReportDao.getTaskReport(taskKey, Constant.TaskReportLevel.ReportReplyType);
if (taskReportDto == null) {
Logger.w(TAG, "taskReportDto is null");
// #32926 作業報告画面改善 start
insertTaskReportReply(taskKey, operationId, contentId, enableReport, taskReport, localAttachedFileName, attachedChangeFlag, dataSendFlg);
// #32926 作業報告画面改善 end
return;
}
JSONObject suggestJson = taskReport.getJSONObject("suggest");
TaskDto taskDto = mTaskDao.getTaskByTaskKey(taskKey);
List<TaskReportItemsDto> taskReportItemsDaoList = mTaskReportItemsDao.getTaskReportItemByTaskKey(taskKey, Constant.TaskReportLevel.ReportReplyType);
for (TaskReportItemsDto taskReportItemsDto : taskReportItemsDaoList) {
try {
String newValue = suggestJson.getString(taskReportItemsDto.itemKey);
if (!newValue.equals(taskReportItemsDto.inputValue)) {
// 値が異なる場合のみ、更新する
taskReportItemsDto.inputValue = newValue;
mTaskReportItemsDao.updateTaskReportItems(taskReportItemsDto);
}
if (taskReportItemsDto.itemKey.startsWith("q_3_")) {
// 値が異なるため、作業コードの入力値を変更する
taskDto.taskStatus = Integer.parseInt(taskReportItemsDto.inputValue);
}
} catch (JSONException e) {
// 値がStringではない場合、無視する
continue;
}
}
taskReportDto.jsonData = taskReport.toString();
taskReportDto.dataSendFlg = dataSendFlg;
// attachedFileSendFlgがtrueの場合は、更新しない
if (!taskReportDto.attachedFileSendFlg) {
taskReportDto.attachedFileSendFlg = attachedChangeFlag;
}
// 作業報告階層
taskReportDto.taskReportLevel = Constant.TaskReportLevel.ReportReplyType;
// 報告可能区分
taskReportDto.enableReport = enableReport;
mTaskReportDao.update(taskReportDto);
mTaskDao.update(taskDto);
String tempDirPath = ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey);
// #32926 作業報告画面改善 start
String operationDrectionOrReportDirPath = ABVEnvironment.getInstance().getOperationTaskReportLevelDirPath(operationId, taskKey, Constant.TaskReportLevel.ReportReplyType);
// #32926 作業報告画面改善 end
if (taskReportDto.attachedFileSendFlg) {
//添付ファイル変更の場合、以下の処理を行う
JSONObject attachedListJson = taskReport.getJSONObject("attached");
List<String> attachedFileNames = JSONObject.getValues(attachedListJson);
// コピー元のファイルで、添付ファイルとして使用しないファイル削除
deleteDifferentialFile(tempDirPath, attachedFileNames);
// 同じファイル名が存在すれば、コピー先ファイルを削除
deleteDifferentialFile(operationDrectionOrReportDirPath, attachedFileNames);
// 添付ディレクトリの移動
boolean result = FileUtil.copy(tempDirPath, operationDrectionOrReportDirPath, true);
if (result) {
FileUtil.delete(tempDirPath);
}
}
}
/**
* 定期点検データ更新
* @param operationId
* @param contentId
* @param taskReportDto
* @param attachedChangeFlag
* @param dataSendFlg
......@@ -633,7 +455,7 @@ public class OperationLogic extends AbstractLogic {
public void updateRoutineTaskReport(long operationId, long contentId, TaskReportDto taskReportDto, boolean attachedChangeFlag, boolean dataSendFlg, boolean reportedFlg) throws IOException {
taskReportDto.attachedFileSendFlg = attachedChangeFlag;
taskReportDto.dataSendFlg = dataSendFlg;
taskReportDto.reportedFlag = reportedFlg;
taskReportDto.reportedFlg = reportedFlg;
mTaskReportDao.updateRoutineTask(taskReportDto);
if (!StringUtil.isNullOrEmpty(taskReportDto.jsonData)) {
......@@ -775,31 +597,6 @@ public class OperationLogic extends AbstractLogic {
}
/**
* 報告回答を削除
* @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;
taskReportDto.jsonData = "";
mTaskReportDao.update(taskReportDto);
}
TaskDto taskDto = mTaskDao.getTaskByTaskKey(taskKey);
if (taskDto != null) {
taskDto.taskStatus = 0;
mTaskDao.update(taskDto);
}
// 作業報告のディレクトリ削除
deleteTaskReportReplyFileData(operationId, contentId, taskKey);
}
/**
* 定期点検用、作業削除
* @param operationId
* @param contentId
......@@ -835,7 +632,7 @@ public class OperationLogic extends AbstractLogic {
taskReportDto.dataSendFlg = true;
taskReportDto.attachedFileSendFlg = false;
taskReportDto.jsonData = "";
taskReportDto.reportedFlag = false;
taskReportDto.reportedFlg = false;
mTaskReportDao.updateRoutineTask(taskReportDto);
}
......@@ -1106,7 +903,7 @@ public class OperationLogic extends AbstractLogic {
taskReportJsonRow.put(ABookKeys.TASK_REPORT_INFO_ID, dto.taskReportInfoId);
taskReportJsonRow.put(ABookKeys.REPORT_START_DATE, DateTimeUtil.toStringInTimeZone(dto.reportStartDate, DateTimeFormat.yyyyMMddHHmmss_hyphen, DateTimeUtil.getLocalTimeZone()));
taskReportJsonRow.put(ABookKeys.REPORT_END_DATE, DateTimeUtil.toStringInTimeZone(dto.reportEndDate, DateTimeFormat.yyyyMMddHHmmss_hyphen, DateTimeUtil.getLocalTimeZone()));
taskReportJsonRow.put(ABookKeys.REPORTED, dto.reportedFlag ? 1 : 0);
taskReportJsonRow.put(ABookKeys.REPORTED, dto.reportedFlg ? 1 : 0);
List<JSONObject> taskReportInfoList = new ArrayList<JSONObject>();
if (!StringUtil.isNullOrEmpty(dto.jsonData)) {
......@@ -1413,20 +1210,15 @@ public class OperationLogic extends AbstractLogic {
* @param contentId
* @param taskKey
*/
public void deleteTaskFileData(long operationId, long contentId, String taskKey) {
public void deleteTaskFileData(long operationId, long contentId, String taskKey, int taskReportLevel) {
FileUtil.delete(ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey));
if (taskReportLevel == Constant.TaskReportLevel.ReportType) {
// 報告
FileUtil.delete(ABVEnvironment.getInstance().getOperationTaskDirFilePath(operationId, taskKey));
} else {
// 報告(回答)
FileUtil.delete(ABVEnvironment.getInstance().getOperationTaskReportLevelDirPath(operationId, taskKey, taskReportLevel));
}
/**
* 作業報告(回答)関連ディレクトリ削除
* @param operationId
* @param contentId
* @param taskKey
*/
public void deleteTaskReportReplyFileData(long operationId, long contentId, String taskKey) {
FileUtil.delete(ABVEnvironment.getInstance().getTempTaskDirPath(contentId, taskKey));
FileUtil.delete(ABVEnvironment.getInstance().getOperationTaskReportLevelDirPath(operationId, taskKey, Constant.TaskReportLevel.ReportReplyType));
}
/**
......@@ -1668,4 +1460,78 @@ public class OperationLogic extends AbstractLogic {
public TaskReportDto getTaskReport(String taskKey, int taskReportlevel) {
return mTaskReportDao.getTaskReport(taskKey, taskReportlevel);
}
/**
* suggestJsonデータをtaskReportItemテーブルに登録
* @param taskKey
* @param reportLevel
* @param suggestJson
*/
public void registTaskReportItem(String taskKey, int reportLevel, JSONObject suggestJson) {
if (suggestJson == null) {
// suggestJsonがnullの場合、return
return;
}
Iterator itemKeys = suggestJson.keys();
while (itemKeys.hasNext()) {
String itemKey = (String) itemKeys.next();
TaskReportItemsDto taskReportItemsDto = mTaskReportItemsDao.getTaskReportItem(taskKey, reportLevel, itemKey);
if (taskReportItemsDto != null) {
// 更新
String newValue = suggestJson.getString(taskReportItemsDto.itemKey);
if (!newValue.equals(taskReportItemsDto.inputValue)) {
// 値が異なる場合のみ、更新する
taskReportItemsDto.inputValue = newValue;
mTaskReportItemsDao.updateTaskReportItems(taskReportItemsDto);
}
} else {
// 登録
taskReportItemsDto = new TaskReportItemsDto();
taskReportItemsDto.taskKey = taskKey;
taskReportItemsDto.itemKey = itemKey;
taskReportItemsDto.taskReportLevel = reportLevel;
try {
taskReportItemsDto.inputValue = suggestJson.getString(itemKey);
} catch (JSONException e) {
// 値がStringではない場合、無視する
continue;
}
mTaskReportItemsDao.insertTaskReportItems(taskReportItemsDto);
}
}
}
/**
* t_taskテーブルに登録(報告データ)
* データが存在しないと登録する
* @param taskKey
* @param operationId
* @param hotSpotInfo
* @param taskStatus
*/
public void registTaskData(String taskKey, Long operationId, String hotSpotInfo, Integer taskStatus) {
TaskDto taskDto = mTaskDao.getTaskByTaskKey(taskKey);
if (taskDto != null) {
// 更新
if (hotSpotInfo != null) {
taskDto.taskHotSpotInfo = hotSpotInfo;
}
if (taskStatus != null) {
taskDto.taskStatus = taskStatus;
}
mTaskDao.update(taskDto);
} else {
// 登録
taskDto = new TaskDto();
taskDto.taskKey = taskKey;
taskDto.operationId = operationId;
if (hotSpotInfo != null) {
taskDto.taskHotSpotInfo = hotSpotInfo;
}
if (taskStatus != null) {
taskDto.taskStatus = taskStatus;
}
mTaskDao.insert(taskDto);
}
}
}
......@@ -831,7 +831,6 @@ public class OperationListActivity extends ABVUIActivity {
JSONObject taskReportJson;
for (TaskDto serverTaskDto : json.taskDtoList) {
List<TaskReportDto> localRemove = new ArrayList();
List<TaskReportDto> localTaskReportList = mTaskReportDao.getTaskReportListByTaskKey(serverTaskDto.taskKey);
for (TaskReportDto localTaskReportDto : localTaskReportList) {
......@@ -842,21 +841,23 @@ public class OperationListActivity extends ABVUIActivity {
// taskDtoが存在するとtaskReportLevel 0 (作業報告)が存在しないことはないので、報告(回答)のみチェックして削除
if (localTaskReportDto.taskReportLevel == Constant.TaskReportLevel.ReportReplyType) {
// 作業報告のディレクトリ削除
mOperationLogic.deleteTaskReportReplyFileData(operationId, operationContentDto.contentId, serverTaskDto.taskKey);
mOperationLogic.deleteTaskFileData(operationId, operationContentDto.contentId, serverTaskDto.taskKey, localTaskReportDto.taskReportLevel);
mTaskReportDao.delete(localTaskReportDto);
}
}
localTaskReportList.remove(localTaskReportDto);
}
}
if (operationDto.reportType == Constant.ReportType.Routine) {
if (isExistsTaskInList(localTaskList, serverTaskDto)) {
// 作業の報告更新
mTaskDao.update(serverTaskDto);
} else {
// 作業の報告登録
mTaskDao.insert(serverTaskDto);
}
if (operationDto.reportType == Constant.ReportType.Routine) {
// サーバーからの情報で更新
for (TaskReportDto taskReportDto : serverTaskDto.taskReportDtoList) {
String reportAttachedFileName = taskReportDto.attachedFileName;
......@@ -876,78 +877,42 @@ public class OperationListActivity extends ABVUIActivity {
}
} else {
if (isExistsTaskInList(localTaskList, serverTaskDto)) {
// 更新
for (TaskReportDto taskReportDto : serverTaskDto.taskReportDtoList) {
String attachedFileName = taskReportDto.attachedFileName;
for (TaskReportDto serverTaskReportDto : serverTaskDto.taskReportDtoList) {
String attachedFileName = serverTaskReportDto.attachedFileName;
// 添付ファイルが存在する場合、取得して解凍する。
try {
refreshTaskFile(operationId, taskReportDto.taskReportLevel, operationContentDto.contentId, serverTaskDto.taskId, serverTaskDto.taskKey, taskReportDto.attachedFileName);
refreshTaskFile(operationId, serverTaskReportDto.taskReportLevel, operationContentDto.contentId, serverTaskDto.taskId, serverTaskDto.taskKey, serverTaskReportDto.attachedFileName);
} catch (Exception e) {
return null;
}
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, taskReportDto.enableReport,
taskReportJson, serverTaskDto.taskHotSpotInfo, attachedFileName, false, false);
} else {
// 作業報告(回答)
if (taskReportDto.jsonData != null) {
// データの更新
mOperationLogic.updateTaskReportReply(serverTaskDto.taskKey, serverTaskDto.operationId, operationContentDto.contentId, taskReportDto.enableReport,
new JSONObject(taskReportDto.jsonData), attachedFileName, false, false);
} else {
// jsonDataがない場合
mOperationLogic.insertTaskReportReply(serverTaskDto.taskKey, operationContentDto.operationId, operationContentDto.contentId, taskReportDto.enableReport,
TaskReportDto localTaskReportDto = mTaskReportDao.selectByTaskKey(serverTaskReportDto.taskKey, serverTaskReportDto.taskReportLevel);
if (localTaskReportDto == null) {
// 登録
if (serverTaskReportDto.jsonData.isEmpty()) {
// jsonDataが空で入る場合、taskReportJsonをnullで登録
mOperationLogic.insertTaskReport(serverTaskDto.taskKey, operationId, operationContentDto.contentId, serverTaskReportDto.taskReportLevel, serverTaskReportDto.enableReport,
null, attachedFileName, false, false);
}
}
// 更新済みの場合、localTaskListから削除
localTaskList.remove(serverTaskDto);
}
} else {
// 登録
for (TaskReportDto taskReportDto : serverTaskDto.taskReportDtoList) {
String attachedFileName = taskReportDto.attachedFileName;
// 添付ファイルが存在する場合、取得して解凍する。
try {
refreshTaskFile(operationId, taskReportDto.taskReportLevel, operationContentDto.contentId, serverTaskDto.taskId, serverTaskDto.taskKey, taskReportDto.attachedFileName);
} catch (Exception e) {
return null;
}
if (taskReportDto.taskReportLevel == Constant.TaskReportLevel.ReportType) {
taskReportJson = new JSONObject(taskReportDto.jsonData);
taskReportJson = new JSONObject(serverTaskReportDto.jsonData);
if (serverTaskReportDto.taskReportLevel == Constant.TaskReportLevel.ReportType) {
taskReportJson.put(ABookKeys.TASK_STATUS, serverTaskDto.taskStatus);
mOperationLogic.insertTaskReport(serverTaskDto.taskKey, operationContentDto.operationId, operationContentDto.contentId, taskReportDto.enableReport,
taskReportJson, serverTaskDto.taskHotSpotInfo, attachedFileName, false, false);
} else {
if (taskReportDto.jsonData != null) {
mOperationLogic.insertTaskReportReply(serverTaskDto.taskKey, operationContentDto.operationId, operationContentDto.contentId, taskReportDto.enableReport,
new JSONObject(taskReportDto.jsonData), attachedFileName, false, false);
} else {
// jsonDataがない場合
mOperationLogic.insertTaskReportReply(serverTaskDto.taskKey, operationContentDto.operationId, operationContentDto.contentId, taskReportDto.enableReport,
null, attachedFileName, false, false);
}
mOperationLogic.insertTaskReport(serverTaskDto.taskKey, operationId, operationContentDto.contentId, serverTaskReportDto.taskReportLevel, serverTaskReportDto.enableReport,
taskReportJson, attachedFileName, false, false);
}
} else {
// 更新
taskReportJson = new JSONObject(serverTaskReportDto.jsonData);
mOperationLogic.updateTaskReport(localTaskReportDto.taskKey, operationId, operationContentDto.contentId, localTaskReportDto.taskReportLevel, serverTaskReportDto.enableReport,
taskReportJson, null, false, false);
}
}
}
progressCallback.callback(new Integer(progress));
}
// サーバーから取得した作業情報がローカルに存在しないので削除する
for (TaskDto taskDto : localTaskList) {
mOperationLogic.deleteTaskFileData(operationId, operationContentDto.contentId, taskDto.taskKey);
mOperationLogic.deleteTaskFileData(operationId, operationContentDto.contentId, taskDto.taskKey, Constant.TaskReportLevel.ReportType);
mTaskDao.delete(taskDto);
}
lastEditDate = json.lastEditDate;
......
......@@ -100,11 +100,7 @@ public class ABookCheckWebViewHelper extends ABookHelper {
mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
copyRoutineTaskReportAttachedMovie(operationId, contentId, taskKey, taskReportId, reportStartDate);
} else {
if (taskReportLevel == Constant.TaskReportLevel.ReportType) {
mOperationLogic.deleteTaskReport(operationId, contentId, taskKey);
} else {
mOperationLogic.deleteTaskReportReply(operationId, contentId, taskKey);
}
mOperationLogic.deleteTaskReport(operationId, contentId, taskKey, taskReportLevel);
mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
}
......@@ -298,21 +294,19 @@ public class ABookCheckWebViewHelper extends ABookHelper {
mOperationLogic.createJsonForOperationContent(operationId, contentPath, true);
copyRoutineTaskReportAttachedMovie(operationId, contentId, taskKey, taskReportId, reportStartDate);
} else {
String hotSpotInfo = param.containsKey(ABookKeys.HOT_SPOT) ? param.get(ABookKeys.HOT_SPOT) : null;
Integer taskStatus = taskReportJson.has(ABookKeys.TASK_STATUS) ? taskReportJson.getInt(ABookKeys.TASK_STATUS) : null;
// task登録・更新処理
mOperationLogic.registTaskData(taskKey, operationId, hotSpotInfo, taskStatus);
TaskReportDto taskReportDto = mOperationLogic.getTaskReport(taskKey, taskReportLevel);
if (taskReportDto != null) {
// 更新
if (taskReportDto.taskReportLevel == Constant.TaskReportLevel.ReportType) {
mOperationLogic.updateTaskReport(taskKey, operationId, contentId, Constant.EnableReport.YES, taskReportJson, param.get(ABookKeys.HOT_SPOT), null, attachedChangeFlag, dataSendFlg);
} else {
mOperationLogic.updateTaskReportReply(taskKey, operationId, contentId, Constant.EnableReport.YES, taskReportJson, null, attachedChangeFlag, dataSendFlg);
}
mOperationLogic.updateTaskReport(taskReportDto.taskKey, operationId, contentId, taskReportLevel, Constant.EnableReport.YES, taskReportJson, null, attachedChangeFlag, dataSendFlg);
} else {
// 登録
if (taskReportLevel == Constant.TaskReportLevel.ReportType) {
mOperationLogic.insertTaskReport(taskKey, operationId, contentId, Constant.EnableReport.YES, taskReportJson, param.get(ABookKeys.HOT_SPOT), null, attachedChangeFlag, dataSendFlg);
} else {
mOperationLogic.insertTaskReportReply(taskKey, operationId, contentId, Constant.EnableReport.YES, taskReportJson, null, attachedChangeFlag, dataSendFlg);
}
mOperationLogic.insertTaskReport(taskKey, operationId, contentId, taskReportLevel, Constant.EnableReport.YES, taskReportJson, null, attachedChangeFlag, dataSendFlg);
}
mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
......
......@@ -44,8 +44,7 @@ public class OperationTaskLayout extends RelativeLayout {
private static final String TAG = "OperationTaskLayout";
private static final String TEMP_TASK_KEY = "00000000-0000-0000-0000-000000000000";
private static final String SCRIPT_SHOW_TASK_LIST = "javascript:CHK_P.updateTaskListForApp(%d)";//CHK.updateTaskListForApp(pageNum)
private static final String SCRIPT_SHOW_TASK_DIRECT = "javascript:CHK.showTaskForm('%s')";//CHK.showTaskForm(taskKey)
private static final String SCRIPT_SHOW_TASK_REPORT = "javascript:CHK.showTaskReportForm('%s')";//CHK.showTaskReportForm(name, taskKey, lookto)
private static final String SCRIPT_SHOW_TASK_REPORT = "javascript:CHK.showReportForm('%s')";//CHK.showTaskReportForm(name, taskKey, lookto)
private static final int ICON_WIDTH = 32;
private static final int ICON_HEIGHT = 32;
......@@ -309,11 +308,7 @@ public class OperationTaskLayout extends RelativeLayout {
final String script;
if (mXWalkOpenType == Constant.XWalkOpenType.TASK_DERECTION) {
script = String.format(SCRIPT_SHOW_TASK_DIRECT, operationTaskDto.taskKey.equals(TEMP_TASK_KEY) ? "" : operationTaskDto.taskKey);
} else {
script = String.format(SCRIPT_SHOW_TASK_REPORT, operationTaskDto.taskKey.equals(TEMP_TASK_KEY) ? "" : operationTaskDto.taskKey);
}
runOnUiThread(new Runnable() {
@Override
......
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