<?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.qcrk.mapper.DataCrkywCmzDefaultMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.unis.crk.business.qcrk.entity.DataCrkywCmzDefault">
        <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="SytelInfoID" property="SytelInfoID" />
        <result column="BuildDate" property="BuildDate" />
        <result column="editor" property="editor" />
        <result column="ModifyDate" property="ModifyDate" />
        <result column="DeptID" property="DeptID" />
        <result column="BizNo" property="BizNo" />
        <result column="PreOrder" property="PreOrder" />
        <result column="ShowOrder" property="ShowOrder" />
        <result column="cmzsj" property="cmzsj" />
        <result column="nrchID" property="nrchID" />
        <result column="jjdh" property="jjdh" />
        <result column="mz" property="mz" />
        <result column="mjy" property="mjy" />
        <result column="nrhwID" property="nrhwID" />
        <result column="nrchbh" property="nrchbh" />
        <result column="nrhwbh" property="nrhwbh" />
        <result column="ywdh" property="ywdh" />
        <result column="rzdh" property="rzdh" />
        <result column="lypz" property="lypz" />
        <result column="zt" property="zt" />
        <result column="djr" property="djr" />
        <result column="zcrq" property="zcrq" />
        <result column="qcph" property="qcph" />
        <result column="zcjs" property="zcjs" />
        <result column="zyz" property="zyz" />
        <result column="bz" property="bz" />
        <result column="lsxz" property="lsxz" />
        <result column="cllx" property="cllx" />
        <result column="jhdbh" property="jhdbh" />
        <result column="htbh" property="htbh" />
        <result column="tzdbh" property="tzdbh" />
        <result column="slrsfzh" property="slrsfzh" />
        <result column="ywdjsj" property="ywdjsj" />
        <result column="ywlx" property="ywlx" />
        <result column="tzdid" property="tzdid" />
        <result column="jhdid" property="jhdid" />
        <result column="slr" property="slr" />
        <result column="cph" property="cph" />
        <result column="khdz" property="khdz" />
        <result column="glhcph" property="glhcph" />
        <result column="hw" property="hw" />
        <result column="khmc" property="khmc" />
        <result column="zyd" property="zyd" />
        <result column="xcx" property="xcx" />
        <result column="zycx" property="zycx" />
        <result column="lspz" property="lspz" />
        <result column="rmdh" property="rmdh" />
        <result column="cyr" property="cyr" />
        <result column="cyrlxdh" property="cyrlxdh" />
        <result column="sczcczzl" property="sczcczzl" />
        <result column="sqbh" property="sqbh" />
        <result column="dclx" property="dclx" />
        <result column="dcjhwjbh" property="dcjhwjbh" />
        <result column="sglryy" property="sglryy" />
        <result column="cpdw" property="cpdw" />
    </resultMap>
    <select id="getPerData" resultType="java.util.Map">
SELECT DISTINCT
	DATA_CRKYW_RMDJ_DEFAULT.ModifyDate AS "ModifyDate",
	DATA_CRKYW_RMDJ_DEFAULT.BizNo AS "BizNo",
	DATA_CRKYW_JYXX_DEFAULT.lsdj AS "lsdj",
	b_1.enumName AS "lsdj_value",
	DATA_CRKYW_RMDJ_DEFAULT.tzdbh AS "tzdbh",
	DATA_CRKYW_RMDJ_DEFAULT.slr AS "slr",
	DATA_CRKYW_RMDJ_DEFAULT.cph AS "cph",
	DATA_CRKYW_RMDJ_DEFAULT.cyr AS "cyr",
	DATA_CRKYW_RMDJ_DEFAULT.lspz AS "lspz",
	b_6.enumName AS "lspz_value",
	DATA_CRKYW_JYXX_DEFAULT.jysj AS "jysj",
	DATA_CRKYW_RMDJ_DEFAULT.cyrlxdh AS "cyrlxdh",
	DATA_CRKYW_JYXX_DEFAULT.jydh AS "jydh",
	DATA_CRKYW_RMDJ_DEFAULT.cydw AS "cydw",
	x.*
FROM
	DATA_CRKYW_RMDJ_DEFAULT
LEFT JOIN DATA_CRKYW_JYXX_DEFAULT ON DATA_CRKYW_RMDJ_DEFAULT.BizNo = DATA_CRKYW_JYXX_DEFAULT.BizNo
LEFT JOIN basic_enum b_1 ON DATA_CRKYW_JYXX_DEFAULT.lsdj = b_1.enumId
LEFT JOIN basic_enum b_6 ON DATA_CRKYW_RMDJ_DEFAULT.lspz = b_6.enumId
RIGHT JOIN (
	SELECT DISTINCT
		a.BillNo AS "BillNo",
		a.TrailID "TrailID",
		c.StepID AS "stepidtop",
		a.ShowOrder,
		c.StepName "StepName",
		b.stepid,
		a.Builder "Builder",
		1 AS "operation",
		a. STATUS,
		a.note
	FROM
		bizflowtrail a
	INNER JOIN fl_businessflow d ON a.FlowID = d.FlowID
	LEFT JOIN fl_businessflow_step b ON a.NextBizNodeID = b.StepID
	AND a.FlowID = b.FlowID
	LEFT JOIN fl_businessflow_step c ON a.CurBizNodeID = c.StepID
	AND b.FlowID = c.FlowID
	WHERE
		a. STATUS IN (0, 2)
	AND a.NextBizNodeID = '4'
	AND d.FLOWTYPE = '01'
	AND a.UnitID = #{ew.unitId}
) x ON x.BillNo = DATA_CRKYW_RMDJ_DEFAULT.BizNo
WHERE
	1 = 1
