Commit f381ab70 by Kazuyuki Hida

Merge branch 'feature/contract/sato/1.0.300_51565_js_interface' into 'contract/sato/1.0.300_dev'

報告書の排他制御

See merge request !262
parents 660516f0 01da32ae
...@@ -20,6 +20,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.CategoriesJSON; ...@@ -20,6 +20,7 @@ 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.ContentCheckDeliverableJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ContentVersionsJSON; import jp.agentec.abook.abv.bl.acms.client.json.ContentVersionsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GroupsJSON; 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; import jp.agentec.abook.abv.bl.acms.client.json.LogSendFlagJSON;
import jp.agentec.abook.abv.bl.acms.client.json.MasterDataJSON; import jp.agentec.abook.abv.bl.acms.client.json.MasterDataJSON;
import jp.agentec.abook.abv.bl.acms.client.json.NewAppStoreLoginJSON; import jp.agentec.abook.abv.bl.acms.client.json.NewAppStoreLoginJSON;
...@@ -32,6 +33,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.FixPushMessageJSON; ...@@ -32,6 +33,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.FixPushMessageJSON;
import jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON; import jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON;
import jp.agentec.abook.abv.bl.acms.client.json.OperationListJSON; import jp.agentec.abook.abv.bl.acms.client.json.OperationListJSON;
import jp.agentec.abook.abv.bl.acms.client.json.SceneEntryJSON; import jp.agentec.abook.abv.bl.acms.client.json.SceneEntryJSON;
import jp.agentec.abook.abv.bl.acms.client.json.UnlockReportJSON;
import jp.agentec.abook.abv.bl.acms.client.json.WorkerGroupJSON; import jp.agentec.abook.abv.bl.acms.client.json.WorkerGroupJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.AbstractAcmsLoginParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.AbstractAcmsLoginParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsContentParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsContentParameters;
...@@ -47,11 +49,13 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.GetContentParameters; ...@@ -47,11 +49,13 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.GetContentParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetEnqueteReplyParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.GetEnqueteReplyParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetOperationDataParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.GetOperationDataParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetTaskFileParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.GetTaskFileParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.LockReportParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.NewAppStoreLoginParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.NewAppStoreLoginParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.PasswordChangeParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.PasswordChangeParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.PostEnqueteReplyParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.PostEnqueteReplyParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.SendPushMessageParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.SendPushMessageParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.ServerTimeParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.ServerTimeParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.UnlockReportParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.UpdateDeviceTokenParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.UpdateDeviceTokenParameters;
import jp.agentec.abook.abv.bl.acms.type.AcmsApis; import jp.agentec.abook.abv.bl.acms.type.AcmsApis;
import jp.agentec.abook.abv.bl.acms.type.LoginStatus; import jp.agentec.abook.abv.bl.acms.type.LoginStatus;
...@@ -719,6 +723,18 @@ public class AcmsClient implements AcmsClientResponseListener { ...@@ -719,6 +723,18 @@ public class AcmsClient implements AcmsClientResponseListener {
return json; return json;
} }
public LockReportJSON sendLockReport(LockReportParameters param) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApiLockReport, param);
String json = response.httpResponseBody;
return new LockReportJSON(json);
}
public UnlockReportJSON sendUnlockReport(UnlockReportParameters param) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApiUnlockReport, param);
String json = response.httpResponseBody;
return new UnlockReportJSON(json);
}
/**********************************************************************************************/ /**********************************************************************************************/
/** 以下、共用メソッド---------------------------------------------------------------------- **/ /** 以下、共用メソッド---------------------------------------------------------------------- **/
/**********************************************************************************************/ /**********************************************************************************************/
...@@ -922,7 +938,9 @@ public class AcmsClient implements AcmsClientResponseListener { ...@@ -922,7 +938,9 @@ public class AcmsClient implements AcmsClientResponseListener {
AcmsApis.ApiUrlNewAppStoreLogin, AcmsApis.ApiUrlNewAppStoreLogin,
AcmsApis.ApiUrlAppStoreNewLogin, AcmsApis.ApiUrlAppStoreNewLogin,
AcmsApis.ApiGetPushMessages, AcmsApis.ApiGetPushMessages,
AcmsApis.ApiSendPushMessage AcmsApis.ApiSendPushMessage,
AcmsApis.ApiLockReport,
AcmsApis.ApiUnlockReport
}; };
public HttpTaskWorker(String methodName, String apiUrl, T param) { public HttpTaskWorker(String methodName, String apiUrl, T param) {
......
...@@ -6,11 +6,15 @@ import jp.agentec.abook.abv.bl.common.exception.AcmsException; ...@@ -6,11 +6,15 @@ import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException; import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.adf.core.CloneableObject; import jp.agentec.adf.core.CloneableObject;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
import jp.agentec.adf.util.StringUtil; import jp.agentec.adf.util.StringUtil;
import org.json.adf.JSONException; import org.json.adf.JSONException;
import org.json.adf.JSONObject; import org.json.adf.JSONObject;
import java.util.Date;
public abstract class AcmsJSONParser extends CloneableObject { public abstract class AcmsJSONParser extends CloneableObject {
/** /**
* {@link AcmsJSONParser} クラスのインスタンスを初期化します。 * {@link AcmsJSONParser} クラスのインスタンスを初期化します。
...@@ -129,4 +133,27 @@ public abstract class AcmsJSONParser extends CloneableObject { ...@@ -129,4 +133,27 @@ public abstract class AcmsJSONParser extends CloneableObject {
} }
} }
protected int getIntOrDef(JSONObject json, String key, int def) {
if (json.has(key)) {
return json.getInt(key);
} else {
return def;
}
}
protected String getStringOrNull(JSONObject json, String key) {
if (json.has(key)) {
return json.getString(key);
} else {
return null;
}
}
protected Date getDateOrNull(JSONObject json, String key) {
if (json.has(key)) {
return DateTimeUtil.toDate(json.getString(key), "UTC", DateTimeFormat.yyyyMMdd_hyphen);
} else {
return null;
}
}
} }
package jp.agentec.abook.abv.bl.acms.client.json;
import org.json.adf.JSONObject;
import java.util.Date;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
/**
* checkapi/lockReport/のレスポンスを変換するクラス
*/
public class LockReportJSON extends AcmsCommonJSON {
public static final int BAD_STATE = 999;
private Date presentTimeUTC;
private int reportStatus;
private String reportLockUserId;
private String reportLockUserName;
private Date reportLockTime;
public LockReportJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) {
presentTimeUTC = getDateOrNull(json, "presentTimeUTC");
reportStatus = getIntOrDef(json, "reportStatus", BAD_STATE);
reportLockUserId = getStringOrNull(json, "reportLockUserId");
reportLockUserName = getStringOrNull(json, "reportLockUserName");
reportLockTime = getDateOrNull(json, "reportLockTime");
}
@SuppressWarnings("unused")
int getHttpStatus() {
return httpStatus;
}
@SuppressWarnings("unused")
Date getPresentTime() {
return presentTime;
}
@SuppressWarnings("unused")
public Date getPresentTimeUTC() {
return presentTimeUTC;
}
@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;
}
}
...@@ -45,6 +45,8 @@ public class OperationDataJSON extends AcmsCommonJSON { ...@@ -45,6 +45,8 @@ public class OperationDataJSON extends AcmsCommonJSON {
public static final String SendBackUserName = "sendBackUserName"; // 差し戻しユーザ名 差し戻された場合のみ public static final String SendBackUserName = "sendBackUserName"; // 差し戻しユーザ名 差し戻された場合のみ
public static final String SendBackComment = "sendBackComment"; // 確認コメント 差し戻された場合のみ public static final String SendBackComment = "sendBackComment"; // 確認コメント 差し戻された場合のみ
public static final String ReportStatus = "reportStatus";
public List<TaskDto> taskDtoList; public List<TaskDto> taskDtoList;
public Date lastEditDate; public Date lastEditDate;
......
package jp.agentec.abook.abv.bl.acms.client.json;
import org.json.adf.JSONObject;
import java.util.Date;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
public class UnlockReportJSON extends AcmsCommonJSON {
public static final int BAD_STATE = 999;
private Date presentTimeUTC;
private int reportStatus;
public UnlockReportJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) {
presentTimeUTC = getDateOrNull(json, "presentTimeUTC");
reportStatus = getIntOrDef(json, "", BAD_STATE);
}
@SuppressWarnings("unused")
public int getHttpStatus() {
return httpStatus;
}
@SuppressWarnings("unused")
public Date getPresentTime() {
return presentTime;
}
@SuppressWarnings("unused")
public Date getPresentTimeUTC() {
return presentTimeUTC;
}
@SuppressWarnings("unused")
public int getReportStatus() {return reportStatus; }
}
package jp.agentec.abook.abv.bl.acms.client.parameters;
import java.util.Date;
/**
* checkapi/lockReport/のリクエストに使うパラメータ
*/
public class LockReportParameters extends AcmsParameters {
private String sid;
private String taskKey;
private Long taskReportId;
private Date reportStartDate;
private String userId;
private String userName;
public LockReportParameters(
String sid,
String taskKey,
Long taskReportId,
Date reportStartDate,
String userId,
String userName
) {
super(sid);
this.taskKey = taskKey;
this.taskReportId = taskReportId;
this.reportStartDate = reportStartDate;
this.userId = userId;
this.userName = userName;
}
public String getTaskKey() {
return taskKey;
}
public Long getTaskReportId() {
return taskReportId;
}
public Date getReportStartDate() {
return reportStartDate;
}
public String getUserId() {
return userId;
}
public String getUserName() {
return userName;
}
}
package jp.agentec.abook.abv.bl.acms.client.parameters;
import java.util.Date;
/**
* checkapi/unlockReport/のリクエストに使うパラメータ
*/
public class UnlockReportParameters extends AcmsParameters {
private String taskKey;
private Long taskReportId;
private Date reportStartDate;
public UnlockReportParameters(
String sid,
String taskKey,
Long taskReportId,
Date reportStartDate
) {
super(sid);
this.taskKey = taskKey;
this.taskReportId = taskReportId;
this.reportStartDate = reportStartDate;
}
String getTaskKey() {
return taskKey;
}
Long getTaskReportId() {
return taskReportId;
}
Date getReportStartDate() {
return reportStartDate;
}
}
...@@ -160,6 +160,11 @@ public class AcmsApis { ...@@ -160,6 +160,11 @@ public class AcmsApis {
public static final String ApiQuickReportSearch = "quickReportSearch"; public static final String ApiQuickReportSearch = "quickReportSearch";
// 簡易帳票リビジョン一覧取得 // 簡易帳票リビジョン一覧取得
public static final String ApiQuickReportRevision = "quickReportRevision"; public static final String ApiQuickReportRevision = "quickReportRevision";
// 報告・点検のロック
public static final String ApiLockReport = "lockReport";
// 報告・点検のロック解除
public static final String ApiUnlockReport = "unlockReport";
// download // download
/** /**
* コンテンツのZIPファイルを取得<br> * コンテンツのZIPファイルを取得<br>
...@@ -182,6 +187,7 @@ public class AcmsApis { ...@@ -182,6 +187,7 @@ public class AcmsApis {
public static final String GetTaskFileUrlFormat = "%s/%s/checkapi/getTaskFile"; public static final String GetTaskFileUrlFormat = "%s/%s/checkapi/getTaskFile";
/** /**
* APIのURLを完成します。 * APIのURLを完成します。
* @param host ACMSのFQDNです。 * @param host ACMSのFQDNです。
......
...@@ -34,6 +34,8 @@ public class ABookKeys { ...@@ -34,6 +34,8 @@ public class ABookKeys {
public static final String CMD_MOVE_PAGE = "movePage"; public static final String CMD_MOVE_PAGE = "movePage";
public static final String CMD_SHOW_RELATED_CONTENT = "showRelatedContent"; public static final String CMD_SHOW_RELATED_CONTENT = "showRelatedContent";
public static final String CMD_PAGE_NUM = "pageNum"; 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 GPS_TYPE = "gpsType"; public static final String GPS_TYPE = "gpsType";
public static final String STATUS_CODE = "statusCode"; public static final String STATUS_CODE = "statusCode";
......
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.dto.MemberInfoDto;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
import static java.net.HttpURLConnection.HTTP_OK;
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.ReportStatus;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.TaskReportId;
import static jp.agentec.abook.abv.bl.common.constant.ABookKeys.TASK_KEY;
public class LockReportLogic extends AbstractLogic {
public static LockReportLogic newInstance() {
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
);
}
private Result sendLockReport(
String taskKey,
Long taskReportId,
Date reportStartDate
) {
AcmsClient client = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter);
MemberInfoDto member = cache.getMemberInfo();
LockReportParameters param = new LockReportParameters(
member.sid,
taskKey,
taskReportId,
reportStartDate,
member.loginId,
member.memberName
);
if (!networkAdapter.isNetworkConnected()) {
// オフラインだったら、ロック成功扱い
return Result.offLine(taskReportId, reportStartDate);
}
try {
LockReportJSON reportJSON = client.sendLockReport(param);
return Result.succsess(reportJSON, taskReportId, reportStartDate);
} catch (Throwable e) {
return Result.failure(e, taskReportId, reportStartDate);
}
}
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;
}
}
// コールバック用のパラメータ
public static class Result {
public static final int BAD_STATUS = 999;
int result;
String message;
ExtParam extParam;
static Result succsess(LockReportJSON reportJSON, Long taskReportId, Date reportStartDate) {
// 成功したとき
Result result = new Result();
result.result = reportJSON.httpStatus == HTTP_OK ? 0 : 1;
result.message = "";
result.extParam = new ExtParam(
reportJSON.getReportStatus(),
reportJSON.getReportLockUserId(),
reportJSON.getReportLockUserName(),
reportJSON.getReportLockTime(),
taskReportId,
reportStartDate
);
return result;
}
@SuppressWarnings("magic_number")
static Result failure(Throwable e, Long taskReportId, Date reportStartDate) {
// 例外がでたとき
Result result = new Result();
result.result = 1;
result.message = e.getLocalizedMessage();
result.extParam = new ExtParam(
BAD_STATUS,
null,
null,
null,
taskReportId,
reportStartDate
);
return result;
}
static Result offLine(Long taskReportId, Date reportStartDate) {
// オフラインは成功扱い
Result result = new Result();
result.result = 0;
result.message = "";
result.extParam = new ExtParam(
3,
null,
null,
null,
taskReportId,
reportStartDate
);
return result;
}
public int getResult() {
return result;
}
public String getMessage() {
return message;
}
public ExtParam getExtParam() {
return extParam;
}
}
static public class ExtParam {
int reportStatus;
String reportLockUserId;
String reportLockUserName;
Date reportLockTime;
Long taskReportId;
Date reportStartDate;
ExtParam(
int reportStatus,
String reportLockUserId,
String reportLockUserName,
Date reportLockTime,
Long taskReportId,
Date reportStartDate
) {
this.reportStatus = reportStatus;
this.reportLockUserId = reportLockUserId;
this.reportLockUserName = reportLockUserName;
this.reportLockTime = reportLockTime;
this.taskReportId = taskReportId;
this.reportStartDate = reportStartDate;
}
public int getReportStatus() {
return reportStatus;
}
public String getReportLockUserId() {
return reportLockUserId;
}
public String getReportLockUserName() {
return reportLockUserName;
}
public Date getReportLockTime() {
return reportLockTime;
}
public String json() {
JSONObject extParam = new JSONObject();
extParam.put(ReportStatus, String.valueOf(reportStatus));
extParam.put(ReportLockUserId, reportLockUserId);
extParam.put(ReportLockUserName, reportLockUserName);
extParam.put(ReportLockTime, DateTimeUtil.formatDate(reportLockTime, DateTimeFormat.yyyyMMddHHmmssSSS_hyphen));
if (taskReportId != null && taskReportId != 0) {
extParam.put(TaskReportId, taskReportId);
}
if (reportStartDate != null) {
extParam.put(ReportStartDate, DateTimeUtil.formatDate(reportStartDate, DateTimeFormat.yyyyMMddHHmmssSSS_hyphen));
}
return extParam.toString();
}
}
}
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.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
import static java.net.HttpURLConnection.HTTP_OK;
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;
public class UnlockReportLogic extends AbstractLogic {
public static UnlockReportLogic newInstance() {
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
);
}
private Result sendUnlockReport(
String taskKey,
Long taskReportId,
Date reportStartDate
) {
NetworkAdapter adapter = ABVEnvironment.getInstance().networkAdapter;
AcmsClient client = AcmsClient.getInstance(cache.getUrlPath(), adapter);
UnlockReportParameters param = new UnlockReportParameters(
cache.getMemberInfo().sid,
taskKey,
taskReportId,
reportStartDate
);
if (!networkAdapter.isNetworkConnected()) {
// オフラインだったら、ロック成功扱い
return Result.offLine(taskReportId, reportStartDate);
}
try {
UnlockReportJSON reportJSON = client.sendUnlockReport(param);
return Result.succsess(reportJSON, taskReportId, reportStartDate);
} catch (Exception e) {
return Result.failure(e, taskReportId, reportStartDate);
}
}
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;
}
}
// コールバック用のパラメータ
public static class Result {
public static final int BAD_STATUS = 999;
int result;
String message;
ExtParam extParam;
static Result succsess(UnlockReportJSON reportJSON, Long taskReportId, Date reportStartDate) {
// 成功したとき
Result result = new Result();
result.result = reportJSON.httpStatus == HTTP_OK ? 0 : 1;
result.message = "";
result.extParam = new ExtParam(reportJSON.getReportStatus(), taskReportId, reportStartDate);
return result;
}
static Result failure(Throwable e, Long taskReportId, Date reportStartDate) {
// 例外がでたとき
Result result = new Result();
result.result = 1;
result.message = e.getLocalizedMessage();
result.extParam = new ExtParam(BAD_STATUS, taskReportId, reportStartDate);
return result;
}
static Result offLine(Long taskReportId, Date reportStartDate) {
// オフラインは成功扱い
Result result = new Result();
result.result = 0;
result.message = "";
result.extParam = new ExtParam(3, taskReportId, reportStartDate);
return result;
}
public int getResult() {
return result;
}
public String getMessage() {
return message;
}
public ExtParam getExtParam() {
return extParam;
}
}
public static class ExtParam {
int reportStatus ;
Long taskReportId;
Date reportStartDate;
ExtParam(int reportStatus, Long taskReportId, Date reportStartDate) {
this.reportStatus = reportStatus;
this.taskReportId = taskReportId;
this.reportStartDate = reportStartDate;
}
public int getReportStatus() {
return reportStatus;
}
public String json() {
JSONObject extParam = new JSONObject();
extParam.put(ReportStatus, String.valueOf(reportStatus));
if (taskReportId != null && taskReportId != 0) {
extParam.put(TaskReportId, taskReportId);
}
if (reportStartDate != null) {
extParam.put(ReportStartDate, DateTimeUtil.formatDate(reportStartDate, DateTimeFormat.yyyyMMddHHmmssSSS_hyphen));
}
return extParam.toString();
}
}
}
...@@ -29,6 +29,7 @@ import org.json.adf.JSONObject; ...@@ -29,6 +29,7 @@ import org.json.adf.JSONObject;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
...@@ -43,6 +44,8 @@ import jp.agentec.abook.abv.bl.common.Constant; ...@@ -43,6 +44,8 @@ import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys; import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.ABVDataCache; 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.download.ContentFileExtractor;
import jp.agentec.abook.abv.bl.dto.ContentDto; import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.dto.MydataDto; import jp.agentec.abook.abv.bl.dto.MydataDto;
...@@ -50,7 +53,9 @@ import jp.agentec.abook.abv.bl.dto.OperationDto; ...@@ -50,7 +53,9 @@ import jp.agentec.abook.abv.bl.dto.OperationDto;
import jp.agentec.abook.abv.bl.dto.OperationTaskDto; import jp.agentec.abook.abv.bl.dto.OperationTaskDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic; import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.ContentReadingLogLogic; 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.OperationLogic;
import jp.agentec.abook.abv.bl.logic.UnlockReportLogic;
import jp.agentec.abook.abv.bl.websocket.MeetingManager; import jp.agentec.abook.abv.bl.websocket.MeetingManager;
import jp.agentec.abook.abv.cl.environment.DeviceInfo; import jp.agentec.abook.abv.cl.environment.DeviceInfo;
import jp.agentec.abook.abv.cl.helper.ContentMarkingFileHelper; import jp.agentec.abook.abv.cl.helper.ContentMarkingFileHelper;
...@@ -75,10 +80,13 @@ import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper; ...@@ -75,10 +80,13 @@ 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.activity.HTMLXWalkWebViewActivity;
import jp.agentec.abook.abv.ui.viewer.activity.NoPdfViewActivity; import jp.agentec.abook.abv.ui.viewer.activity.NoPdfViewActivity;
import jp.agentec.abook.abv.ui.viewer.foxitPdf.FoxitPdfCore; import jp.agentec.abook.abv.ui.viewer.foxitPdf.FoxitPdfCore;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil; import jp.agentec.adf.util.DateTimeUtil;
import jp.agentec.adf.util.FileUtil; import jp.agentec.adf.util.FileUtil;
import jp.agentec.adf.util.StringUtil; import jp.agentec.adf.util.StringUtil;
import static jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON.ReportStartDate;
public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
private static final String TAG ="ABVContentViewActivity"; private static final String TAG ="ABVContentViewActivity";
...@@ -1070,7 +1078,46 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -1070,7 +1078,46 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// ビーコンデータを受信して目的のデバイスIDの信号から値を取得する // ビーコンデータを受信して目的のデバイスIDの信号から値を取得する
// 1:中心温度計 2:置くだけセンサー 3:バーコード // 1:中心温度計 2:置くだけセンサー 3:バーコード
getDeviceInfo(abookCheckParam); 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()
);
// JSコールバック
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
);
// JSコールバック
afterABookCheckApi(
mCmd,
mTaskKey,
r.getResult(),
r.getMessage(),
r.getExtParam().json()
);
} }
} }
...@@ -1323,4 +1370,11 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -1323,4 +1370,11 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
//ABVCheckContentViewActivityから処理 //ABVCheckContentViewActivityから処理
protected void getDeviceInfo(Map<String, String> abookCheckParam) {} protected void getDeviceInfo(Map<String, String> abookCheckParam) {}
}
private Date dateOrNull(String s) {
try {
return DateTimeUtil.toDate(s, "UTC", DateTimeFormat.yyyyMMdd_hyphen);
} catch (Exception e) {
return null;
}
}}
...@@ -24,7 +24,6 @@ import jp.agentec.abook.abv.bl.common.Callback; ...@@ -24,7 +24,6 @@ import jp.agentec.abook.abv.bl.common.Callback;
import jp.agentec.abook.abv.bl.common.CommonExecutor; import jp.agentec.abook.abv.bl.common.CommonExecutor;
import jp.agentec.abook.abv.bl.common.Constant; import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys; import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.exception.ABVException;
import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode; import jp.agentec.abook.abv.bl.common.exception.ABVExceptionCode;
import jp.agentec.abook.abv.bl.common.exception.AcmsException; import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
...@@ -37,7 +36,6 @@ import jp.agentec.abook.abv.bl.logic.OperationLogic; ...@@ -37,7 +36,6 @@ import jp.agentec.abook.abv.bl.logic.OperationLogic;
import jp.agentec.abook.abv.launcher.android.R; import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.activity.ABVContentViewActivity; import jp.agentec.abook.abv.ui.common.activity.ABVContentViewActivity;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType; import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
import jp.agentec.abook.abv.ui.common.constant.ErrorCode;
import jp.agentec.abook.abv.ui.common.constant.ErrorMessage; import jp.agentec.abook.abv.ui.common.constant.ErrorMessage;
import jp.agentec.abook.abv.ui.common.util.PatternStringUtil; import jp.agentec.abook.abv.ui.common.util.PatternStringUtil;
import jp.agentec.abook.abv.ui.common.util.ABVToastUtil; import jp.agentec.abook.abv.ui.common.util.ABVToastUtil;
...@@ -70,15 +68,15 @@ public class ABookCheckWebViewHelper extends ABookHelper { ...@@ -70,15 +68,15 @@ public class ABookCheckWebViewHelper extends ABookHelper {
* parameterによって処理を分ける * parameterによって処理を分ける
* *
* @param context ABVContentViewActivity * @param context ABVContentViewActivity
* @param cmd * @param cmd コマンド
* @param taskKey タスクキー * @param taskKey タスクキー
* @param enableReportHistory * @param enableReportHistory 履歴を残すかどうか
* @param param * @param param パラメータ
* @param operationId プロジェクトID * @param operationId プロジェクトID
* @param contentPath * @param contentPath 添付資料のパス
* @param reportType * @param reportType 報告タイプ
* @param finishCallback * @param finishCallback 最後に呼ぶコールバック
* @param taskReportLevel * @param taskReportLevel 作業の報告レベル
*/ */
public void doABookCheckParam(ABVContentViewActivity context, String cmd, String taskKey, int enableReportHistory, Map<String, String> param, long operationId, String contentPath, long contentId, int reportType, Callback finishCallback, int taskReportLevel) throws IOException { public void doABookCheckParam(ABVContentViewActivity context, String cmd, String taskKey, int enableReportHistory, Map<String, String> param, long operationId, String contentPath, long contentId, int reportType, Callback finishCallback, int taskReportLevel) throws IOException {
int taskReportSendId = 0; int taskReportSendId = 0;
......
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