<?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.cplbusiness.mapper.DataCrkywCpltzdxxDefaultMapper">

        <!-- 通用查询映射结果 -->
        <resultMap id="BaseResultMap" type="com.unis.crk.cplbusiness.entity.DataCrkywCpltzdxxDefault">
                    <id column="DataID" property="DataID" />
                    <result column="UnitID" property="UnitID" />
                    <result column="PeriodID" property="PeriodID" />
                    <result column="RoundID" property="RoundID" />
                    <result column="ModifyDate" property="ModifyDate" />
                    <result column="builder" property="builder" />
                    <result column="UPDATE_TIME" property="updateTime" />
                    <result column="DeptID" property="DeptID" />
                    <result column="SytelInfoID" property="SytelInfoID" />
                    <result column="BuildDate" property="BuildDate" />
                    <result column="editor" property="editor" />
                    <result column="tzdh" property="tzdh" />
                    <result column="kfmc" property="kfmc" />
                    <result column="kfbh" property="kfbh" />
                    <result column="htmc" property="htmc" />
                    <result column="htbh" property="htbh" />
                    <result column="ch" property="ch"/>
                    <result column="chmc" property="chmc"/>
                    <result column="hwh" property="hwh"/>
                    <result column="hwhmc" property="hwhmc"/>
                    <result column="mxpz" property="mxpz" />
                    <result column="rksj" property="rksj" />
                    <result column="sl" property="sl" />
                    <result column="sldx" property="sldx" />
                    <result column="lsrq" property="lsrq" />
                    <result column="dcfy" property="dcfy" />
                    <result column="dj" property="dj" />
                    <result column="bz" property="bz" />
                    <result column="rz" property="rz" />
                    <result column="sf" property="sf" />
                    <result column="zz" property="zz" />
                    <result column="bwskl" property="bwskl" />
                    <result column="kddw" property="kddw" />
                    <result column="kdr" property="kdr" />
                    <result column="kdsj" property="kdsj" />
                    <result column="jhdh" property="jhdh" />
                    <result column="jhdmc" property="jhdmc" />
                    <result column="cazylx" property="cazylx" />
                    <result column="tsdzt" property="tsdzt" />
                    <result column="tzdbm" property="tzdbm" />
                    <result column="thdbm" property="thdbm" />
                    <result column="sysl" property="sysl" />
                    <result column="tzscnf" property="tzscnf" />
                    <result column="tzcd" property="tzcd" />
                    <result column="zxbm" property="zxbm" />
                    <result column="zrbgy" property="zrbgy" />
                    <result column="wcsl" property="wcsl" />
                    <result column="rukushijian" property="rukushijian" />
                    <result column="jhwjh" property="jhwjh" />
                    <result column="qymc" property="qymc" />
                    <result column="xsf" property="xsf" />
                    <result column="jyjg" property="jyjg" />
                    <result column="lspz" property="lspz" />
                    <result column="lsxz" property="lsxz" />
                    <result column="je" property="je" />
                    <result column="lsdj" property="lsdj" />
                    <result column="shr" property="shrmc" />
                    <result column="shsj" property="shsj" />
                    <result column="shzt" property="shzt" />
                    <result column="jsfs" property="jsfs" />
                    <result column="frrq" property="frrq" />
                    <result column="shbz" property="shbz" />
                    <result column="qylx" property="qylx" />
                    <result column="scqysx" property="scqysx" />
                    <result column="kdmc" property="kdmc" />
                    <result column="cksl" property="cksl" />
                    <result column="xsdj" property="xsdj" />
                    <result column="sjxsdj" property="sjxsdj" />
                    <result column="xssr" property="xssr" />
                    <result column="ncksj" property="ncksj" />
                    <result column="jssj" property="jssj" />
                    <result column="zjbh" property="zjbh" />
                    <result column="zxwjh" property="zxwjh" />
                    <result column="jgmc" property="jgmc" />
                    <result column="hlbs" property="hlbs" />
                    <result column="wlgsmc" property="wlgsmc" />
                    <result column="hkzh" property="hkzh" />
                    <result column="js" property="js" />
                    <result column="ckyy" property="ckyy" />
                    <result column="hknhlsj" property="hknhlsj" />
                    <result column="xscb" property="xscb" />
                    <result column="bwtdw" property="bwtdw" />
                    <result column="bwtdwmc" property="bwtdwmc" />
                    <result column="hlhk_update_time" property="hlhkUpdateTime" />
                    <result column="FLOW_ID" property="flowId" />
                    <result column="FLOW_STATUS" property="flowStatus" />
        </resultMap>
    <select id="selectMyMapsPage" resultType="java.util.Map">
        SELECT
        tzdbm,
        jhdmc,
        htmc,
        kfmc,
        sl,
        kdr,
        kdsj,
        k.enumName as cazylx,
        cazylx as cazylx_value,
        DataID,
        sysl,
        wcsl,
        tsdzt
        FROM
        data_crkyw_cpltzdxx_default a
        LEFT JOIN basic_enum k on  a.cazylx = k.enumId
        <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
            where  ${ew.sqlSegment}
        </if>
    </select>
    <select id="getCplTzdList" resultType="java.util.Map">
           SELECT DISTINCT
               a.DataID,
               b.DataID AS fltId,
               tzscnf_enum.enumName AS scnf_value,
               b.scnf,
               a.tzdbm,
               tzcd_enum.enumName AS cd_value,
               b.cd,
               lsxz_enum.enumName AS xz_value,
               b.xz,
               b.dj,
               lspz_enum.enumName AS lspz_value,
               b.lspz,
               b.sl,
               b.lsdj,
               lsdj_enum.enumName AS lsdj_value,
               a.kfmc,
               mxpz_enum.sjjlspmc AS mxpz_value,
               b.mxpz,
               b.sjjlppmcbh,
               lspp_enum.enumName AS lspp_value,
               a.jhdmc,
               a.htmc,
               b.sysl,
               a.ch,
                b.ModifyDate,
               chmc_enum.storehouse_name AS chmc,
               a.hwh,
               hwhmc_enum.warehouse_name AS hwhmc,
                a.cazylx,
                b.bzq,
                k.enumName as cazylxmc,
               a.FLOW_ID AS flowId
    FROM
        data_crkyw_cpltzdxx_default a
            LEFT JOIN data_crkyw_cpltzdxx_flt_001 b ON a.DataID = b.MainDataID
            LEFT JOIN basic_enum tzscnf_enum ON tzscnf_enum.enumId = b.scnf
            LEFT JOIN basic_enum tzcd_enum ON tzcd_enum.enumId = b.cd
            LEFT JOIN basic_enum lsxz_enum ON lsxz_enum.enumId = b.xz
            LEFT JOIN basic_enum lspz_enum ON lspz_enum.enumId = b.lspz
            LEFT JOIN basic_enum lsdj_enum ON lsdj_enum.enumId = b.lsdj
            LEFT JOIN basic_enum lspp_enum ON lspp_enum.enumId = b.sjjlppmcbh
            LEFT JOIN data_crkyw_cplsp_default mxpz_enum ON mxpz_enum.sjjlspmcbh =b.mxpz
          and  mxpz_enum.unitId = b.unitId
            LEFT JOIN fl_businessflow c ON c.FlowID = a.FLOW_ID
            LEFT JOIN basic_storehouse chmc_enum  ON chmc_enum.storehouse_id = a.ch
            LEFT JOIN basic_warehouse hwhmc_enum ON hwhmc_enum.warehouse_id = a.hwh
        LEFT JOIN basic_enum k on  a.cazylx = k.enumId
    WHERE
     a.UnitID = #{unitId}
    <if test='zylx != null and zylx != ""'>
        AND a.cazylx = #{zylx}
    </if>
    AND b.sysl > 0
    order by b.ModifyDate desc
    </select>
    <select id="getCplCrkTzdList" resultType="java.util.Map">
        SELECT DISTINCT
        a.DataID,
        a.tzdbm,
        a.kfmc,
        a.kfbh,
        a.jhdmc,
        a.htmc,
        a.sysl,
        a.sl,
        a.cazylx as "cazylx",
        b.enumName AS "cazylxmc",
        a.ModifyDate,
        a.FLOW_ID AS flowId
        FROM
        data_crkyw_cpltzdxx_default a
        LEFT JOIN basic_enum b on  a.cazylx = b.enumId
        WHERE
        a.UnitID = #{unitId}
        <if test='zylx != null and zylx != ""'>
            AND a.cazylx IN (${zylx})
        </if>
        AND a.sysl > 0
        ORDER BY
        a.ModifyDate DESC
    </select>
    <select id="pfPage" resultType="java.util.Map">
        SELECT
        a.tzdbm,
        a.kfmc,
        lx_enum.enumName AS cazylx,
        a.cazylx AS cazylxId,
        a.DataID,
        a.BuildDate
        FROM
        data_crkyw_cpltzdxx_default a
        LEFT JOIN basic_enum lx_enum ON lx_enum.enumId = a.cazylx
        where a.cazylx='3'
        <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
            and   ${ew.sqlSegment}
        </if>
        order  by  a.BuildDate desc
    </select>

</mapper>
