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,百度下载安装) # ...
随机推荐
- BZOJ 1626 [Usaco2007 Dec]Building Roads 修建道路:kruskal(最小生成树)
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1626 题意: 有n个农场,坐标为(x[i],y[i]). 有m条原先就修好的路,连接农场( ...
- canvas练习单个矩形形变
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- JS遍历获取多个控件(使用索引‘i’)
1.n个tid="n1"的input.n个tid="n2"的input.n个tid="n3"的input---循环遍历 ; i <= ...
- c语言字符串 数字转换函数大全
最近学数据结构老是做实验 常用到字符串和数字的转换 想找却发现网上的资料太散 所以搜集整理一下 方便以后再用 atof(将字符串转换成浮点型数) atoi(将字符串转换成整型数) atol(将字符串转 ...
- listen 57
Secondhand Smoke Exposure Doubled Asthmatic Kids' Hospital Readmissions If your child has asthma哮喘, ...
- PHP读取xml方法介绍
一,什么是xml,xml有什么用途 XML(Extensible Markup Language)即可扩展标记语言,它与HTML一样,都是SGML(Standard Generalized Marku ...
- POJ2155 Matrix(二维树状数组||区间修改单点查询)
Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row an ...
- HDU4348:To the moon
浅谈主席树:https://www.cnblogs.com/AKMer/p/9956734.html 浅谈标记永久化:https://www.cnblogs.com/AKMer/p/10137227. ...
- hdu 5730 Shell Necklace —— 分治FFT
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5730 DP式:\( f[i] = \sum\limits_{j=1}^{i} f[i-j] * a[j] ...
- 将hive搭建到spark上
1. 首先搭建好spark和hive,参见相关文档 2. 在spark/conf下创建hive-site.xml <configuration> <property> < ...