4.2. 検索用SQL¶
本項では、ReportBuilderで使用するSQLの作成方法を説明します。
4.2.1. 概要¶
「拡張設定」を使用することで、SQLの配置先を変更することが可能です。「拡張設定」を使用しない場合のReportBuilderで使用するSQLの配置先は次の通りです。%ModuleProject%/src/main/resources/META-INF/sql/jp/co/slcs/kaiden/v2/generic/report/%レポートID%.sql(レポートIDには、ReportBuilder定義で設定したレポートIDを指定してください。)
検索基準となる値の補完検索基準日・検査基準ロケール・検索基準ユーザが設定されていない場合、次の通り補完して、SQLに引き渡されます。
名称 SQLで使用する値 補完順 検索基準日 searchCriteriaDate リクエストパラメータ > システム日付 検索基準ロケール searchCriteriaLocale リクエストパラメータ > ログインユーザのロケール 検索基準ユーザ searchCriteriaUser リクエストパラメータ > ログインユーザ
4.2.2. 一覧表示部分SQL¶
一覧表示部分のSQLでは、 ReportBuilder機能の一覧として表示するデータを定義します。
一覧表示部分 設定select target.system_matter_id ,target.user_data_id ,target.gadget_class ,target.gadget_instance ,target.gadget_id ,target.gadget_variation ,target.start_date ,target.end_date ,target.currency_cd1 ,target.currency_cd2 ,target.currency_cd3 ,target.amount1 ,target.amount2 ,target.amount3 ,target.summary1 ,target.summary2 ,target.summary3 ,target.summary4 ,target.summary5 ,matter_process.apply_auth_company_code as apply_auth_company_code ,dept_com_sea.department_name as apply_auth_company_name ,matter_process.apply_auth_user_code as apply_auth_user_code ,matter_process.apply_auth_user_name as apply_auth_user_name ,matter_process.apply_execute_user_code as apply_execute_user_code ,matter_process.apply_execute_user_name as apply_execute_user_name ,gadget.gadget_name as gadget_name from k30t_expense_info target left join ( select matter.system_matter_id , matter.flow_id , matter.flow_version_id , matter.flow_name , matter.contents_id , matter.contents_version_id , matter.contents_name , matter.route_id , matter.route_version_id , matter.route_name , matter.app_type_code , matter.app_type_name , matter.matter_number , matter.matter_name , matter.apply_base_date , matter.apply_date , matter.apply_auth_company_code , matter.apply_auth_company_name , matter.apply_auth_user_code , matter.apply_auth_user_name , matter.apply_execute_user_code , matter.apply_execute_user_name , matter.apply_act_flag , matter.matter_cpl_date , matter.archive_date , matter.matter_end_status_code , matter.matter_end_status_name , matter.matter_status_code , matter.matter_status_name , matter.task_status_code , matter.task_status_name , matter.priority_level , matter.process_date , matter.process_hour , matter.process_minute , matter.process_second , matter.process_millisecond , matter.process_date_total , matter.process_hour_total , matter.process_minute_total , matter.process_second_total , matter.process_millisecond_total , matter.process_time , matter.process_history_count , matter.confirm_history_count from k20r_matter_process_info matter ) matter_process on matter_process.system_matter_id = target.system_matter_id left outer join k10m_gadget_description gadget on gadget.gadget_class = target.gadget_class and gadget.gadget_variation = target.gadget_variation /*IF searchCriteriaLocale != null*/ and gadget.locale_id = /*searchCriteriaLocale*/'searchCriteriaLocale' /*END*/ left outer join imm_department dept_com_sea on dept_com_sea.company_cd = matter_process.apply_auth_company_code and dept_com_sea.department_set_cd = matter_process.apply_auth_company_code and dept_com_sea.department_cd = matter_process.apply_auth_company_code /*IF searchCriteriaDate != null*/ and dept_com_sea.start_date <= /*searchCriteriaDate*/'2000/01/01' and dept_com_sea.end_date > /*searchCriteriaDate*/'2000/01/01' /*END*/ /*IF searchCriteriaLocale != null*/ and dept_com_sea.locale_id = /*searchCriteriaLocale*/'searchCriteriaLocale' /*END*/
4.2.3. 検索条件部分SQL¶
検索条件部分のSQLでは、 ReportBuilder機能で使用する検索条件を定義します。画面に入力した値が、リクエストパラメータとして検索条件部分のSQLに渡されます。
検索条件部分 設定where target.gadget_class = 'expenseInfo' and target.gadget_variation in ('v03','v04') /*IF gadgetName != null*/ and gadget.gadget_name like /*gadgetName*/'%' ESCAPE '$' /*END*/ /*IF gadgetId != null*/ and target.gadget_id like /*gadgetId*/'%' ESCAPE '$' /*END*/ /*IF currencyCd1 != null*/ and target.currency_cd1 = /*currencyCd1*/'currencyCd1' /*END*/ /*IF amountFrom != null*/ and target.amount1 >= CAST(/*amountFrom*/'amountFrom' as INTEGER) /*END*/ /*IF amountTo != null*/ and target.amount1 < CAST(/*amountTo*/'amountTo' as INTEGER) /*END*/ /*IF systemMatterId != null*/ and target.system_matter_id = /*systemMatterId*/'systemMatterId' /*END*/ /*IF startDate != null*/ and target.start_date >= /*startDate*/'startDate' /*END*/ /*IF endDate != null*/ and target.end_date < /*endDate*/'endDate' /*END*/ /*IF summary1 != null*/ and target.summary1 like /*summary1*/'%' ESCAPE '$' /*END*/ /*IF summary2 != null*/ and target.summary2 like /*summary2*/'%' ESCAPE '$' /*END*/ /*IF summary3 != null*/ and target.summary3 like /*summary3*/'%' ESCAPE '$' /*END*/ /*IF summary4 != null*/ and target.summary4 like /*summary4*/'%' ESCAPE '$' /*END*/ /*IF applyAuthUserCode != null*/ and matter_process.apply_auth_user_code = /*applyAuthUserCode*/'applyAuthUserCode' /*END*/ /*IF applyExecuteUserCode != null*/ and matter_process.apply_execute_user_code = /*applyExecuteUserCode*/'applyExecuteUserCode' /*END*/ /*IF applyAuthCompanyCode.size() > 0*/ and matter_process.apply_auth_company_code in /*applyAuthCompanyCode*/('applyAuthCompanyCode') /*END*/
4.2.5. Sample¶
次のSQLは出張先一覧の設定を行った場合のサンプルです。select target.system_matter_id ,target.user_data_id ,target.gadget_class ,target.gadget_instance ,target.gadget_id ,target.gadget_variation ,target.start_date ,target.end_date ,target.currency_cd1 ,target.currency_cd2 ,target.currency_cd3 ,target.amount1 ,target.amount2 ,target.amount3 ,target.summary1 ,target.summary2 ,target.summary3 ,target.summary4 ,target.summary5 ,matter_process.apply_auth_company_code as apply_auth_company_code ,dept_com_sea.department_name as apply_auth_company_name ,matter_process.apply_auth_user_code as apply_auth_user_code ,matter_process.apply_auth_user_name as apply_auth_user_name ,matter_process.apply_execute_user_code as apply_execute_user_code ,matter_process.apply_execute_user_name as apply_execute_user_name ,gadget.gadget_name as gadget_name from k30t_expense_info target left join ( select matter.system_matter_id , matter.flow_id , matter.flow_version_id , matter.flow_name , matter.contents_id , matter.contents_version_id , matter.contents_name , matter.route_id , matter.route_version_id , matter.route_name , matter.app_type_code , matter.app_type_name , matter.matter_number , matter.matter_name , matter.apply_base_date , matter.apply_date , matter.apply_auth_company_code , matter.apply_auth_company_name , matter.apply_auth_user_code , matter.apply_auth_user_name , matter.apply_execute_user_code , matter.apply_execute_user_name , matter.apply_act_flag , matter.matter_cpl_date , matter.archive_date , matter.matter_end_status_code , matter.matter_end_status_name , matter.matter_status_code , matter.matter_status_name , matter.task_status_code , matter.task_status_name , matter.priority_level , matter.process_date , matter.process_hour , matter.process_minute , matter.process_second , matter.process_millisecond , matter.process_date_total , matter.process_hour_total , matter.process_minute_total , matter.process_second_total , matter.process_millisecond_total , matter.process_time , matter.process_history_count , matter.confirm_history_count from k20r_matter_process_info matter ) matter_process on matter_process.system_matter_id = target.system_matter_id left outer join k10m_gadget_description gadget on gadget.gadget_class = target.gadget_class and gadget.gadget_variation = target.gadget_variation /*IF searchCriteriaLocale != null*/ and gadget.locale_id = /*searchCriteriaLocale*/'searchCriteriaLocale' /*END*/ left outer join imm_department dept_com_sea on dept_com_sea.company_cd = matter_process.apply_auth_company_code and dept_com_sea.department_set_cd = matter_process.apply_auth_company_code and dept_com_sea.department_cd = matter_process.apply_auth_company_code /*IF searchCriteriaDate != null*/ and dept_com_sea.start_date <= /*searchCriteriaDate*/'2000/01/01' and dept_com_sea.end_date > /*searchCriteriaDate*/'2000/01/01' /*END*/ /*IF searchCriteriaLocale != null*/ and dept_com_sea.locale_id = /*searchCriteriaLocale*/'searchCriteriaLocale' /*END*/ where target.gadget_class = 'expenseInfo' and target.gadget_variation in ('v03','v04') /*IF gadgetName != null*/ and gadget.gadget_name like /*gadgetName*/'%' ESCAPE '$' /*END*/ /*IF gadgetId != null*/ and target.gadget_id like /*gadgetId*/'%' ESCAPE '$' /*END*/ /*IF currencyCd1 != null*/ and target.currency_cd1 = /*currencyCd1*/'currencyCd1' /*END*/ /*IF amountFrom != null*/ and target.amount1 >= CAST(/*amountFrom*/'amountFrom' as INTEGER) /*END*/ /*IF amountTo != null*/ and target.amount1 < CAST(/*amountTo*/'amountTo' as INTEGER) /*END*/ /*IF systemMatterId != null*/ and target.system_matter_id = /*systemMatterId*/'systemMatterId' /*END*/ /*IF startDate != null*/ and target.start_date >= /*startDate*/'startDate' /*END*/ /*IF endDate != null*/ and target.end_date < /*endDate*/'endDate' /*END*/ /*IF summary1 != null*/ and target.summary1 like /*summary1*/'%' ESCAPE '$' /*END*/ /*IF summary2 != null*/ and target.summary2 like /*summary2*/'%' ESCAPE '$' /*END*/ /*IF summary3 != null*/ and target.summary3 like /*summary3*/'%' ESCAPE '$' /*END*/ /*IF summary4 != null*/ and target.summary4 like /*summary4*/'%' ESCAPE '$' /*END*/ /*IF applyAuthUserCode != null*/ and matter_process.apply_auth_user_code = /*applyAuthUserCode*/'applyAuthUserCode' /*END*/ /*IF applyExecuteUserCode != null*/ and matter_process.apply_execute_user_code = /*applyExecuteUserCode*/'applyExecuteUserCode' /*END*/ /*IF applyAuthCompanyCode.size() > 0*/ and matter_process.apply_auth_company_code in /*applyAuthCompanyCode*/('applyAuthCompanyCode') /*END*/ /*IF orderBy != null*/ order by /*$orderBy*/ /*END*/