Commit c524f49f by Kazuyuki Hida

extParamに、taskReportIdとreportStartDateを追加

parent a4f62104
......@@ -21,10 +21,13 @@ public class LockReportLogic extends AbstractLogic {
}
public Result lock(Map<String, String> param) {
Long taskReportId = longOrNull(param.get("taskReportId"));
Date reportStartDate = dateOrNull(param.get("reportStartDate"));
return sendLockReport(
param.get("taskKey"),
longOrNull(param.get("taskReportId")),
dateOrNull(param.get("reportStartDate"))
taskReportId,
reportStartDate
);
}
......@@ -46,19 +49,17 @@ public class LockReportLogic extends AbstractLogic {
if (!networkAdapter.isNetworkConnected()) {
// オフラインだったら、ロック成功扱い
return Result.offLine();
return Result.offLine(taskReportId, reportStartDate);
}
try {
LockReportJSON reportJSON = client.sendLockReport(param);
return Result.succsess(reportJSON);
return Result.succsess(reportJSON, taskReportId, reportStartDate);
} catch (Throwable e) {
return Result.failure(e);
return Result.failure(e, taskReportId, reportStartDate);
}
}
private Long longOrNull(String s) {
try {
return Long.valueOf(s);
......@@ -81,7 +82,7 @@ public class LockReportLogic extends AbstractLogic {
String message;
ExtParam extParam;
static Result succsess(LockReportJSON reportJSON) {
static Result succsess(LockReportJSON reportJSON, Long taskReportId, Date reportStartDate) {
// 成功したとき
Result result = new Result();
result.result = reportJSON.httpStatus == HTTP_OK ? 0 : 1;
......@@ -90,26 +91,43 @@ public class LockReportLogic extends AbstractLogic {
reportJSON.getReportStatus(),
reportJSON.getReportLockUserId(),
reportJSON.getReportLockUserName(),
reportJSON.getReportLockTime()
reportJSON.getReportLockTime(),
taskReportId,
reportStartDate
);
return result;
}
static Result failure(Throwable e) {
@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(999, null, null, null);
result.extParam = new ExtParam(
999,
null,
null,
null,
taskReportId,
reportStartDate
);
return result;
}
static Result offLine() {
static Result offLine(Long taskReportId, Date reportStartDate) {
// オフラインは成功扱い
Result result = new Result();
result.result = 0;
result.message = "";
result.extParam = new ExtParam(3, null, null, null);
result.extParam = new ExtParam(
3,
null,
null,
null,
taskReportId,
reportStartDate
);
return result;
}
......@@ -131,17 +149,23 @@ public class LockReportLogic extends AbstractLogic {
String reportLockUserId;
String reportLockUserName;
Date reportLockTime;
Long taskReportId;
Date reportStartDate;
ExtParam(
int reportStatus,
String reportLockUserId,
String reportLockUserName,
Date reportLockTime
Date reportLockTime,
Long taskReportId,
Date reportStartDate
) {
this.reportStatus = reportStatus;
this.reportLockUserId = reportLockUserId;
this.reportLockUserName = reportLockUserName;
this.reportLockTime = reportLockTime;
this.taskReportId = taskReportId;
this.reportStartDate = reportStartDate;
}
......@@ -166,7 +190,14 @@ public class LockReportLogic extends AbstractLogic {
extParam.put("reportStatus", String.valueOf(reportStatus));
extParam.put("reportLockUserId", reportLockUserId);
extParam.put("reportLockUserName", reportLockUserName);
extParam.put("reportLockTime", reportLockTime);
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();
}
}
......
......@@ -22,10 +22,13 @@ public class UnlockReportLogic extends AbstractLogic {
}
public Result unlock(Map<String, String> param) {
Long taskReportId = longOrNull(param.get("taskReportId"));
Date reportStartDate = dateOrNull(param.get("reportStartDate"));
return sendUnlockReport(
param.get("taskKey"),
longOrNull(param.get("taskReportId")),
dateOrNull(param.get("reportStartDate"))
taskReportId,
reportStartDate
);
}
......@@ -45,14 +48,14 @@ public class UnlockReportLogic extends AbstractLogic {
if (!networkAdapter.isNetworkConnected()) {
// オフラインだったら、ロック成功扱い
return Result.offLine();
return Result.offLine(taskReportId, reportStartDate);
}
try {
UnlockReportJSON reportJSON = client.sendUnlockReport(param);
return Result.succsess(reportJSON);
return Result.succsess(reportJSON, taskReportId, reportStartDate);
} catch (Exception e) {
return Result.failure(e);
return Result.failure(e, taskReportId, reportStartDate);
}
}
......@@ -78,30 +81,30 @@ public class UnlockReportLogic extends AbstractLogic {
String message;
ExtParam extParam;
static Result succsess(UnlockReportJSON reportJSON) {
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());
result.extParam = new ExtParam(reportJSON.getReportStatus(), taskReportId, reportStartDate);
return result;
}
static Result failure(Throwable e) {
static Result failure(Throwable e, Long taskReportId, Date reportStartDate) {
// 例外がでたとき
Result result = new Result();
result.result = 1;
result.message = e.getLocalizedMessage();
result.extParam = new ExtParam(999);
result.extParam = new ExtParam(999, taskReportId, reportStartDate);
return result;
}
static Result offLine() {
static Result offLine(Long taskReportId, Date reportStartDate) {
// オフラインは成功扱い
Result result = new Result();
result.result = 0;
result.message = "";
result.extParam = new ExtParam(3);
result.extParam = new ExtParam(3, taskReportId, reportStartDate);
return result;
}
......@@ -120,9 +123,13 @@ public class UnlockReportLogic extends AbstractLogic {
public static class ExtParam {
int reportStatus ;
Long taskReportId;
Date reportStartDate;
ExtParam(int reportStatus) {
ExtParam(int reportStatus, Long taskReportId, Date reportStartDate) {
this.reportStatus = reportStatus;
this.taskReportId = taskReportId;
this.reportStartDate = reportStartDate;
}
public int getReportStatus() {
......@@ -132,6 +139,12 @@ public class UnlockReportLogic extends AbstractLogic {
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();
}
}
......
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