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,百度下载安装) # ...
随机推荐
- Vue 数组中更新属性值后,视图不更新,等待其他元素更新后会触发的解决办法
因为 JavaScript 的限制,Vue.js 不能检测到下面数组变化: 直接用索引设置元素,如 vm.items[0] = {}: 修改数据的长度,如 vm.items.length = 0. t ...
- POJ 2497 Strategies
题意:有三个人,Bill, Steve and Linus,他们参加竞赛,给出竞赛的题目和比赛时间,然后给出每道题需要的时间(他们解同一道题花的时间相同),然后他们有不同的策略来做题.每道题的得分为当 ...
- Mybatis中的like模糊查询
1. 参数中直接加入%% param.setUsername("%CD%"); param.setPassword("%11%"); <sel ...
- Python: scikit-image canny 边缘检测
这个用例说明canny 边缘检测的用法 import numpy as np import matplotlib.pyplot as plt from scipy import ndimage as ...
- 1072 Gas Station (30)(30 分)
A gas station has to be built at such a location that the minimum distance between the station and a ...
- 【Lintcode】159.Find Minimum in Rotated Sorted Array
题目: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 ...
- bzoj 4275 Badania naukowe —— DP
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4275 枚举 \( C \) 在 \( A \) 和 \( B \) 中的位置,然后取它前后的 ...
- bzoj 2159 Crash 的文明世界 & hdu 4625 JZPTREE —— 第二类斯特林数+树形DP
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2159 使用公式:\( n^{k} = \sum\limits_{i=0}^{k} S(k,i ...
- ZigBee简介
前言 目前,中国大力推广的物联网是zigbee 应用的主战场,物联网通过智能感知.识别技术与普适计算(我还特意申请了个域名psjs.vip).泛在网络的融合应用,被称为继计算机.互联网之后世界信息产业 ...
- ReSIProcate环境搭建
1首先下载resiprocate-1.6 2取消resiprocate-1.6目录的只读属性 3然后使用Visual Studio 2008打开resiprocate-1.6下的reSIProcate ...