12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?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.zhyc.xps.aqpt.mapper.CheckRecordStatisMapper">
- <!-- 按状态统计 -->
- <select id="counterByStatus" parameterType="java.util.Map" resultType="com.zhyc.xps.aqpt.vo.CheckRecordByStatusVo">
- SELECT
- IFNULL(SUM( CASE WHEN A.check_result = 1 THEN 1 ELSE 0 END ), 0) AS 'passed',
- IFNULL(SUM( CASE WHEN A.check_result = -1 THEN 1 ELSE 0 END ), 0) AS 'failed'
- FROM check_record AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
- WHERE 1 = 1
- <if test="ocId != null">
- AND A.oc_id = #{ocId}
- </if>
- <if test="account_id != null">
- AND A.account_id = #{account_id, jdbcType=BIGINT}
- </if>
- <if test="checklistId != null">
- AND A.checklist_id = #{checklistId, jdbcType=BIGINT}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND B.node_left >= #{nodeLeft, jdbcType=BIGINT}
- AND B.node_right <= #{nodeRight, jdbcType=BIGINT}
- ]]>
- </if>
- <if test="day != null">
- AND date_format(A.check_time , '%Y-%m-%d') = #{day}
- </if>
- <if test="startDate != null and endDate != null">
- AND A.check_time BETWEEN #{startDate} and #{endDate}
- </if>
- </select>
- <!-- 按条件统计 -->
- <select id="counterByCondition" resultType="int" parameterType="java.util.Map">
- SELECT
- count( 0 ) AS count
- FROM check_record AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
- WHERE 1 = 1
- <if test="ocId != null">
- AND A.oc_id = #{ocId, jdbcType=BIGINT}
- </if>
- <if test="accountId != null">
- AND A.account_id = #{accountId, jdbcType=BIGINT}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND B.node_left >= #{nodeLeft, jdbcType=BIGINT}
- AND B.node_right <= #{nodeRight, jdbcType=BIGINT}
- ]]>
- </if>
- <if test="day != null">
- AND date_format(A.check_time , '%Y-%m-%d') = #{day}
- </if>
- <if test="startDate != null and endDate != null">
- AND A.check_time BETWEEN #{startDate} and #{endDate}
- </if>
- </select>
- <!-- 按清单统计 -->
- <select id="counterByChecklist" parameterType="java.util.Map" resultType="com.zhyc.xps.aqpt.vo.CheckRecordByChecklistVo">
- SELECT
- A.checklist_id,
- count( 0 ) AS num
- FROM check_record A
- LEFT JOIN s_group B ON ( A.oc_id = B.oc_id AND A.group_id = B.group_id )
- LEFT JOIN checklist C ON ( A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id)
- WHERE 1 = 1
- <if test="ocId != null">
- AND A.oc_id = #{ocId, jdbcType=BIGINT}
- </if>
- <if test="accountId != null">
- AND A.account_id = #{accountId, jdbcType=BIGINT}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND B.node_left >= #{nodeLeft, jdbcType=BIGINT}
- AND B.node_right <= #{nodeRight, jdbcType=BIGINT}
- ]]>
- </if>
- <if test="day != null">
- AND date_format(A.check_time , '%Y-%m-%d') = #{day}
- </if>
- <if test="startDate != null and endDate != null">
- AND A.check_time BETWEEN #{startDate} and #{endDate}
- </if>
- GROUP BY A.checklist_id ASC
- </select>
- </mapper>
|