Commit 55c7a54f by Lee Jaebin

#34190 作業種別毎に作業を絞り込み機能修正

parent 8d3866b7
...@@ -246,7 +246,17 @@ public class OperationDao extends AbstractDao { ...@@ -246,7 +246,17 @@ public class OperationDao extends AbstractDao {
* @return * @return
*/ */
public List<OperationDto> getOperations(String searchOperationName, String searchStartDateStr, String searchEndDateStr, String reportTypeStr) { public List<OperationDto> getOperations(String searchOperationName, String searchStartDateStr, String searchEndDateStr, String reportTypeStr) {
String sql = generateGetOperationQuery(searchOperationName, searchStartDateStr, searchEndDateStr, reportTypeStr); String sql = generateGetOperationQuery(searchOperationName, searchStartDateStr, searchEndDateStr, reportTypeStr, null);
return rawQueryGetDtoList(sql, null, OperationDto.class);
}
/**
* カテゴリの作業一覧検索用
* @param operationGroupMasterId
* @return
*/
public List<OperationDto> getOperationsByGroupMasterId(Integer operationGroupMasterId) {
String sql = generateGetOperationQuery(null, null, null, null, operationGroupMasterId);
return rawQueryGetDtoList(sql, null, OperationDto.class); return rawQueryGetDtoList(sql, null, OperationDto.class);
} }
...@@ -259,7 +269,7 @@ public class OperationDao extends AbstractDao { ...@@ -259,7 +269,7 @@ public class OperationDao extends AbstractDao {
* @param reportTypeStr * @param reportTypeStr
* @return * @return
*/ */
private String generateGetOperationQuery(String searchOperationName, String searchStartDateStr, String searchEndDateStr, String reportTypeStr) { private String generateGetOperationQuery(String searchOperationName, String searchStartDateStr, String searchEndDateStr, String reportTypeStr, Integer operationGroupMasterId) {
String curDate = DateTimeUtil.toStringInTimeZone(new Date(), DateTimeFormat.yyyyMMddHHmmss_hyphen, "UTC"); String curDate = DateTimeUtil.toStringInTimeZone(new Date(), DateTimeFormat.yyyyMMddHHmmss_hyphen, "UTC");
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
...@@ -304,6 +314,14 @@ public class OperationDao extends AbstractDao { ...@@ -304,6 +314,14 @@ public class OperationDao extends AbstractDao {
sql.append(" LEFT OUTER JOIN r_operation_content AS rpc "); sql.append(" LEFT OUTER JOIN r_operation_content AS rpc ");
sql.append(" ON top.operation_id = rpc.operation_id "); sql.append(" ON top.operation_id = rpc.operation_id ");
sql.append(" AND rpc.operation_content_flg = 1 "); 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 "); sql.append(" WHERE top.operation_id IS NOT NULL ");
if (!StringUtil.isNullOrEmpty(searchOperationName)) { if (!StringUtil.isNullOrEmpty(searchOperationName)) {
sql.append(" AND top.operation_name GLOB " + "'*" + searchOperationName + "*'"); sql.append(" AND top.operation_name GLOB " + "'*" + searchOperationName + "*'");
...@@ -362,25 +380,4 @@ public class OperationDao extends AbstractDao { ...@@ -362,25 +380,4 @@ public class OperationDao extends AbstractDao {
updateNeedSyncFlg(operationDto.operationId, true); updateNeedSyncFlg(operationDto.operationId, true);
} }
} }
/**
* 作業種別IDで関連する作業リストを取得
* @param operationGroupMasterId
* @return
*/
public List<OperationDto> getOperationByOperationGroupMasterId(Integer operationGroupMasterId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT * ");
sql.append(" FROM t_operation AS top");
// INNER JOIN r_operation_group_master_relation
sql.append(" INNER JOIN r_operation_group_master_relation AS rog");
sql.append(" ON rog.operation_id = top.operation_id");
// LEFT OUTER JOIN r_operation_content
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 ");
sql.append(" WHERE rog.operation_group_master_id = ?");
sql.append(" ORDER BY top.operation_start_date DESC, top.operation_id DESC");
return rawQueryGetDtoList(sql.toString(), new String[] { "" + operationGroupMasterId }, OperationDto.class);
}
} }
\ No newline at end of file
...@@ -157,14 +157,10 @@ public class OperationGroupMasterDao extends AbstractDao { ...@@ -157,14 +157,10 @@ public class OperationGroupMasterDao extends AbstractDao {
/** /**
* 階層の作業種別情報取得(検索結果を元にデータ取得) * 階層の作業種別情報取得(検索結果を元にデータ取得)
* @param searchOperationName
* @param searchStartDateStr
* @param searchEndDateStr
* @param reportTypeStr
* @param level * @param level
* @return * @return
*/ */
public List<OperationGroupMasterDto> getOperationGroupMasterListBylevel(String searchOperationName, String searchStartDateStr, String searchEndDateStr, String reportTypeStr, Integer level) { public List<OperationGroupMasterDto> getOperationGroupMasterListBylevel(Integer level) {
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
sql.append(" SELECT M1.*, count(R1.operation_id) AS operation_count FROM m_operation_group_master AS M1"); 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(" LEFT OUTER JOIN r_operation_group_master_relation R1");
...@@ -172,23 +168,7 @@ public class OperationGroupMasterDao extends AbstractDao { ...@@ -172,23 +168,7 @@ public class OperationGroupMasterDao extends AbstractDao {
sql.append(" AND R1.operation_id IN("); sql.append(" AND R1.operation_id IN(");
sql.append(" SELECT operation_id FROM t_operation top"); sql.append(" SELECT operation_id FROM t_operation top");
sql.append(" WHERE top.operation_id IS NOT NULL"); 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 (reportTypeStr != null) {
sql.append(" AND top.report_type in ("+ reportTypeStr +")");
}
sql.append(" )"); sql.append(" )");
sql.append(" WHERE M1.operation_group_master_level =? "); sql.append(" WHERE M1.operation_group_master_level =? ");
sql.append(" GROUP BY M1.operation_group_master_id"); sql.append(" GROUP BY M1.operation_group_master_id");
......
...@@ -99,16 +99,12 @@ public class OperationGroupMasterLogic extends AbstractLogic { ...@@ -99,16 +99,12 @@ public class OperationGroupMasterLogic extends AbstractLogic {
/** /**
* 作業種別毎に作業数(子グループの作業も含む)を * 作業種別毎に作業数(子グループの作業も含む)を
* operationCountMapにセットする * operationCountMapにセットする
* @param searchOperationName
* @param searchStartDateStr
* @param searchEndDateStr
* @param reportTypeStr
* @param level * @param level
* @param operationCountMap * @param operationCountMap
*/ */
public void getAllOperationCount(String searchOperationName, String searchStartDateStr, String searchEndDateStr, String reportTypeStr, int level, Map<Integer, Integer> operationCountMap) { public void getAllOperationCount(int level, Map<Integer, Integer> operationCountMap) {
List<OperationGroupMasterDto> operationGroupMasterDtoList; List<OperationGroupMasterDto> operationGroupMasterDtoList;
operationGroupMasterDtoList = mOperationGroupMasterDao.getOperationGroupMasterListBylevel(searchOperationName, searchStartDateStr, searchEndDateStr, reportTypeStr, level); operationGroupMasterDtoList = mOperationGroupMasterDao.getOperationGroupMasterListBylevel(level);
// ルート階層の場合は以下の処理しない // ルート階層の場合は以下の処理しない
if (level > 0 && operationGroupMasterDtoList != null) { if (level > 0 && operationGroupMasterDtoList != null) {
...@@ -131,7 +127,7 @@ public class OperationGroupMasterLogic extends AbstractLogic { ...@@ -131,7 +127,7 @@ public class OperationGroupMasterLogic extends AbstractLogic {
} }
} }
level--; level--;
getAllOperationCount(searchOperationName, searchStartDateStr, searchEndDateStr, reportTypeStr, level, operationCountMap); // 再帰呼び出し getAllOperationCount(level, operationCountMap); // 再帰呼び出し
} }
} }
...@@ -170,6 +166,6 @@ public class OperationGroupMasterLogic extends AbstractLogic { ...@@ -170,6 +166,6 @@ public class OperationGroupMasterLogic extends AbstractLogic {
* @return * @return
*/ */
public List<OperationDto> getOperationByOperationGroupMasterId(Integer operationGroupMasterId) { public List<OperationDto> getOperationByOperationGroupMasterId(Integer operationGroupMasterId) {
return mOperationDao.getOperationByOperationGroupMasterId(operationGroupMasterId); return mOperationDao.getOperationsByGroupMasterId(operationGroupMasterId);
} }
} }
...@@ -411,6 +411,7 @@ public class OperationListActivity extends ABVUIActivity { ...@@ -411,6 +411,7 @@ public class OperationListActivity extends ABVUIActivity {
mSearchButton.setImageDrawable(getRDrawable(R.drawable.ic_operation_search)); mSearchButton.setImageDrawable(getRDrawable(R.drawable.ic_operation_search));
setEnabledImageButton(mSearchButton); setEnabledImageButton(mSearchButton);
} else { } else {
// 全て
cancelToolbarEnabledIcon(); cancelToolbarEnabledIcon();
} }
} else { } else {
...@@ -2020,8 +2021,7 @@ public class OperationListActivity extends ABVUIActivity { ...@@ -2020,8 +2021,7 @@ public class OperationListActivity extends ABVUIActivity {
Integer lastLevel = mOperationGroupMasterLogic.getLastGroupLevel(); Integer lastLevel = mOperationGroupMasterLogic.getLastGroupLevel();
operationCountMap = new HashMap<Integer, Integer>(); operationCountMap = new HashMap<Integer, Integer>();
// 作業種別毎に作業数をMapにセット // 作業種別毎に作業数をMapにセット
String reportTypeStr = getUserPref(AppDefType.UserPrefKey.OPERATION_REPORT_TYPES, null); mOperationGroupMasterLogic.getAllOperationCount(lastLevel, operationCountMap);
mOperationGroupMasterLogic.getAllOperationCount(mSearchWord, mStartDateStr, mEndDateStr, reportTypeStr, lastLevel, operationCountMap);
} }
// 既にダイアログが存在するか、開いた状態である場合は何もしない // 既にダイアログが存在するか、開いた状態である場合は何もしない
if (mShowDialog != null && mShowDialog.isShowing()) { if (mShowDialog != null && mShowDialog.isShowing()) {
......
...@@ -64,13 +64,8 @@ public class OperationGroupMasterListHelper extends HierarchyOperationListHelper ...@@ -64,13 +64,8 @@ public class OperationGroupMasterListHelper extends HierarchyOperationListHelper
*/ */
@Override @Override
protected List<OperationDto> findOperationList() throws Exception { protected List<OperationDto> findOperationList() throws Exception {
OperationGroupMasterDto peekOperationGroupMasterDto = stack.peek(); // クリアフラグがfalseの場合
String reportTypeStr = getUserPref(mAppActivity, AppDefType.UserPrefKey.OPERATION_REPORT_TYPES, null); if (ABVEnvironment.getInstance().getOperationGroupMasterClearFlg()) {
Integer operationGroupMasterId = null;
// operationGroupMasterIdのデータが存在、且つクリアフラグがfalseの場合
if (mOperationGroupMasterDao.isExistOperationGroupMaster(peekOperationGroupMasterDto.operationGroupMasterId) && !ABVEnvironment.getInstance().getOperationGroupMasterClearFlg()) {
operationGroupMasterId = peekOperationGroupMasterDto.operationGroupMasterId;
} else {
// 表示する作業種別が既に削除された場合、最上位階層に戻る(リセット) // 表示する作業種別が既に削除された場合、最上位階層に戻る(リセット)
popList(breadCrumbList.size() - 1, false); popList(breadCrumbList.size() - 1, false);
// クリアフラグをfalseにセット // クリアフラグをfalseにセット
...@@ -78,8 +73,9 @@ public class OperationGroupMasterListHelper extends HierarchyOperationListHelper ...@@ -78,8 +73,9 @@ public class OperationGroupMasterListHelper extends HierarchyOperationListHelper
// 作業種別の選択画面を閉じる // 作業種別の選択画面を閉じる
mAppActivity.closeOperationGroupMasterDialog(); mAppActivity.closeOperationGroupMasterDialog();
} }
OperationGroupMasterDto peekOperationGroupMasterDto = stack.peek();
// 作業種別IDで紐づく作業リストを取得 // 作業種別IDで紐づく作業リストを取得
return mOperationGroupMasterLogic.getOperationByOperationGroupMasterId(operationGroupMasterId); return mOperationGroupMasterLogic.getOperationByOperationGroupMasterId(peekOperationGroupMasterDto.operationGroupMasterId);
} }
/** /**
......
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