Execution of a parameter method: A query of a common method, a query that can be an empty method. Bulk processing of SQL statements.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.