Commit e04c90ef by Lee Jaebin

ホットスポット更新処理の修正(hotspot_changed_flg制御をt_taskからt_task_report_sendに変更して、履歴なし・ありの処理修正

parent 89a8b4f6
......@@ -524,7 +524,7 @@ public class AcmsClient implements AcmsClientResponseListener {
* @throws NetworkDisconnectedException
* @throws IOException
*/
public AcmsMessageJSON sendTaskData(String sid, Long operationId, TaskReportDto taskReportDto, File formFile, Date taskReportSendSaveDate, int reportType) throws ABVException, NetworkDisconnectedException, IOException {
public AcmsMessageJSON sendTaskData(String sid, Long operationId, TaskReportDto taskReportDto, File formFile, Date taskReportSendSaveDate, int reportType, boolean hotspotChangeFlg) throws ABVException, NetworkDisconnectedException, IOException {
if (networkAdapter != null && !networkAdapter.isNetworkConnected()) { // NWのチェック
throw new NetworkDisconnectedException();
}
......@@ -540,6 +540,7 @@ public class AcmsClient implements AcmsClientResponseListener {
HttpMultipartList.add(new HttpMultipart(ABookKeys.TASK_REPORT_INFO, taskReportDto.jsonData));
HttpMultipartList.add(new HttpMultipart(ABookKeys.ATTACHED_CHANGE_FLAG, taskReportDto.attachedFileSendFlg ? "1" : "0"));
HttpMultipartList.add(new HttpMultipart(ABookKeys.ROUTINE_TASK_FLAG, reportType == Constant.ReportType.RoutineTask ? "1" : "0"));
HttpMultipartList.add(new HttpMultipart(ABookKeys.UPDATE_HOTSPOT_ONLY_FLAG, hotspotChangeFlg ? "1" : "0"));
// 定期点検用
if (reportType == Constant.ReportType.RoutineTask) {
......
......@@ -44,6 +44,7 @@ public class ABookKeys {
public static final String DIRECTION_FLG = "directionFlg";
public static final String ATTACHED_CHANGE_FLAG = "attachedChangeFlag";
public static final String ROUTINE_TASK_FLAG = "routineTaskFlag";
public static final String UPDATE_HOTSPOT_ONLY_FLAG = "updateHotSpotOnlyFlag";
// #32782 指示者テーブル関連削除 start
// TODO change TASK_DIRECTIONS 削除が必要
// public static final String TASK_DIRECTIONS = "taskReport";
......
......@@ -52,10 +52,6 @@ public class TaskDao extends AbstractDao {
if (column != -1) {
dto.taskHasAuthority = toBool(cursor.getInt(column));
}
column = cursor.getColumnIndex("hotspot_changed_flg");
if (column != -1) {
dto.hotspotChangeFlg = toBool(cursor.getInt(column));
}
return dto;
}
......@@ -79,10 +75,9 @@ public class TaskDao extends AbstractDao {
+ "operation_id, "
+ "task_code, "
+ "task_status, "
+ "task_hotspot_info, "
+ "hotspot_changed_flg) "
+ "task_hotspot_info) "
+ "values "
+ "(?,?,?,?,?,?,?)",
+ "(?,?,?,?,?,?)",
dto.getInsertValues());
}
......@@ -94,8 +89,7 @@ public class TaskDao extends AbstractDao {
+ "task_code=?, "
+ "task_status=?, "
+ "task_hotspot_info=?, "
+ "del_flg=?, "
+ "hotspot_changed_flg=?"
+ "del_flg=? "
+ "where task_key=?",
dto.getUpdateValues());
return count > 0;
......
......@@ -54,6 +54,11 @@ public class TaskReportSendDao extends AbstractDao {
dto.deleteFlg = toBool(cursor.getInt(column));
}
column = cursor.getColumnIndex("hotspot_changed_flg");
if (column != -1) {
dto.hotspotChangeFlg = toBool(cursor.getInt(column));
}
return dto;
}
......@@ -69,6 +74,21 @@ public class TaskReportSendDao extends AbstractDao {
return rawQueryGetInt("select ifnull(max(task_report_send_id),0) from t_task_report_send where task_key = ? and task_report_id = ? and report_start_date = ?", new String[]{ taskKey, "" + taskReportId, reportStartDate });
}
/**
* 最新の送信データを取得
* @param taskKey
* @return
*/
public TaskReportSendDto getLastTaskReportSend(String taskKey) {
int lastSendId = getLastTaskReportSendId(taskKey);
StringBuilder sb = new StringBuilder();
sb.append(" select * ");
sb.append(" from t_task_report_send ");
sb.append(" where task_report_send_id = ? ");
sb.append(" order by task_report_send_id asc");
return rawQueryGetDto(sb.toString(), new String[]{ "" + lastSendId }, TaskReportSendDto.class);
}
public int insert(TaskReportSendDto dto) {
dto.taskReportSendId = getNewTaskReportSendId();
......@@ -79,9 +99,10 @@ public class TaskReportSendDao extends AbstractDao {
+ "report_start_date, "
+ "json_data, "
+ "save_date, "
+ "hotspot_changed_flg, "
+ "delete_flg) "
+ "values "
+ "(?,?,?,?,?,?,?)",
+ "(?,?,?,?,?,?,?,?)",
dto.getInsertValues());
return dto.taskReportSendId;
......@@ -97,6 +118,7 @@ public class TaskReportSendDao extends AbstractDao {
+ "set "
+ "json_data=?, "
+ "save_date=?, "
+ "hotspot_changed_flg=?, "
+ "delete_flg=? "
+ "where task_report_send_id = ?",
dto.getUpdateValues());
......@@ -138,10 +160,26 @@ public class TaskReportSendDao extends AbstractDao {
sb.append(" select count(task_report_send_id) ");
sb.append(" from t_task_report_send ");
sb.append(" where task_key = ? ");
sb.append(" AND hotspot_changed_flg = 0");
sb.append(" order by task_report_send_id asc");
return rawQueryGetInt(sb.toString(), new String[]{ taskKey }) == 0;
}
/**
* ホットスポット更新フラグが存在するかチェック
* @param taskKey
* @return
*/
public TaskReportSendDto getHotspotChangedData(String taskKey) {
StringBuilder sb = new StringBuilder();
sb.append(" select * ");
sb.append(" from t_task_report_send ");
sb.append(" where hotspot_changed_flg = 1 ");
sb.append(" AND task_key = ?");
sb.append(" order by task_report_send_id asc");
return rawQueryGetDto(sb.toString(), new String[]{ taskKey }, TaskReportSendDto.class);
}
public List<TaskReportSendDto> getSendableTaskReportSendData(String taskKey, int taskReportId, String reportStartDate) {
StringBuilder sb = new StringBuilder();
sb.append(" select * ");
......@@ -180,4 +218,17 @@ public class TaskReportSendDao extends AbstractDao {
}
return rawQueryGetInt(sb.toString(), new String[]{ "" + operationId });
}
/**
* ホットスポット更新フラグが存在すれば、削除
* @param taskKey
* @return
*/
public boolean deleteHotspotChangedData(String taskKey) {
TaskReportSendDto hotspotChangedData = getHotspotChangedData(taskKey);
if (hotspotChangedData != null) {
return deleteBySendId(hotspotChangedData.taskReportSendId);
}
return false;
}
}
......@@ -36,6 +36,7 @@ public class TTaskReportSend extends SQLiteTableScript {
sql.append(" , json_data TEXT NOT NULL ");
sql.append(" , save_date DATE NOT NULL ");
sql.append(" , delete_flg BOOLEAN NOT NULL DEFAULT 0 ");
sql.append(" , hotspot_changed_flg BOOLEAN DEFAULT 0 ");
sql.append(" ) ");
ddl.add(sql.toString());
......
......@@ -21,16 +21,14 @@ public class TaskDto extends AbstractDto {
public boolean taskHasAuthority; // タスク別の権限
public boolean hotspotChangeFlg;
@Override
public Object[] getInsertValues() {
return new Object[] { taskKey, taskId, operationId, taskCode, taskStatus, taskHotSpotInfo, hotspotChangeFlg };
return new Object[] { taskKey, taskId, operationId, taskCode, taskStatus, taskHotSpotInfo };
}
@Override
public Object[] getUpdateValues() {
return new Object[] { taskId, operationId, taskCode, taskStatus, taskHotSpotInfo, delFlg, hotspotChangeFlg, taskKey };
return new Object[] { taskId, operationId, taskCode, taskStatus, taskHotSpotInfo, delFlg, taskKey };
}
@Override
......
......@@ -14,15 +14,16 @@ public class TaskReportSendDto extends AbstractDto {
public String jsonData;
public Date saveDate;
public boolean deleteFlg;
public boolean hotspotChangeFlg; // ホットスポット更新フラグ
@Override
public Object[] getInsertValues() {
return new Object[] { taskReportSendId, taskKey, taskReportId, reportStartDate, jsonData, saveDate, deleteFlg };
return new Object[] { taskReportSendId, taskKey, taskReportId, reportStartDate, jsonData, saveDate, hotspotChangeFlg, deleteFlg };
}
@Override
public Object[] getUpdateValues() {
return new Object[] { jsonData, saveDate, deleteFlg, taskReportSendId };
return new Object[] { jsonData, saveDate, hotspotChangeFlg, deleteFlg, taskReportSendId };
}
@Override
......
......@@ -548,7 +548,10 @@ public class OperationLogic extends AbstractLogic {
* @return
* @throws IOException
*/
public int insertTaskReportSend(String taskKey, int taskReportId, String reportStartDate, JSONObject taskReportJson, boolean deleteFlg) throws IOException {
public int insertTaskReportSend(String taskKey, int taskReportId, String reportStartDate, JSONObject taskReportJson, boolean deleteFlg, boolean hotspotChangeFlg) throws IOException {
// 登録前にホットスポット更新フラグが存在すれば、そのデータは削除する
mTaskReportSendDao.deleteHotspotChangedData(taskKey);
TaskReportSendDto taskReportSendDto = new TaskReportSendDto();
taskReportSendDto.taskKey = taskKey;
......@@ -565,6 +568,7 @@ public class OperationLogic extends AbstractLogic {
}
taskReportSendDto.saveDate = DateTimeUtil.getCurrentSqlDate();
taskReportSendDto.deleteFlg = deleteFlg;
taskReportSendDto.hotspotChangeFlg = hotspotChangeFlg;
return mTaskReportSendDao.insert(taskReportSendDto);
}
......@@ -580,7 +584,16 @@ public class OperationLogic extends AbstractLogic {
* @throws IOException
*/
public int updateTaskReportSend(String taskKey, int taskReportId, String reportStartDate, JSONObject taskReportJson, boolean deleteFlg) throws IOException {
TaskReportSendDto taskReportSendDto = new TaskReportSendDto();
// 登録前にホットスポット更新フラグが存在すれば、そのデータは削除する
mTaskReportSendDao.deleteHotspotChangedData(taskKey);
// 最新のtaskReportSendデータを更新(更新時、データは1つしかないのが前提)
TaskReportSendDto taskReportSendDto = mTaskReportSendDao.getLastTaskReportSend(taskKey);
if (taskReportSendDto == null) {
// データがない場合、insertを行うため新しいインスタントでセット
taskReportSendDto = new TaskReportSendDto();
}
taskReportSendDto.taskKey = taskKey;
......@@ -600,7 +613,7 @@ public class OperationLogic extends AbstractLogic {
int taskReportSendId = mTaskReportSendDao.update(taskReportSendDto);
if (taskReportSendId == 0) {
taskReportSendId = insertTaskReportSend(taskKey, taskReportId, reportStartDate, taskReportJson, false);
taskReportSendId = insertTaskReportSend(taskKey, taskReportId, reportStartDate, taskReportJson, false, false);
}
return taskReportSendId;
......@@ -672,11 +685,15 @@ public class OperationLogic extends AbstractLogic {
* @param taskKey
* @param param
*/
public void updateTaskHotspot(String taskKey, Map<String, String> param) {
public void updateTaskHotspot(String taskKey, Map<String, String> param) throws IOException {
TaskDto taskDto = mTaskDao.getTaskByTaskKey(taskKey);
TaskReportDto taskReportDto = mTaskReportDao.getTaskReport(taskKey, Constant.TaskReportLevel.ReportType);
taskReportDto.dataSendFlg = true;
if (mTaskReportSendDao.isNotExistSendableData(taskReportDto.taskKey) && !taskReportDto.dataSendFlg && !taskReportDto.localSavedFlg) {
// 送信データが存在しない場合のみ、ホットスポットをtrueにセット
insertTaskReportSend(taskReportDto.taskKey, taskReportDto.taskReportId, null, new JSONObject(taskReportDto.jsonData), false, true);
}
taskDto.taskHotSpotInfo = param.get(ABookKeys.HOT_SPOT);
taskReportDto.dataSendFlg = true;
mTaskReportDao.update(taskReportDto);
mTaskDao.update(taskDto);
}
......@@ -690,7 +707,7 @@ public class OperationLogic extends AbstractLogic {
* @param newY
*/
public void updateTaskHotspot(String taskKey, float newX, float newY, int taskReportLevel) {
public void updateTaskHotspot(String taskKey, float newX, float newY, int taskReportLevel) throws IOException {
TaskDto taskDto = mTaskDao.getTaskByTaskKey(taskKey);
// #32782 指示者テーブル関連削除 start
TaskReportDto taskReportDto = mTaskReportDao.getTaskReport(taskKey, taskReportLevel);
......@@ -698,9 +715,12 @@ public class OperationLogic extends AbstractLogic {
hotSpot.put("x", newX);
hotSpot.put("y", newY);
taskDto.taskHotSpotInfo = hotSpot.toString();
taskDto.hotspotChangeFlg = true;
if (mTaskReportSendDao.isNotExistSendableData(taskReportDto.taskKey) && !taskReportDto.dataSendFlg && !taskReportDto.localSavedFlg) {
// 送信データが存在しない場合のみ、ホットスポットをtrueにセット
insertTaskReportSend(taskReportDto.taskKey, taskReportDto.taskReportId, null, new JSONObject(taskReportDto.jsonData), false, true);
}
taskReportDto.dataSendFlg = true;
mTaskReportDao.update(taskReportDto);
// #32782 指示者テーブル関連削除 end
mTaskDao.update(taskDto);
}
......@@ -1123,9 +1143,7 @@ public class OperationLogic extends AbstractLogic {
OperationDto operationDto = mOperationDao.getOperation(operationId);
List<TaskReportDto> taskReportDtoList = null;
int maxProgress = 0;
// 作業担当レベルが0且つ、t_task_report_sendテーブルのデータが存在しない場合、
// ホットスポット変更フラグがtrueであれば、t_task_report_sendデータを登録する
updateHotspotChanged(operationId, taskKey);
if (taskKey == null) {
taskReportDtoList = mTaskReportDao.getSendableTaskData(operationId);
maxProgress = 40;
......@@ -1188,7 +1206,8 @@ public class OperationLogic extends AbstractLogic {
taskReportDto,
zipFile,
taskReportSendDto.saveDate,
operationDto.reportType
operationDto.reportType,
taskReportSendDto.hotspotChangeFlg
);
progressCallback.callback(new Integer(progress));
removeTaskReportSendIds.add(taskReportSendDto.taskReportSendId);
......@@ -1340,29 +1359,6 @@ public class OperationLogic extends AbstractLogic {
}
/**
* ホットスポットのアップデートがあるが、sendテーブルに存在しない場合、登録して
* t_task_reportのdata_send_flgをtrueにセットする
* @param operationId
* @param taskKey
* @throws IOException
*/
public void updateHotspotChanged(long operationId, String taskKey) throws IOException {
List<TaskReportDto> taskReportDtoList = mTaskReportDao.getUpdateTargetHotSpotTaskData(operationId, taskKey);
for (TaskReportDto taskReportDto : taskReportDtoList) {
if (mTaskReportSendDao.isNotExistSendableData(taskReportDto.taskKey)) {
insertTaskReportSend(taskReportDto.taskKey, taskReportDto.taskReportId, DateTimeUtil.toString(taskReportDto.reportStartDate,
DateTimeFormat.yyyyMMddHHmmss_hyphen), new JSONObject(taskReportDto.jsonData), false);
TaskDto taskDto = mTaskDao.getTaskByTaskKey(taskReportDto.taskKey);
taskReportDto.dataSendFlg = true;
mTaskReportDao.update(taskReportDto);
taskDto.hotspotChangeFlg = false;
mTaskDao.update(taskDto);
}
}
}
/**
* 作業の添付ファイルのzip生成
* @param operationId
* @param taskKey
......
......@@ -36,7 +36,6 @@ import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.activity.ABVContentViewActivity;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
import jp.agentec.abook.abv.ui.common.util.PatternStringUtil;
import jp.agentec.abook.abv.ui.viewer.activity.CheckOZDViewActivity;
import jp.agentec.abook.abv.ui.common.util.ABVToastUtil;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
......@@ -121,7 +120,7 @@ public class ABookCheckWebViewHelper extends ABookHelper {
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);
mOperationLogic.insertTaskReportSend(taskKey, taskReportId, reportStartDate, null, true, false);
}
sendTaskData(context, operationId, taskKey, taskReportLevel);
......@@ -352,7 +351,7 @@ public class ABookCheckWebViewHelper extends ABookHelper {
//データ無い場合は中でinsertされる
taskReportSendId = mOperationLogic.updateTaskReportSend(taskKey, taskReportId, reportStartDate, taskReportJson, false);
} else {
taskReportSendId = mOperationLogic.insertTaskReportSend(taskKey, taskReportId, reportStartDate, taskReportJson, false);
taskReportSendId = mOperationLogic.insertTaskReportSend(taskKey, taskReportId, reportStartDate, taskReportJson, false, false);
}
// #32926 作業報告画面改善 start
copyReportTaskSendFiles(operationId, taskKey, taskReportSendId, reportType == Constant.ReportType.RoutineTask, taskReportId, reportStartDate, taskReportLevel);
......
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