<?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.business.kcgl.mapper.DataKcglQckcDefaultMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.unis.crk.business.kcgl.entity.DataKcglQckcDefault">
        <id column="DataID" property="DataID" />
        <result column="UnitID" property="UnitID" />
        <result column="PeriodID" property="PeriodID" />
        <result column="RoundID" property="RoundID" />
        <result column="builder" property="builder" />
        <result column="UPDATE_TIME" property="updateTime" />
        <result column="BuildDate" property="BuildDate" />
        <result column="editor" property="editor" />
        <result column="ModifyDate" property="ModifyDate" />
        <result column="DeptID" property="DeptID" />
        <result column="SytelInfoID" property="SytelInfoID" />
        <result column="lkmc" property="lkmc" />
        <result column="lkbh" property="lkbh" />
        <result column="hwxz" property="hwxz" />
        <result column="ch" property="ch" />
        <result column="hwh" property="hwh" />
        <result column="pz" property="pz" />
        <result column="mxpz" property="mxpz" />
        <result column="dj" property="dj" />
        <result column="jcrq" property="jcrq" />
        <result column="wjh" property="wjh" />
        <result column="kcsl" property="kcsl" />
        <result column="cjsj" property="cjsj" />
        <result column="cfmc" property="cfmc" />
        <result column="hwmc" property="hwmc" />
        <result column="cd" property="cd" />
        <result column="scnf" property="scnf" />
        <result column="rc" property="rc" />
        <result column="hcph" property="hcph" />
        <result column="bz" property="bz" />
    </resultMap>

    <select id="selectMyMapsPage" resultType="java.util.Map">
        SELECT DISTINCT
        DATA_KCGL_QCKC_DEFAULT.ModifyDate AS "ModifyDate",
        DATA_KCGL_QCKC_DEFAULT.scnf AS "scnf",
        b_0.enumName AS "scnf_value",
        DATA_KCGL_QCKC_DEFAULT.lkbh AS "lkbh",
        DATA_KCGL_QCKC_DEFAULT.rc AS "rc",
        DATA_KCGL_QCKC_DEFAULT.pz AS "pz",
        b_3.enumName AS "pz_value",
        DATA_KCGL_QCKC_DEFAULT.wjh AS "wjh",
        c.warehouse_name AS "hwmc",
        b.storehouse_name AS "cfmc",
        DATA_KCGL_QCKC_DEFAULT.dj AS "dj",
        b_7.enumName AS "dj_value",
        DATA_KCGL_QCKC_DEFAULT.kcsl AS "kcsl",
        DATA_KCGL_QCKC_DEFAULT.hwxz AS "hwxz",
        b_9.enumName AS "hwxz_value",
        DATA_KCGL_QCKC_DEFAULT.DataID AS DataID
        FROM
        DATA_KCGL_QCKC_DEFAULT
        LEFT JOIN basic_enum b_0 ON DATA_KCGL_QCKC_DEFAULT.scnf = b_0.enumId
        LEFT JOIN basic_enum b_3 ON DATA_KCGL_QCKC_DEFAULT.pz = b_3.enumId
        LEFT JOIN basic_enum b_7 ON DATA_KCGL_QCKC_DEFAULT.dj = b_7.enumId
        LEFT JOIN basic_enum b_9 ON DATA_KCGL_QCKC_DEFAULT.hwxz = b_9.enumId
        LEFT JOIN basic_storehouse b  on DATA_KCGL_QCKC_DEFAULT.ch = b.storehouse_id
        LEFT JOIN basic_warehouse c  on DATA_KCGL_QCKC_DEFAULT.hwh = c.warehouse_id
        WHERE
        ifnull(
        DATA_KCGL_QCKC_DEFAULT.SytelInfoID,
        ''
        ) = '4028816964a5eeff0164a76caeab045f'
        AND DATA_KCGL_QCKC_DEFAULT.PeriodID = '12'
        AND DATA_KCGL_QCKC_DEFAULT.RoundId = 0
        <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
            and  ${ew.sqlSegment}
        </if>
    </select>
    <select id="getOneQckc" resultType="java.util.Map">
        SELECT
        a.cjsj AS "cjsj",
        a.pz AS "pz",
        b_0.enumName AS "pz_value",
        a.hwh AS "hwh",
        a.wjh AS "wjh",
        a.hwmc AS "hwmc",
        a.lkmc AS "lkmc",
        a.kcsl AS "kcsl",
        a.scnf AS "scnf",
        b_4.enumName AS "scnf_value",
        a.ch AS "ch",
        a.dj AS "dj",
        a.rc AS "rc",
        a.mxpz AS "mxpz",
        b_1.enumName AS "mxpz_value",
        a.dj AS "dj",
        b_3.enumName AS "dj_value",
        a.lkbh AS "lkbh",
        a.cfmc AS "cfmc",
        a.cd AS "cd",
        b_5.enumName AS "cd_value",
        a.hwxz AS "hwxz",
        b_2.enumName AS "hwxz_value",
        a.bz as "bz",
        a.DataID AS "DataID"
        FROM
        DATA_KCGL_QCKC_DEFAULT a
        LEFT JOIN basic_enum b_0 ON a.pz = b_0.enumId
        LEFT JOIN basic_enum b_1 ON a.mxpz = b_1.enumId
        LEFT JOIN basic_enum b_2 ON a.hwxz = b_2.enumId
        LEFT JOIN basic_enum b_3 ON a.dj = b_3.enumId
        LEFT JOIN basic_enum b_4 ON a.scnf = b_4.enumId
        LEFT JOIN basic_enum b_5 ON a.cd = b_5.enumId
        <where>
            <if test='id != null and id != ""'>
                a.DataID = #{id}
            </if>
        </where>
    </select>
</mapper>