AND DATA_CRKYW_RMDJ_DEFAULT.PeriodID = '11'
AND DATA_CRKYW_RMDJ_DEFAULT.UnitId = #{ew.unitId}
AND DATA_CRKYW_RMDJ_DEFAULT.RoundId = 0
ORDER BY
	DATA_CRKYW_RMDJ_DEFAULT.ModifyDate DESC

    </select>
    <select id="selectMyMapsPage" resultType="java.util.Map">
        SELECT DISTINCT
        DATA_CRKYW_CMZ_DEFAULT.ModifyDate AS "ModifyDate",
        DATA_CRKYW_RMDJ_DEFAULT.cph AS "cph",
        DATA_CRKYW_RMDJ_DEFAULT.slr AS "slr",
        DATA_CRKYW_RMDJ_DEFAULT.cyr AS "cyr",
        DATA_CRKYW_RMDJ_DEFAULT.cydw AS "cydw",
        DATA_CRKYW_RMDJ_DEFAULT.lspz AS "lspz",
        b_4.enumName AS "lspz_value",
        DATA_CRKYW_CMZ_DEFAULT.BizNo AS "BizNo",
        DATA_CRKYW_CMZ_DEFAULT.sglryy AS "sglryy",
        DATA_CRKYW_CMZ_DEFAULT.nrhwbh AS "nrhwbh",
        DATA_CRKYW_CMZ_DEFAULT.nrchID AS "nrchID",
        DATA_CRKYW_CMZ_DEFAULT.nrchbh AS "nrchbh",
        DATA_CRKYW_CMZ_DEFAULT.mjy AS "mjy",
        DATA_CRKYW_CMZ_DEFAULT.mz AS "mz",
        DATA_CRKYW_CMZ_DEFAULT.cmzsj AS "cmzsj",
        DATA_CRKYW_CMZ_DEFAULT.DataID AS DataID
        FROM
        DATA_CRKYW_RMDJ_DEFAULT
        LEFT JOIN DATA_CRKYW_CMZ_DEFAULT ON DATA_CRKYW_RMDJ_DEFAULT.BizNo = DATA_CRKYW_CMZ_DEFAULT.BizNo
        LEFT JOIN basic_enum b_4 ON DATA_CRKYW_RMDJ_DEFAULT.lspz = b_4.enumId
        WHERE
        ifnull(
        DATA_CRKYW_CMZ_DEFAULT.SytelInfoID,
        ''
        ) = '4028814763a546b20163a9c8ca7a0002'
        AND DATA_CRKYW_CMZ_DEFAULT.PeriodID = '11'
        AND DATA_CRKYW_CMZ_DEFAULT.RoundId = 0
        <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
            and ${ew.sqlSegment}
        </if>
    </select>
    <select id="getOne" resultType="java.util.Map">
        SELECT
        a.tzdcbid AS "tzdcbid",
        a.cydw AS "cydw",
        a.cph AS "cph",
        a.slrsfzh AS "slrsfzh",
        a.cllx AS "cllx",
        a.slr AS "slr",
        a.slrdz AS "slrdz",
        a.tzdbh AS "tzdbh",
        a.lsxz AS "lsxz",
        f.enumName AS "lsxz_value",
        a.slrdh AS "slrdh",
        a.lspz AS "lspz",
        d.enumName AS "lspz_value",
        b.jybz AS "jybz",
        c.nrhwID AS "nrhwID",
        c.sglryy AS "sglryy",
        c.BizNo AS "BizNo",
        c.jjdh AS "jjdh",
        c.mjy AS "mjy",
        c.nrchID AS "nrchID",
        c.nrhwbh AS "nrhwbh",
        c.mz AS "mz",
        c.cmzsj AS "cmzsj",
        c.nrchbh AS "nrchbh",
        c.DataID AS "DataID"
        FROM
        DATA_CRKYW_RMDJ_DEFAULT a
        LEFT JOIN DATA_CRKYW_JYXX_DEFAULT b ON a.BizNo = b.BizNo
        LEFT JOIN DATA_CRKYW_CMZ_DEFAULT c ON a.BizNo = c.BizNo
        LEFT JOIN basic_enum d ON a.lspz = d.enumId
        LEFT JOIN basic_enum f ON a.lsxz = f.enumId
        <where>
            <if test='id != null and id != ""'>
                and c.DataID = #{id}
            </if>
            <if test='bizNo != null and bizNo != ""'>
                and a.bizNo = #{bizNo}
            </if>

        </where>
    </select>
</mapper>