Commit 658b9ed9 by Kazuyuki Hida

Merge branch 'contract/sato/1.0.300_hida' into 'contract/sato/1.0.300_dev'

ダッシュボードの実装

See merge request !264
parents f381ab70 67bed2d6
[submodule "ABVJE_Launcher_Android/assets/dashboard"]
path = ABVJE_Launcher_Android/assets/dashboard
url = git@gitlab.agentec.jp:haccp_atform/app_dashboard.git
package jp.agentec.abook.abv.bl.acms.client;
import org.json.adf.JSONObject;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
......@@ -19,6 +21,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.AuthLevelJSON;
import jp.agentec.abook.abv.bl.acms.client.json.CategoriesJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ContentCheckDeliverableJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ContentVersionsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.DashboardStatusJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GroupsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.LockReportJSON;
import jp.agentec.abook.abv.bl.acms.client.json.LogSendFlagJSON;
......@@ -80,6 +83,7 @@ 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.abook.abv.bl.logic.ReportStatusLogic;
import jp.agentec.adf.net.http.HttpDownloadState;
import jp.agentec.adf.net.http.HttpFileDownloader;
import jp.agentec.adf.net.http.HttpMultipart;
......@@ -89,6 +93,9 @@ import jp.agentec.adf.net.http.HttpResponse;
import jp.agentec.adf.util.DateTimeUtil;
import jp.agentec.adf.util.StringUtil;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportStatus;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.Message;
/**
* ACMSのAPIにアクセスするにはこのクラスを継承します。
* @author Taejin Hong
......@@ -568,6 +575,14 @@ public class AcmsClient implements AcmsClientResponseListener {
AcmsMessageJSON json = new AcmsMessageJSON(result.httpResponseBody);
// JSのコールバックに渡すために必要な情報をストックしておく(暫定的な実装 fixme )
if (apiUrl.contains(AcmsApis.ApiSendTaskData)) {
JSONObject res = new JSONObject(result.httpResponseBody);
int reportStatus = res.has(ReportStatus) ? res.getInt(ReportStatus) : null;
String message = res.has(Message) ? res.getString(Message) : null;
ReportStatusLogic.TaskReportExtParam.stock(String.valueOf(reportStatus), message);
}
Logger.d(TAG, "sendTaskData res: %s", json);
if (json.errorMessage != null) {
......@@ -735,6 +750,12 @@ public class AcmsClient implements AcmsClientResponseListener {
return new UnlockReportJSON(json);
}
public DashboardStatusJSON getDashboardStatus(AcmsParameters sid) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApiGetDashboardStatus, sid);
String json = response.httpResponseBody;
return new DashboardStatusJSON(json);
}
/**********************************************************************************************/
/** 以下、共用メソッド---------------------------------------------------------------------- **/
/**********************************************************************************************/
......@@ -940,7 +961,8 @@ public class AcmsClient implements AcmsClientResponseListener {
AcmsApis.ApiGetPushMessages,
AcmsApis.ApiSendPushMessage,
AcmsApis.ApiLockReport,
AcmsApis.ApiUnlockReport
AcmsApis.ApiUnlockReport,
AcmsApis.ApiGetDashboardStatus
};
public HttpTaskWorker(String methodName, String apiUrl, T param) {
......
......@@ -133,6 +133,30 @@ public abstract class AcmsJSONParser extends CloneableObject {
}
}
protected long getLongOrZero(JSONObject json, String key) {
if (json.has(key)) {
return json.getLong(key);
} else {
return 0;
}
}
protected Long getLongOrNull(JSONObject json, String key) {
if (json.has(key)) {
return json.getLong(key);
} else {
return null;
}
}
protected int getIntOrZero(JSONObject json, String key) {
if (json.has(key)) {
return json.getInt(key);
} else {
return 0;
}
}
protected int getIntOrDef(JSONObject json, String key, int def) {
if (json.has(key)) {
return json.getInt(key);
......@@ -156,4 +180,6 @@ public abstract class AcmsJSONParser extends CloneableObject {
return null;
}
}
}
package jp.agentec.abook.abv.bl.acms.client.json;
import org.json.adf.JSONArray;
import org.json.adf.JSONObject;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.DashboardStatusDto;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.OperationId;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.OperationList;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportList;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportStartDate;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportStatus;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.TaskKey;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.TaskReportId;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationListJSON.OperationName;
public class DashboardStatusJSON extends AcmsCommonJSON {
private static final String TAG = "DashboardStatusJSON";
private List<DashboardStatusDto> reportStatuses;
public DashboardStatusJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) {
// 使わないので無視 → //presentTimeUTC = dateOrNull(json.getString("presentTimeUTC"));
JSONArray oprations = json.getJSONArray(OperationList);
reportStatuses = new ArrayList<DashboardStatusDto>();
for (int i = 0; i < oprations.length(); i++) {
JSONObject opJson = oprations.getJSONObject(i);
try {
long operationId = getLongOrZero(opJson, OperationId);
String operationName = getStringOrNull(opJson, OperationName);
JSONArray reports = opJson.getJSONArray(ReportList);
for (int j = 0; j < reports.length(); j++) {
JSONObject repJson = reports.getJSONObject(j);
String taskKey = getStringOrNull(repJson, TaskKey);
Long taskReportId = getLongOrNull(repJson, TaskReportId);
Date reportStartDate = getDateOrNull(repJson, ReportStartDate);
int reportStatus = getIntOrZero(repJson,ReportStatus);
DashboardStatusDto rep = new DashboardStatusDto(
taskKey,
taskReportId,
reportStartDate,
operationId,
operationName,
reportStatus
);
reportStatuses.add(rep);
}
} catch (Throwable e) {
Logger.e(TAG, e);
}
}
}
public List<DashboardStatusDto> getReportStatuses() {
return reportStatuses;
}
}
......@@ -21,6 +21,10 @@ public class OperationDataJSON extends AcmsCommonJSON {
public static final String OperationLastEditDate = "operationLastEditDate";
public static final String TaskList = "taskList";
public static final String OperationId = "operationId";
public static final String OperationList = "operationList";
public static final String ReportStatusId = "reportStatusId";
public static final String ReportStatusCount = "reportStatusCount";
public static final String ReportStatusCountList = "reportStatusCountList";
public static final String TaskId = "taskId";
public static final String TaskKey = "taskKey";
public static final String TaskCode = "taskCode";
......@@ -45,7 +49,9 @@ public class OperationDataJSON extends AcmsCommonJSON {
public static final String SendBackUserName = "sendBackUserName"; // 差し戻しユーザ名 差し戻された場合のみ
public static final String SendBackComment = "sendBackComment"; // 確認コメント 差し戻された場合のみ
public static final String ReportList = "reportList";
public static final String ReportStatus = "reportStatus";
public static final String Message = "message";
public List<TaskDto> taskDtoList;
public Date lastEditDate;
......
......@@ -2,6 +2,9 @@ package jp.agentec.abook.abv.bl.acms.client.parameters;
import java.util.Date;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
/**
* checkapi/lockReport/のリクエストに使うパラメータ
*/
......@@ -10,7 +13,7 @@ public class LockReportParameters extends AcmsParameters {
private String sid;
private String taskKey;
private Long taskReportId;
private Date reportStartDate;
private String reportStartDate; // 書式の問題があるので、あえて文字列
private String userId;
private String userName;
......@@ -23,10 +26,10 @@ public class LockReportParameters extends AcmsParameters {
String userName
) {
super(sid);
this.sid = sid;
this.taskKey = taskKey;
this.taskReportId = taskReportId;
this.reportStartDate = reportStartDate;
this.reportStartDate = DateTimeUtil.toString(reportStartDate, DateTimeFormat.yyyyMMddHHmmssSSS_hyphen);
this.userId = userId;
this.userName = userName;
}
......@@ -39,7 +42,7 @@ public class LockReportParameters extends AcmsParameters {
return taskReportId;
}
public Date getReportStartDate() {
public String getReportStartDate() {
return reportStartDate;
}
......
......@@ -2,6 +2,9 @@ package jp.agentec.abook.abv.bl.acms.client.parameters;
import java.util.Date;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
/**
* checkapi/unlockReport/のリクエストに使うパラメータ
*/
......@@ -9,7 +12,7 @@ public class UnlockReportParameters extends AcmsParameters {
private String taskKey;
private Long taskReportId;
private Date reportStartDate;
private String reportStartDate; // 書式の問題があるので、あえて文字列
public UnlockReportParameters(
String sid,
......@@ -21,18 +24,18 @@ public class UnlockReportParameters extends AcmsParameters {
this.taskKey = taskKey;
this.taskReportId = taskReportId;
this.reportStartDate = reportStartDate;
this.reportStartDate = DateTimeUtil.toString(reportStartDate, DateTimeFormat.yyyyMMddHHmmssSSS_hyphen);
}
String getTaskKey() {
public String getTaskKey() {
return taskKey;
}
Long getTaskReportId() {
public Long getTaskReportId() {
return taskReportId;
}
Date getReportStartDate() {
public String getReportStartDate() {
return reportStartDate;
}
}
......@@ -164,6 +164,8 @@ public class AcmsApis {
public static final String ApiLockReport = "lockReport";
// 報告・点検のロック解除
public static final String ApiUnlockReport = "unlockReport";
// ダッシュボード
public static final String ApiGetDashboardStatus = "getDashboardStatus";
// download
/**
......@@ -211,7 +213,9 @@ public class AcmsApis {
methodName.equals(ApiSendPushMessage) || methodName.equals(ApiGetPushMessages) || methodName.equals(ApiSendRoutineTaskData) ||
methodName.equals(ApiGetMasterData) ||
// カテゴリ選択機能、IO帳票で3つ追加
methodName.equals(ApiOperationGroupMaster) || methodName.equals(ApiQuickReportSearch) || methodName.equals(ApiQuickReportRevision)) {
methodName.equals(ApiOperationGroupMaster) || methodName.equals(ApiQuickReportSearch) || methodName.equals(ApiQuickReportRevision) ||
// ダッシュボード、ロック追加
methodName.equals(ApiGetDashboardStatus) || methodName.equals(ApiLockReport) || methodName.equals(ApiUnlockReport)) {
apiValue = Constant.ApiValue.checkapi;
}
......
......@@ -36,6 +36,9 @@ public class ABookKeys {
public static final String CMD_PAGE_NUM = "pageNum";
public static final String CMD_LOCK_REPORT = "lockReport";
public static final String CMD_UNLOCK_REPORT = "unlockReport";
public static final String CMD_GET_REPORT_LIST = "getReportList";
public static final String CMD_GET_REPORT_STATUS_COUNT = "getReportStatusCount";
public static final String CMD_GO_REPORT_DETAIL = "goReportDetail";
public static final String GPS_TYPE = "gpsType";
public static final String STATUS_CODE = "statusCode";
......
......@@ -37,6 +37,7 @@ import jp.agentec.abook.abv.bl.data.tables.TEnquete;
import jp.agentec.abook.abv.bl.data.tables.TMarkingSetting;
import jp.agentec.abook.abv.bl.data.tables.TOperation;
import jp.agentec.abook.abv.bl.data.tables.TPushMessage;
import jp.agentec.abook.abv.bl.data.tables.TTaskReportStatus;
import jp.agentec.abook.abv.bl.data.tables.TSppDevice;
import jp.agentec.abook.abv.bl.data.tables.TTask;
import jp.agentec.abook.abv.bl.data.tables.TTaskReport;
......@@ -97,6 +98,7 @@ public class ABVDataOpenHelper {
iTableScripts.add(new TTaskReportSend());
iTableScripts.add(new TTaskReportItems());
iTableScripts.add(new TPushMessage());
iTableScripts.add(new TTaskReportStatus());
// SPP通信端末管理テーブルをスクリプトに追加
iTableScripts.add(new TSppDevice());
......
......@@ -19,7 +19,7 @@ import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase;
public class DBConnector {
private static volatile DBConnector dbConnector = null;
public static final String DatabaseName = "ABVJE";
public static final int DatabaseVersion = DatabaseVersions.Ver1_0_5;
public static final int DatabaseVersion = DatabaseVersions.Ver1_0_4;
protected SQLiteDatabase db = null;
......
......@@ -5,7 +5,5 @@ public class DatabaseVersions {
public static final int Ver1_0_0 = 1;
public static final int Ver1_0_2 = 11; // SATO HACCP 1.0.2
public static final int Ver1_0_3 = 21; // @From カテゴリ選択機能追加
public static final int Ver1_0_4 = 31; // @From 作業の進捗状況を追加
public static final int Ver1_0_5 = 41; // @From 作業のロック、差し戻し対応
public static final int Ver1_0_6 = 51; // @From 作業のロック情報を追加
public static final int Ver1_0_4 = 31; // @From ロック、ダッシュボード対応
}
package jp.agentec.abook.abv.bl.data.dao;
import org.json.adf.JSONArray;
import org.json.adf.JSONObject;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import jp.agentec.abook.abv.bl.common.db.Cursor;
import jp.agentec.abook.abv.bl.data.tables.TTaskReportStatus;
import jp.agentec.abook.abv.bl.dto.DashboardStatusDto;
import jp.agentec.abook.abv.bl.dto.ReportStatusCountDto;
import jp.agentec.abook.abv.bl.dto.ReportStatusDto;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportStatusCount;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportStatusCountList;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportStatusId;
public class ReportStatusDao extends AbstractDao {
public void insert(DashboardStatusDto dto) {
StringBuilder sql = new StringBuilder();
sql.append("INSERT INTO ").append(TTaskReportStatus.tableName).append(" (");
sql.append(" task_key,");
sql.append(" task_report_id,");
sql.append(" report_start_date,");
sql.append(" operation_id,");
sql.append(" operation_name,");
sql.append(" report_status,");
sql.append(" untouched_flg,");
sql.append(" working_flg,");
sql.append(" complete_ok_flg,");
sql.append(" complete_ng_flg,");
sql.append(" incomplete_flg,");
sql.append(" alert_flg,");
sql.append(" send_backed_flg)");
sql.append(" VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
insert(sql.toString(), dto.getInsertValues());
}
public void deleteAll() {
execSql("DELETE FROM " + TTaskReportStatus.tableName);
}
private StringBuilder reportStatusSql() {
StringBuilder sql = new StringBuilder();
sql.append("SELECT");
sql.append(" t_task_report_status.report_status AS report_status,");
sql.append(" t_task_report_status.operation_id AS operation_id,");
sql.append(" t_task_report_status.operation_name AS operation_name,");
sql.append(" t_task_report.task_key AS task_key,");
sql.append(" t_task.task_code AS task_code,");
sql.append(" t_task_report.json_data AS json_data,");
sql.append(" t_task_report.task_report_id AS task_report_id,");
sql.append(" t_task_report.report_start_date AS report_start_date,");
sql.append(" t_task_report.report_lock_user_id AS report_lock_user_id,");
sql.append(" t_task_report.report_lock_user_name AS report_lock_user_name,");
sql.append(" t_task_report.report_lock_time AS report_lock_time,");
sql.append(" t_task_report.send_back_user_id AS send_back_user_id,");
sql.append(" t_task_report.send_back_user_name AS send_back_user_name,");
sql.append(" t_task_report.send_back_comment AS send_back_comment ");
sql.append(" FROM t_task_report ");
sql.append(" INNER JOIN t_task ");
sql.append(" ON t_task_report.task_key = t_task.task_key ");
sql.append(" INNER JOIN t_task_report_status");
// 定期点検の場合
sql.append(" ON (t_task_report.task_report_id = t_task_report_status.task_report_id");
sql.append(" AND t_task_report.report_start_date = t_task_report_status.report_start_date)");
// 報告の場合
sql.append(" OR (t_task_report.task_key = t_task_report_status.task_key");
sql.append(" AND t_task_report_status.task_report_id is null");
sql.append(" AND t_task_report_status.report_start_date is null)");
return sql;
}
public List<ReportStatusDto> getUntouchedReport() {
StringBuilder sql = reportStatusSql();
sql.append("WHERE t_task_report_status.untouched_flg <> 0");
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
}
public List<ReportStatusDto> getWorkingReport() {
StringBuilder sql = reportStatusSql();
sql.append("WHERE t_task_report_status.working_flg <> 0");
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
}
public List<ReportStatusDto> getCompleteOkReport() {
StringBuilder sql = reportStatusSql();
sql.append("WHERE t_task_report_status.complete_ok_flg <> 0");
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
}
public List<ReportStatusDto> getCompleteNgReport() {
StringBuilder sql = reportStatusSql();
sql.append("WHERE t_task_report_status.complete_ng_flg <> 0");
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
}
public List<ReportStatusDto> getIncompleteReport() {
StringBuilder sql = reportStatusSql();
sql.append("WHERE t_task_report_status.incomplete_flg <> 0");
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
}
public List<ReportStatusDto> getAlertReport() {
StringBuilder sql = reportStatusSql();
sql.append("WHERE t_task_report_status.alert_flg <> 0");
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
}
public List<ReportStatusDto> getSendBackedReport() {
StringBuilder sql = reportStatusSql();
sql.append("WHERE t_task_report_status.send_backed_flg <> 0");
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
}
public List<ReportStatusDto> getPendingReport() {
StringBuilder sql = new StringBuilder();
sql.append("SELECT");
sql.append(" 0 AS report_status,");
sql.append(" t_operation.operation_id AS operation_id,");
sql.append(" t_operation.operation_name AS operation_name,");
sql.append(" t_task_report.task_key AS task_key,");
sql.append(" t_task.task_code AS task_code,");
sql.append(" t_task_report.json_data AS json_data,");
sql.append(" t_task_report.task_report_id AS task_report_id,");
sql.append(" t_task_report.report_start_date AS report_start_date,");
sql.append(" t_task_report.report_lock_user_id AS report_lock_user_id,");
sql.append(" t_task_report.report_lock_user_name AS report_lock_user_name,");
sql.append(" t_task_report.report_lock_time AS report_lock_time,");
sql.append(" t_task_report.send_back_user_id AS send_back_user_id,");
sql.append(" t_task_report.send_back_user_name AS send_back_user_name,");
sql.append(" t_task_report.send_back_comment AS send_back_comment ");
sql.append(" FROM t_task_report ");
sql.append(" INNER JOIN t_task ");
sql.append(" ON t_task_report.task_key = t_task.task_key ");
sql.append(" INNER JOIN t_operation ");
sql.append(" ON t_task.operation_id = t_operation.operation_id ");
sql.append(" WHERE t_task_report.local_saved_flg <> 0");
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
}
@Override
protected ReportStatusDto convert(Cursor cursor) {
ReportStatusDto dto = new ReportStatusDto();
dto.reportStatus = intOrZero(cursor, "report_status");
dto.operationId = longOrZero(cursor, "operation_id");
dto.operationName = stringOrEmpty(cursor, "operation_name");
dto.taskKey = stringOrEmpty(cursor, "task_key");
dto.taskCode = stringOrNull(cursor, "task_code");
dto.taskReportInfo = stringOrEmpty(cursor, "json_data");
dto.taskReportId = longOrNull(cursor, "task_report_id");
dto.reportStartDate = dateOrNull(cursor, "report_start_date");
dto.reportLockUserId = stringOrNull(cursor, "report_lock_user_id");
dto.reportLockUserName = stringOrNull(cursor, "report_lock_user_name");
dto.reportLockTime = dateOrNull(cursor, "report_lock_time");
dto.sendBackUserId = stringOrNull(cursor, "send_back_user_id");
dto.sendBackUserName = stringOrNull(cursor, "send_back_user_name");
dto.sendBackComment = stringOrNull(cursor, "send_back_comment");
return dto;
}
private String stringOrNull(Cursor cursor, String name) {
int column = cursor.getColumnIndex(name);
if (column < 0) {
return null;
} else {
return cursor.getString(column);
}
}
private String stringOrEmpty(Cursor cursor, String name) {
int column = cursor.getColumnIndex(name);
if (column < 0) {
return "";
} else {
return cursor.getString(column);
}
}
private Date dateOrNull(Cursor cursor, String name) {
int column = cursor.getColumnIndex(name);
if (column < 0) {
return null;
} else {
String date = cursor.getString(column);
return DateTimeUtil.toDate(date, "UTC", DateTimeFormat.yyyyMMdd_hyphen);
}
}
private int intOrZero(Cursor cursor, String name) {
int column = cursor.getColumnIndex(name);
if (column < 0) {
return 0;
} else {
return cursor.getInt(column);
}
}
private long longOrZero(Cursor cursor, String name) {
int column = cursor.getColumnIndex(name);
if (column < 0) {
return 0;
} else {
return cursor.getLong(column);
}
}
private Long longOrNull(Cursor cursor, String name) {
int column = cursor.getColumnIndex(name);
if (column < 0) {
return null;
} else {
return cursor.getLong(column);
}
}
public List<ReportStatusCountDto> getReportStatusCountList() {
List<ReportStatusCountDto> list = new ArrayList<ReportStatusCountDto>();
/*
0:未実施、1:作業中、
2:作業完了(異常なし)、
3:作業完了(異常あり)、
4:期限切れ、5:アラート、
6:差し戻し、7:一時保存
*/
list.add(makeDto(0, getUntouchedReport().size()));
list.add(makeDto(1, getWorkingReport().size()));
list.add(makeDto(2, getCompleteOkReport().size()));
list.add(makeDto(3, getCompleteNgReport().size()));
list.add(makeDto(4, getIncompleteReport().size()));
list.add(makeDto(5, getAlertReport().size()));
list.add(makeDto(6, getSendBackedReport().size()));
list.add(makeDto(7, getPendingReport().size()));
return list;
}
private ReportStatusCountDto makeDto(int id, int count) {
return new ReportStatusCountDto(String.valueOf(id), String.valueOf(count));
}
public JSONObject getReportStatusCountJson() {
JSONArray list = new JSONArray();
for (ReportStatusCountDto dto: getReportStatusCountList()) {
JSONObject json = new JSONObject();
json.put(ReportStatusId, dto.getReportStatusId());
json.put(ReportStatusCount, dto.getReportStatusCount());
list.put(json);
}
JSONObject result = new JSONObject();
result.put(ReportStatusCountList, list);
return result;
}
}
......@@ -177,7 +177,7 @@ public class TaskReportDao extends AbstractDao {
*/
public boolean update(TaskReportDto dto) {
Object[] objects;
StringBuffer sql = new StringBuffer();
StringBuilder sql = new StringBuilder();
sql.append("UPDATE t_task_report SET ");
sql.append("json_data=?, ");
sql.append("attached_file_name=?, ");
......@@ -223,15 +223,17 @@ public class TaskReportDao extends AbstractDao {
* @param reportLockUserId
* @param reportLockUserName
* @param reportLockTime
* @param loginId
* @return
*/
public boolean updateReportLock(
public void updateReportLock(
String taskKey,
Date reportStartDate,
int reportStatus,
String reportLockUserId,
String reportLockUserName,
Date reportLockTime
Date reportLockTime,
String loginId
) {
StringBuilder sql = new StringBuilder();
List<Object> args = new ArrayList<Object>();
......@@ -241,7 +243,7 @@ public class TaskReportDao extends AbstractDao {
sql.append(" report_lock_user_id=?, ");
sql.append(" report_lock_user_name=?, ");
sql.append(" report_lock_time=? ");
sql.append("WHERE task_key=? ");
sql.append(" WHERE task_key=? ");
if (reportStartDate != null) {
sql.append("AND datetime(report_start_date)=datetime(?);");
}
......@@ -254,8 +256,11 @@ public class TaskReportDao extends AbstractDao {
if (reportStartDate != null) {
args.add(reportStartDate);
}
if (loginId != null) {
args.add(loginId);
}
return update(sql.toString(), args.toArray()) > 0;
update(sql.toString(), args.toArray());
}
/**
......
......@@ -46,6 +46,8 @@ public class TTaskReport extends SQLiteTableScript {
sql.append(" ) ");
ddl.add(sql.toString());
ddl.add("CREATE INDEX idx_task_key1 ON t_task_report(task_key, task_report_id, report_start_date)");
return ddl;
}
......@@ -53,7 +55,7 @@ public class TTaskReport extends SQLiteTableScript {
@Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) {
List<String> ddl = new ArrayList<String>();
if (oldVersion < DatabaseVersions.Ver1_0_5) {
if (oldVersion < DatabaseVersions.Ver1_0_4) {
ddl.add(" ALTER TABLE t_task_report ADD COLUMN report_lock_user_id TEXT"); // 報告ロックユーザId
ddl.add(" ALTER TABLE t_task_report ADD COLUMN report_lock_user_name TEXT"); //報告ロックユーザ名
ddl.add(" ALTER TABLE t_task_report ADD COLUMN report_lock_time DATETIME"); // 報告ロック日時
......@@ -61,10 +63,11 @@ public class TTaskReport extends SQLiteTableScript {
ddl.add(" ALTER TABLE t_task_report ADD COLUMN send_back_user_name TEXT"); // 差し戻しユーザ名 差し戻された場合のみ
ddl.add(" ALTER TABLE t_task_report ADD COLUMN send_back_comment TEXT"); // 確認コメント 差し戻された場合のみ
ddl.add(" ALTER TABLE t_task_report ADD COLUMN task_status INTEGER NOT NULL DEFAULT 0"); // 状況 0:未実施、1:作業中、999:作業完了
}
if (oldVersion < DatabaseVersions.Ver1_0_6) {
ddl.add(" ALTER TABLE t_task_report ADD COLUMN report_status INTEGER NOT NULL DEFAULT 0"); // 0:ロック成功、1:ロック中、2:承認中、999:その他エラー
ddl.add("CREATE INDEX idx_task_key1 on t_task_report(task_key, task_id, report_start_date)");
ddl.add("CREATE INDEX idx_task_key2 on t_task_report_status(task_key, task_id, report_start_date)");
}
return ddl;
}
......
package jp.agentec.abook.abv.bl.data.tables;
import java.util.ArrayList;
import java.util.List;
import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase;
import static jp.agentec.abook.abv.bl.data.DatabaseVersions.Ver1_0_4;
public class TTaskReportStatus extends SQLiteTableScript {
public static final String tableName = "t_task_report_status";
@Override
public List<String> getCreateScript(int version) {
List<String> ddl = new ArrayList<String>();
StringBuilder sql = new StringBuilder();
sql.append("CREATE TABLE " + tableName +" ( ");
sql.append(" task_key TEXT NOT NULL DEFAULT '',");
sql.append(" task_code TEXT NOT NULL DEFAULT '',");
sql.append(" task_report_id INTEGER,");
sql.append(" report_start_date DATETIME,");
sql.append(" operation_id BIGINT NOT NULL DEFAULT 0,");
sql.append(" operation_name TEXT NOT NULL DEFAULT '',");
sql.append(" report_status INTEGER NOT NULL DEFAULT 0,");
sql.append(" untouched_flg INTEGER NOT NULL DEFAULT 0,"); // 未実施(0x01)
sql.append(" working_flg INTEGER NOT NULL DEFAULT 0,"); // 作業中(0x02)
sql.append(" complete_ok_flg INTEGER NOT NULL DEFAULT 0,"); // 作業完了 異常なし(0x04)
sql.append(" complete_ng_flg INTEGER NOT NULL DEFAULT 0,"); // 作業完了 異常あり(0x08)
sql.append(" incomplete_flg INTEGER NOT NULL DEFAULT 0,"); // 期限切れ(0x10)
sql.append(" alert_flg INTEGER NOT NULL DEFAULT 0,"); // アラート(0x20)
sql.append(" send_backed_flg INTEGER NOT NULL DEFAULT 0)"); // 差し戻し(0x40)
ddl.add(sql.toString());
ddl.add("CREATE INDEX idx_task_key2 ON t_task_report_status(task_key, task_report_id, report_start_date)");
return ddl;
}
@Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) {
if (oldVersion < Ver1_0_4) {
return getCreateScript(newVersion);
} else {
return null;
}
}
@Override
public List<String> getMigrationScript(SQLiteDatabase databaseConnection, int oldVersion, int newVersion, Object[] params) {
return null;
}
}
package jp.agentec.abook.abv.bl.dto;
import java.util.Date;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
public class DashboardStatusDto extends AbstractDto {
private static final int FLG_UNTOUCHED = 0x01; // 未実施(0x01)
private static final int FLG_WORKING = 0x02; // 作業中(0x02)
private static final int FLG_COMPLETE_OK = 0x04; // 作業完了 異常なし(0x04)
private static final int FLG_COMPLETE_NG = 0x08; // 作業完了 異常あり(0x08)
private static final int FLD_INCOMPLETED = 0x10; // 期限切れ(0x10)
private static final int FLG_ALERT = 0x20; // アラート(0x20)
private static final int FLG_SEND_BACK = 0x40; // 差し戻し(0x40)
public static int UNTOUCHED = 0; // 0:未実施
public static int WORKING = 1; // 1:作業中
public static int COMPLETE_OK = 2; // 2:作業完了(異常なし)
public static int COMPLETE_NG = 3; // 3:作業完了(異常あり)
public static int INCOMPLETED = 4; // 4:期限切れ
public static int ALERT = 5; // 5:アラート
public static int SEND_BACKED = 6; // 6:差し戻し
public static int IN_PROGRESS = 7; // 7:一時保存
// taskReportを一意にさすためのキー
private String taskKey;
private Long taskReportId;
private Date reportStartDate;
// 一覧表示で必要な付加情報
private long operationId;
private String operationName;
// taskの状態を示すビットフィールド
private int reportStatus;
// reportStatusの各ビットに対応するフラグ
private int untouchedFlg;
private int workingFlg;
private int completeOkFlg;
private int completeNgFlg;
private int incompleteFlg;
private int alertFlg;
private int sendBackedFlg;
public DashboardStatusDto(
String taskKey,
Long taskReportId,
Date reportStartDate,
long operationId,
String operatonName,
int reportStatus
) {
this.taskKey = taskKey;
this.taskReportId = taskReportId;
this.reportStartDate = reportStartDate;
this.operationId = operationId;
this.operationName = operatonName;
this.reportStatus = reportStatus;
untouchedFlg = reportStatus & FLG_UNTOUCHED;
workingFlg = reportStatus & FLG_WORKING;
completeOkFlg = reportStatus & FLG_COMPLETE_OK;
completeNgFlg = reportStatus & FLG_COMPLETE_NG;
incompleteFlg = reportStatus & FLD_INCOMPLETED;
alertFlg = reportStatus & FLG_ALERT;
sendBackedFlg = reportStatus & FLG_SEND_BACK;
}
@Override
public String[] getKeyValues() {
return new String[] {
String.valueOf(taskKey),
String.valueOf(taskReportId),
DateTimeUtil.toString(reportStartDate, DateTimeFormat.yyyyMMdd_hyphen)
};
}
@Override
public Object[] getInsertValues() {
return new Object[] {
taskKey,
taskReportId,
reportStartDate,
operationId,
operationName,
reportStatus,
untouchedFlg, // 未実施(0x01)
workingFlg, // 作業中(0x02)
completeOkFlg, // 作業完了 異常なし(0x04)
completeNgFlg, // 作業完了 異常あり(0x08)
incompleteFlg, // 期限切れ(0x10)
alertFlg, // アラート(0x20)
sendBackedFlg // 差し戻し(0x40)
};
}
public String getTaskKey() {
return taskKey;
}
public Long getTaskReportId() {
return taskReportId;
}
public Date getReportStartDate() {
return reportStartDate;
}
public int getReportStatus() {
return reportStatus;
}
public long getOperationId() {
return operationId;
}
public String getOperationName() {
return operationName;
}
}
package jp.agentec.abook.abv.bl.dto;
public class ReportStatusCountDto extends AbstractDto {
@Override
public String[] getKeyValues() {
return new String[0];
}
@Override
public Object[] getInsertValues() {
return new Object[0];
}
public ReportStatusCountDto(String id, String count) {
reportStatusId = id;
reportStatusCount = count;
}
private final String reportStatusId;
private final String reportStatusCount;
public String getReportStatusId() {
return reportStatusId;
}
public String getReportStatusCount() {
return reportStatusCount;
}
}
package jp.agentec.abook.abv.bl.dto;
import java.util.Date;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
public class ReportStatusDto extends AbstractDto {
public int reportStatus;
public long operationId;
public String operationName;
public String taskKey;
public String taskCode;
public String taskReportInfo;
public Long taskReportId;
public Date reportStartDate;
public String reportLockUserId;
public String reportLockUserName;
public Date reportLockTime;
public String sendBackUserId;
public String sendBackUserName;
public String sendBackComment;
@Override
public String[] getKeyValues() {
return new String[0];
}
@Override
public Object[] getInsertValues() {
return new Object[0];
}
public int getReportStatus() {
return reportStatus;
}
public long getOperationId() {
return operationId;
}
public String getOperationName() {
return operationName;
}
public String getTaskKey() {
return taskKey;
}
public String getTaskCode() {
return taskCode;
}
public String getTaskReportInfo() {
return taskReportInfo;
}
public Long getTaskReportId() {
return taskReportId;
}
public Date getReportStartDate() {
return reportStartDate;
}
public String getReportStartDateAsString() {
return DateTimeUtil.toString(reportStartDate, DateTimeFormat.yyyyMMddHHmmss_hyphen);
}
public String getReportLockUserId() {
return reportLockUserId;
}
public String getReportLockUserName() {
return reportLockUserName;
}
public Date getReportLockTime() {
return reportLockTime;
}
public String getReportLockTimeAsString() {
return DateTimeUtil.toString(reportLockTime, DateTimeFormat.yyyyMMddHHmmss_hyphen);
}
public String getSendBackUserId() {
return sendBackUserId;
}
public String getSendBackUserName() {
return sendBackUserName;
}
public String getSendBackComment() {
return sendBackComment;
}
}
package jp.agentec.abook.abv.bl.dto.comparator;
import java.util.Comparator;
import jp.agentec.abook.abv.bl.dto.ReportStatusDto;
public class ReportStatusCompalator implements Comparator<ReportStatusDto> {
@Override
public int compare(ReportStatusDto o1, ReportStatusDto o2) {
if (o1 == null && o2 == null) {
return 0;
} else if (o1 == null) {
return 1;
} else if (o2 == null) {
return -1;
}
return Long.compare(o1.getOperationId(), o2.getOperationId());
}
}
......@@ -3,11 +3,12 @@ package jp.agentec.abook.abv.bl.logic;
import org.json.adf.JSONObject;
import java.util.Date;
import java.util.Map;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.LockReportJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.LockReportParameters;
import jp.agentec.abook.abv.bl.data.dao.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.TaskReportDao;
import jp.agentec.abook.abv.bl.dto.MemberInfoDto;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
......@@ -27,15 +28,12 @@ public class LockReportLogic extends AbstractLogic {
return new LockReportLogic();
}
public Result lock(Map<String, String> param) {
Long taskReportId = longOrNull(param.get(TaskReportId));
Date reportStartDate = dateOrNull(param.get(ReportStartDate));
return sendLockReport(
param.get(TASK_KEY),
taskReportId,
reportStartDate
);
public Result lock(String taskKey, Long taskReportId, Date reportStartDate) {
Result r = sendLockReport(taskKey, taskReportId, reportStartDate);
if (r.result == 0) {
updateLocalDB(taskKey, reportStartDate, r.getExtParam().reportStatus);
}
return r;
}
private Result sendLockReport(
......@@ -67,20 +65,22 @@ public class LockReportLogic extends AbstractLogic {
}
}
private Long longOrNull(String s) {
try {
return Long.valueOf(s);
} catch (Exception e) {
return null;
}
}
private Date dateOrNull(String s) {
try {
return DateTimeUtil.toDate(s, "UTC", DateTimeFormat.yyyyMMdd_hyphen);
} catch (Exception e) {
return null;
}
private void updateLocalDB(
String taskKey,
Date reportStartDate,
int reportStatus
) {
MemberInfoDto member = cache.getMemberInfo();
TaskReportDao dao = AbstractDao.getDao(TaskReportDao.class);
dao.updateReportLock(
taskKey,
reportStartDate,
reportStatus,
member.loginId,
member.memberName,
new Date(),
null
);
}
// コールバック用のパラメータ
......@@ -176,23 +176,27 @@ public class LockReportLogic extends AbstractLogic {
this.reportStartDate = reportStartDate;
}
@SuppressWarnings("unused")
public int getReportStatus() {
return reportStatus;
}
@SuppressWarnings("unused")
public String getReportLockUserId() {
return reportLockUserId;
}
@SuppressWarnings("unused")
public String getReportLockUserName() {
return reportLockUserName;
}
@SuppressWarnings("unused")
public Date getReportLockTime() {
return reportLockTime;
}
@SuppressWarnings("unused")
public String json() {
JSONObject extParam = new JSONObject();
extParam.put(ReportStatus, String.valueOf(reportStatus));
......
......@@ -24,8 +24,6 @@ import jp.agentec.abook.abv.bl.acms.client.json.SceneEntryJSON;
import jp.agentec.abook.abv.bl.acms.client.json.WorkerGroupJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetTaskFileParameters;
import jp.agentec.abook.abv.bl.acms.type.OperationSortingType;
import jp.agentec.abook.abv.bl.acms.type.OperationType;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.Callback;
......@@ -252,6 +250,12 @@ public class OperationLogic extends AbstractLogic {
String operationTaskDirPath = ABVEnvironment.getInstance().getOperationDirFile(deleteOperationDto.operationId);
FileUtil.delete(operationTaskDirPath);
}
// 一通りの更新が終わってから、ダッシュボード用の情報を取得する
// todo
Logger.i(TAG, "update tasks on dashboard");
ReportStatusLogic logic = new ReportStatusLogic();
logic.loadReportStatus();
}
/**
......
package jp.agentec.abook.abv.bl.logic;
import java.util.List;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.DashboardStatusJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsParameters;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.dao.ReportStatusDao;
import jp.agentec.abook.abv.bl.dto.DashboardStatusDto;
public class ReportStatusLogic extends AbstractLogic {
private static final String TAG = "ReportStatusLogic";
private List<DashboardStatusDto> getDashboardStatus() {
if (!networkAdapter.isNetworkConnected()) {
return null;
}
try {
AcmsClient client = AcmsClient.getInstance(networkAdapter);
String sid = cache.getMemberInfo().sid;
AcmsParameters params = new AcmsParameters(sid);
DashboardStatusJSON statuses = client.getDashboardStatus(params);
return statuses.getReportStatuses();
} catch (NetworkDisconnectedException e) {
return null;
} catch (AcmsException e) {
Logger.e(TAG, e.getLocalizedMessage());
return null;
}
}
public void loadReportStatus() {
List<DashboardStatusDto> received = getDashboardStatus();
if (received != null && !received.isEmpty()) {
// DBの更新
ReportStatusDao dao = new ReportStatusDao();
dao.beginTransaction();
try {
dao.deleteAll();
for (DashboardStatusDto dto : received) {
dao.insert(dto);
}
dao.commit();
} catch (Throwable e) {
dao.rollback();
}
}
}
/**
* API checkapi/taskData/で得られた、
*   reportStatus
*   message
* をJavaScriptのコールバックを呼び出すときに使用するため保持しておくところ。
* スレッドセーフにはなっていないし、スコープはpublicだしという行儀の悪い実装方法であるが、
* APIの呼び出しとコールバックの呼び出しが、コードとして遠くに離れているので、
* 適切な方法がないため、やむなくこのような実装になっている。
*/
public static class TaskReportExtParam {
public String reportStatus; // 0:成功、2:承認中、999:その他エラー
public String message; // reportStatus = 0 以外の時のエラーメッセージ reportStatus = 0 の時は無し
private static TaskReportExtParam instance = null;
public static void stock(String reportStatus, String message) {
if (instance == null) {
instance = new TaskReportExtParam();
}
instance.reportStatus = reportStatus;
instance.message = message;
}
public static TaskReportExtParam pick() {
if (instance == null || instance.reportStatus == null) {
return null;
} else {
return instance;
}
}
public static void clear() {
if (instance != null) {
instance.message = null;
instance.reportStatus = null;
}
}
}
}
......@@ -3,13 +3,14 @@ package jp.agentec.abook.abv.bl.logic;
import org.json.adf.JSONObject;
import java.util.Date;
import java.util.Map;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.UnlockReportJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.UnlockReportParameters;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.nw.NetworkAdapter;
import jp.agentec.abook.abv.bl.data.dao.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.TaskReportDao;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
......@@ -25,15 +26,13 @@ public class UnlockReportLogic extends AbstractLogic {
return new UnlockReportLogic();
}
public Result unlock(Map<String, String> param) {
Long taskReportId = longOrNull(param.get(TaskReportId));
Date reportStartDate = dateOrNull(param.get(ReportStartDate));
return sendUnlockReport(
param.get(TaskKey),
taskReportId,
reportStartDate
);
public Result unlock(String taskKey, Long taskReportId, Date reportStartDate) {
String loginId = cache.getMemberInfo().loginId;
Result r = sendUnlockReport(taskKey, taskReportId, reportStartDate);
if (r.result == 0) {
updateLocalDB(taskKey, reportStartDate, r.extParam.getReportStatus(), loginId);
}
return r;
}
private Result sendUnlockReport(
......@@ -63,20 +62,23 @@ public class UnlockReportLogic extends AbstractLogic {
}
}
private Long longOrNull(String s) {
try {
return Long.valueOf(s);
} catch (Exception e) {
return null;
}
}
private Date dateOrNull(String s) {
try {
return DateTimeUtil.toDate(s, "UTC", DateTimeFormat.yyyyMMdd_hyphen);
} catch (Exception e) {
return null;
}
private void updateLocalDB(
String taskKey,
Date reportStartDate,
int reportStatus,
String loginId
) {
// ローカルDBに反映
TaskReportDao dao = AbstractDao.getDao(TaskReportDao.class);
dao.updateReportLock(
taskKey,
reportStartDate,
reportStatus,
null,
null,
null,
loginId
);
}
// コールバック用のパラメータ
......
Subproject commit 7bcb5bfc6820f6ea7f9dc94d32dc982deaced578
package jp.agentec.abook.abv.ui.common.activity;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
......@@ -44,8 +45,6 @@ import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.ABVDataCache;
import jp.agentec.abook.abv.bl.data.dao.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.TaskReportDao;
import jp.agentec.abook.abv.bl.download.ContentFileExtractor;
import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.dto.MydataDto;
......@@ -55,6 +54,7 @@ import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.ContentReadingLogLogic;
import jp.agentec.abook.abv.bl.logic.LockReportLogic;
import jp.agentec.abook.abv.bl.logic.OperationLogic;
import jp.agentec.abook.abv.bl.logic.ReportStatusLogic;
import jp.agentec.abook.abv.bl.logic.UnlockReportLogic;
import jp.agentec.abook.abv.bl.websocket.MeetingManager;
import jp.agentec.abook.abv.cl.environment.DeviceInfo;
......@@ -85,7 +85,10 @@ 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.Message;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportStartDate;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportStatus;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.TaskKey;
public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
......@@ -147,6 +150,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
private boolean mLocationSendResult; // GPS送信フラグ
@SuppressLint("SourceLockedOrientationActivity")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -652,7 +656,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
finish();
}
protected void createCheckToolbar() {
@SuppressLint("SourceLockedOrientationActivity")
protected void createCheckToolbar() {
final RelativeLayout fl;
if (operationDto != null && operationDto.operationType == OperationType.PDF && mXWalkOpenType == Constant.XWalkOpenType.TASK_REPORT) {
fl = (RelativeLayout) findViewById(R.id.RelativeLayout2);
......@@ -889,11 +894,11 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
mAddReport = Integer.parseInt(abookCheckParam.get(ABookKeys.ADD_REPORT)) > 0 ? true : false;
}
int taskReportId = 0;
long taskReportId = 0;
String reportStartDate = "";
if (operationDto.reportType == Constant.ReportType.RoutineTask && abookCheckParam.get(ABookKeys.TASK_REPORT_ID) != null && abookCheckParam.get(ABookKeys.REPORT_START_DATE) != null) {
taskReportId = Integer.parseInt(abookCheckParam.get(ABookKeys.TASK_REPORT_ID));
taskReportId = Long.parseLong(abookCheckParam.get(ABookKeys.TASK_REPORT_ID));
reportStartDate = abookCheckParam.get(ABookKeys.REPORT_START_DATE);
}
......@@ -974,8 +979,15 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
afterABookCheckApi(mCmd, mTaskKey, 0, "", null, isOperationPdf());
return null;
}
if (mAddReport) { // 作業追加ありの場合
if (mCmd.equals(ABookKeys.CMD_INSERT_TASK_REPORT) || mCmd.equals(ABookKeys.CMD_UPDATE_TASK_REPORT)) {
ReportStatusLogic.TaskReportExtParam extParam = ReportStatusLogic.TaskReportExtParam.pick();
JSONObject extJson = new JSONObject();
if (extParam != null) {
extJson.put(ReportStatus, extParam.reportStatus);
extJson.put(Message, extParam.message);
}
afterABookCheckApi(mCmd, mTaskKey, 0, "", extJson.toString(), isOperationPdf());
} else if (mAddReport) { // 作業追加ありの場合
// コールバック処理のみ行う。
afterABookCheckApi(mCmd, mTaskKey, 0, "", null, isOperationPdf());
} else {
......@@ -1079,45 +1091,19 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// 1:中心温度計 2:置くだけセンサー 3:バーコード
getDeviceInfo(abookCheckParam);
} else if (mCmd.equals(ABookKeys.CMD_LOCK_REPORT)) {
LockReportLogic.Result r = LockReportLogic.newInstance().lock(abookCheckParam);
// ローカルDBに反映
TaskReportDao dao = AbstractDao.getDao(TaskReportDao.class);
dao.updateReportLock(
mTaskKey,
dateOrNull(abookCheckParam.get(ReportStartDate)),
r.getExtParam().getReportStatus(),
r.getExtParam().getReportLockUserId(),
r.getExtParam().getReportLockUserName(),
r.getExtParam().getReportLockTime()
);
String taskKey = abookCheckParam.get(TaskKey);
Date startDate = DateTimeUtil.toDate(reportStartDate, "UTC", DateTimeFormat.yyyyMMdd_hyphen);
// ロック
LockReportLogic.Result r = LockReportLogic.newInstance().lock(taskKey, taskReportId, startDate);
// JSコールバック
afterABookCheckApi(
mCmd,
mTaskKey,
r.getResult(),
r.getMessage(),
r.getExtParam().json()
);
afterABookCheckApi(mCmd, mTaskKey, r.getResult(), r.getMessage(), r.getExtParam().json());
} else if (mCmd.equals(ABookKeys.CMD_UNLOCK_REPORT)) {
UnlockReportLogic.Result r = UnlockReportLogic.newInstance().unlock(abookCheckParam);
// ローカルDBに反映
TaskReportDao dao = AbstractDao.getDao(TaskReportDao.class);
dao.updateReportLock(
mTaskKey,
dateOrNull(abookCheckParam.get(ReportStartDate)),
r.getExtParam().getReportStatus(),
null,
null,
null
);
String taskKey = abookCheckParam.get(TaskKey);
Date startDate = dateOrNull(abookCheckParam.get("reportStartDate"));
// アンロック
UnlockReportLogic.Result r = UnlockReportLogic.newInstance().unlock(taskKey, taskReportId, startDate);
// JSコールバック
afterABookCheckApi(
mCmd,
mTaskKey,
r.getResult(),
r.getMessage(),
r.getExtParam().json()
);
afterABookCheckApi(mCmd, mTaskKey, r.getResult(), r.getMessage(), r.getExtParam().json());
}
}
......
package jp.agentec.abook.abv.ui.home.activity;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.webkit.ValueCallback;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
......@@ -15,14 +16,67 @@ import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import org.json.adf.JSONArray;
import org.json.adf.JSONObject;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jp.agentec.abook.abv.bl.acms.type.OperationType;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
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.OperationContentDao;
import jp.agentec.abook.abv.bl.data.dao.OperationDao;
import jp.agentec.abook.abv.bl.data.dao.ReportStatusDao;
import jp.agentec.abook.abv.bl.download.ContentFileExtractor;
import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.dto.OperationContentDto;
import jp.agentec.abook.abv.bl.dto.OperationDto;
import jp.agentec.abook.abv.bl.dto.ReportStatusDto;
import jp.agentec.abook.abv.bl.dto.comparator.ReportStatusCompalator;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.LockReportLogic;
import jp.agentec.abook.abv.bl.logic.OperationLogic;
import jp.agentec.abook.abv.bl.logic.UnlockReportLogic;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.constant.ErrorCode;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
import jp.agentec.abook.abv.ui.viewer.activity.HTMLXWalkWebViewActivity;
import jp.agentec.abook.abv.ui.viewer.view.CheckFormWebview;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.OperationId;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportList;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportLockTime;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportLockUserId;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportLockUserName;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportStartDate;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportStatusId;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.SendBackUserId;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.SendBackUserName;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.TaskKey;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.TaskReportId;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.TaskReportInfo;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationListJSON.OperationList;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationListJSON.OperationName;
import static jp.agentec.abook.abv.bl.common.constant.ABookKeys.CMD_GET_REPORT_LIST;
import static jp.agentec.abook.abv.bl.common.constant.ABookKeys.CMD_GET_REPORT_STATUS_COUNT;
import static jp.agentec.abook.abv.bl.common.constant.ABookKeys.CMD_GO_REPORT_DETAIL;
import static jp.agentec.abook.abv.bl.common.constant.ABookKeys.CMD_LOCK_REPORT;
import static jp.agentec.abook.abv.bl.common.constant.ABookKeys.CMD_UNLOCK_REPORT;
public class DashboardActivity extends OperationActivity {
private static final String TAG = "DashboardActivity";
private static final String DASHBOARD_URL = "file:///android_asset/dashboard/app/index.html";
private WebView webView;
private String url = "https://abook188-1.abook.bz/acms/asp/login/";
private ProgressBar progress;
@Override
......@@ -36,7 +90,7 @@ public class DashboardActivity extends OperationActivity {
@Override
public void onClick(View v) {
Logger.d(TAG, "ReloadUrl");
webView.loadUrl(url + "&reload=true");
webView.loadUrl(DASHBOARD_URL);
}
});
......@@ -47,7 +101,7 @@ public class DashboardActivity extends OperationActivity {
frameLayout.addView(webView, new LinearLayout.LayoutParams(FP, FP));
// 読み込み
webView.loadUrl(url);
webView.loadUrl(DASHBOARD_URL);
}
@Override
......@@ -87,10 +141,10 @@ public class DashboardActivity extends OperationActivity {
}
initSettings(webView.getSettings());
webView.setWebChromeClient(new ChromeClient());
webView.setWebViewClient(new WebViewClient());
webView.setWebViewClient(new ViewClient());
// webView.addJavascriptInterface(jsInf, "android");
Logger.d(TAG, "loadUrl: " + url);
webView.addJavascriptInterface(new JsInf(), "android");
Logger.d(TAG, "loadUrl: " + DASHBOARD_URL);
}
@SuppressLint("SetJavaScriptEnabled")
......@@ -124,54 +178,337 @@ public class DashboardActivity extends OperationActivity {
}
}
}
}
private class JsInf {
@JavascriptInterface
public void existSetLocation(String ret) {
Logger.d(TAG, "existSetLocation=%s", ret);
if (ret != null && ret.equals("true")) { // setLocationメソッドが存在する場合、ページ読み込み完了とみなす
//isPageFinished = true;
} else { // 存在しない場合、ページ読み込み未完了とみなし1秒後に再度呼出しを繰り返す
handler.postDelayed(new Runnable() {
@Override
public void run() {
//callExistsSetLocation();
}
}, 1000);
}
}
@JavascriptInterface
public void existSendLog(String ret) {
Logger.d(TAG, "existSendLog=%s", ret);
if (ret != null && ret.equals("true")) {
runOnUiThread(new Runnable() { // sendLogメソッドが存在する場合、呼び出す
@Override
public void run() {
try {
webView.loadUrl("javascript:sendLog()");
} catch (Exception e) {
Logger.e(TAG, "javascript:sendLog error. " + e.toString());
}
}
});
} else {
finish();
}
}
@JavascriptInterface
public void getAttachedDataUrl(String taskKey, String data) {
//commonAttachedDataUrl(taskKey, data);
}
}
private class ViewClient extends WebViewClient {
@SuppressWarnings("deprecation")
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Logger.e(TAG, "onReceivedError errorCode=%s, description=%s, failingUrl=%s", errorCode, description, failingUrl);
}
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback,
FileChooserParams fileChooserParams) {
Logger.i(TAG, "oepnFile acceptType : %s", fileChooserParams.getAcceptTypes()[0]);
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Logger.v(TAG, "shouldOverrideUrlLoading: %s", url);
if (url.startsWith("abook")) {
final Uri uri = Uri.parse(url);
// AndroidOSが5以下のPANO_SERVER処理のため、置き換える必要がある。
url = "/" + url;
if (url.contains(ABookKeys.ABOOK_CHECK_API)) {
return checkApiLoding(uri);
}
return true;
}
return false;
}
}
private boolean checkApiLoding(Uri uri) {
Map<String, String> param = new HashMap<>();
for (String key : uri.getQueryParameterNames()) {
param.put(key, uri.getQueryParameter(key));
}
String cmd = param.get(ABookKeys.CMD);
if (cmd == null) {
return false;
}
try {
switch (cmd) {
case CMD_GET_REPORT_STATUS_COUNT: {
return getReportStatusCount();
}
case CMD_GET_REPORT_LIST: {
String reportStatusId = param.get(ReportStatusId);
if (reportStatusId != null) {
return getReportList(Integer.parseInt(reportStatusId));
} else {
return false;
}
}
case CMD_GO_REPORT_DETAIL: {
Long operationId = getLongOrNull(param.get(OperationId));
if (operationId == null) {
return true;
} else {
return goReportDetail(operationId);
}
}
case CMD_LOCK_REPORT: {
String taskKey = param.get(TaskKey);
Long taskReportId = getLongOrNull(param.get(TaskReportId));
Date reportStartDate = getDateOrNull(param.get(ReportStartDate));
return lockReport(taskKey, taskReportId, reportStartDate);
}
case CMD_UNLOCK_REPORT: {
String taskKey = param.get(TaskKey);
Long taskReportId = getLongOrNull(param.get(TaskReportId));
Date reportStartDate = getDateOrNull(param.get(ReportStartDate));
return unlockReport(taskKey, taskReportId, reportStartDate);
}
}
} catch (Throwable e) {
Logger.e(TAG, e.getLocalizedMessage());
return false;
}
return false;
}
// private class JsInf {
//
// @JavascriptInterface
// public void existSetLocation(String ret) {
// Logger.d(TAG, "existSetLocation=%s", ret);
// if (ret != null && ret.equals("true")) { // setLocationメソッドが存在する場合、ページ読み込み完了とみなす
// isPageFinished = true;
// } else { // 存在しない場合、ページ読み込み未完了とみなし1秒後に再度呼出しを繰り返す
// handler.postDelayed(new Runnable() {
// @Override
// public void run() {
// callExistsSetLocation();
// }
// }, 1000);
// }
// }
//
// @JavascriptInterface
// public void existSendLog(String ret) {
// Logger.d(TAG, "existSendLog=%s", ret);
// if (ret != null && ret.equals("true")) {
// runOnUiThread(new Runnable() { // sendLogメソッドが存在する場合、呼び出す
// @Override
// public void run() {
// try {
// webView.loadUrl("javascript:sendLog()");
// } catch (Exception e) {
// Logger.e(TAG, "javascript:sendLog error. " + e.toString());
// }
// }
// });
// } else {
// finishActivity();
// }
// }
//
// @JavascriptInterface
// public void getAttachedDataUrl(String taskKey, String data) {
// commonAttachedDataUrl(taskKey, data);
// }
// }
private boolean getReportStatusCount() {
//todo
return false;
}
private boolean getReportList(int reportStatusId) {
ReportStatusDao dao = AbstractDao.getDao(ReportStatusDao.class);
List<ReportStatusDto> reports = null;
switch (reportStatusId) {
case 0: {
reports = dao.getUntouchedReport();
break;
}
case 1: {
reports = dao.getWorkingReport();
break;
}
case 2: {
reports = dao.getCompleteOkReport();
break;
}
case 3: {
reports = dao.getCompleteNgReport();
break;
}
case 4: {
reports = dao.getIncompleteReport();
break;
}
case 5: {
reports = dao.getAlertReport();
break;
}
case 6: {
reports = dao.getSendBackedReport();
break;
}
case 7: {
reports = dao.getPendingReport();
}
}
if (reports != null) {
JSONObject param = makeReportTree(reportStatusId, reports);
String script = "javascript:CHK_Dashboard.reportListCallback(" + reportStatusId + "," + param.toString() + ")";
webView.loadUrl(script);
return true;
} else {
return false;
}
}
private JSONObject makeReportTree(int reportStatusId, List<ReportStatusDto> reports) {
JSONObject tree = new JSONObject();
tree.put(ReportStatusId, reportStatusId);
JSONArray operationList = new JSONArray();
tree.put(OperationList, operationList);
// operationIDで、ソートしておく
Collections.sort(reports, new ReportStatusCompalator());
JSONObject operation = null;
for (ReportStatusDto report : reports) {
if (operation == null || operation.getLong(OperationId) != report.getOperationId()) {
// 新しい作業の追加
operation = new JSONObject();
operation.put(OperationId, report.getOperationId());
operation.put(OperationName, report.getOperationName());
operation.put(ReportList, new JSONArray());
tree.getJSONArray("operationList").put(operation);
}
JSONObject task = new JSONObject();
task.put(TaskKey, report.getTaskKey());
task.put(TaskReportInfo, report.getTaskReportInfo());
task.put(TaskReportId, report.getTaskReportId());
task.put(ReportStartDate, report.getReportStartDateAsString());
task.put(ReportLockUserId, report.getReportLockUserId());
task.put(ReportLockUserName, report.getReportLockUserName());
task.put(ReportLockTime, report.getReportLockTimeAsString());
task.put(SendBackUserId, report.getSendBackUserId());
task.put(SendBackUserName, report.getSendBackUserName());
operation.getJSONArray(ReportList).put(task);
}
return tree;
}
private boolean goReportDetail(long operationId) {
if (ActivityHandlingHelper.getInstance().isMeetingConnected()) {
return true;
}
// 新着更新を止める
contentRefresher.stopRefresh();
OperationDao operationDao = AbstractDao.getDao(OperationDao.class);
OperationDto operationDto = operationDao.getOperation(operationId);
// t_operationテーブルにcontent_idは含まれていないので、この時点でoperationDto.contentIdはnull
// なので、contentDtoを取り出す
OperationContentDao operationContentDao = AbstractDao.getDao(OperationContentDao.class);
OperationContentDto operationContentDto = operationContentDao.getOperationMainContent(operationId);
ContentDto contentDto = contentDao.getContent(operationContentDto.contentId);
try {
if (contentDto != null && contentDto.downloadedFlg) {
String contentPath = ABVEnvironment.getInstance().getTaskListDirName(ContentFileExtractor.getInstance().getContentCacheDirWithExtract(contentDto.contentId));
// プロジェクトの指示/報告表示時、必要なJSONファイル作成
OperationLogic operationLogic = AbstractLogic.getLogic(OperationLogic.class);
operationLogic.createJsonForOperationContent(operationDto.operationId, contentPath, operationDto.reportType == Constant.ReportType.RoutineTask);
// サーバ作業後、対応必要
StringBuilder path = new StringBuilder();
path.append(contentPath);
// #32926 作業報告画面改善 start
path.append("/index.html?app=android");
path.append("&report_type=").append(operationDto.reportType); // 作業報告タイプ : 0:報告 1:定期点検 2:報告(回答)
path.append("&mobile_flg=").append(isNormalSize() ? "1" : "0"); // ScreenType
Logger.d(TAG, "path : " + path);
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, Constant.XWalkOpenType.TASK_REPORT);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
if(operationDto.operationType == OperationType.PDF) {
intent.putExtra("LINKURL", "file://" + path);
ActivityHandlingHelper.getInstance().checkContentActivity(operationDto.contentId, 0, intent);
} else {
intent.setClass(this, HTMLXWalkWebViewActivity.class);
ActivityHandlingHelper.getInstance().startHTMLXWalkWebActivity(this, intent, "file://" + path, contentDto.contentId, -1, -1, -1, -1, -1);
}
return true;
} else {
Logger.w(TAG, "content is not download");
}
} catch (Exception e) {
Logger.e(TAG, e);
handleErrorMessageToast(ErrorCode.E107);
}
return false;
}
private boolean lockReport(String taskKey, Long taskReportId, Date reportStartDate) {
try {
LockReportLogic.Result r = LockReportLogic.newInstance().lock(taskKey, taskReportId, reportStartDate);
// JSコールバック
afterABookCheckApi(
CMD_LOCK_REPORT,
taskKey,
r.getResult(),
r.getMessage(),
r.getExtParam().json()
);
return true;
} catch (Throwable e) {
e.printStackTrace();
return false;
}
}
private boolean unlockReport(String taskKey, Long taskReportId, Date reportStartDate) {
try {
UnlockReportLogic.Result r = UnlockReportLogic.newInstance().unlock(taskKey, taskReportId, reportStartDate);
// JSコールバック
afterABookCheckApi(
CMD_UNLOCK_REPORT,
taskKey,
r.getResult(),
r.getMessage(),
r.getExtParam().json()
);
return true;
} catch (Throwable e) {
e.printStackTrace();
return false;
}
}
public void afterABookCheckApi(final String cmd, final String taskKey, final int result, final String message, final String extParam) {
Logger.v(TAG, "run javaScript for ABookCheck : cmd=%s, taskKey=%s, result=%s, message=%s", cmd, taskKey, result, message);
runOnUiThread(new Runnable() {
@Override
public void run() {
String callback = String.format("javascript:CHK.afterABookCheckApi('%s', '%s', '%s', '%s', %s)", cmd, taskKey, result, message, extParam);
Logger.i(TAG, callback);
webView.loadUrl(callback);
}
});
}
private Long getLongOrNull(String s) {
try {
return Long.parseLong(s);
} catch (Exception e) {
Logger.e(TAG, e.getLocalizedMessage());
return null;
}
}
private Date getDateOrNull(String s) {
try {
return DateTimeUtil.toDate(s, "UTC", DateTimeFormat.yyyyMMdd_hyphen);
} catch (Exception e) {
Logger.e(TAG, e.getLocalizedMessage());
return null;
}
}
}
......@@ -633,6 +633,7 @@ public class EnqueteWebViewActivity extends ABVContentViewActivity {
return false;
}
@Override
public void finishActivity() {
setResult(RESULT_OK, new Intent());
finish();
......
......@@ -189,6 +189,7 @@ public class NoPdfViewActivity extends ABVContentViewActivity {
historyListBtn.setVisibility(View.INVISIBLE);
}
@Override
protected void finishActivity() {
Logger.d(TAG, "finishActivity");
finish();
......
......@@ -39,6 +39,8 @@ app_versioncode=1
#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
#syncview server
websocket_server_http_url=https://abook188-1.abook.bz/v1
......
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