|
@@ -12,6 +12,11 @@
|
|
|
<result column="water" jdbcType="INTEGER" property="water" />
|
|
|
<result column="electricity" jdbcType="INTEGER" property="electricity" />
|
|
|
</resultMap>
|
|
|
+ <resultMap id="useBean" type="com.shawn.model.Bean.UseBean">
|
|
|
+ <result column="categorie" jdbcType="VARCHAR" property="categorie" />
|
|
|
+ <result column="regularTimes" jdbcType="INTEGER" property="regularTimes" />
|
|
|
+ <result column="randomTimes" jdbcType="DECIMAL" property="randomTimes" />
|
|
|
+ </resultMap>
|
|
|
<sql id="Example_Where_Clause">
|
|
|
<where>
|
|
|
<foreach collection="oredCriteria" item="criteria" separator="or">
|
|
@@ -111,6 +116,53 @@
|
|
|
<include refid="Example_Where_Clause" />
|
|
|
</if>
|
|
|
</delete>
|
|
|
+
|
|
|
+ <!-- 汇总统计-->
|
|
|
+ <select id="getMainStatistics" resultMap="useBean">
|
|
|
+ select 'day' as categorie, sum(IF(a.`type` = '1', 1, 0)) AS randomTimes,sum(IF(a.`type` = '0', 1, 0)) AS regularTimes
|
|
|
+ from t_clean_history a
|
|
|
+ where 1=1
|
|
|
+ <if test="adminId != null and adminId !=''">
|
|
|
+ and a.admin_id= #{adminId}
|
|
|
+ </if>
|
|
|
+ <if test="equipmentId != null and equipmentId !=''">
|
|
|
+ and a.equipment_id= #{equipmentId}
|
|
|
+ </if>
|
|
|
+ and date_format(a.create_date,'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
|
|
|
+ UNION all
|
|
|
+ select 'week' as categorie, sum(IF(a.`type` = '1', 1, 0)) AS randomTimes,sum(IF(a.`type` = '0', 1, 0)) AS regularTimes
|
|
|
+ from t_clean_history a
|
|
|
+ where 1=1
|
|
|
+ <if test="adminId != null and adminId !=''">
|
|
|
+ and a.admin_id= #{adminId}
|
|
|
+ </if>
|
|
|
+ <if test="equipmentId != null and equipmentId !=''">
|
|
|
+ and a.equipment_id= #{equipmentId}
|
|
|
+ </if>
|
|
|
+ and YEARWEEK(date_format(a.create_date,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
|
|
|
+ UNION all
|
|
|
+ select 'month' as categorie, sum(IF(a.`type` = '1', 1, 0)) AS randomTimes,sum(IF(a.`type` = '0', 1, 0)) AS regularTimes
|
|
|
+ from t_clean_history a
|
|
|
+ where 1=1
|
|
|
+ <if test="adminId != null and adminId !=''">
|
|
|
+ and a.admin_id= #{adminId}
|
|
|
+ </if>
|
|
|
+ <if test="equipmentId != null and equipmentId !=''">
|
|
|
+ and a.equipment_id= #{equipmentId}
|
|
|
+ </if>
|
|
|
+ and date_format(a.create_date,'%Y-%m') = date_format(now(),'%Y-%m')
|
|
|
+ UNION all
|
|
|
+ select 'year' as categorie, sum(IF(a.`type` = '1', 1, 0)) AS randomTimes,sum(IF(a.`type` = '0', 1, 0)) AS regularTimes
|
|
|
+ from t_clean_history a
|
|
|
+ where 1=1
|
|
|
+ <if test="adminId != null and adminId !=''">
|
|
|
+ and a.admin_id= #{adminId}
|
|
|
+ </if>
|
|
|
+ <if test="equipmentId != null and equipmentId !=''">
|
|
|
+ and a.equipment_id= #{equipmentId}
|
|
|
+ </if>
|
|
|
+ and date_format(a.create_date,'%Y') = date_format(now(),'%Y')
|
|
|
+ </select>
|
|
|
<insert id="insert" parameterType="com.shawn.model.entity.TCleanHistory">
|
|
|
insert into t_clean_history (id, create_date, modify_date,
|
|
|
type, client_id, admin_id,
|