<?xml version="1.0" encoding="UTF-8" ?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<mapper namespace="com.gk.hotwork.Mapper.ReserveMapper" >
|
<resultMap id="BaseResultMap" type="com.gk.hotwork.Domain.Reserve" >
|
<!-- -->
|
<id column="id" property="id" jdbcType="BIGINT" />
|
<result column="space" property="space" jdbcType="INTEGER" />
|
<result column="hoisting" property="hoisting" jdbcType="INTEGER" />
|
<result column="soild" property="soild" jdbcType="INTEGER" />
|
<result column="breaks" property="breaks" jdbcType="INTEGER" />
|
<result column="high" property="high" jdbcType="INTEGER" />
|
<result column="electricity" property="electricity" jdbcType="INTEGER" />
|
<result column="blindboard" property="blindboard" jdbcType="INTEGER" />
|
<result column="fire" property="fire" jdbcType="INTEGER" />
|
<result column="appointment" property="appointment" jdbcType="TIMESTAMP" />
|
<result column="createtime" property="createtime" jdbcType="TIMESTAMP" />
|
<result column="updatetime" property="updatetime" jdbcType="TIMESTAMP" />
|
<result column="validflag" property="validflag" jdbcType="TINYINT" />
|
<result column="createby" property="createby" jdbcType="BIGINT" />
|
<result column="createbyname" property="createbyname" jdbcType="VARCHAR" />
|
<result column="updatebyname" property="updatebyname" jdbcType="VARCHAR" />
|
<result column="createbydepartment" property="createbydepartment" jdbcType="VARCHAR" />
|
|
</resultMap>
|
<sql id="Base_Column_List" >
|
<!-- -->
|
id, space, hoisting, soild, breaks, high, electricity, blindboard, fire, appointment,
|
createtime, updatetime, validflag, createby, createbyname, updatebyname,createbydepartment
|
</sql>
|
<select id="statistics" resultType="java.util.Map">
|
|
select
|
department.department,
|
ifnull(reserve.space,0) space,
|
ifnull(reserve.hoisting,0) hoisting,
|
ifnull(reserve.soild,0) soild,
|
ifnull(reserve.breaks,0) breaks,
|
ifnull(reserve.high,0) high,
|
ifnull(reserve.electricity,0) electricity,
|
ifnull(reserve.blindboard,0) blindboard,
|
ifnull(reserve.fire,0) fire,
|
date_format(reserve.appointment,"%Y-%m-%d") appointment
|
from reserve as reserve
|
right join (
|
select d.department
|
from department as d
|
where d.isdel = 0
|
<if test="params.department != null and params.department != ''">
|
and d.department = #{params.department}
|
</if>
|
) as department on department.department = reserve.createbydepartment
|
where reserve.validflag = 1
|
<if test="params.appointment != null and params.appointment != ''">
|
and date(reserve.appointment) = date(#{params.appointment})
|
</if>
|
|
|
|
|
</select>
|
<select id="selectStatisticsTotal" resultType="java.util.Map">
|
|
|
select
|
count(0) department,
|
sum(reserve.space) space,
|
sum(reserve.hoisting) hoisting,
|
sum(reserve.soild) soild,
|
sum(reserve.breaks) breaks,
|
sum(reserve.high) high,
|
sum(reserve.electricity) electricity,
|
sum(reserve.blindboard) blindboard,
|
sum(reserve.fire) fire
|
from (
|
select
|
reserve.createbydepartment ,
|
sum(reserve.space) space,
|
sum(reserve.hoisting) hoisting,
|
sum(reserve.soild) soild,
|
sum(reserve.breaks) breaks,
|
sum(reserve.high) high,
|
sum(reserve.electricity) electricity,
|
sum(reserve.blindboard) blindboard,
|
sum(reserve.fire) fire
|
from reserve as reserve
|
where reserve.validflag = 1
|
<if test="params.appointment != null and params.appointment != ''">
|
and date(reserve.appointment) = date(#{params.appointment})
|
</if>
|
<if test="params.department != null and params.department != ''">
|
and reserve.createbydepartment = #{params.department}
|
</if>
|
group by reserve.createbydepartment) as reserve
|
|
|
|
</select>
|
|
</mapper>
|