Commit e38d4b24 by Kazuyuki Hida

ダッシュボード用のAPI(getReportStatusCount)を実装した。動作確認ができていない。

parent 5e96dcf4
package jp.agentec.abook.abv.bl.data.dao;
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.db.Cursor;
import jp.agentec.abook.abv.bl.data.tables.TTaskReportStatus;
import jp.agentec.abook.abv.bl.dto.DashboardStatusDto;
import jp.agentec.abook.abv.bl.dto.ReportStatusCountDto;
import jp.agentec.abook.abv.bl.dto.ReportStatusDto;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
......@@ -82,7 +87,7 @@ public class ReportStatusDao extends AbstractDao {
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
}
public List<ReportStatusDto> getcompleteOkReport() {
public List<ReportStatusDto> getCompleteOkReport() {
StringBuilder sql = reportStatusSql();
sql.append("WHERE t_task_report_status.complete_ok_flg <> 0");
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
......@@ -215,4 +220,45 @@ public class ReportStatusDao extends AbstractDao {
return cursor.getLong(column);
}
}
public List<ReportStatusCountDto> getReportStatusCountList() {
List<ReportStatusCountDto> list = new ArrayList<ReportStatusCountDto>();
/*
0:未実施、1:作業中、
2:作業完了(異常なし)、
3:作業完了(異常あり)、
4:期限切れ、5:アラート、
6:差し戻し、7:一時保存
*/
list.add(makeDto(0, getUntouchedReport().size()));
list.add(makeDto(1, getWorkingReport().size()));
list.add(makeDto(2, getCompleteOkReport().size()));
list.add(makeDto(3, getCompleteNgReport().size()));
list.add(makeDto(4, getIncompleteReport().size()));
list.add(makeDto(5, getAlertReport().size()));
list.add(makeDto(6, getSendBackedReport().size()));
list.add(makeDto(7, getPendingReport().size()));
return list;
}
private ReportStatusCountDto makeDto(int id, int count) {
return new ReportStatusCountDto(String.valueOf(id), String.valueOf(count));
}
public JSONObject getReportStatusCountJson() {
JSONArray list = new JSONArray();
for (ReportStatusCountDto dto: getReportStatusCountList()) {
JSONObject json = new JSONObject();
json.put("reportStatusId", dto.getReportStatusId());
json.put("reportStatusCount", dto.getReportStatusCount());
list.put(json);
}
JSONObject result = new JSONObject();
result.put("reportStatusCountList", list);
return result;
}
}
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;
}
}
......@@ -6,6 +6,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
......@@ -74,7 +75,8 @@ public class DashboardActivity extends OperationActivity {
@Override
public void onClick(View v) {
Logger.d(TAG, "ReloadUrl");
webView.loadUrl(DASHBOARD_URL);
webView.loadUrl("javascript:CHK_Dashboard.init()");
// webView.loadUrl(DASHBOARD_URL);
}
});
......@@ -127,7 +129,7 @@ public class DashboardActivity extends OperationActivity {
webView.setWebChromeClient(new ChromeClient());
webView.setWebViewClient(new ViewClient());
// webView.addJavascriptInterface(jsInf, "android");
webView.addJavascriptInterface(new JsInf(), "android");
Logger.d(TAG, "loadUrl: " + DASHBOARD_URL);
}
......@@ -164,47 +166,47 @@ public class DashboardActivity extends OperationActivity {
}
}
// private class JsInf {
//
// @JavascriptInterface
// public void existSetLocation(String ret) {
// Logger.d(TAG, "existSetLocation=%s", ret);
// if (ret != null && ret.equals("true")) { // setLocationメソッドが存在する場合、ページ読み込み完了とみなす
// isPageFinished = true;
// } else { // 存在しない場合、ページ読み込み未完了とみなし1秒後に再度呼出しを繰り返す
// handler.postDelayed(new Runnable() {
// @Override
// public void run() {
// callExistsSetLocation();
// }
// }, 1000);
// }
// }
//
// @JavascriptInterface
// public void existSendLog(String ret) {
// Logger.d(TAG, "existSendLog=%s", ret);
// if (ret != null && ret.equals("true")) {
// runOnUiThread(new Runnable() { // sendLogメソッドが存在する場合、呼び出す
// @Override
// public void run() {
// try {
// webView.loadUrl("javascript:sendLog()");
// } catch (Exception e) {
// Logger.e(TAG, "javascript:sendLog error. " + e.toString());
// }
// }
// });
// } else {
// finishActivity();
// }
// }
//
// @JavascriptInterface
// public void getAttachedDataUrl(String taskKey, String data) {
// commonAttachedDataUrl(taskKey, data);
// }
// }
private class JsInf {
@JavascriptInterface
public void existSetLocation(String ret) {
Logger.d(TAG, "existSetLocation=%s", ret);
if (ret != null && ret.equals("true")) { // setLocationメソッドが存在する場合、ページ読み込み完了とみなす
//isPageFinished = true;
} else { // 存在しない場合、ページ読み込み未完了とみなし1秒後に再度呼出しを繰り返す
handler.postDelayed(new Runnable() {
@Override
public void run() {
//callExistsSetLocation();
}
}, 1000);
}
}
@JavascriptInterface
public void existSendLog(String ret) {
Logger.d(TAG, "existSendLog=%s", ret);
if (ret != null && ret.equals("true")) {
runOnUiThread(new Runnable() { // sendLogメソッドが存在する場合、呼び出す
@Override
public void run() {
try {
webView.loadUrl("javascript:sendLog()");
} catch (Exception e) {
Logger.e(TAG, "javascript:sendLog error. " + e.toString());
}
}
});
} else {
finish();
}
}
@JavascriptInterface
public void getAttachedDataUrl(String taskKey, String data) {
//commonAttachedDataUrl(taskKey, data);
}
}
private class ViewClient extends WebViewClient {
......@@ -302,7 +304,7 @@ public class DashboardActivity extends OperationActivity {
break;
}
case 2: {
reports = dao.getcompleteOkReport();
reports = dao.getCompleteOkReport();
break;
}
case 3: {
......@@ -495,4 +497,6 @@ public class DashboardActivity extends OperationActivity {
return null;
}
}
}
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