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 ロック、ダッシュボード対応
}
......@@ -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());
}
}
......
......@@ -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