namedJDBC查询
import java.util.ArrayList;
import java.util.List; import org.apache.log4j.Logger;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.stereotype.Repository; import com.yundaex.common.dao.impl.BaseDaoImpl;
import com.yundaex.wms.basicdata.constant.RivPrintHistoryLSqlConstant;
import com.yundaex.wms.basicdata.dao.RivPrintHistoryLDao;
import com.yundaex.wms.basicdata.po.RivPrintHistoryL;
import com.yundaex.wms.basicdata.vo.DifferentUserQtyVO; @Repository("printHistoryLDao")
public class RivPrintHistoryLDaoImpl extends BaseDaoImpl<RivPrintHistoryL> implements RivPrintHistoryLDao { @Override
public List<DifferentUserQtyVO> queryTopQtyUser(String beginDate, String endDate, Integer orgId) {
MapSqlParameterSource map = new MapSqlParameterSource();
map.addValue("beginDate", beginDate);
map.addValue("endDate", endDate);
map.addValue("orgId", orgId);
List<DifferentUserQtyVO> results = this.jdbcTemplate.query(RivPrintHistoryLSqlConstant.PRINT_HISTORY_TOP_QTY_USER_SQL,map,
new BeanPropertyRowMapper<DifferentUserQtyVO>(DifferentUserQtyVO.class));
return results;
}
}
public class RivPrintHistoryLSqlConstant {
    public static String PRINT_HISTORY_TOP_QTY_USER_SQL =
                      "     SELECT                                                                                    "
                    + "         '打印' AS operateType,                                                                 "
                    + "         tab1.PHL_PRINT_USER_ID AS userId,                                                     "
                    + "         (                                                                                     "
                    + "             SELECT                                                                            "
                    + "                 UP_NAME                                                                       "
                    + "             FROM                                                                              "
                    + "                 tab_user_profile                                                              "
                    + "             WHERE                                                                             "
                    + "                 UP_USER_ID = tab1.PHL_PRINT_USER_ID                                           "
                    + "         ) AS userName,                                                                        "
                    + "         tab1.qty                                                                              "
                    + "     FROM                                                                                      "
                    + "         (                                                                                     "
                    + "             SELECT                                                                            "
                    + "                 PHL_PRINT_USER_ID,                                                            "
                    + "                 count(1) AS qty                                                               "
                    + "             FROM                                                                              "
                    + "                 riv_print_history_l                                                           "
                    + "             WHERE                                                                             "
                    + "                 CREATE_TIME >= :beginDate                                                     "
                    + "             AND CREATE_TIME < :endDate                                                        "
                    + "             GROUP BY                                                                          "
                    + "                 PHL_PRINT_USER_ID                                                             "
                    + "             ORDER BY                                                                          "
                    + "                 qty DESC                                                                      "
                    + "             LIMIT 1                                                                           "
                    + "         ) tab1                                                                                "
                    + "     WHERE                                                                                     "
                    + "         tab1.PHL_PRINT_USER_ID IN (                                                           "
                    + "             SELECT                                                                            "
                    + "                 u.usr_id                                                                      "
                    + "             FROM                                                                              "
                    + "                 tab_user u                                                                    "
                    + "             INNER JOIN tab_user_role ur ON ur.ur_user_id = u.usr_id                           "
                    + "             INNER JOIN tab_role r ON ur.ur_role_id = r.rl_id                                  "
                    + "             INNER JOIN tab_role_data_authority rda ON rda.rda_role_id = r.rl_id               "
                    + "             WHERE                                                                             "
                    + "                 rda.rda_dimension_code = 'organization'                                       "
                    + "             AND rda.rda_entity_id = :orgId                                                    "
                    + "             UNION                                                                             "
                    + "                 SELECT                                                                        "
                    + "                     u.usr_id                                                                  "
                    + "                 FROM                                                                          "
                    + "                     tab_user u                                                                "
                    + "                 INNER JOIN tab_user_profile up ON up.UP_USER_ID = u.usr_id                    "
                    + "                 INNER JOIN tab_domain dmn ON dmn.dmn_id = up.up_domain                        "
                    + "                 INNER JOIN tab_domain_role dr ON dr.dr_domain_id = dmn.dmn_id                 "
                    + "                 INNER JOIN tab_role r ON dr.dr_role_id = r.rl_id                              "
                    + "                 INNER JOIN tab_role_data_authority rda ON rda.rda_role_id = r.rl_id           "
                    + "                 WHERE                                                                         "
                    + "                     rda.rda_dimension_code = 'organization'                                   "
                    + "                 AND rda.rda_entity_id = :orgId                                                "
                    + "                 UNION                                                                         "
                    + "                     SELECT                                                                    "
                    + "                         up.up_id                                                              "
                    + "                     FROM                                                                      "
                    + "                         tab_user_profile up                                                   "
                    + "                     WHERE                                                                     "
                    + "                         up.up_user_prop = 'admin'                                             "
                    + "         )                                                                                     "
            ;
}
public List<Map<String, Object>> queryOrgInfo(List<String> orgParam) {
        Map<String, Object> params = new HashMap<String, Object>();
        String sql = "select org.org_id, org.org_code from riv_organization org where org.org_code in (:orgCodes)";
        params.put("orgCodes", orgParam);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, params);
        return list;
    }
