Commit 1d21c8a2 by onuma

#41843 @Form I/O帳票Android ソースコピー ビルドエラーなし

parent c5440035
......@@ -23,6 +23,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.GroupsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.LogSendFlagJSON;
import jp.agentec.abook.abv.bl.acms.client.json.MasterDataJSON;
import jp.agentec.abook.abv.bl.acms.client.json.NewAppStoreLoginJSON;
import jp.agentec.abook.abv.bl.acms.client.json.OperationGroupMasterJSON;
import jp.agentec.abook.abv.bl.acms.client.json.RequirePasswordChangeJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ResultJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ServerTimeZoneJSON;
......@@ -980,4 +981,21 @@ public class AcmsClient implements AcmsClientResponseListener {
MasterDataJSON json = new MasterDataJSON(response.httpResponseBody);
return json;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// カテゴリ選択機能
///////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* 作業種別の取得API
* @param param
* @return
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
public OperationGroupMasterJSON getOperationGroupMaster(AcmsParameters param) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApiOperationGroupMaster, param);
OperationGroupMasterJSON json = new OperationGroupMasterJSON(response.httpResponseBody);
return json;
}
}
package jp.agentec.abook.abv.bl.acms.client.json;
import org.json.adf.JSONArray;
import org.json.adf.JSONObject;
import java.util.ArrayList;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
import jp.agentec.abook.abv.bl.dto.OperationGroupMasterDto;
import jp.agentec.abook.abv.bl.dto.OperationGroupMasterRelationDto;
/**
* Created by leej on 2019/06/24.
*/
public class OperationGroupMasterJSON extends AcmsCommonJSON {
public static final String OperationGroupMasterList = "operationGroupMasterList";
public static final String OperationGroupMasterId = "operationGroupMasterId";
public static final String OperationGroupMasterName = "operationGroupMasterName";
public static final String OperationGroupMasterLevel = "operationGroupMasterLevel";
public static final String ParentOperationGroupMasterId = "parentOperationGroupMasterId";
public Integer[] userGroupIds;
public ArrayList<OperationGroupMasterDto> operationGroupMasterList;
public OperationGroupMasterJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
operationGroupMasterList = new ArrayList<OperationGroupMasterDto>();
if (json.has(OperationGroupMasterList)) {
JSONArray operationGroupMasterJsonList = json.getJSONArray(OperationGroupMasterList);
for (int i = 0; i < operationGroupMasterJsonList.length(); i++) {
OperationGroupMasterDto dto = new OperationGroupMasterDto();
JSONObject operationGroupMasterJson = operationGroupMasterJsonList.getJSONObject(i);
dto.operationGroupMasterId = getInt(operationGroupMasterJson, OperationGroupMasterId);
dto.operationGroupMasterName = getString(operationGroupMasterJson, OperationGroupMasterName);
dto.operationGroupMasterLevel = getInt(operationGroupMasterJson, OperationGroupMasterLevel);
dto.parentOperationGroupMasterId = getInt(operationGroupMasterJson, ParentOperationGroupMasterId);
operationGroupMasterList.add(dto);
}
}
}
}
......@@ -258,4 +258,10 @@ public class AcmsApis {
public static String getTaskFileUrl(String host, String urlPath) {
return String.format(GetTaskFileUrlFormat, StringUtil.trimLastSlashOrSpace(host), StringUtil.trimLastSlashOrSpace(urlPath));
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// カテゴリ選択機能
///////////////////////////////////////////////////////////////////////////////////////////////////////
// 作業種別データ取得
public static final String ApiOperationGroupMaster = "operationGroupMaster";
}
package jp.agentec.abook.abv.bl.acms.type;
/**
* Created by leej on 2019/08/21.
*/
public enum OperationSortingType {
OperationName(0),
OperationStartDateDESC(1),
OperationStartDateASC(2),
OperationType(3),
ReadingDate(4);
private final int operationSorting;
OperationSortingType(int operationSorting) {
this.operationSorting = operationSorting;
}
/**
* 検索をかける項目の番号を返します。
* @return 検索をかける項目の番号です。
* @since 1.0.0
*/
public int type() {
return operationSorting;
}
/**
* 指定した数字に対応するSecurityPolicyCodeの値を返します。
* @param operationSorting 数字のコードです。
* @return 指定した数字に対応するSearchDivisionTypeの値です。
* @since 1.0.0
*/
public static OperationSortingType parse(int operationSorting) {
OperationSortingType sortingType;
switch (operationSorting) {
case 0: // 作業名
sortingType = OperationSortingType.OperationName;
break;
case 1: // 作業期間が新しい順
sortingType = OperationSortingType.OperationStartDateDESC;
break;
case 2: // 作業時間が古い順
sortingType = OperationSortingType.OperationStartDateASC;
break;
case 3: // 報告タイプ
sortingType = OperationSortingType.OperationType;
break;
case 4: // 閲覧日が新しい順
sortingType = OperationSortingType.ReadingDate;
break;
default: // 作業名(デフォルト)
sortingType = OperationSortingType.OperationName;
break;
}
return sortingType;
}
}
......@@ -775,4 +775,26 @@ public class ABVEnvironment {
public String getMasterFilePath() {
return String.format(OperationMasterDataDirFormat, rootDirectory);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// カテゴリ選択機能
///////////////////////////////////////////////////////////////////////////////////////////////////////
public boolean operationGroupMasterClearFlg;
/**
* 作業種別のクリア判定フラグをセット
* @param clearFlg
*/
public void setOperationGroupMasterClearFlg(boolean clearFlg) {
this.operationGroupMasterClearFlg = clearFlg;
}
/**
* 作業種別のクリア判定フラグ取得
* @return
*/
public boolean getOperationGroupMasterClearFlg() {
return operationGroupMasterClearFlg;
}
}
......@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import jp.agentec.abook.abv.bl.acms.type.OperationSortingType;
import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.common.db.Cursor;
import jp.agentec.abook.abv.bl.common.log.Logger;
......@@ -336,4 +337,174 @@ public class OperationDao extends AbstractDao {
updateNeedSyncFlg(operationDto.operationId, true);
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// カテゴリ選択機能
///////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* 作業グループに紐づく同期可能な作業リストが存在するかチェック
* @param operationGroupMasterId
* @return
*/
public boolean hasNeedSyncOperationByGroupMasterId(Integer operationGroupMasterId) {
List<OperationDto> operationDtoList = getNeedSyncOperationByGroupMasterId(operationGroupMasterId);
return operationDtoList != null && operationDtoList.size() > 0;
}
/**
* 作業グループに紐づく同期可能な作業リストを取得
* @param operationGroupMasterId
* @return
*/
public List<OperationDto> getNeedSyncOperationByGroupMasterId(Integer operationGroupMasterId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT * ");
sql.append(" FROM t_operation AS top ");
sql.append(" INNER JOIN r_operation_content AS rop ");
sql.append(" ON top.operation_id = rop.operation_id ");
sql.append(" AND rop.operation_content_flg = 1 ");
sql.append(" INNER JOIN r_operation_group_master_relation AS rogm ");
sql.append(" ON top.operation_id = rogm.operation_id ");
sql.append(" WHERE top.need_sync_flg = 1");
sql.append(" AND rogm.operation_group_master_id = ?");
return rawQueryGetDtoList(sql.toString(), new String[] { "" + operationGroupMasterId }, OperationDto.class);
}
/**
* カテゴリの作業一覧検索用
* @param operationGroupMasterId カテゴリID
* @param operationSortingType ソートタイプ
* @return カテゴリに紐づく作業リスト
*/
public List<OperationDto> getOperationsByGroupMasterId(Integer operationGroupMasterId, OperationSortingType operationSortingType) {
String sql = generateGetOperationQuery(null, null, null, operationSortingType, operationGroupMasterId);
return rawQueryGetDtoList(sql, null, OperationDto.class);
}
// ABookCheckでは、同名の関数があるが、引数の数がちがったのでコピーした
/**
* 引数の検索条件で作業情報リストを
* 取得用のsql文作成
* @param searchOperationName
* @param searchStartDateStr
* @param searchEndDateStr
* @param operationSortingType
* @return
*/
private String generateGetOperationQuery(String searchOperationName, String searchStartDateStr, String searchEndDateStr, OperationSortingType operationSortingType, Integer operationGroupMasterId) {
String curDate = DateTimeUtil.toStringInTimeZone(new Date(), DateTimeFormat.yyyyMMddHHmmss_hyphen, "UTC");
StringBuffer sql = new StringBuffer();
sql.append(" SELECT top.operation_id, ");
sql.append(" top.operation_name, ");
sql.append(" top.operation_type, ");
sql.append(" top.operation_descriptions, ");
sql.append(" top.operation_start_date, ");
sql.append(" top.operation_end_date, ");
sql.append(" top.last_edit_date, ");
sql.append(" top.edit_lock_flg, ");
sql.append(" top.need_sync_flg, ");
sql.append(" top.content_creating_flg, ");
sql.append(" top.report_type, ");
sql.append(" top.report_cycle, ");
sql.append(" top.enable_report_update, ");
sql.append(" top.enable_report_edit, ");
sql.append(" top.enable_add_report, ");
sql.append(" CASE ");
sql.append(" WHEN report_type = 1 THEN ( ");
sql.append(" SELECT strftime('%Y/%m/%d %H:%M', datetime(ttr.report_start_date, 'localtime')) || ' ~ ' || strftime('%Y/%m/%d %H:%M', datetime(ttr.report_end_date, 'localtime')) ");
sql.append(" FROM t_task tt ");
sql.append(" INNER JOIN t_task_report ttr ");
sql.append(" ON tt.task_key = ttr.task_key ");
sql.append(" AND tt.del_flg = 0 ");
//sql.append(" AND datetime(ttr.report_start_date) <= datetime('" + curDate + "') ");
sql.append(" AND datetime(ttr.report_end_date) >= datetime('" + curDate + "') ");
sql.append(" WHERE tt.operation_id = top.operation_id ");
sql.append(" ORDER BY ttr.report_start_date ASC LIMIT 1 ) ");
sql.append(" ELSE '' ");
sql.append(" END AS report_period, ");
sql.append(" CASE ");
sql.append(" WHEN report_type = 1 THEN ( ");
sql.append(" SELECT count(*) ");
sql.append(" FROM t_task_report ");
sql.append(" WHERE task_key = (SELECT task_key FROM t_task WHERE operation_id = top.operation_id LIMIT 1) ) ");
sql.append(" ELSE 0 ");
sql.append(" END AS report_count, ");
sql.append(" rpc.content_id ");
sql.append(" FROM t_operation AS top ");
sql.append(" LEFT OUTER JOIN r_operation_content AS rpc ");
sql.append(" ON top.operation_id = rpc.operation_id ");
sql.append(" AND rpc.operation_content_flg = 1 ");
// 作業種別IDに紐づく作業のみ検索するため、INNER JOINする
if (operationGroupMasterId != null) {
sql.append(" INNER JOIN r_operation_group_master_relation AS rogmo ");
sql.append(" ON rogmo.operation_id = top.operation_id ");
sql.append(" AND rogmo.operation_group_master_id =" + operationGroupMasterId);
}
sql.append(" WHERE top.operation_id IS NOT NULL ");
if (!StringUtil.isNullOrEmpty(searchOperationName)) {
sql.append(" AND top.operation_name GLOB " + "'*" + searchOperationName + "*'");
}
if (!StringUtil.isNullOrEmpty(searchStartDateStr)) {
Date startDate = DateTimeUtil.toDate(searchStartDateStr, "UTC", DateTimeFormat.yyyyMMdd_hyphen);
sql.append(" AND top.operation_end_date >= '" + DateTimeUtil.toString(startDate, DateTimeFormat.yyyyMMdd_hyphen) + "'");
}
if (!StringUtil.isNullOrEmpty(searchEndDateStr)) {
Date endDate = DateTimeUtil.toDate(searchEndDateStr, "UTC", DateTimeFormat.yyyyMMdd_hyphen);
sql.append(" AND top.operation_start_date <= '" + DateTimeUtil.toString(endDate, DateTimeFormat.yyyyMMdd_hyphen) + "'");
}
// 並び順
if (operationSortingType != null) {
switch (operationSortingType) {
case OperationName:
sql.append(" ORDER BY top.operation_name ASC ");
break;
case OperationStartDateASC:
sql.append(" ORDER BY top.operation_start_date ASC ");
break;
case OperationStartDateDESC:
sql.append(" ORDER BY top.operation_start_date DESC ");
break;
case OperationType:
sql.append(" ORDER BY top.report_type ASC ");
break;
case ReadingDate:
sql.append(" ORDER BY top.operation_open_date DESC ");
break;
default:
sql.append(" ORDER BY top.operation_name ASC ");
break;
}
} else {
sql.append(" ORDER BY top.operation_name ASC ");
}
// 必ずORDER BYが存在する 2次ソート
sql.append(", top.operation_id DESC");
Logger.v(TAG, "sql=%s", sql);
return sql.toString();
}
// ABookCheckでは、同名の関数があるが、引数の数がちがったのでコピーした
/**
* 引数の検索条件で作業情報リストを取得(作業一覧表示用)
* @param searchOperationName
* @param searchStartDateStr
* @param searchEndDateStr
* @param operationSortType
* @return
*/
public List<OperationDto> getOperations(String searchOperationName, String searchStartDateStr, String searchEndDateStr, OperationSortingType operationSortType) {
String sql = generateGetOperationQuery(searchOperationName, searchStartDateStr, searchEndDateStr, operationSortType, null);
return rawQueryGetDtoList(sql, null, OperationDto.class);
}
}
\ No newline at end of file
package jp.agentec.abook.abv.bl.data.dao;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import jp.agentec.abook.abv.bl.acms.type.SearchDivisionType;
import jp.agentec.abook.abv.bl.common.db.Cursor;
import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.GroupDto;
import jp.agentec.abook.abv.bl.dto.OperationGroupMasterDto;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
import jp.agentec.adf.util.NumericUtil;
import jp.agentec.adf.util.StringUtil;
/**
* Created by leej on 2019/06/25.
*/
public class OperationGroupMasterDao extends AbstractDao {
private static final String TAG = "OperationGroupMasterDao";
private enum QueryType {GetAllGroups, GetRootGroups, GetGroups}
/*package*/ OperationGroupMasterDao() {
}
@Override
protected OperationGroupMasterDto convert(Cursor cursor) {
OperationGroupMasterDto dto = new OperationGroupMasterDto();
int column = cursor.getColumnIndex("operation_group_master_id");
if (column != -1) {
dto.operationGroupMasterId = cursor.getInt(column);
}
column = cursor.getColumnIndex("operation_group_master_name");
if (column != -1) {
dto.operationGroupMasterName = cursor.getString(column);
}
if (column != -1) {
column = cursor.getColumnIndex("parent_operation_group_master_id");
dto.parentOperationGroupMasterId = cursor.getInt(column);
}
column = cursor.getColumnIndex("operation_group_master_level");
if (column != -1) {
dto.operationGroupMasterLevel = cursor.getInt(column);
}
column = cursor.getColumnIndex("operation_count");
if (column != -1) {
dto.operationCount = cursor.getInt(column);
}
return dto;
}
/**
* 作業種別をDB登録処理
* @param dto
*/
public void insertOperationGroupMaster(OperationGroupMasterDto dto) {
StringBuffer sql = new StringBuffer();
sql.append(" INSERT OR IGNORE INTO m_operation_group_master (operation_group_master_id, operation_group_master_name, parent_operation_group_master_id, operation_group_master_level) ");
sql.append(" VALUES (?,?,?,?) ");
try {
beginTransaction();
insert(sql.toString(), dto.getInsertValues());
commit();
} catch (Exception e) {
rollback();
Logger.e("insertOperationGroupMaster failed.", e);
throw new RuntimeException(e);
}
Logger.v(TAG, "sql=%s", sql);
}
/**
* 作業種別をDB更新処理
* @param dto
*/
public void updateOperationGroupMaster(OperationGroupMasterDto dto) {
StringBuffer sql = new StringBuffer();
sql.append(" UPDATE m_operation_group_master ");
sql.append(" SET operation_group_master_name = ? ");
sql.append(" ,parent_operation_group_master_id = ? ");
sql.append(" ,operation_group_master_level = ? ");
sql.append(" WHERE operation_group_master_id = ? ");
try {
beginTransaction();
update(sql.toString(), dto.getUpdateValues());
commit();
} catch (Exception e) {
rollback();
Logger.e("insertGroup failed.", e);
throw new RuntimeException(e);
}
Logger.v(TAG, "sql=%s", sql);
}
/**
* 親階層のIDで子供の階層を取得
* sort:作業種別名 昇順
* @param parentId
* @return
*/
public List<OperationGroupMasterDto> getOperationGroupMasterChildList(int parentId) {
List<OperationGroupMasterDto> list;
list = rawQueryGetDtoList("select * from m_operation_group_master where parent_operation_group_master_id = ? order by operation_group_master_name ASC", new String[]{""+ parentId}, OperationGroupMasterDto.class);
return list;
}
/**
* 最上位階層を取得
* @return
*/
public OperationGroupMasterDto getTopOperationGroupMaster() {
return rawQueryGetDto("select * from m_operation_group_master where operation_group_master_level = 0", null, OperationGroupMasterDto.class);
}
/**
* 全作業種別を取得
* @return
*/
public List<OperationGroupMasterDto> getAllOperationGroupMaster() {
return rawQueryGetDtoList("select * from m_operation_group_master", null, OperationGroupMasterDto.class);
}
/**
* operationGroupMasterIdで作業種別を取得
* @param operationGroupMasterId
* @return
*/
public OperationGroupMasterDto getOperationGroupMaster(Integer operationGroupMasterId) {
return rawQueryGetDto("select * from m_operation_group_master where operation_group_master_id = ?", new String[]{"" + operationGroupMasterId}, OperationGroupMasterDto.class);
}
/**
* operationGroupMasterIdのデータ存在チェック
* @param operationGroupMasterId
* @return
*/
public boolean isExistOperationGroupMaster(Integer operationGroupMasterId) {
return getOperationGroupMaster(operationGroupMasterId) != null;
}
/**
* 作業種別に関連するテーブルを全て削除
* @param dto
*/
public void delete(OperationGroupMasterDto dto) {
// 作業種別と作業のリレーションテーブル
delete("r_operation_group_master_relation", "operation_group_master_id=?", dto.getKeyValues());
// 作業種別のマスタテーブル
delete("m_operation_group_master", "operation_group_master_id=?", dto.getKeyValues());
}
/**
* 階層の作業種別情報取得(検索結果を元にデータ取得)
* @param level
* @return
*/
public List<OperationGroupMasterDto> getOperationGroupMasterListBylevel(Integer level) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT M1.*, count(R1.operation_id) AS operation_count FROM m_operation_group_master AS M1");
sql.append(" LEFT OUTER JOIN r_operation_group_master_relation R1");
sql.append(" ON R1.operation_group_master_id = M1.operation_group_master_id");
sql.append(" AND R1.operation_id IN(");
sql.append(" SELECT operation_id FROM t_operation top");
sql.append(" WHERE top.operation_id IS NOT NULL");
sql.append(" )");
sql.append(" WHERE M1.operation_group_master_level =? ");
sql.append(" GROUP BY M1.operation_group_master_id");
Logger.v(TAG, "sql=%s", sql);
return rawQueryGetDtoList(sql.toString(), new String[]{""+ level}, OperationGroupMasterDto.class);
}
/**
* 最後のOperationGroupMasterレベル取得
* @return
*/
public Integer getLastGroupLevel() {
return rawQueryGetInt("SELECT MAX(operation_group_master_level) FROM m_operation_group_master", null);
}
}
\ No newline at end of file
package jp.agentec.abook.abv.bl.dto;
import java.util.List;
/**
* Created by leej on 2019/06/25.
*/
public class OperationGroupMasterDto extends AbstractDto {
public int operationGroupMasterId; // 作業種別ID
public String operationGroupMasterName; // 作業種別名称
public int parentOperationGroupMasterId; // 作業種別の親階層ID
public int operationGroupMasterLevel; // 作業種別の階層レベル
public int operationCount = 0; // 作業種別に紐づく作業数
public OperationGroupMasterDto() {
}
@Override
public Object[] getInsertValues() {
return new Object[]{operationGroupMasterId, operationGroupMasterName, parentOperationGroupMasterId, operationGroupMasterLevel};
}
@Override
public Object[] getUpdateValues() {
return new Object[]{operationGroupMasterName, parentOperationGroupMasterId, operationGroupMasterLevel, operationGroupMasterId};
}
@Override
public String[] getKeyValues() {
return new String[]{""+ operationGroupMasterId};
}
}
\ No newline at end of file
package jp.agentec.abook.abv.bl.dto;
/**
* Created by leej on 2019/06/25.
*/
public class OperationGroupMasterRelationDto extends AbstractDto {
// 作業種別ID
public Integer operationGroupMasterId;
// 作業ID
public Long operationId;
@Override
public Object[] getInsertValues() {
return new Object[]{operationGroupMasterId, operationId};
}
@Override
public String[] getKeyValues() {
return new String[]{""+ operationGroupMasterId};
}
}
\ No newline at end of file
package jp.agentec.abook.abv.bl.dto.comparator;
import java.util.Comparator;
import jp.agentec.abook.abv.bl.dto.OperationGroupMasterDto;
/**
* Created by leej on 2019/06/28.
*/
public class OperationGroupMasterLevelComparator implements Comparator<OperationGroupMasterDto> {
@Override
public int compare(OperationGroupMasterDto dto1, OperationGroupMasterDto dto2) {
int operationGroupMasterLevel1 = dto1.operationGroupMasterLevel;
int operationGroupMasterLevel2 = dto2.operationGroupMasterLevel;
int result;
if (operationGroupMasterLevel1 > operationGroupMasterLevel2) {
result = 1;
} else if(operationGroupMasterLevel1 == operationGroupMasterLevel2) {
result = 0;
} else {
result = -1;
}
return result;
}
}
\ No newline at end of file
package jp.agentec.abook.abv.bl.logic;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.OperationGroupMasterJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsParameters;
import jp.agentec.abook.abv.bl.acms.type.OperationSortingType;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
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.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.OperationDao;
import jp.agentec.abook.abv.bl.data.dao.OperationGroupMasterDao;
import jp.agentec.abook.abv.bl.dto.OperationDto;
import jp.agentec.abook.abv.bl.dto.OperationGroupMasterDto;
import jp.agentec.abook.abv.bl.dto.comparator.OperationGroupMasterLevelComparator;
/**
* Created by leej on 2019/06/26.
*/
public class OperationGroupMasterLogic extends AbstractLogic {
private static final String TAG = "OperationGroupMasterLogic";
private OperationGroupMasterDao mOperationGroupMasterDao = AbstractDao.getDao(OperationGroupMasterDao.class);
private OperationDao mOperationDao = AbstractDao.getDao(OperationDao.class);
/**
* 作業種別・作業種別に紐づいた作業IDを取得して
* DBに登録する
*/
public void setOperationGroupMaster() throws NetworkDisconnectedException, AcmsException {
try {
// サーバー通信で、作業種別情報を取得する
List<OperationGroupMasterDto> serverOperationGroupMasterDtos = getOperationGroupMasterServerData();
// ローカルDBに存在する作業種別情報をDto配列でセット
List<OperationGroupMasterDto> localOperationGroupMasterDtos = mOperationGroupMasterDao.getAllOperationGroupMaster();
List<Integer> localOperationGroupMasterIds = new ArrayList<Integer>();
boolean updateFlg = false;
for (OperationGroupMasterDto serverOperationGroupMasterDto : serverOperationGroupMasterDtos) {
// DB登録フラグ
boolean insertFlg = true;
for (OperationGroupMasterDto localOperationGroupMasterDto : localOperationGroupMasterDtos) {
// サーバーで取得したIDでローカルに存在するか比較して、更新・登録を判定
if (serverOperationGroupMasterDto.operationGroupMasterId == localOperationGroupMasterDto.operationGroupMasterId) {
// DB更新処理(作業種別の親階層が変更されたか、作業種別名が変更されたときのみ)
if (serverOperationGroupMasterDto.parentOperationGroupMasterId != localOperationGroupMasterDto.parentOperationGroupMasterId || !serverOperationGroupMasterDto.operationGroupMasterName.equals(localOperationGroupMasterDto.operationGroupMasterName)) {
Logger.d(TAG, "[UPDATE] OperationGroupMaster operationGroupMasterId=" + serverOperationGroupMasterDto.operationGroupMasterId + " operationGroupMasterName=" + serverOperationGroupMasterDto.operationGroupMasterName);
mOperationGroupMasterDao.updateOperationGroupMaster(serverOperationGroupMasterDto);
updateFlg = true;
}
// 更新処理が終わったら登録フラグをfalseにしてlocalOperationGroupMasterDtosから除外する
insertFlg = false;
localOperationGroupMasterDtos.remove(localOperationGroupMasterDto);
break;
}
}
// 更新されたら以下の処理は行わない
if (insertFlg) {
Logger.d(TAG, "[INSERT] OperationGroupMaster operationGroupMasterId=" + serverOperationGroupMasterDto.operationGroupMasterId + " operationGroupMasterName=" + serverOperationGroupMasterDto.operationGroupMasterName);
// DB登録処理
mOperationGroupMasterDao.insertOperationGroupMaster(serverOperationGroupMasterDto);
}
}
// 作業種別関連テーブルの削除処理
for (OperationGroupMasterDto deleteOperationGroupMasterDto : localOperationGroupMasterDtos) {
updateFlg = true;
mOperationGroupMasterDao.delete(deleteOperationGroupMasterDto);
}
// 作業種別のクリアフラグをセット
ABVEnvironment.getInstance().setOperationGroupMasterClearFlg(updateFlg);
} catch (Exception e) {
Logger.e(e.getMessage());
}
}
/**
* API通信で取得した作業種別情報のリストを返す
* @return
* @throws NetworkDisconnectedException
* @throws AcmsException
*/
private List<OperationGroupMasterDto> getOperationGroupMasterServerData() throws NetworkDisconnectedException, AcmsException {
AcmsParameters param = new AcmsParameters(cache.getMemberInfo().sid);
OperationGroupMasterJSON json = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).getOperationGroupMaster(param);
return json.operationGroupMasterList;
}
/**
* 作業種別毎に作業数(子グループの作業も含む)を
* operationCountMapにセットする
* @param level
* @param operationCountMap
*/
public void getAllOperationCount(int level, Map<Integer, Integer> operationCountMap) {
List<OperationGroupMasterDto> operationGroupMasterDtoList;
operationGroupMasterDtoList = mOperationGroupMasterDao.getOperationGroupMasterListBylevel(level);
// ルート階層の場合は以下の処理しない
if (level > 0 && operationGroupMasterDtoList != null) {
for (OperationGroupMasterDto operationGroupMasterDto : operationGroupMasterDtoList) {
if (operationCountMap.containsKey(operationGroupMasterDto.operationGroupMasterId)) {
operationCountMap.put(operationGroupMasterDto.operationGroupMasterId, operationCountMap.get(operationGroupMasterDto.operationGroupMasterId) + operationGroupMasterDto.operationCount);
} else {
operationCountMap.put(operationGroupMasterDto.operationGroupMasterId, operationGroupMasterDto.operationCount);
}
// 値が存在する場合
if (operationCountMap.get(operationGroupMasterDto.operationGroupMasterId) > 0) {
if (operationCountMap.containsKey(operationGroupMasterDto.parentOperationGroupMasterId)) {
// 更新
operationCountMap.put(operationGroupMasterDto.parentOperationGroupMasterId, operationCountMap.get(operationGroupMasterDto.parentOperationGroupMasterId) + operationCountMap.get(operationGroupMasterDto.operationGroupMasterId));
} else {
// 新規
operationCountMap.put(operationGroupMasterDto.parentOperationGroupMasterId, operationCountMap.get(operationGroupMasterDto.operationGroupMasterId));
}
}
}
level--;
getAllOperationCount(level, operationCountMap); // 再帰呼び出し
}
}
/**
* 最後の階層レベル取得
* @return
*/
public Integer getLastGroupLevel() {
return mOperationGroupMasterDao.getLastGroupLevel();
}
/**
* 親の階層パスをリストでセット
* @param operationGroupMasterId カテゴリID
* @return
*/
public List<OperationGroupMasterDto> getParentOperationGroupMasterForPath (Integer operationGroupMasterId) {
List<OperationGroupMasterDto> operationGroupMasterDtoList = new ArrayList<OperationGroupMasterDto>();
// 作業種別DTO取得
OperationGroupMasterDto dto = mOperationGroupMasterDao.getOperationGroupMaster(operationGroupMasterId);
operationGroupMasterDtoList.add(dto);
int parentId = dto.parentOperationGroupMasterId;
for (int i = 0; i < dto.operationGroupMasterLevel; i++) {
OperationGroupMasterDto parentOperationDto = mOperationGroupMasterDao.getOperationGroupMaster(parentId);
parentId = parentOperationDto.parentOperationGroupMasterId;
operationGroupMasterDtoList.add(parentOperationDto);
}
Collections.sort(operationGroupMasterDtoList, new OperationGroupMasterLevelComparator());
return operationGroupMasterDtoList;
}
/**
* 作業種別IDで関連する作業リストを取得
* @param operationGroupMasterId カテゴリID
* @param operationSortingType ソートタイプ
* @return
*/
public List<OperationDto> getOperationByOperationGroupMasterId(Integer operationGroupMasterId, OperationSortingType operationSortingType) {
return mOperationDao.getOperationsByGroupMasterId(operationGroupMasterId, operationSortingType);
}
}
......@@ -24,6 +24,7 @@ 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;
......@@ -1760,4 +1761,32 @@ public class OperationLogic extends AbstractLogic {
}
return result;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// カテゴリ選択機能
///////////////////////////////////////////////////////////////////////////////////////////////////////
// ABookCheckでは、同名の関数があるが、引数の数がちがったのでコピーした
/**
* 作業一覧取得
*
* @param searchWord 検索条件:作業名
* @param searchStartDateStr 検索条件:作業日範囲(開始)
* @param searchEndDateStr  検索条件:作業日範囲(終了)
* @param operationSortingType ソート順
* @return 作業リスト
*/
public List<OperationDto> getRefreshOperation(String searchWord, String searchStartDateStr, String searchEndDateStr, OperationSortingType operationSortingType) {
List<OperationDto> operationDtoList;
operationDtoList = mOperationDao.getOperations(searchWord, searchStartDateStr, searchEndDateStr, operationSortingType);
for (OperationDto operationDto : operationDtoList) {
// 作業送信フラグが存在する場合またはホットスポット更新フラグが存在する場合、needSyncFlgをtrueにセット
if (mTaskReportDao.isExistSendTaskData(operationDto.operationId) || mTaskReportDao.isExistUpdateTargetHotSpotTaskData(operationDto.operationId)) {
mOperationDao.updateNeedSyncFlg(operationDto.operationId, true);
}
}
return operationDtoList;
}
}
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:state_pressed="true"
android:drawable="@drawable/ic_show_list_off"/>
<item
android:drawable="@drawable/ic_show_list_on"/>
</selector>
\ No newline at end of file
......@@ -1432,4 +1432,10 @@
<string name="msg_no_nfc_setting">端末の設定からNFCを有効にする必要があります。\n端末の設定画面へ遷移しますか?</string>
<string name="select_spp_device_title">シリアル通信機器選択</string>
<string name="msg_bluetooth_connect_timeout_error">%1$sとの接続が切れました。%1$sの電源や距離を確認し、再度お試し下さい。(%2$s)</string>
<!-- カテゴリ選択機能 -->
<string name="no_child">これより下はありません。</string>
<string name="category_list">カテゴリ一覧</string>
<string name="title_category">カテゴリ</string>
<string name="title_all_operation">全作業</string>
</resources>
......@@ -1440,4 +1440,10 @@
<string name="msg_no_nfc_setting">단말기의 설정에서 NFC을 \n단말기의 설정화면으로 이동하시겠습니까?</string>
<string name="select_spp_device_title">시리얼 통신 기기 선택</string>
<string name="msg_bluetooth_connect_timeout_error">%1$s와의 연결이 끊겼습니다. %1$s의 전원과 거리를 확인하고 다시 시도해주세요.(%s)</string>
<!-- カテゴリ選択機能 -->
<string name="no_child">이 아래로는 데이터가 없습니다.</string>
<string name="category_list">분류 목록</string>
<string name="title_category">분류</string>
<string name="title_all_operation">전체 작업</string>
</resources>
\ No newline at end of file
......@@ -1439,4 +1439,9 @@
<string name="select_spp_device_title">シリアル通信機器選択</string>
<string name="msg_bluetooth_connect_timeout_error">%1$s with the central thermometer has been lost. Check the power and distance of %1$s and try again.(%2$s)</string>
<!-- カテゴリ選択機能 -->
<string name="no_child">No more data below.</string>
<string name="category_list">Select Category</string>
<string name="title_category">Category</string>
<string name="title_all_operation">All</string>
</resources>
\ No newline at end of file
......@@ -31,6 +31,16 @@
android:onClick="onClickOperationFilterList"
android:src="@drawable/ic_filter" />
<!-- カテゴリ選択機能追加 -->
<ImageButton
android:id="@+id/btn_category_location"
style="@style/ToolBarIcon"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/icon_filter"
android:onClick="onClickGroupLocationByNormalSize"
android:src="@drawable/ic_category_off" />
<!-- ここまで -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:gravity="center_vertical"
android:orientation="horizontal" >
<Button
android:id="@+id/btn_show_list_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_show_list" />
<HorizontalScrollView
android:id="@+id/bread_crumbs_scroll_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
<LinearLayout
android:id="@+id/bread_crumbs_layout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal" >
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:gravity="center_vertical"
android:paddingLeft="6dip"
android:paddingRight="6dip"
android:textColor="@color/text_select"
android:text="@string/dummy_str"
/>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:paddingLeft="10dp"
android:paddingBottom="8dp"
android:src="@drawable/icon_folder_empty_on" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/itemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/imageView1"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:layout_gravity="center"
android:text="@string/dummy_str"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/text_select" />
<TextView
android:id="@+id/itemCountText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toLeftOf="@+id/nextLevel"
android:layout_gravity="center"
android:textSize="20sp" />
<ImageView
android:id="@+id/nextLevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="@drawable/ic_navigation_next_item"
android:layout_gravity="center"
android:visibility="invisible" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -9,7 +9,16 @@
<RelativeLayout
android:id="@+id/toolbar"
style="@style/DialogToolBarHolo">
<!-- ここからABook Checkからコピー コンパイルとおすために -->
<Button
android:id="@+id/popup_left_title"
style="@style/ButtonABookLight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:visibility="gone" />
<!-- ここまで-->
<TextView
android:id="@+id/popup_title"
style="@style/DialogToolBarTitle"
......@@ -48,7 +57,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/left_item"
android:id="@+id/header_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/btn_layout"
......
......@@ -112,4 +112,9 @@
<item>Report</item>
<item>Routine</item>
</string-array>
<string-array name="category_types">
<item>All</item>
<item>Category</item>
</string-array>
</resources>
\ No newline at end of file
......@@ -6,6 +6,7 @@ import jp.agentec.abook.abv.bl.common.Constant.DeviceType;
import jp.agentec.abook.abv.bl.common.Constant.ReportType;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.BluetoothPairingDeviceInfoDto;
import jp.agentec.abook.abv.bl.dto.OperationGroupMasterDto;
import jp.agentec.abook.abv.cl.util.PreferenceUtil;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType.DefPrefKey;
......@@ -15,6 +16,7 @@ import jp.agentec.adf.util.StringUtil;
import android.content.Context;
import java.util.List;
import java.util.Stack;
public class ABVUIDataCache {
private static final String TAG = "ABVUIDataCache";
......@@ -264,4 +266,51 @@ public class ABVUIDataCache {
PreferenceUtil.removeUserPref(context, UserPrefKey.BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS);
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// カテゴリ選択機能
///////////////////////////////////////////////////////////////////////////////////////////////////////
// 作業種別絞り込み用のスタック
public Stack<OperationGroupMasterDto> operationGroupMasterStack;
/**
* xmlにファイル書き込みされた
* 通常・作業種別のモード切り替えの値を取得
* @return
*/
public int getOperationGroupMasterMode() {
return PreferenceUtil.getUserPref(context, UserPrefKey.OPERATION_GROUP_MASERT_MODE, 0);
}
/**
* 通常・作業種別のモード切り替えの値をxmlにファイル書き込みする
* @param operationGroupMasterMode
*/
public void setOperationGroupMasterMode(int operationGroupMasterMode) {
PreferenceUtil.putUserPref(context, UserPrefKey.OPERATION_GROUP_MASERT_MODE, operationGroupMasterMode);
}
/**
* xmlに書き込みされた作業種別IDを取得
* @return
*/
public int getOperationGroupMasterId() {
return PreferenceUtil.getUserPref(context, UserPrefKey.OPERATION_GROUP_MASERT_ID, 0);
}
/**
* ソート条件を取得
* @return ソートタイプ(デフォルト : 1(作業期間が新しい順))
*/
public int getSortCondition() {
return PreferenceUtil.getUserPref(context, UserPrefKey.OPERATION_SORT_CONDITION, 1);
}
/**
* xmlに作業種別IDをファイル書き込みする
* @param operationGroupMasterId
*/
public void setOperationGroupMasterId(int operationGroupMasterId) {
PreferenceUtil.putUserPref(context, UserPrefKey.OPERATION_GROUP_MASERT_ID, operationGroupMasterId);
}
}
......@@ -11,6 +11,15 @@ public interface AppDefType {
int PANEL = 0;
int LIST = 1;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// カテゴリ選択機能
///////////////////////////////////////////////////////////////////////////////////////////////////////
// 作業種別モードフラグ
interface OperationLocationType {
int ALL = 0;
int CATEGORY = 1;
}
interface DefPrefKey {
String REPEATABLE_PLAY = "repeatablePlay";
......@@ -66,6 +75,13 @@ public interface AppDefType {
String BLE_DEVICE_RADIATION_TEMPERATURE_ADDRESS = "bleDeviceRadiationTemperatureAddress"; // 放射温度計機器のアドレス
String MASTER_DATA_FETCH_DATE = "masterDataFetchDate"; // マスタデータのFetchDate
///////////////////////////////////////////////////////////////////////////////////////////////////////
// カテゴリ選択機能
///////////////////////////////////////////////////////////////////////////////////////////////////////
String OPERATION_GROUP_MASERT_MODE = "operation_group_master"; // 通常・作業種別モード(画面)
String OPERATION_GROUP_MASERT_ID = "operation_group_master_id"; // 作業種別のID
String OPERATION_SORT_CONDITION = "operation_sort_condition"; // 作業のソート
}
/**
......
......@@ -103,22 +103,6 @@ public class ABVListDialog extends Dialog {
getListView().setOnItemLongClickListener(listener);
}
public void setLeftItemOnClickListener(String itemName, View.OnClickListener l) {
// Button itemButton = (Button) mRoot.findViewById(R.id.popup_title_left);
// if (itemButton != null) {
// itemButton.setVisibility(View.VISIBLE);
// itemButton.setText(itemName);
// itemButton.setOnClickListener(l);
// } else {
// 携帯の場合
LinearLayout linearLayout = (LinearLayout) mRoot.findViewById(R.id.left_item);
linearLayout.setOnClickListener(l);
linearLayout.setVisibility(View.VISIBLE);
TextView textView = (TextView) mRoot.findViewById(R.id.header_title);
String suffixText = getContext().getResources().getString(R.string.to_back);
textView.setText(String.format(suffixText, itemName));
// }
}
public void setRightItemOnClickListener(int resId, View.OnClickListener l) {
ImageButton itemButton = (ImageButton) mRoot.findViewById(R.id.popup_right_image);
if (itemButton != null) {
......@@ -227,5 +211,64 @@ public class ABVListDialog extends Dialog {
((BaseAdapter)mAdapter).notifyDataSetChanged();
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// カテゴリ選択機能
///////////////////////////////////////////////////////////////////////////////////////////////////////
/** popup_left_title が足りないので
* list_dialog.xml に ダミーを追加してある
*
*/
}
public void setHeaderItemOnClickListener(String itemName, View.OnClickListener l) {
// Button itemButton = (Button) mRoot.findViewById(R.id.popup_title_left);
// if (itemButton != null) {
// itemButton.setVisibility(View.VISIBLE);
// itemButton.setText(itemName);
// itemButton.setOnClickListener(l);
// } else {
// 携帯の場合
LinearLayout linearLayout = (LinearLayout) mRoot.findViewById(R.id.header_item);
linearLayout.setOnClickListener(l);
linearLayout.setVisibility(View.VISIBLE);
TextView textView = (TextView) mRoot.findViewById(R.id.header_title);
String suffixText = getContext().getResources().getString(R.string.to_back);
textView.setText(String.format(suffixText, itemName));
// }
}
// left_item が存在しないのと、関数の中身が全然ちがうので、ABookCheckから丸コピー
//
//
/**
public void setLeftItemOnClickListener(String itemName, View.OnClickListener l) {
// Button itemButton = (Button) mRoot.findViewById(R.id.popup_title_left);
// if (itemButton != null) {
// itemButton.setVisibility(View.VISIBLE);
// itemButton.setText(itemName);
// itemButton.setOnClickListener(l);
// } else {
// 携帯の場合
LinearLayout linearLayout = (LinearLayout) mRoot.findViewById(R.id.left_item);
linearLayout.setOnClickListener(l);
linearLayout.setVisibility(View.VISIBLE);
TextView textView = (TextView) mRoot.findViewById(R.id.header_title);
String suffixText = getContext().getResources().getString(R.string.to_back);
textView.setText(String.format(suffixText, itemName));
// }
}
*/
/**
* 左側の要素イベント
* @param itemName
* @param l
*/
public void setLeftItemOnClickListener(String itemName, View.OnClickListener l) {
Button itemButton = (Button) mRoot.findViewById(R.id.popup_left_title);
if (itemButton != null) {
itemButton.setText(itemName);
itemButton.setVisibility(View.VISIBLE);
itemButton.setOnClickListener(l);
}
}
}
package jp.agentec.abook.abv.ui.home.adapter;
import java.util.ArrayList;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.launcher.android.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class HierarchyOperationGroupListAdapter extends BaseAdapter {
private static LayoutInflater mInflater = null;
private ArrayList<String> mNameList = new ArrayList<>();
private boolean[] mHaveChildFlags;
private int[] mOperationCounts;
public HierarchyOperationGroupListAdapter(Context context, ArrayList<String> nameList, boolean[] haveChildFlags, int[] operationCounts) {
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mNameList = nameList;
mHaveChildFlags = haveChildFlags;
mOperationCounts = operationCounts;
}
@Override
public int getCount() {
return mNameList.size();
}
@Override
public Object getItem(int position) {
return mNameList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
public void remove(int position) {
mNameList.remove(position);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (null == convertView) {
convertView = mInflater.inflate(R.layout.item_popup_list_item, null);
holder = new ViewHolder();
holder.title = (TextView) convertView.findViewById(R.id.itemText);
holder.nextLevel = (ImageView) convertView.findViewById(R.id.nextLevel);
holder.itemCount = (TextView) convertView.findViewById(R.id.itemCountText);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
// タイトル
holder.title.setText((String)getItem(position));
// 子作業種別がある場合、「>」を表示
if (mHaveChildFlags[position]) {
holder.nextLevel.setVisibility(View.VISIBLE);
} else {
holder.nextLevel.setVisibility(View.INVISIBLE);
}
// 作業数
holder.itemCount.setText("(" + mOperationCounts[position] + ")");
return convertView;
}
static class ViewHolder {
TextView title;
ImageView nextLevel;
TextView itemCount;
}
}
package jp.agentec.abook.abv.ui.home.helper;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.home.activity.OperationListActivity;
import jp.agentec.abook.abv.ui.home.view.BreadCrumbButton;
import static jp.agentec.abook.abv.cl.util.PreferenceUtil.getUserPref;
/**
* 階層構造をロジックの共通処理を実装
* @author jang
*
*/
public abstract class CategoryOperationListHelper<StackObject> extends OperationListHelper implements OnClickListener {
private final int MP = LayoutParams.MATCH_PARENT;
private final int WP = LayoutParams.WRAP_CONTENT;
protected Stack<StackObject> stack;
private LinearLayout mHierarchyContentLayout = null;
private LinearLayout mBreadCrumbsLayout = null;
private ViewGroup mOperationListView = null;
protected ArrayList<BreadCrumbButton> breadCrumbList = null;
private HorizontalScrollView panList;
/**
* 階層構造を持つ親クラス
* @param appActivity
*/
public CategoryOperationListHelper(OperationListActivity appActivity) {
super(appActivity);
mHierarchyContentLayout = new LinearLayout(appActivity);
mHierarchyContentLayout.setOrientation(LinearLayout.VERTICAL);
View v = new View(appActivity);
v.setBackgroundColor(Color.GRAY);
LinearLayout.LayoutParams vlp = new LinearLayout.LayoutParams(MP, 1);
mHierarchyContentLayout.addView(v, vlp);
LinearLayout panListLayout = (LinearLayout) LayoutInflater.from(appActivity).inflate(R.layout.content_breadcrumb_layout, null);
// 階層構造ビューを表示するボタン
panListLayout.findViewById(R.id.btn_show_list_view).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mAppActivity.showOperationGroupMasterDialog(true);
}
});
// パンくずのスクロールを作成
panList = (HorizontalScrollView) panListLayout.findViewById(R.id.bread_crumbs_scroll_view);
mBreadCrumbsLayout = (LinearLayout) panListLayout.findViewById(R.id.bread_crumbs_layout);
breadCrumbList = new ArrayList<>();
// パンくずリストを追加
mHierarchyContentLayout.addView(panListLayout, new LinearLayout.LayoutParams(MP, WP));
}
public void addBreadCrumbs(String name) {
addBreadCrumbs(name, stack.size() + 1);
}
public void addBreadCrumbs(String name, int level) {
BreadCrumbButton bcb = new BreadCrumbButton(mAppActivity, name);
bcb.level = level;
breadCrumbList.add(bcb);
bcb.setOnClickListener(this);
LayoutParams l = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
mBreadCrumbsLayout.addView(bcb, l);
// 右側へスクロールさせる
panList.post(new Runnable() {
@Override
public void run() {
panList.fullScroll(View.FOCUS_RIGHT);
}
});
}
protected void removeBreadCrumbs(View v) {
mBreadCrumbsLayout.removeView(v);
if (v instanceof BreadCrumbButton) {
breadCrumbList.remove(v);
}
}
/**
* 作業一覧のViewGroup取得
* @return
*/
@Override
public ViewGroup getOperationView() {
if (mOperationListView != null) {
ViewGroup parent = (ViewGroup) mOperationListView.getParent();
if (parent != null) {
parent.removeView(mOperationListView);
}
}
mOperationListView = super.getOperationView();
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(MP, 1);
lp.weight = 1;
mHierarchyContentLayout.addView(mOperationListView, 0, lp);
return mHierarchyContentLayout;
}
/**
* HorizontalScrollViewパンくずボタンをクリック時に呼ばれるメソッド
*/
@Override
public void onClick(View v) {
BreadCrumbButton button = (BreadCrumbButton) v;
int popCount = mBreadCrumbsLayout.getChildCount() - button.level;
if (popCount > 0) {
popList(popCount, true);
}
}
/**
* 階層スタックの現在のサイズを返します
*
* @return
*/
public int getStackSize() {
return stack.size();
}
/**
* 指定した階層分上のリストへ移動する
*
* @param popCount いくつ上の階層を表示するか指定します。
*/
abstract public void popList(int popCount, boolean isReload);
/**
* 一つ下の階層のリストへ移動する
*
* @param stackObject
*/
abstract public void pushList(StackObject stackObject);
/**
* 子階層の一覧を取得します
* @return
*/
abstract public List<StackObject> getChildList();
/**
* 現在の階層の名前を取得します
* @return
*/
abstract public String getPeekName();
/**
* 一つ上の階層の名前を取得します
* @return
*/
abstract public String getPrePeekName();
}
package jp.agentec.abook.abv.ui.home.helper;
import java.util.List;
import jp.agentec.abook.abv.bl.acms.type.OperationSortingType;
import jp.agentec.abook.abv.bl.dto.OperationDto;
import jp.agentec.abook.abv.ui.home.activity.OperationListActivity;
/**
* Created by leej on 2019/06/24.
*/
public class HomeOperationListHelper extends OperationListHelper {
private static final String TAG = "HomeOperationListHelper";
public HomeOperationListHelper(OperationListActivity activity) {
super(activity);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// カテゴリ選択機能
///////////////////////////////////////////////////////////////////////////////////////////////////////
// OperationLogicのgetRefreshOperationは、最後の引数がString なので、
/**
@Override
protected List<OperationDto> findOperationList() throws Exception {
int operationSortType = mAppActivity.getSortCondition();
OperationSortingType operationSortingType = OperationSortingType.parse(operationSortType);
return operationLogic.getRefreshOperation(mAppActivity.mSearchWord, mAppActivity.mStartDateStr, mAppActivity.mEndDateStr, operationSortingType);
}
*/
@Override
protected List<OperationDto> findOperationList() throws Exception {
int operationSortType = mAppActivity.getSortCondition();
OperationSortingType operationSortingType = OperationSortingType.parse(operationSortType);
return operationLogic.getRefreshOperation(mAppActivity.mSearchWord, mAppActivity.mStartDateStr, mAppActivity.mEndDateStr, operationSortingType);
}
}
\ No newline at end of file
package jp.agentec.abook.abv.ui.home.helper;
import java.util.List;
import jp.agentec.abook.abv.bl.acms.type.OperationSortingType;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
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.OperationGroupMasterDao;
import jp.agentec.abook.abv.bl.dto.OperationDto;
import jp.agentec.abook.abv.bl.dto.OperationGroupMasterDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.OperationGroupMasterLogic;
import jp.agentec.abook.abv.launcher.android.ABVApplication;
import jp.agentec.abook.abv.ui.home.activity.OperationListActivity;
import jp.agentec.adf.util.CollectionUtil;
public class OperationGroupMasterListHelper extends CategoryOperationListHelper<OperationGroupMasterDto> {
private static final String TAG = "OperationGroupMasterListHelper";
private OperationGroupMasterDao mOperationGroupMasterDao = AbstractDao.getDao(OperationGroupMasterDao.class);
private OperationGroupMasterLogic mOperationGroupMasterLogic = AbstractLogic.getLogic(OperationGroupMasterLogic.class);
public OperationGroupMasterListHelper(OperationListActivity appActivity) {
super(appActivity);
// キャッシュのスタックを利用する
stack = ABVApplication.getABVUIDataCache(mAppActivity).operationGroupMasterStack;
if (stack.size() == 0) {
// スタックが空の場合、全体を入れる
OperationGroupMasterDto operationGroupMasterDto;
// 保存されたoperationGroupmasterIdが0または、存在しない場合
if (mAppActivity.getOperationGroupMasterId() == 0 || !mOperationGroupMasterDao.isExistOperationGroupMaster(mAppActivity.getOperationGroupMasterId())) {
// 最上位階層をセット
operationGroupMasterDto = mOperationGroupMasterDao.getTopOperationGroupMaster();
if (operationGroupMasterDto != null) {
pushList(operationGroupMasterDto);
}
} else {
// 前回開いた際のIDでセット
List<OperationGroupMasterDto> operationGroupMasterDtoList = mOperationGroupMasterLogic.getParentOperationGroupMasterForPath(mAppActivity.getOperationGroupMasterId());
if (CollectionUtil.isNotEmpty(operationGroupMasterDtoList)) {
for (OperationGroupMasterDto dto : operationGroupMasterDtoList) {
pushList(dto);
}
}
}
} else {
// スタックに積まれている分だけパンくずボタンを作成
for (int i = 0; i < stack.size(); i++) {
OperationGroupMasterDto groupDto = stack.get(i);
addBreadCrumbs(groupDto.operationGroupMasterName, i + 1);
}
}
}
/**
* データの取得処理(新着更新処理完了後行われる)
* @return 作業一覧に表示されるリスト
* @throws Exception
*/
@Override
protected List<OperationDto> findOperationList() throws Exception {
// クリアフラグがfalseの場合
if (ABVEnvironment.getInstance().getOperationGroupMasterClearFlg()) {
// 表示する作業種別が既に削除された場合、最上位階層に戻る(リセット)
popList(breadCrumbList.size() - 1, false);
// クリアフラグをfalseにセット
ABVEnvironment.getInstance().setOperationGroupMasterClearFlg(false);
// 作業種別の選択画面を閉じる
mAppActivity.closeOperationGroupMasterDialog();
}
OperationGroupMasterDto peekOperationGroupMasterDto = stack.peek();
mAppActivity.checkBatchNeedSyncButton(peekOperationGroupMasterDto.operationGroupMasterId);
int operationSortType = mAppActivity.getSortCondition();
OperationSortingType operationSortingType = OperationSortingType.parse(operationSortType);
// 作業種別IDで紐づく作業リストを取得
return mOperationGroupMasterLogic.getOperationByOperationGroupMasterId(peekOperationGroupMasterDto.operationGroupMasterId, operationSortingType);
}
/**
* 親階層へ移動処理
* @param popCount いくつ上の階層を表示するか指定します。
* @param isReload リロードする・しない判定
*/
@Override
public void popList(int popCount, boolean isReload) {
for (int i = 0; i < popCount; i++) {
stack.pop();
// パンくずリスト削除
removeBreadCrumbs(breadCrumbList.get(breadCrumbList.size() - 1));
}
// 移動した作業種別のIDセット
mAppActivity.setOperationGroupMasterId(stack.get(getStackSize() - 1).operationGroupMasterId);
breadCrumbList.get(breadCrumbList.size() - 1);
if (isReload) {
// 作業一覧画面を更新する
refreshList();
}
}
@Override
public void pushList(OperationGroupMasterDto operationGroupMasterDto) {
if (operationGroupMasterDto == null) {
Logger.w(TAG, "[pushList] groupDto is null");
return;
}
// パンくずリスト追加
addBreadCrumbs(operationGroupMasterDto.operationGroupMasterName);
// ID保存
mAppActivity.setOperationGroupMasterId(operationGroupMasterDto.operationGroupMasterId);
stack.push(operationGroupMasterDto);
refreshList();
}
@Override
public String getPrePeekName() {
String groupName = "";
if (stack.size() > 1) {
groupName = stack.get(stack.size() - 2).operationGroupMasterName;
}
return groupName;
}
@Override
public String getPeekName() {
String groupName = "";
if (stack.size() > 0) {
groupName = stack.peek().operationGroupMasterName;
}
return groupName;
}
/**
* 親階層の情報で下の階層をリストで取得
* @return List<OperationGroupMasterDto>
*/
@Override
public List<OperationGroupMasterDto> getChildList() {
OperationGroupMasterDto peekOperationGroupMasterDto = stack.peek();
return getChildList(peekOperationGroupMasterDto.operationGroupMasterId);
}
/**
* 親階層のIDで下の階層をリストで取得
* @param operationGroupMasterId
* @return List<OperationGroupMasterDto>
*/
public List<OperationGroupMasterDto> getChildList(Integer operationGroupMasterId) {
return mOperationGroupMasterDao.getOperationGroupMasterChildList(operationGroupMasterId);
}
}
package jp.agentec.abook.abv.ui.home.helper;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.Toast;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshGridView;
......@@ -15,6 +12,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.OperationDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
......@@ -25,7 +23,6 @@ import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType.ViewMode;
import jp.agentec.abook.abv.ui.common.constant.ErrorCode;
import jp.agentec.abook.abv.ui.common.constant.ErrorMessage;
import jp.agentec.abook.abv.ui.common.util.ABVToastUtil;
import jp.agentec.abook.abv.ui.common.util.PatternStringUtil;
import jp.agentec.abook.abv.ui.home.activity.OperationListActivity;
import jp.agentec.abook.abv.ui.home.adapter.AbstractOperationAdapter;
......@@ -42,13 +39,13 @@ import static jp.agentec.abook.abv.cl.util.PreferenceUtil.getUserPref;
* Created by leej on 2019/03/06.
*/
public class OperationListHelper {
public abstract class OperationListHelper {
private static final String TAG = "OperationListHelper";
private OperationListActivity mAppActivity;
protected OperationListActivity mAppActivity;
private AbstractOperationAdapter mAdapter;
private PullToRefreshListView mPullToRefreshListView;
private PullToRefreshGridView mPullToRefreshGridView;
private OperationLogic mOperationLogic = AbstractLogic.getLogic(OperationLogic.class);
protected OperationLogic operationLogic = AbstractLogic.getLogic(OperationLogic.class);
private List<OperationDto> operationDtoList = new ArrayList<>();
// スマートフォンの1行のパンネル数
......@@ -68,7 +65,7 @@ public class OperationListHelper {
private List<OperationDto> filterOperationList() {
try {
String reportTypeStr = getUserPref(mAppActivity, AppDefType.UserPrefKey.OPERATION_REPORT_TYPES, null);
operationDtoList = mOperationLogic.getRefreshOperation(mAppActivity.mSearchWord, mAppActivity.mStartDateStr, mAppActivity.mEndDateStr, reportTypeStr);
operationDtoList = operationLogic.getRefreshOperation(mAppActivity.mSearchWord, mAppActivity.mStartDateStr, mAppActivity.mEndDateStr, reportTypeStr);
for (OperationDto operationDto : operationDtoList) {
// 該当する作業の最後に同期した日付を取得
......@@ -77,7 +74,7 @@ public class OperationListHelper {
if (!StringUtil.isNullOrEmpty(syncedDateStr)) {
syncedDate = DateTimeUtil.toDate(syncedDateStr, DateTimeFormat.yyyyMMddHHmmss_slash);
}
mOperationLogic.updateOperationNeedSyncFlg(operationDto, syncedDate);
operationLogic.updateOperationNeedSyncFlg(operationDto, syncedDate);
}
} catch (Exception e) {
Logger.e(TAG, "findOperationList", e);
......@@ -275,4 +272,18 @@ public class OperationListHelper {
public List<OperationDto> getOperationList() {
return operationDtoList;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// カテゴリ選択機能
///////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* 作業を検索してListを返す
*
* @return
* @throws Exception
* @throws NetworkDisconnectedException
*/
abstract protected List<OperationDto> findOperationList() throws Exception;
}
package jp.agentec.abook.abv.ui.home.view;
import jp.agentec.abook.abv.launcher.android.R;
import android.content.Context;
import android.graphics.Color;
import android.widget.Button;
/**
* パンくず履歴用のボタン
* @author jang
*
*/
public class BreadCrumbButton extends Button {
private BreadCrumbButton(Context context) {
super(context);
}
public BreadCrumbButton(Context context, String name) {
super(context);
this.name = name;
setText(name);
setTextColor(Color.BLACK);
setBackgroundResource(R.drawable.btn_breadcrumbs);
setPadding(10, 0, 40, 0);
}
public int level;
public String name;
}
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