Commit 1bb6e002 by Kazuyuki Hida

JSに渡すJSONを作るところまでできた。

parent df49fae1
......@@ -155,6 +155,7 @@
<option name="ignoreEqualsMethod" value="false" />
<option name="m_limit" value="1" />
</inspection_tool>
<inspection_tool class="MultipleVariablesInDeclaration" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="NegatedIfElse" enabled="true" level="ERROR" enabled_by_default="true">
<option name="m_ignoreNegatedNullComparison" value="true" />
<option name="m_ignoreNegatedZeroComparison" value="false" />
......@@ -217,6 +218,7 @@
</inspection_tool>
<inspection_tool class="ReuseOfLocalVariable" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="SSBasedInspection" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="SameParameterValue" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SimplifiableIfStatement" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="INFO" enabled_by_default="false">
<option name="processCode" value="true" />
......@@ -225,6 +227,7 @@
</inspection_tool>
<inspection_tool class="StaticCallOnSubclass" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="StaticFieldReferenceOnSubclass" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="StringBufferReplaceableByString" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="StringConcatenationInFormatCall" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="StringConcatenationInMessageFormatCall" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="StringConcatenationMissingWhitespace" enabled="false" level="ERROR" enabled_by_default="false" />
......@@ -239,6 +242,9 @@
<inspection_tool class="SuspiciousNameCombination" enabled="false" level="ERROR" enabled_by_default="false">
<group names="x,width,left,right" />
<group names="y,height,top,bottom" />
<ignored>
<option name="METHOD_MATCHER_CONFIG" value="java.io.PrintStream,println,java.io.PrintWriter,println,java.lang.System,identityHashCode,java.sql.PreparedStatement,set.*,java.sql.ResultSet,update.*,java.sql.SQLOutput,write.*,java.lang.Integer,compare.*,java.lang.Long,compare.*,java.lang.Short,compare,java.lang.Byte,compare,java.lang.Character,compare,java.lang.Boolean,compare,java.lang.Math,.*,java.lang.StrictMath,.*" />
</ignored>
</inspection_tool>
<inspection_tool class="SuspiciousSystemArraycopy" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="SuspiciousToArrayCall" enabled="true" level="ERROR" enabled_by_default="true" />
......
......@@ -9,14 +9,14 @@ import java.util.List;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.ReportStatusDto;
import jp.agentec.abook.abv.bl.dto.DashboardStatusDto;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
public class DashboardStatusJSON extends AcmsCommonJSON {
private static final String TAG = "DashboardStatusJSON";
private List<ReportStatusDto> reportStatuses = new ArrayList<ReportStatusDto>();
private List<DashboardStatusDto> reportStatuses;
public DashboardStatusJSON(String jsonString) throws AcmsException {
super(jsonString);
......@@ -24,23 +24,30 @@ public class DashboardStatusJSON extends AcmsCommonJSON {
@Override
protected void parse(JSONObject json) {
// 使わないので無視 //presentTimeUTC = dateOrNull(json.getString("presentTimeUTC"));
// 使わないので無視 //presentTimeUTC = dateOrNull(json.getString("presentTimeUTC"));
JSONArray oprations = json.getJSONArray("operationList");
reportStatuses = new ArrayList<DashboardStatusDto>();
for (int i = 0; i < oprations.length(); i++) {
JSONObject opJson = oprations.getJSONObject(i);
try {
Long operationId = longOrNull(opJson.getString("operationId"));
String operationName = opJson.getString("operationName");
long operationId = longOrZero(opJson, "operationId");
String operationName = stringOrNull(opJson, "operationName");
JSONArray reports = opJson.getJSONArray("reportList");
for (int j = 0; j < reports.length(); j++) {
JSONObject repJson = reports.getJSONObject(j);
String taskKey = repJson.getString("taskKey");
Long taskReportId = longOrNull(repJson.getString("taskReportId"));
Date reportStartDate = dateOrNull(repJson.getString("reportStartDate"));
int reportStatus = repJson.getInt("reportStatus");
ReportStatusDto rep = new ReportStatusDto(
taskKey, taskReportId, reportStartDate,
operationId, operationName, reportStatus
String taskKey = stringOrNull(repJson,"taskKey");
Long taskReportId = longOrNull(repJson, "taskReportId");
Date reportStartDate = dateOrNull(repJson, "reportStartDate");
int reportStatus = intOrZero(repJson,"reportStatus");
DashboardStatusDto rep = new DashboardStatusDto(
taskKey,
taskReportId,
reportStartDate,
operationId,
operationName,
reportStatus
);
reportStatuses.add(rep);
}
......@@ -50,21 +57,65 @@ public class DashboardStatusJSON extends AcmsCommonJSON {
}
}
public List<ReportStatusDto> getReportStatuses() {
public List<DashboardStatusDto> getReportStatuses() {
return reportStatuses;
}
private Long longOrNull(String s) {
private Long longOrNull(JSONObject json, String key) {
try {
return Long.valueOf(s);
if (json.has(key)) {
return json.getLong(key);
} else {
return null;
}
} catch (Exception e) {
return null;
}
}
private Date dateOrNull(String s) {
private long longOrZero(JSONObject json, String key) {
try {
if (json.has(key)) {
return json.getLong(key);
} else {
return 0;
}
} catch (Exception e) {
return 0;
}
}
private int intOrZero(JSONObject json, String key) {
try {
return DateTimeUtil.toDate(s, "UTC", DateTimeFormat.yyyyMMdd_hyphen);
if (json.has(key)) {
return json.getInt(key);
} else {
return 0;
}
} catch (Exception e) {
return 0;
}
}
private Date dateOrNull(JSONObject json, String key) {
try {
if (json.has(key)) {
return DateTimeUtil.toDate(json.getString(key), "UTC", DateTimeFormat.yyyyMMdd_hyphen);
} else {
return null;
}
} catch (Exception e) {
return null;
}
}
private String stringOrNull(JSONObject json, String key) {
try {
if (json.has(key)) {
return json.getString(key);
} else {
return null;
}
} catch (Exception e) {
return null;
}
......
......@@ -213,7 +213,9 @@ public class AcmsApis {
methodName.equals(ApiSendPushMessage) || methodName.equals(ApiGetPushMessages) || methodName.equals(ApiSendRoutineTaskData) ||
methodName.equals(ApiGetMasterData) ||
// カテゴリ選択機能、IO帳票で3つ追加
methodName.equals(ApiOperationGroupMaster) || methodName.equals(ApiQuickReportSearch) || methodName.equals(ApiQuickReportRevision)) {
methodName.equals(ApiOperationGroupMaster) || methodName.equals(ApiQuickReportSearch) || methodName.equals(ApiQuickReportRevision) ||
// ダッシュボード追加
methodName.equals(ApiGetDashboardStatus)) {
apiValue = Constant.ApiValue.checkapi;
}
......
......@@ -37,6 +37,7 @@ import jp.agentec.abook.abv.bl.data.tables.TEnquete;
import jp.agentec.abook.abv.bl.data.tables.TMarkingSetting;
import jp.agentec.abook.abv.bl.data.tables.TOperation;
import jp.agentec.abook.abv.bl.data.tables.TPushMessage;
import jp.agentec.abook.abv.bl.data.tables.TTaskReportStatus;
import jp.agentec.abook.abv.bl.data.tables.TSppDevice;
import jp.agentec.abook.abv.bl.data.tables.TTask;
import jp.agentec.abook.abv.bl.data.tables.TTaskReport;
......@@ -97,6 +98,7 @@ public class ABVDataOpenHelper {
iTableScripts.add(new TTaskReportSend());
iTableScripts.add(new TTaskReportItems());
iTableScripts.add(new TPushMessage());
iTableScripts.add(new TTaskReportStatus());
// SPP通信端末管理テーブルをスクリプトに追加
iTableScripts.add(new TSppDevice());
......
......@@ -19,7 +19,7 @@ import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase;
public class DBConnector {
private static volatile DBConnector dbConnector = null;
public static final String DatabaseName = "ABVJE";
public static final int DatabaseVersion = DatabaseVersions.Ver1_0_5;
public static final int DatabaseVersion = DatabaseVersions.Ver1_0_7;
protected SQLiteDatabase db = null;
......
......@@ -8,4 +8,5 @@ public class DatabaseVersions {
public static final int Ver1_0_4 = 31; // @From 作業の進捗状況を追加
public static final int Ver1_0_5 = 41; // @From 作業のロック、差し戻し対応
public static final int Ver1_0_6 = 51; // @From 作業のロック情報を追加
public static final int Ver1_0_7 = 61; // @From ダッシュボード対応
}
package jp.agentec.abook.abv.bl.data.dao;
public class ReportStatusDao {
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.ReportStatusDto;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
public class ReportStatusDao extends AbstractDao {
public void insert(DashboardStatusDto dto) {
StringBuilder sql = new StringBuilder();
sql.append("INSERT INTO ").append(TTaskReportStatus.tableName).append(" (");
sql.append(" task_key,");
sql.append(" task_report_id,");
sql.append(" report_start_date,");
sql.append(" operation_id,");
sql.append(" operation_name,");
sql.append(" report_status,");
sql.append(" untouched_flg,");
sql.append(" working_flg,");
sql.append(" complete_ok_flg,");
sql.append(" complete_ng_flg,");
sql.append(" incomplete_flg,");
sql.append(" alert_flg,");
sql.append(" send_backed_flg)");
sql.append(" VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
insert(sql.toString(), dto.getInsertValues());
}
public void deleteAll() {
execSql("DELETE FROM " + TTaskReportStatus.tableName);
}
private StringBuilder commonSql() {
StringBuilder sql = new StringBuilder();
sql.append("SELECT");
sql.append(" t_task_report_status.report_status AS report_status,");
sql.append(" t_task_report_status.operation_id AS operation_id,");
sql.append(" t_task_report_status.operation_name AS operation_name,");
sql.append(" t_task_report.task_key AS task_key,");
sql.append(" t_task.task_code AS task_code,");
sql.append(" t_task_report.json_data AS json_data,");
sql.append(" t_task_report.task_report_id AS task_report_id,");
sql.append(" t_task_report.report_start_date AS report_start_date,");
sql.append(" t_task_report.report_lock_user_id AS report_lock_user_id,");
sql.append(" t_task_report.report_lock_user_name AS report_lock_user_name,");
sql.append(" t_task_report.report_lock_time AS report_lock_time,");
sql.append(" t_task_report.send_back_user_id AS send_back_user_id,");
sql.append(" t_task_report.send_back_user_name AS send_back_user_name,");
sql.append(" t_task_report.send_back_comment AS send_back_comment ");
sql.append(" FROM t_task_report ");
sql.append(" INNER JOIN t_task ");
sql.append(" ON t_task_report.task_key = t_task.task_key ");
sql.append(" INNER JOIN t_task_report_status");
// 定期点検の場合
sql.append(" ON (t_task_report.task_report_id = t_task_report_status.task_report_id");
sql.append(" AND t_task_report.report_start_date = t_task_report_status.report_start_date)");
// 報告の場合
sql.append(" OR (t_task_report.task_key = t_task_report_status.task_key");
sql.append(" AND t_task_report_status.task_report_id is null");
sql.append(" AND t_task_report_status.report_start_date is null)");
return sql;
}
public List<ReportStatusDto> getUntouchedReport() {
StringBuilder sql = commonSql();
sql.append("WHERE t_task_report_status.untouched_flg <> 0");
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
}
public List<ReportStatusDto> getWorkingReport() {
StringBuilder sql = commonSql();
sql.append("WHERE t_task_report_status.working_flg <> 0");
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
}
public List<ReportStatusDto> getcompleteOkReport() {
StringBuilder sql = commonSql();
sql.append("WHERE t_task_report_status.complete_ok_flg <> 0");
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
}
public List<ReportStatusDto> getCompleteNgReport() {
StringBuilder sql = commonSql();
sql.append("WHERE t_task_report_status.complete_ng_flg <> 0");
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
}
public List<ReportStatusDto> getIncompleteReport() {
StringBuilder sql = commonSql();
sql.append("WHERE t_task_report_status.incomplete_flg <> 0");
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
}
public List<ReportStatusDto> getAlertReport() {
StringBuilder sql = commonSql();
sql.append("WHERE t_task_report_status.alert_flg <> 0");
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
}
public List<ReportStatusDto> getSendBackedReport() {
StringBuilder sql = commonSql();
sql.append("WHERE t_task_report_status.send_backed_flg <> 0");
return rawQueryGetDtoList(sql.toString(), new String[] {}, ReportStatusDto.class);
}
public List<ReportStatusDto> getPendingReport() {
// 空のリストを返しておく todo
return new ArrayList<ReportStatusDto>();
}
@Override
protected ReportStatusDto convert(Cursor cursor) {
ReportStatusDto dto = new ReportStatusDto();
dto.reportStatus = intOrZero(cursor, "report_status");
dto.operationId = longOrZero(cursor, "operation_id");
dto.operationName = stringOrEmpty(cursor, "operation_name");
dto.taskKey = stringOrEmpty(cursor, "task_key");
dto.taskCode = stringOrNull(cursor, "task_code");
dto.taskReportInfo = stringOrEmpty(cursor, "json_data");
dto.taskReportId = longOrNull(cursor, "task_report_id");
dto.reportStartDate = dateOrNull(cursor, "report_start_date");
dto.reportLockUserId = stringOrNull(cursor, "report_lock_user_id");
dto.reportLockUserName = stringOrNull(cursor, "report_lock_user_name");
dto.reportLockTime = dateOrNull(cursor, "report_lock_time");
dto.sendBackUserId = stringOrNull(cursor, "send_back_user_id");
dto.sendBackUserName = stringOrNull(cursor, "send_back_user_name");
dto.sendBackComment = stringOrNull(cursor, "send_back_comment");
return dto;
}
private String stringOrNull(Cursor cursor, String name) {
int column = cursor.getColumnIndex(name);
if (column < 0) {
return null;
} else {
return cursor.getString(column);
}
}
private String stringOrEmpty(Cursor cursor, String name) {
int column = cursor.getColumnIndex(name);
if (column < 0) {
return "";
} else {
return cursor.getString(column);
}
}
private Date dateOrNull(Cursor cursor, String name) {
int column = cursor.getColumnIndex(name);
if (column < 0) {
return null;
} else {
String date = cursor.getString(column);
return DateTimeUtil.toDate(date, "UTC", DateTimeFormat.yyyyMMdd_hyphen);
}
}
private int intOrZero(Cursor cursor, String name) {
int column = cursor.getColumnIndex(name);
if (column < 0) {
return 0;
} else {
return cursor.getInt(column);
}
}
private long longOrZero(Cursor cursor, String name) {
int column = cursor.getColumnIndex(name);
if (column < 0) {
return 0;
} else {
return cursor.getLong(column);
}
}
private Long longOrNull(Cursor cursor, String name) {
int column = cursor.getColumnIndex(name);
if (column < 0) {
return null;
} else {
return cursor.getLong(column);
}
}
}
package jp.agentec.abook.abv.bl.data.tables;
import java.util.ArrayList;
import java.util.List;
import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase;
import static jp.agentec.abook.abv.bl.data.DatabaseVersions.Ver1_0_7;
public class TTaskReportStatus extends SQLiteTableScript {
public static final String tableName = "t_task_report_status";
@Override
public List<String> getCreateScript(int version) {
List<String> ddl = new ArrayList<String>();
StringBuilder sql = new StringBuilder();
sql.append("CREATE TABLE " + tableName +" ( ");
sql.append(" task_key TEXT NOT NULL DEFAULT '',");
sql.append(" task_code TEXT NOT NULL DEFAULT '',");
sql.append(" task_report_id INTEGER,");
sql.append(" report_start_date DATETIME,");
sql.append(" operation_id BIGINT NOT NULL DEFAULT 0,");
sql.append(" operation_name TEXT NOT NULL DEFAULT '',");
sql.append(" report_status INTEGER NOT NULL DEFAULT 0,");
sql.append(" untouched_flg INTEGER NOT NULL DEFAULT 0,"); // 未実施(0x01)
sql.append(" working_flg INTEGER NOT NULL DEFAULT 0,"); // 作業中(0x02)
sql.append(" complete_ok_flg INTEGER NOT NULL DEFAULT 0,"); // 作業完了 異常なし(0x04)
sql.append(" complete_ng_flg INTEGER NOT NULL DEFAULT 0,"); // 作業完了 異常あり(0x08)
sql.append(" incomplete_flg INTEGER NOT NULL DEFAULT 0,"); // 期限切れ(0x10)
sql.append(" alert_flg INTEGER NOT NULL DEFAULT 0,"); // アラート(0x20)
sql.append(" send_backed_flg INTEGER NOT NULL DEFAULT 0)"); // 差し戻し(0x40)
ddl.add(sql.toString());
return ddl;
}
@Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) {
if (oldVersion < Ver1_0_7) {
return getCreateScript(newVersion);
} else {
return null;
}
}
@Override
public List<String> getMigrationScript(SQLiteDatabase databaseConnection, int oldVersion, int newVersion, Object[] params) {
return null;
}
}
package jp.agentec.abook.abv.bl.dto;
import java.util.Date;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
public class DashboardStatusDto extends AbstractDto {
private static final int FLG_UNTOUCHED = 0x01; // 未実施(0x01)
private static final int FLG_WORKING = 0x02; // 作業中(0x02)
private static final int FLG_COMPLETE_OK = 0x04; // 作業完了 異常なし(0x04)
private static final int FLG_COMPLETE_NG = 0x08; // 作業完了 異常あり(0x08)
private static final int FLD_INCOMPLETED = 0x10; // 期限切れ(0x10)
private static final int FLG_ALERT = 0x20; // アラート(0x20)
private static final int FLG_SEND_BACK = 0x40; // 差し戻し(0x40)
public static int UNTOUCHED = 0; // 0:未実施
public static int WORKING = 1; // 1:作業中
public static int COMPLETE_OK = 2; // 2:作業完了(異常なし)
public static int COMPLETE_NG = 3; // 3:作業完了(異常あり)
public static int INCOMPLETED = 4; // 4:期限切れ
public static int ALERT = 5; // 5:アラート
public static int SEND_BACKED = 6; // 6:差し戻し
public static int IN_PROGRESS = 7; // 7:一時保存
// taskReportを一意にさすためのキー
private String taskKey;
private Long taskReportId;
private Date reportStartDate;
// 一覧表示で必要な付加情報
private long operationId;
private String operationName;
// taskの状態を示すビットフィールド
private int reportStatus;
// reportStatusの各ビットに対応するフラグ
private int untouchedFlg;
private int workingFlg;
private int completeOkFlg;
private int completeNgFlg;
private int incompleteFlg;
private int alertFlg;
private int sendBackedFlg;
public DashboardStatusDto(
String taskKey,
Long taskReportId,
Date reportStartDate,
long operationId,
String operatonName,
int reportStatus
) {
this.taskKey = taskKey;
this.taskReportId = taskReportId;
this.reportStartDate = reportStartDate;
this.operationId = operationId;
this.operationName = operatonName;
this.reportStatus = reportStatus;
untouchedFlg = reportStatus & FLG_UNTOUCHED;
workingFlg = reportStatus & FLG_WORKING;
completeOkFlg = reportStatus & FLG_COMPLETE_OK;
completeNgFlg = reportStatus & FLG_COMPLETE_NG;
incompleteFlg = reportStatus & FLD_INCOMPLETED;
alertFlg = reportStatus & FLG_ALERT;
sendBackedFlg = reportStatus & FLG_SEND_BACK;
}
@Override
public String[] getKeyValues() {
return new String[] {
String.valueOf(taskKey),
String.valueOf(taskReportId),
DateTimeUtil.toString(reportStartDate, DateTimeFormat.yyyyMMdd_hyphen)
};
}
@Override
public Object[] getInsertValues() {
return new Object[] {
taskKey,
taskReportId,
reportStartDate,
operationId,
operationName,
reportStatus,
untouchedFlg, // 未実施(0x01)
workingFlg, // 作業中(0x02)
completeOkFlg, // 作業完了 異常なし(0x04)
completeNgFlg, // 作業完了 異常あり(0x08)
incompleteFlg, // 期限切れ(0x10)
alertFlg, // アラート(0x20)
sendBackedFlg // 差し戻し(0x40)
};
}
public String getTaskKey() {
return taskKey;
}
public Long getTaskReportId() {
return taskReportId;
}
public Date getReportStartDate() {
return reportStartDate;
}
public int getReportStatus() {
return reportStatus;
}
public long getOperationId() {
return operationId;
}
public String getOperationName() {
return operationName;
}
}
......@@ -2,95 +2,87 @@ package jp.agentec.abook.abv.bl.dto;
import java.util.Date;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
public class ReportStatusDto extends AbstractDto {
private static final int FLG_UNTOUCHED = 0x01; // 未実施(0x01)
private static final int FLG_WORKING = 0x02; // 作業中(0x02)
private static final int FLG_COMPLETE_OK = 0x04; // 作業完了 異常なし(0x04)
private static final int FLG_COMPLETE_NG = 0x08; // 作業完了 異常あり(0x08)
private static final int FLD_INCOMPLETED = 0x10; // 期限切れ(0x10)
private static final int FLG_ALERT = 0x20; // アラート(0x20)
private static final int FLG_SEND_BACK = 0x40; // 差し戻し(0x40)
public static int UNTOUCHED = 0; // 0:未実施
public static int WORKING = 1; // 1:作業中
public static int COMPLETE_OK = 2; // 2:作業完了(異常なし)
public static int COMPLETE_NG = 3; // 3:作業完了(異常あり)
public static int INCOMPLETED = 4; // 4:期限切れ
public static int ALERT = 5; // 5:アラート
public static int SEND_BACKED = 6; // 6:差し戻し
public static int IN_PROGRESS = 7; // 7:一時保存
// taskReportを一意にさすためのキー
private String taskKey;
private Long taskReportId;
private Date reportStartDate;
// 一覧表示で必要な付加情報
private long operationId;
private String operatonName;
// taskの状態を示すビットフィールド
private int reportStatus;
// reportStatusの各ビットに対応するフラグ
private boolean untouchedFlg;
private boolean workingFlg;
private boolean completeOkFlg;
private boolean completeNgFlg;
private boolean incompleteFlg;
private boolean alertFlg;
private boolean sendBackedFlg;
public ReportStatusDto(
String taskKey,
Long taskReportId,
Date reportStartDate,
Long operationId,
String operatonName,
int reportStatus
) {
this.taskKey = taskKey;
this.taskReportId = taskReportId;
this.reportStartDate = reportStartDate;
this.operationId = operationId;
this.operatonName = operatonName;
this.reportStatus = reportStatus;
untouchedFlg = (reportStatus & FLG_UNTOUCHED) != 0;
workingFlg = (reportStatus & FLG_WORKING) != 0;
completeOkFlg = (reportStatus & FLG_COMPLETE_OK) != 0;
completeNgFlg = (reportStatus & FLG_COMPLETE_NG) != 0;
incompleteFlg = (reportStatus & FLD_INCOMPLETED) != 0;
alertFlg = (reportStatus & FLG_ALERT) != 0;
sendBackedFlg = (reportStatus & FLG_SEND_BACK) != 0;
}
public int reportStatus;
public long operationId;
public String operationName;
public String taskKey;
public String taskCode;
public String taskReportInfo;
public Long taskReportId;
public Date reportStartDate;
public String reportLockUserId;
public String reportLockUserName;
public Date reportLockTime;
public String sendBackUserId;
public String sendBackUserName;
public String sendBackComment;
@Override
public String[] getKeyValues() {
return new String[] {
String.valueOf(taskKey),
String.valueOf(taskReportId),
DateTimeUtil.toString(reportStartDate, DateTimeFormat.yyyyMMdd_hyphen)
};
return new String[0];
}
@Override
public Object[] getInsertValues() {
return new Object[] {
taskKey,
taskReportId,
reportStartDate,
operationId,
operatonName,
reportStatus,
untouchedFlg, // 未実施(0x01)
workingFlg, // 作業中(0x02)
completeOkFlg, // 作業完了 異常なし(0x04)
completeNgFlg, // 作業完了 異常あり(0x08)
incompleteFlg, // 期限切れ(0x10)
alertFlg, // アラート(0x20)
sendBackedFlg // 差し戻し(0x40)
};
return new Object[0];
}
public int getReportStatus() {
return reportStatus;
}
public long getOperationId() {
return operationId;
}
public String getOperationName() {
return operationName;
}
public String getTaskKey() {
return taskKey;
}
public String getTaskCode() {
return taskCode;
}
public String getTaskReportInfo() {
return taskReportInfo;
}
public Long getTaskReportId() {
return taskReportId;
}
public Date getReportStartDate() {
return reportStartDate;
}
public String getReportLockUserId() {
return reportLockUserId;
}
public String getReportLockUserName() {
return reportLockUserName;
}
public Date getReportLockTime() {
return reportLockTime;
}
public String getSendBackUserId() {
return sendBackUserId;
}
public String getSendBackUserName() {
return sendBackUserName;
}
public String getSendBackComment() {
return sendBackComment;
}
}
......@@ -26,13 +26,13 @@ public class TaskReportDto extends AbstractDto {
public String attachedFileName;
public boolean localSavedFlg; // 一時保存用
public String reportLockUserId = "報告ユーザID"; // 報告ロックユーザId
public String reportLockUserName = "報告ユーザ名"; // 報告ロックユーザ名
public Date reportLockTime = new Date(); // 報告ロック日時
public String sendBackUserId = "差戻ユーザID"; // 差し戻しユーザId 差し戻された場合のみ
public String sendBackUserName = "差戻ユーザ名"; // 差し戻しユーザ名 差し戻された場合のみ
public String sendBackComment = "確認コメント"; // 確認コメント 差し戻された場合のみ
public int taskStatus = 0; // 状況 0:未実施、1:作業中、999:作業完了
public String reportLockUserId = null; // 報告ロックユーザId
public String reportLockUserName = null; // 報告ロックユーザ名
public Date reportLockTime = null; // 報告ロック日時
public String sendBackUserId = null; // 差し戻しユーザId 差し戻された場合のみ
public String sendBackUserName = null; // 差し戻しユーザ名 差し戻された場合のみ
public String sendBackComment = null; // 確認コメント 差し戻された場合のみ
public int taskStatus = 0; // 状況 0:未実施、1:作業中、999:作業完了
public int reportStatus = 0;
@Override
......
......@@ -24,8 +24,6 @@ import jp.agentec.abook.abv.bl.acms.client.json.SceneEntryJSON;
import jp.agentec.abook.abv.bl.acms.client.json.WorkerGroupJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.GetTaskFileParameters;
import jp.agentec.abook.abv.bl.acms.type.OperationSortingType;
import jp.agentec.abook.abv.bl.acms.type.OperationType;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.Callback;
......@@ -252,6 +250,12 @@ public class OperationLogic extends AbstractLogic {
String operationTaskDirPath = ABVEnvironment.getInstance().getOperationDirFile(deleteOperationDto.operationId);
FileUtil.delete(operationTaskDirPath);
}
// 一通りの更新が終わってから、ダッシュボード用の情報を取得する
// todo
Logger.i(TAG, "update tasks on dashboard");
ReportStatusLogic logic = new ReportStatusLogic();
logic.loadReportStatus();
}
/**
......
package jp.agentec.abook.abv.bl.logic;
import java.util.List;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.DashboardStatusJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsParameters;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.dao.ReportStatusDao;
import jp.agentec.abook.abv.bl.dto.DashboardStatusDto;
import jp.agentec.abook.abv.bl.dto.ReportStatusDto;
public class ReportStatusLogic extends AbstractLogic {
private static final String TAG = "ReportStatusLogic";
private List<DashboardStatusDto> getDashboardStatus() {
if (!networkAdapter.isNetworkConnected()) {
return null;
}
try {
AcmsClient client = AcmsClient.getInstance(networkAdapter);
String sid = cache.getMemberInfo().sid;
AcmsParameters params = new AcmsParameters(sid);
DashboardStatusJSON statuses = client.getDashboardStatus(params);
return statuses.getReportStatuses();
} catch (NetworkDisconnectedException e) {
return null;
} catch (AcmsException e) {
Logger.e(TAG, e.getLocalizedMessage());
return null;
}
}
public void loadReportStatus() {
List<DashboardStatusDto> received = getDashboardStatus();
if (received != null && !received.isEmpty()) {
// DBの更新
ReportStatusDao dao = new ReportStatusDao();
dao.beginTransaction();
try {
dao.deleteAll();
for (DashboardStatusDto dto : received) {
dao.insert(dto);
}
dao.commit();
} catch (Throwable e) {
dao.rollback();
}
}
}
}
......@@ -14,11 +14,20 @@ import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import org.json.adf.JSONArray;
import org.json.adf.JSONObject;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
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.ReportStatusDao;
import jp.agentec.abook.abv.bl.dto.ReportStatusDto;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.viewer.view.CheckFormWebview;
......@@ -213,7 +222,17 @@ public class DashboardActivity extends OperationActivity {
switch (cmd) {
case CMD_GET_REPORT_LIST: {
return getReportList();
try {
String reportStatusId = abookCheckParam.get("reportStatusId");
if (reportStatusId != null) {
return getReportList(Integer.parseInt(reportStatusId));
} else {
return false;
}
} catch (Throwable e) {
Logger.e(TAG, e);
return false;
}
}
case CMD_LOCK_REPORT: {
return lockReport();
......@@ -225,9 +244,102 @@ public class DashboardActivity extends OperationActivity {
return false;
}
private boolean getReportList() {
//todo
return true;
private boolean getReportList(int reportStatusId) {
ReportStatusDao dao = AbstractDao.getDao(ReportStatusDao.class);
List<ReportStatusDto> reports = null;
switch (reportStatusId) {
case 0: {
reports = dao.getUntouchedReport();
break;
}
case 1: {
reports = dao.getWorkingReport();
break;
}
case 2: {
reports = dao.getcompleteOkReport();
break;
}
case 3: {
reports = dao.getCompleteNgReport();
break;
}
case 4: {
reports = dao.getIncompleteReport();
break;
}
case 5: {
reports = dao.getAlertReport();
break;
}
case 6: {
reports = dao.getSendBackedReport();
break;
}
case 7: {
reports = dao.getPendingReport();
}
}
if (reports != null) {
JSONObject param = makeReportTree(reportStatusId, reports);
return true;
} else {
return false;
}
}
private JSONObject makeReportTree(int reportStatusId, List<ReportStatusDto> reports) {
JSONObject tree = new JSONObject();
tree.put("reportStatusId", reportStatusId);
JSONArray operationList = new JSONArray();
tree.put("operationList", operationList);
// operationIDで、ソートしておく
Collections.sort(reports, new ReportCompalator());
JSONObject operation = null;
for (ReportStatusDto report : reports) {
if (operation == null || operation.getLong("operationId") != report.getOperationId()) {
// 新しい作業の追加
operation = new JSONObject();
operation.put("operationId", report.getOperationId());
operation.put("operationName", report.getOperationName());
operation.put("reportList", new JSONArray());
tree.getJSONArray("operationList").put(operation);
}
JSONObject task = new JSONObject();
task.put("taskKey", report.getTaskKey());
task.put("taskReportInfo", report.getTaskReportInfo());
task.put("taskReportId", report.getTaskReportId());
task.put("reportStartDate", report.getReportStartDate());
task.put("reportLockUserId", report.getReportLockUserId());
task.put("reportLockUserName", report.getReportLockUserName());
task.put("reportLockTime", report.reportLockTime);
task.put("sendBackUserId", report.sendBackUserId);
task.put("sendBackUserName", report.sendBackUserName);
operation.getJSONArray("reportList").put(task);
}
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 lockReport() {
......
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