<?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.keystar.plane.inspection.mapper.PhotoResultMapper">


    <select id="queryResultByPhotoId" resultType="com.keystar.plane.inspection.entity.PhotoResultEntity">
        SELECT
            *
        FROM
            kr_photo_result
        WHERE
            photo_id = #{photoId}
    </select>

    <select id="queryFltPVString" resultType="com.keystar.plane.inspection.entity.PhotoResultEntity">
        SELECT DISTINCT
            r.photo_id, array_index
        FROM
			`kr_plane_photo` AS p,
            `kr_photo_result` AS r
        WHERE
			p.id = r.photo_id
		AND
			p.record_id = #{recordId}
		<if test = "type != null">
		     AND `type` = #{type}
        </if>
    </select>

    <select id="queryFltPVPanel" resultType="com.keystar.plane.inspection.entity.PhotoResultEntity">
        SELECT DISTINCT
            r.photo_id, array_index, row_index, column_index
        FROM
			`kr_plane_photo` AS p,
            `kr_photo_result` AS r
        WHERE
			p.id = r.photo_id
		AND
			p.record_id = #{recordId}
        <if test = "type != null">
            AND `type` = #{type}
        </if>
    </select>


    <select id="queryFltPz" resultType="com.keystar.plane.inspection.entity.PlanePhotoEntity">
        SELECT DISTINCT
        p.pz_name
        FROM
        `kr_plane_photo` AS p,
        `kr_photo_result` AS r
        WHERE
        p.id = r.photo_id
        AND
        p.record_id = #{recordId}
        <if test = "type != null">
            AND `type` = #{type}
        </if>
    </select>


    <select id="queryResultByRecordId" resultType="com.keystar.plane.inspection.entity.PhotoResultEntity">
        SELECT
            *
        FROM
            kr_photo_result
        WHERE
            photo_id = #{recoedId}
    </select>
</mapper>