import java.util.List; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.stereotype.Repository; import com.yundaex.common.dao.impl.BaseDaoImpl;
import com.yundaex.wms.outbound.dao.RivMainpickStartPrintTemplateDao;
import com.yundaex.wms.outbound.po.RivMainpickStartPrintTemplate; @Repository
public class RivMainpickStartPrintTemplateDaoImpl extends BaseDaoImpl<RivMainpickStartPrintTemplate> implements RivMainpickStartPrintTemplateDao { @Override
public List<Integer> queryExistRecordsByOnhIds(List<Integer> onhIds) {
MapSqlParameterSource map = new MapSqlParameterSource();
map.addValue("onhIds", onhIds);
String sql = "select ONH_ID from riv_mainpick_start_print_template where ONH_ID in(:onhIds)";
List<Integer> results = this.jdbcTemplate.queryForList(sql,map,Integer.class);
return results;
}
}
namedJDBC查询的更多相关文章
- 使用TSQL查询和更新 JSON 数据
		JSON是一个非常流行的,用于数据交换的文本数据(textual data)格式,主要用于Web和移动应用程序中.JSON 使用“键/值对”(Key:Value pair)存储数据,能够表示嵌套键值对 ... 
- UWP 律师查询 MVVM
		APP简介 律师查询是基于聚合数据的律师查询接口做的,这个接口目前处于停用状态,但是,由于我是之前申请的,所以,还可以用,应该是无法再申请了. 效果图 开发 一.HttpHelper 既然是请求接口的 ... 
- Elasticsearch 5.0 中term 查询和match 查询的认识
		Elasticsearch 5.0 关于term query和match query的认识 一.基本情况 前言:term query和match query牵扯的东西比较多,例如分词器.mapping ... 
- ASP.NET Aries 入门开发教程4:查询区的下拉配置
		背景: 今天去深圳溜达了一天,刚回来,看到首页都是微软大法好,看来离.NET的春天就差3个月了~~ 回到正题,这篇的教程讲解下拉配置. 查询区的下拉配置: 1:查询框怎么配置成下拉? 在配置表头:格式 ... 
- ASP.NET Aries 入门开发教程3:开发一个列表页面及操控查询区
		前言: Aries框架毕竟是开发框架,所以重点还是要写代码的,这样开发人员才不会失业,哈. 步骤1:新建html 建一个Html,主要有三步: 1:引入Aries.Loader.js 2:弄一个tab ... 
- ExtJS 4.2 业务开发(二)数据展示和查询
		本篇开始模拟一个船舶管理系统,提供查询.添加.修改船舶的功能,这里介绍其中的数据展示和查询功能. 目录 1. 数据展示 2. 数据查询 3. 在线演示 1. 数据展示 在这里我们将模拟一个船舶管理系统 ... 
- 深入理解MySql子查询IN的执行和优化
		IN为什么慢? 在应用程序中使用子查询后,SQL语句的查询性能变得非常糟糕.例如: SELECT driver_id FROM driver where driver_id in (SELECT dr ... 
- ElasticSearch 5学习(10)——结构化查询(包括新特性)
		之前我们所有的查询都属于命令行查询,但是不利于复杂的查询,而且一般在项目开发中不使用命令行查询方式,只有在调试测试时使用简单命令行查询,但是,如果想要善用搜索,我们必须使用请求体查询(request ... 
- 【初学python】使用python连接mysql数据查询结果并显示
		因为测试工作经常需要与后台数据库进行数据比较和统计,所以采用python编写连接数据库脚本方便测试,提高工作效率,脚本如下(python连接mysql需要引入第三方库MySQLdb,百度下载安装) # ... 
随机推荐
- python to 可执行文件
			cx_Freeze for Windows, Linux, and Mac OS X (Python 2.7, 3.x) pyinstaller for Windows, Linux, and Mac ... 
- C++(一)— stringstream的用法
			输入输出的头文件 <iostream> string流的头文件 <sstream> 文件流的头文件 <fstream> 1.利用输入输出做数据转换 stri ... 
- hdu 1002  A + B Problem II(大数)
			题意:就是求a+b (a,b都不超过1000位) 思路:用数组存储 第一道大数的题目,虽然很水,纪念一下! 代码: #include<cstdio> #include<cstring ... 
- 勤于思考:Objective-C特性的扩展
			赋值 assign:直接赋值.默认 @interface Car : NSObject { NSString *_name; } @property (assign,nonatomic) NSStri ... 
- rust borrow and move
			extern crate core; #[deriving(Show)] struct Foo { f : Box<int> } fn main(){ let mut a = Foo {f ... 
- 《java编程思想》读后笔记:一,标签
			标签 是后面跟有冒号的标识符,格式如下: label : java中通过break与continue关键词可以完成类似于跳转的操作,其实现机制便是标签. 虽然很少有人使用,但是其有自身的适用场景:多层 ... 
- ACM学习历程—HDU 2795 Billboard(线段树)
			Description At the entrance to the university, there is a huge rectangular billboard of size h*w (h ... 
- 【C】字符串常量和字符数组
			此次博客是转载某位博主的文章,不过现在找不到了,所以先声明一下. 先贴一段代码: #include <stdio.h> int main(int argc, const char** ar ... 
- 11g dataguard  类型、保护模式、服务
			一. Dataguard中的备库分为物理备库和逻辑备库及快照备库 备库是主库的一致性拷贝,使用一个主库的备份可以创建多到30个备库,将其加入到dataguard环境中,创建成功后,dataguard通 ... 
- BZOJ2467五角形生成树——数学
			题目:http://www.lydsy.com/JudgeOnline/problem.php?id=2467 可以得出只需在每个五角形中去掉任意一条边,在某个五角形中去掉包括内边的两条边即可. 代码 ... 
