mybatis 查询无结果,SQL查询有结果
public class GzltjCount implements Serializable {
private static final long serialVersionUID = 1L;
private String CId;
private String CName;
private String CDeptId;
private String CDeptName;
private String CCountCun;
private String CCountQu;
/**
* 创建扫描任务的扫描任务
*/
private String CCountCreateScan;
private String CCountDoScan;
private String CCountDoHeyan;
private String CCountUpCl;
/**
* 平均取件天数
*/
private String CAvgQuDay;
/**
* 文件滞留天数
*/
private String CRetentionFileDay;
}
xml
<resultMap id="BaseResultMap" type="com.thunisoft.ssclsz.platform.pojo.GzltjCount">
<!-- WARNING - @mbggenerated This element is automatically generated by
MyBatis Generator, do not modify. -->
<id column="cid" jdbcType="VARCHAR" property="CId" />
<result column="deptName" jdbcType="VARCHAR" property="CDeptName" />
<result column="deptId" jdbcType="VARCHAR" property="CDeptId" />
<result column="countCun" jdbcType="VARCHAR" property="CCountCun" />
<result column="countQu" jdbcType="VARCHAR" property="CCountQu" />
<result column="countCreateScan" jdbcType="VARCHAR" property="CCountCreateScan" />
<result column="countDoScan" jdbcType="VARCHAR" property="CCountDoScan" />
<result column="countDoHy" jdbcType="VARCHAR" property="CCountDoHeyan" />
<result column="countUpCl" jdbcType="VARCHAR" property="CCountUpCl" />
<result column="countAvg" jdbcType="VARCHAR" property="CAvgQuDay" />
<result column="countRetention" jdbcType="VARCHAR" property="CRetentionFileDay" />
</resultMap>
<select id="selectZlForDept" resultMap="BaseResultMap" parameterType="java.util.Map">
SELECT
foo.c_id AS "cid",
SUM (FIRST) AS "countCun",
SUM (SECOND) AS "countQu",
SUM (third) AS "countAvg",
SUM (forth) AS "countRetention"
FROM
(
SELECT
t_court_user.c_id,
COUNT (1) AS "first",
0 AS "second",
0 AS "third",
0 AS "forth"
FROM
t_szxx_history
LEFT JOIN t_court_user ON c_input_user_id = t_court_user.c_id
WHERE
c_input_user_id IS NOT NULL
AND c_input_user_id != ''
AND d_cfsj BETWEEN '2017-04-20'
AND '2019-04-20'
AND c_js_dept_id = '157286457'
GROUP BY
t_court_user.c_id
UNION ALL
SELECT
t_court_user.c_id,
0,
COUNT (1),
0,
0
FROM
t_szxx_history
LEFT JOIN t_court_user ON c_output_user_id = t_court_user.c_id
WHERE
c_output_user_id IS NOT NULL
AND c_output_user_id != ''
AND d_cfsj BETWEEN '2017-04-20'
AND '2019-04-20'
AND c_js_dept_id = '157286457'
GROUP BY
t_court_user.c_id
UNION ALL
SELECT
t_court_user.c_id,
0,
0,
SUM (
date_part(
'day',
t_szxx_history.d_cfsj :: TIMESTAMP - t_szxx_history.d_update :: TIMESTAMP
) + 1
) / COUNT (1),
MAX (
date_part(
'day',
t_szxx_history.d_cfsj :: TIMESTAMP - t_szxx_history.d_update :: TIMESTAMP
) + 1
)
FROM
t_szxx_history
LEFT JOIN t_court_user ON c_input_user_id = t_court_user.c_id
WHERE
t_szxx_history.d_cfsj BETWEEN '2017-04-20'
AND '2019-04-20'
AND c_js_dept_id = '157286457'
AND t_szxx_history.n_zt = 4
AND t_szxx_history.c_input_user_id IS NOT NULL
AND t_szxx_history.c_input_user_id != ''
GROUP BY
t_court_user.c_id
) AS foo
GROUP BY c_id
</select>
实现层
public List<GzltjCount> selectZlForDept(Timestamp alarmStartTime,
Timestamp alarmEndTime, String column, String sort) {
Map<String, Object> selectInfo = new HashMap<String, Object>();
selectInfo.put("alarmStartTime", alarmStartTime);
selectInfo.put("alarmEndTime", alarmEndTime);
selectInfo.put("column", column);
selectInfo.put("sort", sort);
List<GzltjCount> list = szxxCountMapper.selectZlForDept(selectInfo);
return list;
}
相关推荐
自己整合的SpringMVC+Mybatis+easyUI完整项和sql查询结果
自己的SpringMVC+Mybatis+easyUI项目整合示例代码,后台运用easyUI,以及sql查询结果,仅供参考。
深入剖析MyBatis SQL执行流程:从配置到查询结果的全程追踪
本文深入分析了MyBatis执行SQL的整个流程,从SqlSessionFactory的创建到SQL语句的执行,揭示了MyBatis工作的内部机制。首先,通过SqlSessionFactoryBuilder,MyBatis解析配置文件生成Configuration对象,并创建SqlSessionFactory。SqlSessionFactory负责生成SqlSession,SqlSession是与数据库交互的主要接口。在SqlSession中,通过动态代理机制获取Mapper对象。这些Mapper对象是通过MapperProxyFactory生成的,负责将接口方法调用转换为SQL语句的执行。 当执行Mapper方法时,MyBatis使用MapperProxy的invoke方法创建或获取缓存的MapperMethod对象。MapperMethod负责判断SQL操作类型(增删改查)并执行相应操作。在此过程中,Executor组件发挥关键作用,它封装了JDBC操作,管理SQL语句的生成和查询缓存的维护。Executor根据配置可分为SimpleExecutor、ReuseExecutor
基于SpringJDBC的轻量级ORM框架FastSQL-支持SQL构建与执行-命名参数绑定-查询结果自动映射-通用DAO工具-结合Hibernate快速开发与Mybatis高效执.zip
基于SpringJDBC的轻量级ORM框架FastSQL_支持SQL构建与执行_命名参数绑定_查询结果自动映射_通用DAO工具_结合Hibernate快速开发与Mybatis高效执.zip毕业设计课题--智能农业管理系统
mybatis查询入门(log4j控制台sql语句日记输出的)
NULL 博文链接:https://wangxuehui.iteye.com/blog/1636946
MyBatis模糊查询
MyBatis模糊查询


Java SE
