<?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.lutao.cloud.oil.mapper.ProfEquipmentInfoMapper">


    <select id="getEquipmentTypePie" resultType="com.lutao.cloud.oil.pojo.vo.EquipmentTypePieVO">
        SELECT et.type_name AS equipTypeName, COUNT(*) AS equipTypeNumber
        FROM prof_equipment_info pei
        LEFT JOIN equipment_type et ON pei.prof_equip_type = et.id
        <where>
            <if test="param.platformId != null and param.platformId != ''">
                pei.platform_code = #{param.platformId}
            </if>
            <if test="param.appId != null and param.appId != ''">
                AND pei.app_id = #{param.appId}
            </if>
        </where>
        GROUP BY pei.prof_equip_type
        ORDER BY et.id
    </select>
    <select id="getEquipTypeInpectList" resultType="com.lutao.cloud.oil.pojo.vo.EquipTypeInspectVO">
        SELECT et.type_name AS equipmentType, COUNT(*) AS equipTypeNumber
        FROM prof_equipment_info pei
        LEFT JOIN equipment_type et ON pei.prof_equip_type = et.id
        <where>
            <if test="param.platformId != null and param.platformId != ''">
                pei.platform_code = #{param.platformId}
            </if>
            <if test="param.appId != null and param.appId != ''">
                AND pei.app_id = #{param.appId}
            </if>
            <if test="inspectType != null">
                <choose>
                    <when test="inspectType == 1">
                        AND pei.inspection_type like '%2%'
                    </when>
                    <when test="inspectType == 2">
                        AND pei.inspection_type like '%1%'
                    </when>
                </choose>
            </if>
        </where>
        GROUP BY pei.prof_equip_type
        ORDER BY et.id
    </select>
</mapper>