Commit aefef9c5 by Lee Jaebin

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

parent d17f9d1c
...@@ -257,6 +257,36 @@ public class AbstractDao { ...@@ -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型リストで返します。 * クエリを実行し、最初の行の最初の列の値をInteger型リストで返します。
* *
* @param sql * @param sql
......
...@@ -56,9 +56,9 @@ public class TaskReportDao extends AbstractDao { ...@@ -56,9 +56,9 @@ public class TaskReportDao extends AbstractDao {
if (column != -1) { if (column != -1) {
dto.delFlg = toBool(cursor.getInt(column)); dto.delFlg = toBool(cursor.getInt(column));
} }
column = cursor.getColumnIndex("reported_flag"); column = cursor.getColumnIndex("reported_flg");
if (column != -1) { if (column != -1) {
dto.reportedFlag = toBool(cursor.getInt(column)); dto.reportedFlg = toBool(cursor.getInt(column));
} }
column = cursor.getColumnIndex("enable_report"); column = cursor.getColumnIndex("enable_report");
...@@ -70,6 +70,17 @@ public class TaskReportDao extends AbstractDao { ...@@ -70,6 +70,17 @@ public class TaskReportDao extends AbstractDao {
if (column != -1) { if (column != -1) {
dto.taskReportLevel = cursor.getInt(column); 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; return dto;
} }
...@@ -208,8 +219,14 @@ public class TaskReportDao extends AbstractDao { ...@@ -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}); 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() { public List<TaskReportDto> selectAll() {
...@@ -238,11 +255,11 @@ public class TaskReportDao extends AbstractDao { ...@@ -238,11 +255,11 @@ public class TaskReportDao extends AbstractDao {
+ "attached_file_name=?, " + "attached_file_name=?, "
+ "local_attached_file_name=?, " + "local_attached_file_name=?, "
+ "json_data=?, " + "json_data=?, "
+ "data_send_flag=?, " + "data_send_flg=?, "
+ "attached_file_send_flag=? " + "attached_file_send_flg=? "
+ "reported_flag=? " + "reported_flg=? "
+ "where task_key=? and task_report_id=? and datetime(report_start_date)=datetime(?)", + "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; return count > 0;
} }
......
...@@ -48,6 +48,17 @@ public class TaskReportItemsDao extends AbstractDao { ...@@ -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); 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) { public List<TaskReportItemsDto> getTaskReportItemByOperationId(Long operationId) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(" select distinct ttri.* "); sb.append(" select distinct ttri.* ");
......
...@@ -24,6 +24,7 @@ public class TTaskReportItems extends SQLiteTableScript { ...@@ -24,6 +24,7 @@ public class TTaskReportItems extends SQLiteTableScript {
sql.append(" CREATE TABLE t_task_report_items ( "); sql.append(" CREATE TABLE t_task_report_items ( ");
sql.append(" task_key TEXT NOT NULL "); sql.append(" task_key TEXT NOT NULL ");
sql.append(" , task_report_level INTEGER default 0 "); sql.append(" , task_report_level INTEGER default 0 ");
sql.append(" , item_key VARCHAR(64) "); sql.append(" , item_key VARCHAR(64) ");
sql.append(" , input_value VARCHAR(64) "); sql.append(" , input_value VARCHAR(64) ");
sql.append(" ) "); sql.append(" ) ");
......
...@@ -23,7 +23,7 @@ public class OperationDto extends AbstractDto { ...@@ -23,7 +23,7 @@ public class OperationDto extends AbstractDto {
public List<OperationContentDto> operationContentDtoList; public List<OperationContentDto> operationContentDtoList;
public List<TaskDto> taskDtoList; public List<TaskDto> taskDtoList;
public List<PushMessageDto> pushMessageList; public List<PushMessageDto> pushMessageList;
public int reportType; //0:通常 1:定期点検 public int reportType; // 報告タイプ 0 : 報告 1 : 定期点検 2 : 報告(回答)
public int reportCycle; //0:日次 1:月次 2:年次 public int reportCycle; //0:日次 1:月次 2:年次
public int enableReportUpdate; //0:不可 1:可 public int enableReportUpdate; //0:不可 1:可
public String reportPeriod; //定期点検、2018/12/20 08:10:00 ~ 2018/12/21 18:10:00 public String reportPeriod; //定期点検、2018/12/20 08:10:00 ~ 2018/12/21 18:10:00
......
...@@ -25,16 +25,16 @@ public class TaskReportDto extends AbstractDto { ...@@ -25,16 +25,16 @@ public class TaskReportDto extends AbstractDto {
public int enableReport; // 報告可能区分 public int enableReport; // 報告可能区分
public String attachedFileName; public String attachedFileName;
public String taskReportInfo; public String taskReportInfo;
public boolean reportedFlag; // 定期点検用 public boolean reportedFlg; // 定期点検用
@Override @Override
public Object[] getInsertValues() { 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 @Override
public Object[] getUpdateValues() { 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 @Override
......
...@@ -100,11 +100,7 @@ public class ABookCheckWebViewHelper extends ABookHelper { ...@@ -100,11 +100,7 @@ public class ABookCheckWebViewHelper extends ABookHelper {
mOperationLogic.createJsonForOperationContent(operationId, contentPath, false); mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
copyRoutineTaskReportAttachedMovie(operationId, contentId, taskKey, taskReportId, reportStartDate); copyRoutineTaskReportAttachedMovie(operationId, contentId, taskKey, taskReportId, reportStartDate);
} else { } else {
if (taskReportLevel == Constant.TaskReportLevel.ReportType) { mOperationLogic.deleteTaskReport(operationId, contentId, taskKey, taskReportLevel);
mOperationLogic.deleteTaskReport(operationId, contentId, taskKey);
} else {
mOperationLogic.deleteTaskReportReply(operationId, contentId, taskKey);
}
mOperationLogic.createJsonForOperationContent(operationId, contentPath, false); mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel); copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
} }
...@@ -298,21 +294,19 @@ public class ABookCheckWebViewHelper extends ABookHelper { ...@@ -298,21 +294,19 @@ public class ABookCheckWebViewHelper extends ABookHelper {
mOperationLogic.createJsonForOperationContent(operationId, contentPath, true); mOperationLogic.createJsonForOperationContent(operationId, contentPath, true);
copyRoutineTaskReportAttachedMovie(operationId, contentId, taskKey, taskReportId, reportStartDate); copyRoutineTaskReportAttachedMovie(operationId, contentId, taskKey, taskReportId, reportStartDate);
} else { } 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); TaskReportDto taskReportDto = mOperationLogic.getTaskReport(taskKey, taskReportLevel);
if (taskReportDto != null) { if (taskReportDto != null) {
// 更新 // 更新
if (taskReportDto.taskReportLevel == Constant.TaskReportLevel.ReportType) { mOperationLogic.updateTaskReport(taskReportDto.taskKey, operationId, contentId, taskReportLevel, Constant.EnableReport.YES, taskReportJson, null, attachedChangeFlag, dataSendFlg);
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);
}
} else { } else {
// 登録 // 登録
if (taskReportLevel == Constant.TaskReportLevel.ReportType) { mOperationLogic.insertTaskReport(taskKey, operationId, contentId, taskReportLevel, Constant.EnableReport.YES, taskReportJson, null, attachedChangeFlag, dataSendFlg);
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.createJsonForOperationContent(operationId, contentPath, false); mOperationLogic.createJsonForOperationContent(operationId, contentPath, false);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel); copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
......
...@@ -44,8 +44,7 @@ public class OperationTaskLayout extends RelativeLayout { ...@@ -44,8 +44,7 @@ public class OperationTaskLayout extends RelativeLayout {
private static final String TAG = "OperationTaskLayout"; private static final String TAG = "OperationTaskLayout";
private static final String TEMP_TASK_KEY = "00000000-0000-0000-0000-000000000000"; 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_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.showReportForm('%s')";//CHK.showTaskReportForm(name, taskKey, lookto)
private static final String SCRIPT_SHOW_TASK_REPORT = "javascript:CHK.showTaskReportForm('%s')";//CHK.showTaskReportForm(name, taskKey, lookto)
private static final int ICON_WIDTH = 32; private static final int ICON_WIDTH = 32;
private static final int ICON_HEIGHT = 32; private static final int ICON_HEIGHT = 32;
...@@ -309,11 +308,7 @@ public class OperationTaskLayout extends RelativeLayout { ...@@ -309,11 +308,7 @@ public class OperationTaskLayout extends RelativeLayout {
final String script; final String script;
if (mXWalkOpenType == Constant.XWalkOpenType.TASK_DERECTION) { script = String.format(SCRIPT_SHOW_TASK_REPORT, operationTaskDto.taskKey.equals(TEMP_TASK_KEY) ? "" : operationTaskDto.taskKey);
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() { runOnUiThread(new Runnable() {
@Override @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