Commit c524f49f by Kazuyuki Hida

extParamに、taskReportIdとreportStartDateを追加

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