Commit 8d4e25d8 by Kazuyuki Hida

報告書の送信時に件数調整を行うようにした

parent 044e5047
package jp.agentec.abook.abv.bl.data.dao;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -550,4 +549,61 @@ public class OperationDao extends AbstractDao {
return sql.toString();
}
private String incrementCount(long operationId, String column) {
StringBuilder sql = new StringBuilder();
sql.append("UPDATE t_operation ");
sql.append(" SET ").append(column).append(" = (").append(column).append(" + 1)");
sql.append(" WHERE operation_id = ").append(operationId);
return sql.toString();
}
private String decrementCount(long operationId, String column) {
StringBuilder sql = new StringBuilder();
sql.append("UPDATE t_operation ");
sql.append(" SET ").append(column).append(" = (").append(column).append(" - 1)");
sql.append(" WHERE operation_id = ").append(operationId);
sql.append(" AND ").append(column).append(" > 0");
return sql.toString();
}
public void countUpCompleted(long operationId) {
beginTransaction();
try {
execSql(decrementCount(operationId, "status_not_started_count"));
execSql(incrementCount(operationId, "status_completed_count"));
commit();
} catch (Throwable e) {
rollback();
Logger.e(TAG, e);
}
}
public void countUpWorking(long operationId) {
beginTransaction();
try {
execSql(decrementCount(operationId, "status_not_started_count"));
execSql(incrementCount(operationId, "status_working_count"));
commit();
} catch (Throwable e) {
rollback();
Logger.e(TAG, e);
}
}
public void coutUpCompletedFromWorking(long operationId) {
beginTransaction();
try {
execSql(decrementCount(operationId, "status_working_count"));
execSql(incrementCount(operationId, "status_completed_count"));
commit();
} catch (Throwable e) {
rollback();
Logger.e(TAG, e);
}
}
}
......@@ -494,4 +494,40 @@ public class TaskReportDao extends AbstractDao {
public String getRoutineTaskReportAttachedFileName(String taskKey, int taskReportId, String reportStartDate) {
return rawQueryGetString("select local_attached_file_name from t_task_report where task_key=? and task_report_id=? and datetime(report_start_date)=datetime(?, 'utc')", new String[]{ taskKey, "" + taskReportId, reportStartDate });
}
public boolean isLocalSaved(String taskKey, int taskReportId, String reportStartDate) {
int count;
StringBuilder sql = new StringBuilder();
sql.append("SELECT count(*) FROM t_task_report");
sql.append(" WHERE local_saved_flg > 0");
if (reportStartDate == null) {
// 報告
sql.append(" AND task_key=?");
count = rawQueryGetInt(sql.toString(), new String[] { taskKey });
} else {
// 点検
sql.append(" AND task_report_id=?");
sql.append(" AND datetime(report_start_date)=datetime(?, 'utc')");
count = rawQueryGetInt(sql.toString(), new String[] { String.valueOf(taskReportId), reportStartDate });
}
return count > 0;
}
public boolean isCompleted(String taskKey, int taskReportId, String reportStartDate) {
int count;
StringBuilder sql = new StringBuilder();
sql.append("SELECT count(*) FROM t_task_report");
sql.append(" WHERE task_report_info_id > 0");
if (reportStartDate == null) {
// 報告
sql.append(" AND task_key=?");
count = rawQueryGetInt(sql.toString(), new String[] { taskKey });
} else {
// 点検
sql.append(" AND task_report_id=?");
sql.append(" AND datetime(report_start_date)=datetime(?, 'utc')");
count = rawQueryGetInt(sql.toString(), new String[] { String.valueOf(taskReportId), reportStartDate });
}
return count > 0;
}
}
......@@ -18,6 +18,7 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.Callback;
......@@ -27,6 +28,9 @@ import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.dao.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.OperationDao;
import jp.agentec.abook.abv.bl.data.dao.TaskReportDao;
import jp.agentec.abook.abv.bl.dto.OperationDto;
import jp.agentec.abook.abv.bl.dto.OperationTaskDto;
import jp.agentec.abook.abv.bl.dto.TaskDto;
......@@ -44,6 +48,8 @@ import jp.agentec.adf.util.DateTimeUtil;
import jp.agentec.adf.util.FileUtil;
import jp.agentec.adf.util.StringUtil;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportStartDate;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.TaskReportId;
import static jp.agentec.abook.abv.cl.util.PreferenceUtil.getUserPref;
/**
......@@ -89,25 +95,51 @@ public class ABookCheckWebViewHelper extends ABookHelper {
switch (cmd) {
case ABookKeys.CMD_INSERT_TASK_REPORT:
case ABookKeys.CMD_UPDATE_TASK_REPORT:
case ABookKeys.CMD_UPDATE_TASK_REPORT: {
// もとから作業中だったかを調べる
TaskReportDao taskReportDao = AbstractDao.getDao(TaskReportDao.class);
int rportId = Integer.parseInt(String.valueOf(param.getOrDefault(TaskReportId, "0")));
String startDate = param.getOrDefault(ReportStartDate, null);
boolean isLocalSaved = taskReportDao.isLocalSaved(taskKey, rportId, startDate);
boolean isCompleted = taskReportDao.isCompleted(taskKey, rportId, startDate);
// 報告書の更新
insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, reportType, taskReportLevel, false);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
sendTaskData(context, operationId, taskKey, taskReportLevel);
// 作業ステータスのカウントを変える
OperationDao operationDao = AbstractDao.getDao(OperationDao.class);
if (isLocalSaved) {
operationDao.coutUpCompletedFromWorking(operationId);
} else if (! isCompleted) {
operationDao.countUpCompleted(operationId);
}
break;
}
case ABookKeys.CMD_LOCAL_SAVE_TASK_REPORT: // 一時保存
// もとから作業中だったかを調べる
TaskReportDao taskReportDao = AbstractDao.getDao(TaskReportDao.class);
int rportId = Integer.parseInt(String.valueOf(param.getOrDefault(TaskReportId, "0")));
String startDate = param.getOrDefault(ReportStartDate, null);
boolean isLocalSaved = taskReportDao.isLocalSaved(taskKey, rportId, startDate);
// 報告書の更新
insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, reportType, taskReportLevel, true);
copyTaskAttachedMovie(operationId, contentId, taskKey, taskReportLevel);
ABVToastUtil.showMakeText(context, R.string.msg_temp_save_result, Toast.LENGTH_SHORT);
// 作業ステータスのカウントを変える
if (! isLocalSaved) {
OperationDao operationDao = AbstractDao.getDao(OperationDao.class);
operationDao.countUpWorking(operationId);
}
mFinishCallback.callback(false);
break;
case ABookKeys.CMD_DELETE_TASK_REPORT:
case ABookKeys.CMD_DELETE_TASK_REPORT: {
int taskReportId = 0;
String reportStartDate = "";
boolean sendTaskReportDataFlg = false;
if (reportType == Constant.ReportType.RoutineTask) {
taskReportId = Integer.valueOf(param.get(ABookKeys.TASK_REPORT_ID));
reportStartDate = param.get(ABookKeys.REPORT_START_DATE).replace("T", " ");
reportStartDate = param.get(ABookKeys.REPORT_START_DATE);
mOperationLogic.deleteRoutineTaskReport(operationId, contentId, taskKey, taskReportId, reportStartDate);
mOperationLogic.createJsonForOperationContent(operationId, contentPath, true);
copyRoutineTaskReportAttachedMovie(operationId, contentId, taskKey, taskReportId, reportStartDate);
......@@ -128,6 +160,7 @@ public class ABookCheckWebViewHelper extends ABookHelper {
sendTaskData(context, operationId, taskKey, taskReportLevel);
break;
}
case ABookKeys.CMD_MOVE_HOT_SPOT:
mOperationLogic.updateTaskHotspot(taskKey, param);
mOperationLogic.createHopSpotJson(operationId, contentPath);
......
......@@ -37,10 +37,10 @@ app_versioncode=1
# abvEnvironments.xml
#cms server
acms_address=https://check.abookcloud.com/acms
download_server_address=https://check.abookcloud.com/acms
#acms_address=https://abook188-1.abook.bz/acms
#download_server_address=https://abook188-1.abook.bz/acms
#acms_address=https://check.abookcloud.com/acms
#download_server_address=https://check.abookcloud.com/acms
acms_address=https://abook188-1.abook.bz/acms
download_server_address=https://abook188-1.abook.bz/acms
#acms_address=http://10.0.2.2:8080/acms
#download_server_address=http://10.0.2.2:8080/acms
......@@ -96,8 +96,8 @@ hope_page=http://www.sato.co.jp
contact_email=grp-atform_support@sato-global.com
#Log Settings
log_level=2
#log_level=1
#log_level=2
log_level=1
default_log_name=abvje
#エラーレポート/Exportログ送信方法 1:acms 2:平文メール(開発・テスト時のみ) 3:暗号化添付メール
......
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