Query for common methods:
@Override Public List<map<string, object>> selectspentamount (integer mat_type_, String dept_code_, Integer year_, Map< String, object> operator) { = "Select Mat_no_, sum (amount_) as Spent_amount_ from Dm_mat_month_plan where Mat_type_ =? and Dept_code_ =? and Year_ =? and Process_status_ in (1, 2) GROUP by Mat_no_ "; return dmjdbctemplate.queryforlist (SQL, Mat_type_, Dept_code_, year_); }
A query that can be empty method:
@Override PublicList<map<string, object>> selectspentbudget (integer mat_type_, String dept_code_, integer year_, integer Month_, String mat_budget_cat_id_, list<integer> process_status_list, map<string, Object>operator) {String SQL= "Select Mat_no_, SUM (Planned_price_ * amount_) as spent_budget_ from Dm_mat_month_plan where 1 = 1"; Map<string, object> parammap =NewHashmap<string, object>(); if(Mat_type_! =NULL) {SQL+ = "and Mat_type_ =: Mat_type_"; Parammap.put ("Mat_type_", Mat_type_); } if(Stringutils.isnotempty (dept_code_)) {SQL+ = "and Dept_code_ =:D Ept_code_"; Parammap.put ("Dept_code_", Dept_code_); } if(Year_! =NULL) {SQL+ = "and Year_ =: Year_"; Parammap.put ("Year_", Year_); } if(Month_! =NULL) {SQL+ = "and Month_ =: Month_"; Parammap.put ("Month_", Month_); } if(Stringutils.isnotempty (mat_budget_cat_id_)) {SQL+ = "and Mat_budget_cat_id_ =: Mat_budget_cat_id_"; Parammap.put ("Mat_budget_cat_id_", mat_budget_cat_id_); } if(Process_status_list! =NULL&& process_status_list.size () > 0) {SQL+ = "and Process_status_ in (:P rocess_status_list)"; Parammap.put ("Process_status_list", process_status_list); } SQL+ = "GROUP BY Mat_no_"; Namedparameterjdbctemplate namedparameterjdbctemplate=Newnamedparameterjdbctemplate (dmjdbctemplate); returnnamedparameterjdbctemplate.queryforlist (SQL, PARAMMAP); }
Bulk processing of SQL statements:
@Override Public intUpdateStatus (FinalList<string> Mat_aux_plan_rec_id_list,FinalMap<string, object>operator) { if(Mat_aux_plan_rec_id_list = =NULL|| Mat_aux_plan_rec_id_list.size () = = 0) { return0; } String SQL= "Update Dm_mat_aux_plan_rec set status_ = 1 where mat_aux_plan_rec_id_ =?" and Status_ = 0 "; BatchPreparedStatementSetter Batch=NewBatchPreparedStatementSetter () { Public voidSetvalues (PreparedStatement PS,intIthrowsSQLException {ps.setstring (1, Mat_aux_plan_rec_id_list.get (i)); } Public intgetbatchsize () {returnmat_aux_plan_rec_id_list.size (); } }; returndmjdbctemplate.batchupdate (SQL, Batch). length; }
Execution of a parameter method: A query of a common method, a query that can be an empty method. Bulk processing of SQL statements.