<?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.unis.crk.quality.mapper.QualityCheckitemMapper">

        <!-- 通用查询映射结果 -->
        <resultMap id="BaseResultMap" type="com.unis.crk.quality.entity.QualityCheckitem">
                    <id column="CheckItemID" property="CheckItemID" />
                    <result column="StandardID" property="StandardID" />
                    <result column="FoodGrade" property="FoodGrade" />
                    <result column="CheckCode" property="CheckCode" />
                    <result column="CheckValue" property="CheckValue" />
                    <result column="ddmid" property="ddmid" />
        </resultMap>

    <select id="getCplBzz" resultType="java.util.Map">
       SELECT
        b.enumId,
        b.enumName,
        c.FoodGrade,
        c.StandardID,
        c.CheckCode,
        c.ddmid,
        IFNULL(c.CheckValue,a.CheckValue) as CheckValue
        FROM
            basic_enum b
        inner  JOIN quality_checkitem a  on b.parentId  LIKE '95276%' and b.enumCode LIKE '${lspzCode}%'  AND a.CheckCode = b.enumCode and a.StandardID = #{standardID} and a.FoodGrade = '01'
        inner  JOIN quality_checkitem c  on b.parentId  LIKE '95276%' and b.enumCode LIKE '${lspzCode}%'   AND c.CheckCode = b.enumCode and c.StandardID = #{standardID} and c.FoodGrade = #{lsdjCode}
        ORDER BY
		CheckCode
    </select>

    <select id="getYlBzz" resultType="java.util.Map">
        SELECT
            b.enumId,
            b.enumCode,
            b.enumName,
            a.FoodGrade,
            a.StandardID,
            a.CheckCode,
            a.ddmid
        FROM
            basic_enum b
                INNER JOIN quality_checkitem a ON  b.parentId NOT LIKE '95276%'
                AND a.CheckCode = b.enumCode
                AND a.StandardID =#{standardID}
                AND a.FoodGrade =#{lsdjCode}
        ORDER BY
            CheckCode
    </select>
    <select id="selectMyMapsPage" resultType="java.util.Map">
        SELECT *   FROM  quality_checkitem
        <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
            where  ${ew.sqlSegment}
        </if>
    </select>
</mapper>