Commit d07cec67 by Kazuyuki Hida

ロック関係の実装を変更した

parent 737a1a48
...@@ -2,6 +2,9 @@ package jp.agentec.abook.abv.bl.acms.client.parameters; ...@@ -2,6 +2,9 @@ package jp.agentec.abook.abv.bl.acms.client.parameters;
import java.util.Date; import java.util.Date;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
/** /**
* checkapi/lockReport/のリクエストに使うパラメータ * checkapi/lockReport/のリクエストに使うパラメータ
*/ */
...@@ -10,7 +13,7 @@ public class LockReportParameters extends AcmsParameters { ...@@ -10,7 +13,7 @@ public class LockReportParameters extends AcmsParameters {
private String sid; private String sid;
private String taskKey; private String taskKey;
private Long taskReportId; private Long taskReportId;
private Date reportStartDate; private String reportStartDate; // 書式の問題があるので、あえて文字列
private String userId; private String userId;
private String userName; private String userName;
...@@ -23,10 +26,10 @@ public class LockReportParameters extends AcmsParameters { ...@@ -23,10 +26,10 @@ public class LockReportParameters extends AcmsParameters {
String userName String userName
) { ) {
super(sid); super(sid);
this.sid = sid;
this.taskKey = taskKey; this.taskKey = taskKey;
this.taskReportId = taskReportId; this.taskReportId = taskReportId;
this.reportStartDate = reportStartDate; this.reportStartDate = DateTimeUtil.toString(reportStartDate, DateTimeFormat.yyyyMMddHHmmssSSS_hyphen);
this.userId = userId; this.userId = userId;
this.userName = userName; this.userName = userName;
} }
...@@ -39,7 +42,7 @@ public class LockReportParameters extends AcmsParameters { ...@@ -39,7 +42,7 @@ public class LockReportParameters extends AcmsParameters {
return taskReportId; return taskReportId;
} }
public Date getReportStartDate() { public String getReportStartDate() {
return reportStartDate; return reportStartDate;
} }
......
...@@ -214,8 +214,8 @@ public class AcmsApis { ...@@ -214,8 +214,8 @@ public class AcmsApis {
methodName.equals(ApiGetMasterData) || methodName.equals(ApiGetMasterData) ||
// カテゴリ選択機能、IO帳票で3つ追加 // カテゴリ選択機能、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(ApiGetDashboardStatus) || methodName.equals(ApiLockReport) || methodName.equals(ApiUnlockReport)) {
apiValue = Constant.ApiValue.checkapi; apiValue = Constant.ApiValue.checkapi;
} }
......
...@@ -177,7 +177,7 @@ public class TaskReportDao extends AbstractDao { ...@@ -177,7 +177,7 @@ public class TaskReportDao extends AbstractDao {
*/ */
public boolean update(TaskReportDto dto) { public boolean update(TaskReportDto dto) {
Object[] objects; Object[] objects;
StringBuffer sql = new StringBuffer(); StringBuilder sql = new StringBuilder();
sql.append("UPDATE t_task_report SET "); sql.append("UPDATE t_task_report SET ");
sql.append("json_data=?, "); sql.append("json_data=?, ");
sql.append("attached_file_name=?, "); sql.append("attached_file_name=?, ");
...@@ -223,15 +223,17 @@ public class TaskReportDao extends AbstractDao { ...@@ -223,15 +223,17 @@ public class TaskReportDao extends AbstractDao {
* @param reportLockUserId * @param reportLockUserId
* @param reportLockUserName * @param reportLockUserName
* @param reportLockTime * @param reportLockTime
* @param loginId
* @return * @return
*/ */
public boolean updateReportLock( public void updateReportLock(
String taskKey, String taskKey,
Date reportStartDate, Date reportStartDate,
int reportStatus, int reportStatus,
String reportLockUserId, String reportLockUserId,
String reportLockUserName, String reportLockUserName,
Date reportLockTime Date reportLockTime,
String loginId
) { ) {
StringBuilder sql = new StringBuilder(); StringBuilder sql = new StringBuilder();
List<Object> args = new ArrayList<Object>(); List<Object> args = new ArrayList<Object>();
...@@ -240,10 +242,13 @@ public class TaskReportDao extends AbstractDao { ...@@ -240,10 +242,13 @@ public class TaskReportDao extends AbstractDao {
sql.append(" report_status=?, "); sql.append(" report_status=?, ");
sql.append(" report_lock_user_id=?, "); sql.append(" report_lock_user_id=?, ");
sql.append(" report_lock_user_name=?, "); sql.append(" report_lock_user_name=?, ");
sql.append(" report_lock_time=?, "); sql.append(" report_lock_time=? ");
sql.append("WHERE task_key=? "); sql.append(" WHERE task_key=? ");
if (reportStartDate != null) { if (reportStartDate != null) {
sql.append("AND datetime(report_start_date)=datetime(?);"); sql.append(" AND datetime(report_start_date)=datetime(?) ");
}
if (loginId != null) {
sql.append(" AND report_lock_user_id <> ? "); //自分以外のロックを変更しないため
} }
args.add(reportStatus); args.add(reportStatus);
...@@ -254,8 +259,11 @@ public class TaskReportDao extends AbstractDao { ...@@ -254,8 +259,11 @@ public class TaskReportDao extends AbstractDao {
if (reportStartDate != null) { if (reportStartDate != null) {
args.add(reportStartDate); args.add(reportStartDate);
} }
if (loginId != null) {
args.add(loginId);
}
return update(sql.toString(), args.toArray()) > 0; update(sql.toString(), args.toArray());
} }
/** /**
......
...@@ -2,6 +2,9 @@ package jp.agentec.abook.abv.bl.dto; ...@@ -2,6 +2,9 @@ package jp.agentec.abook.abv.bl.dto;
import java.util.Date; import java.util.Date;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
public class ReportStatusDto extends AbstractDto { public class ReportStatusDto extends AbstractDto {
public int reportStatus; public int reportStatus;
...@@ -62,6 +65,10 @@ public class ReportStatusDto extends AbstractDto { ...@@ -62,6 +65,10 @@ public class ReportStatusDto extends AbstractDto {
return reportStartDate; return reportStartDate;
} }
public String getReportStartDateAsString() {
return DateTimeUtil.toString(reportStartDate, DateTimeFormat.yyyyMMddHHmmss_hyphen);
}
public String getReportLockUserId() { public String getReportLockUserId() {
return reportLockUserId; return reportLockUserId;
} }
...@@ -74,6 +81,10 @@ public class ReportStatusDto extends AbstractDto { ...@@ -74,6 +81,10 @@ public class ReportStatusDto extends AbstractDto {
return reportLockTime; return reportLockTime;
} }
public String getReportLockTimeAsString() {
return DateTimeUtil.toString(reportLockTime, DateTimeFormat.yyyyMMddHHmmss_hyphen);
}
public String getSendBackUserId() { public String getSendBackUserId() {
return sendBackUserId; return sendBackUserId;
} }
......
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; ...@@ -3,11 +3,12 @@ package jp.agentec.abook.abv.bl.logic;
import org.json.adf.JSONObject; import org.json.adf.JSONObject;
import java.util.Date; 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.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.LockReportJSON; 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.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.abook.abv.bl.dto.MemberInfoDto;
import jp.agentec.adf.util.DateTimeFormat; import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil; import jp.agentec.adf.util.DateTimeUtil;
...@@ -20,15 +21,10 @@ public class LockReportLogic extends AbstractLogic { ...@@ -20,15 +21,10 @@ public class LockReportLogic extends AbstractLogic {
return new LockReportLogic(); return new LockReportLogic();
} }
public Result lock(Map<String, String> param) { public Result lock(String taskKey, Long taskReportId, Date reportStartDate) {
Long taskReportId = longOrNull(param.get("taskReportId")); Result r = sendLockReport(taskKey, taskReportId, reportStartDate);
Date reportStartDate = dateOrNull(param.get("reportStartDate")); updateLocalDB(taskKey, reportStartDate, r.getExtParam().reportStatus);
return r;
return sendLockReport(
param.get("taskKey"),
taskReportId,
reportStartDate
);
} }
private Result sendLockReport( private Result sendLockReport(
...@@ -60,20 +56,22 @@ public class LockReportLogic extends AbstractLogic { ...@@ -60,20 +56,22 @@ public class LockReportLogic extends AbstractLogic {
} }
} }
private Long longOrNull(String s) { private void updateLocalDB(
try { String taskKey,
return Long.valueOf(s); Date reportStartDate,
} catch (Exception e) { int reportStatus
return null; ) {
} MemberInfoDto member = cache.getMemberInfo();
} TaskReportDao dao = AbstractDao.getDao(TaskReportDao.class);
dao.updateReportLock(
private Date dateOrNull(String s) { taskKey,
try { reportStartDate,
return DateTimeUtil.toDate(s, "UTC", DateTimeFormat.yyyyMMdd_hyphen); reportStatus,
} catch (Exception e) { member.loginId,
return null; member.memberName,
} new Date(),
null
);
} }
// コールバック用のパラメータ // コールバック用のパラメータ
...@@ -101,11 +99,12 @@ public class LockReportLogic extends AbstractLogic { ...@@ -101,11 +99,12 @@ public class LockReportLogic extends AbstractLogic {
@SuppressWarnings("magic_number") @SuppressWarnings("magic_number")
static Result failure(Throwable e, Long taskReportId, Date reportStartDate) { static Result failure(Throwable e, Long taskReportId, Date reportStartDate) {
// 例外がでたとき // 例外がでたとき
final int BAD_STATUS = 999;
Result result = new Result(); Result result = new Result();
result.result = 1; result.result = 1;
result.message = e.getLocalizedMessage(); result.message = e.getLocalizedMessage();
result.extParam = new ExtParam( result.extParam = new ExtParam(
999, BAD_STATUS,
null, null,
null, null,
null, null,
...@@ -168,35 +167,39 @@ public class LockReportLogic extends AbstractLogic { ...@@ -168,35 +167,39 @@ public class LockReportLogic extends AbstractLogic {
this.reportStartDate = reportStartDate; this.reportStartDate = reportStartDate;
} }
@SuppressWarnings("unused")
public int getReportStatus() { public int getReportStatus() {
return reportStatus; return reportStatus;
} }
@SuppressWarnings("unused")
public String getReportLockUserId() { public String getReportLockUserId() {
return reportLockUserId; return reportLockUserId;
} }
@SuppressWarnings("unused")
public String getReportLockUserName() { public String getReportLockUserName() {
return reportLockUserName; return reportLockUserName;
} }
@SuppressWarnings("unused")
public Date getReportLockTime() { public Date getReportLockTime() {
return reportLockTime; return reportLockTime;
} }
@SuppressWarnings("unused")
public String json() { public String json() {
JSONObject extParam = new JSONObject(); JSONObject extParam = new JSONObject();
extParam.put("reportStatus", String.valueOf(reportStatus)); extParam.put("reportStatus", String.valueOf(reportStatus));
extParam.put("reportLockUserId", reportLockUserId); extParam.put("reportLockUserId", reportLockUserId);
extParam.put("reportLockUserName", reportLockUserName); extParam.put("reportLockUserName", reportLockUserName);
extParam.put("reportLockTime", DateTimeUtil.formatDate(reportLockTime, DateTimeFormat.yyyyMMddHHmmssSSS_hyphen)); extParam.put("reportLockTime", reportLockTime);
if (taskReportId != null && taskReportId != 0) { if (taskReportId != null && taskReportId != 0) {
extParam.put("taskReportId", taskReportId); extParam.put("taskReportId", taskReportId);
} }
if (reportStartDate != null) { if (reportStartDate != null) {
extParam.put("reportStartDate", DateTimeUtil.formatDate(reportStartDate, DateTimeFormat.yyyyMMddHHmmssSSS_hyphen)); extParam.put("reportStartDate", DateTimeUtil.toString(reportStartDate, DateTimeFormat.yyyyMMddHHmmss_hyphen));
} }
return extParam.toString(); return extParam.toString();
} }
......
...@@ -10,7 +10,7 @@ import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException; ...@@ -10,7 +10,7 @@ import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException;
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.dao.ReportStatusDao; import jp.agentec.abook.abv.bl.data.dao.ReportStatusDao;
import jp.agentec.abook.abv.bl.dto.DashboardStatusDto; import jp.agentec.abook.abv.bl.dto.DashboardStatusDto;
import jp.agentec.abook.abv.bl.dto.ReportStatusDto;
public class ReportStatusLogic extends AbstractLogic { public class ReportStatusLogic extends AbstractLogic {
private static final String TAG = "ReportStatusLogic"; private static final String TAG = "ReportStatusLogic";
......
...@@ -3,13 +3,14 @@ package jp.agentec.abook.abv.bl.logic; ...@@ -3,13 +3,14 @@ package jp.agentec.abook.abv.bl.logic;
import org.json.adf.JSONObject; import org.json.adf.JSONObject;
import java.util.Date; 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.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.UnlockReportJSON; 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.acms.client.parameters.UnlockReportParameters;
import jp.agentec.abook.abv.bl.common.ABVEnvironment; import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.nw.NetworkAdapter; 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.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil; import jp.agentec.adf.util.DateTimeUtil;
...@@ -21,15 +22,11 @@ public class UnlockReportLogic extends AbstractLogic { ...@@ -21,15 +22,11 @@ public class UnlockReportLogic extends AbstractLogic {
return new UnlockReportLogic(); return new UnlockReportLogic();
} }
public Result unlock(Map<String, String> param) { public Result unlock(String taskKey, Long taskReportId, Date reportStartDate) {
Long taskReportId = longOrNull(param.get("taskReportId")); String loginId = cache.getMemberInfo().loginId;
Date reportStartDate = dateOrNull(param.get("reportStartDate")); Result r = sendUnlockReport(taskKey, taskReportId, reportStartDate);
updateLocalDB(taskKey, reportStartDate, r.extParam.getReportStatus(), loginId);
return sendUnlockReport( return r;
param.get("taskKey"),
taskReportId,
reportStartDate
);
} }
private Result sendUnlockReport( private Result sendUnlockReport(
...@@ -59,20 +56,23 @@ public class UnlockReportLogic extends AbstractLogic { ...@@ -59,20 +56,23 @@ public class UnlockReportLogic extends AbstractLogic {
} }
} }
private Long longOrNull(String s) { private void updateLocalDB(
try { String taskKey,
return Long.valueOf(s); Date reportStartDate,
} catch (Exception e) { int reportStatus,
return null; String loginId
} ) {
} // ローカルDBに反映
TaskReportDao dao = AbstractDao.getDao(TaskReportDao.class);
private Date dateOrNull(String s) { dao.updateReportLock(
try { taskKey,
return DateTimeUtil.toDate(s, "UTC", DateTimeFormat.yyyyMMdd_hyphen); reportStartDate,
} catch (Exception e) { reportStatus,
return null; null,
} null,
null,
loginId
);
} }
// コールバック用のパラメータ // コールバック用のパラメータ
...@@ -92,10 +92,11 @@ public class UnlockReportLogic extends AbstractLogic { ...@@ -92,10 +92,11 @@ public class UnlockReportLogic extends AbstractLogic {
static Result failure(Throwable e, Long taskReportId, Date reportStartDate) { static Result failure(Throwable e, Long taskReportId, Date reportStartDate) {
// 例外がでたとき // 例外がでたとき
final int BAD_STATUS = 999;
Result result = new Result(); Result result = new Result();
result.result = 1; result.result = 1;
result.message = e.getLocalizedMessage(); result.message = e.getLocalizedMessage();
result.extParam = new ExtParam(999, taskReportId, reportStartDate); result.extParam = new ExtParam(BAD_STATUS, taskReportId, reportStartDate);
return result; return result;
} }
......
package jp.agentec.abook.abv.ui.common.activity; package jp.agentec.abook.abv.ui.common.activity;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
...@@ -145,6 +146,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -145,6 +146,7 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
private boolean mLocationSendResult; // GPS送信フラグ private boolean mLocationSendResult; // GPS送信フラグ
@SuppressLint("SourceLockedOrientationActivity")
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -650,7 +652,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -650,7 +652,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
finish(); finish();
} }
protected void createCheckToolbar() { @SuppressLint("SourceLockedOrientationActivity")
protected void createCheckToolbar() {
final RelativeLayout fl; final RelativeLayout fl;
if (operationDto != null && operationDto.operationType == OperationType.PDF && mXWalkOpenType == Constant.XWalkOpenType.TASK_REPORT) { if (operationDto != null && operationDto.operationType == OperationType.PDF && mXWalkOpenType == Constant.XWalkOpenType.TASK_REPORT) {
fl = (RelativeLayout) findViewById(R.id.RelativeLayout2); fl = (RelativeLayout) findViewById(R.id.RelativeLayout2);
...@@ -887,11 +890,11 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -887,11 +890,11 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
mAddReport = Integer.parseInt(abookCheckParam.get(ABookKeys.ADD_REPORT)) > 0 ? true : false; mAddReport = Integer.parseInt(abookCheckParam.get(ABookKeys.ADD_REPORT)) > 0 ? true : false;
} }
int taskReportId = 0; long taskReportId = 0;
String reportStartDate = ""; String reportStartDate = "";
if (operationDto.reportType == Constant.ReportType.RoutineTask && abookCheckParam.get(ABookKeys.TASK_REPORT_ID) != null && abookCheckParam.get(ABookKeys.REPORT_START_DATE) != null) { 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); reportStartDate = abookCheckParam.get(ABookKeys.REPORT_START_DATE);
} }
...@@ -1077,45 +1080,19 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity { ...@@ -1077,45 +1080,19 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// 1:中心温度計 2:置くだけセンサー 3:バーコード // 1:中心温度計 2:置くだけセンサー 3:バーコード
getDeviceInfo(abookCheckParam); getDeviceInfo(abookCheckParam);
} else if (mCmd.equals(ABookKeys.CMD_LOCK_REPORT)) { } else if (mCmd.equals(ABookKeys.CMD_LOCK_REPORT)) {
LockReportLogic.Result r = LockReportLogic.newInstance().lock(abookCheckParam); String taskKey = abookCheckParam.get("taskKey");
// ローカルDBに反映 Date startDate = DateTimeUtil.toDate(reportStartDate, "UTC", DateTimeFormat.yyyyMMdd_hyphen);
TaskReportDao dao = AbstractDao.getDao(TaskReportDao.class); // ロック
dao.updateReportLock( LockReportLogic.Result r = LockReportLogic.newInstance().lock(taskKey, taskReportId, startDate);
mTaskKey,
dateOrNull(abookCheckParam.get("reportStartDate")),
r.getExtParam().getReportStatus(),
r.getExtParam().getReportLockUserId(),
r.getExtParam().getReportLockUserName(),
r.getExtParam().getReportLockTime()
);
// JSコールバック // JSコールバック
afterABookCheckApi( afterABookCheckApi(mCmd, mTaskKey, r.getResult(), r.getMessage(), r.getExtParam().json());
mCmd,
mTaskKey,
r.getResult(),
r.getMessage(),
r.getExtParam().json()
);
} else if (mCmd.equals(ABookKeys.CMD_UNLOCK_REPORT)) { } else if (mCmd.equals(ABookKeys.CMD_UNLOCK_REPORT)) {
UnlockReportLogic.Result r = UnlockReportLogic.newInstance().unlock(abookCheckParam); String taskKey = abookCheckParam.get("taskKey");
// ローカルDBに反映 Date startDate = dateOrNull(abookCheckParam.get("reportStartDate"));
TaskReportDao dao = AbstractDao.getDao(TaskReportDao.class); // アンロック
dao.updateReportLock( UnlockReportLogic.Result r = UnlockReportLogic.newInstance().unlock(taskKey, taskReportId, startDate);
mTaskKey,
dateOrNull(abookCheckParam.get("reportStartDate")),
r.getExtParam().getReportStatus(),
null,
null,
null
);
// JSコールバック // JSコールバック
afterABookCheckApi( afterABookCheckApi(mCmd, mTaskKey, r.getResult(), r.getMessage(), r.getExtParam().json());
mCmd,
mTaskKey,
r.getResult(),
r.getMessage(),
r.getExtParam().json()
);
} }
} }
......
...@@ -18,7 +18,7 @@ import org.json.adf.JSONArray; ...@@ -18,7 +18,7 @@ import org.json.adf.JSONArray;
import org.json.adf.JSONObject; import org.json.adf.JSONObject;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -27,12 +27,14 @@ import jp.agentec.abook.abv.bl.common.constant.ABookKeys; ...@@ -27,12 +27,14 @@ 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.dao.AbstractDao; import jp.agentec.abook.abv.bl.data.dao.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.ReportStatusDao; import jp.agentec.abook.abv.bl.data.dao.ReportStatusDao;
import jp.agentec.abook.abv.bl.data.dao.TaskReportDao;
import jp.agentec.abook.abv.bl.dto.ReportStatusDto; import jp.agentec.abook.abv.bl.dto.ReportStatusDto;
import jp.agentec.abook.abv.bl.dto.comparator.ReportStatusCompalator;
import jp.agentec.abook.abv.bl.logic.LockReportLogic; import jp.agentec.abook.abv.bl.logic.LockReportLogic;
import jp.agentec.abook.abv.bl.logic.UnlockReportLogic; import jp.agentec.abook.abv.bl.logic.UnlockReportLogic;
import jp.agentec.abook.abv.launcher.android.R; import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.viewer.view.CheckFormWebview; 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.common.constant.ABookCommConstants.DASHBOARD_URL; import static jp.agentec.abook.abv.bl.common.constant.ABookCommConstants.DASHBOARD_URL;
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_LIST;
...@@ -243,14 +245,19 @@ public class DashboardActivity extends OperationActivity { ...@@ -243,14 +245,19 @@ public class DashboardActivity extends OperationActivity {
} }
} }
case CMD_GO_REPORT_DETAIL: { case CMD_GO_REPORT_DETAIL: {
return goReportDetail();
break;
} }
case CMD_LOCK_REPORT: { case CMD_LOCK_REPORT: {
return lockReport(param); String taskKey = param.get("taskKey");
Long taskReportId = longOrNull(param.get("taskReportId"));
Date reportStartDate = dateOrNull(param.get("reportStartDate"));
return lockReport(taskKey, taskReportId, reportStartDate);
} }
case CMD_UNLOCK_REPORT: { case CMD_UNLOCK_REPORT: {
return unlockReport(param); String taskKey = param.get("taskKey");
Long taskReportId = longOrNull(param.get("taskReportId"));
Date reportStartDate = dateOrNull(param.get("reportStartDate"));
return unlockReport(taskKey, taskReportId, reportStartDate);
} }
} }
return false; return false;
...@@ -299,8 +306,8 @@ public class DashboardActivity extends OperationActivity { ...@@ -299,8 +306,8 @@ public class DashboardActivity extends OperationActivity {
} }
if (reports != null) { if (reports != null) {
JSONObject param = makeReportTree(reportStatusId, reports); JSONObject param = makeReportTree(reportStatusId, reports);
String response = "javascript:CHK_Dashboard.reportListCallback(" + reportStatusId + "," + param.toString() + ")"; String script = "javascript:CHK_Dashboard.reportListCallback(" + reportStatusId + "," + param.toString() + ")";
webView.loadUrl(response); webView.loadUrl(script);
return true; return true;
} else { } else {
return false; return false;
...@@ -316,7 +323,7 @@ public class DashboardActivity extends OperationActivity { ...@@ -316,7 +323,7 @@ public class DashboardActivity extends OperationActivity {
tree.put("operationList", operationList); tree.put("operationList", operationList);
// operationIDで、ソートしておく // operationIDで、ソートしておく
Collections.sort(reports, new ReportCompalator()); Collections.sort(reports, new ReportStatusCompalator());
JSONObject operation = null; JSONObject operation = null;
for (ReportStatusDto report : reports) { for (ReportStatusDto report : reports) {
...@@ -332,80 +339,86 @@ public class DashboardActivity extends OperationActivity { ...@@ -332,80 +339,86 @@ public class DashboardActivity extends OperationActivity {
task.put("taskKey", report.getTaskKey()); task.put("taskKey", report.getTaskKey());
task.put("taskReportInfo", report.getTaskReportInfo()); task.put("taskReportInfo", report.getTaskReportInfo());
task.put("taskReportId", report.getTaskReportId()); task.put("taskReportId", report.getTaskReportId());
task.put("reportStartDate", report.getReportStartDate()); task.put("reportStartDate", report.getReportStartDateAsString());
task.put("reportLockUserId", report.getReportLockUserId()); task.put("reportLockUserId", report.getReportLockUserId());
task.put("reportLockUserName", report.getReportLockUserName()); task.put("reportLockUserName", report.getReportLockUserName());
task.put("reportLockTime", report.reportLockTime); task.put("reportLockTime", report.getReportLockTimeAsString());
task.put("sendBackUserId", report.sendBackUserId); task.put("sendBackUserId", report.getSendBackUserId());
task.put("sendBackUserName", report.sendBackUserName); task.put("sendBackUserName", report.getSendBackUserName());
operation.getJSONArray("reportList").put(task); operation.getJSONArray("reportList").put(task);
} }
return tree; return tree;
} }
private static class ReportCompalator 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());
}
}
private boolean goReportDetail() { private boolean goReportDetail() {
//todo //todo
return false; return false;
} }
private boolean lockReport(Map<String, String> param) { private boolean lockReport(String taskKey, Long taskReportId, Date reportStartDate) {
// LockReportLogic.Result r = LockReportLogic.newInstance().lock(param); try {
// ローカルDBに反映 LockReportLogic.Result r = LockReportLogic.newInstance().lock(taskKey, taskReportId, reportStartDate);
// TaskReportDao dao = AbstractDao.getDao(TaskReportDao.class); // JSコールバック
// dao.updateReportLock( afterABookCheckApi(
// mTaskKey, CMD_LOCK_REPORT,
// dateOrNull(param.get("reportStartDate")), taskKey,
// r.getExtParam().getReportStatus(), r.getResult(),
// r.getExtParam().getReportLockUserId(), r.getMessage(),
// r.getExtParam().getReportLockUserName(), r.getExtParam().json()
// r.getExtParam().getReportLockTime() );
// ); return true;
// JSコールバック } catch (Throwable e) {
// afterABookCheckApi( e.printStackTrace();
// mCmd, return false;
// mTaskKey, }
// r.getResult(), }
// r.getMessage(),
// r.getExtParam().json() private boolean unlockReport(String taskKey, Long taskReportId, Date reportStartDate) {
// ); try {
return true; 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 longOrNull(String s) {
try {
return Long.parseLong(s);
} catch (Exception e) {
Logger.e(TAG, e.getLocalizedMessage());
return null;
}
} }
private boolean unlockReport(Map<String, String> param) { private Date dateOrNull(String s) {
// UnlockReportLogic.Result r = UnlockReportLogic.newInstance().unlock(param); try {
// // ローカルDBに反映 return DateTimeUtil.toDate(s, "UTC", DateTimeFormat.yyyyMMdd_hyphen);
// TaskReportDao dao = AbstractDao.getDao(TaskReportDao.class); } catch (Exception e) {
// dao.updateReportLock( Logger.e(TAG, e.getLocalizedMessage());
// mTaskKey, return null;
// dateOrNull(param.get("reportStartDate")), }
// r.getExtParam().getReportStatus(),
// null,
// null,
// null
// );
// // JSコールバック
// afterABookCheckApi(
// mCmd,
// mTaskKey,
// r.getResult(),
// r.getMessage(),
// r.getExtParam().json()
// );
return true;
} }
} }
...@@ -633,7 +633,8 @@ public class EnqueteWebViewActivity extends ABVContentViewActivity { ...@@ -633,7 +633,8 @@ public class EnqueteWebViewActivity extends ABVContentViewActivity {
return false; return false;
} }
public void finishActivity() { @Override
public void finishActivity() {
setResult(RESULT_OK, new Intent()); setResult(RESULT_OK, new Intent());
finish(); finish();
if (objectId == -1) { // Enqueteコンテンツの場合で、KeyUpではない場合、全コンテンツActivityを終了 if (objectId == -1) { // Enqueteコンテンツの場合で、KeyUpではない場合、全コンテンツActivityを終了
......
...@@ -189,7 +189,8 @@ public class NoPdfViewActivity extends ABVContentViewActivity { ...@@ -189,7 +189,8 @@ public class NoPdfViewActivity extends ABVContentViewActivity {
historyListBtn.setVisibility(View.INVISIBLE); historyListBtn.setVisibility(View.INVISIBLE);
} }
protected void finishActivity() { @Override
protected void finishActivity() {
Logger.d(TAG, "finishActivity"); Logger.d(TAG, "finishActivity");
finish(); finish();
if (isLinkedContent) { if (isLinkedContent) {
......
...@@ -39,10 +39,10 @@ app_versioncode=1 ...@@ -39,10 +39,10 @@ app_versioncode=1
#cms server #cms server
#acms_address=https://check.abookcloud.com/acms #acms_address=https://check.abookcloud.com/acms
#download_server_address=https://check.abookcloud.com/acms #download_server_address=https://check.abookcloud.com/acms
acms_address=https://abook188-1.abook.bz/acms #acms_address=https://abook188-1.abook.bz/acms
download_server_address=https://abook188-1.abook.bz/acms #download_server_address=https://abook188-1.abook.bz/acms
#acms_address=http://10.0.2.2:8080/acms acms_address=http://10.0.2.2:8080/acms
#download_server_address=http://10.0.2.2:8080/acms download_server_address=http://10.0.2.2:8080/acms
#syncview server #syncview server
websocket_server_http_url=https://abook188-1.abook.bz/v1 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