<?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.DataCrkywJsxxDefaultMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.unis.crk.business.qcrk.entity.DataCrkywJsxxDefault">
        <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="jsy" property="jsy" />
        <result column="zjsjk" property="zjsjk" />
        <result column="yfje" property="yfje" />
        <result column="hhyhmc" property="hhyhmc" />
        <result column="lxdh" property="lxdh" />
        <result column="cllx" property="cllx" />
        <result column="hfyhhb" property="hfyhhb" />
        <result column="smlkj" property="smlkj" />
        <result column="xckz" property="xckz" />
        <result column="jsdh" property="jsdh" />
        <result column="yhkh" property="yhkh" />
        <result column="yfjedx" property="yfjedx" />
        <result column="zsf" property="zsf" />
        <result column="jsdj" property="jsdj" />
        <result column="xzzl" property="xzzl" />
        <result column="jszl" property="jszl" />
        <result column="mlrqz" property="mlrqz" />
        <result column="fky" property="fky" />
        <result column="jssj" property="jssj" />
        <result column="jjdh" property="jjdh" />
        <result column="zsfzz" property="zsfzz" />
        <result column="khmc" property="khmc" />
        <result column="khzzh" property="khzzh" />
        <result column="khlxdh" property="khlxdh" />
        <result column="khhh" property="khhh" />
        <result column="fphm" property="fphm" />
        <result column="fpzt" property="fpzt" />
        <result column="jsfs" property="jsfs" />
        <result column="jjjydbh" property="jjjydbh" />
        <result column="skr" property="skr" />
        <result column="lldbh" property="lldbh" />
    </resultMap>
    <select id="getPerData" resultType="java.util.Map">
 SELECT
	DATA_CRKYW_RMDJ_DEFAULT.ywdjsj AS "ywdjsj",
	DATA_CRKYW_RMDJ_DEFAULT.cyrlxdh AS "cyrlxdh",
	DATA_CRKYW_RMDJ_DEFAULT.BizNo AS "bizNo",
	DATA_CRKYW_RMDJ_DEFAULT.cph AS "cph",
	DATA_CRKYW_RMDJ_DEFAULT.lspz AS "lspz",
	b_4.enumName AS "lspz_value",
	DATA_CRKYW_RMDJ_DEFAULT.tzdbh AS "tzdbh",
	DATA_CRKYW_RMDJ_DEFAULT.slr AS "slr",
	DATA_CRKYW_RMDJ_DEFAULT.cyr AS "cyr",
	DATA_CRKYW_RMDJ_DEFAULT.djr AS "djr",
	x.*
FROM
	DATA_CRKYW_RMDJ_DEFAULT
LEFT JOIN basic_enum b_4 ON  DATA_CRKYW_RMDJ_DEFAULT.lspz = b_4.enumId
RIGHT JOIN (
	SELECT DISTINCT
		a.BillNo,
		a.TrailID AS "TrailID",
		c.StepID AS "StepIDTop",
		a.ShowOrder AS "ShowOrder",
		c.StepName AS "StepName",
		b.StepID AS "StepID",
		a.Builder AS "Builder",
		A.BuildDate AS "buildDate",
		1 AS "operation",
		a.STATUS AS "status "
	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
		(
			ifnull(a. STATUS, 0) = 0
			OR ifnull(a. STATUS, 0) = 2
		)
	AND a.NextBizNodeID = '6'
	AND a.UnitID = #{ew.unitId}
	AND d.FLOWTYPE = '01'
	ORDER BY
		buildDate DESC
) 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.buildDate DESC
    </select>
    <select id="selectMyMapsPage" resultType="java.util.Map">
        SELECT DISTINCT
        DATA_CRKYW_JSXX_DEFAULT.ModifyDate AS "ModifyDate",
        DATA_CRKYW_RMDJ_DEFAULT.cyr AS "cyr",
        DATA_CRKYW_RMDJ_DEFAULT.cph AS "cph",
        DATA_CRKYW_RMDJ_DEFAULT.slr AS "slr",
        DATA_CRKYW_RMDJ_DEFAULT.lspz AS "lspz",
        b_3.enumName AS "lspz_value",
        DATA_CRKYW_CMZ_DEFAULT.mz AS "mz",
        DATA_CRKYW_CPZ_DEFAULT.pz AS "pz",
        DATA_CRKYW_CPZ_DEFAULT.cpzsj AS "cpzsj",
        DATA_CRKYW_CPZ_DEFAULT.xzklhjz AS "xzklhjz",
        DATA_CRKYW_CPZ_DEFAULT.sjhwbh AS "sjhwbh",
        DATA_CRKYW_CPZ_DEFAULT.sjcfbh AS "sjcfbh",
        DATA_CRKYW_JSXX_DEFAULT.jssj AS "jssj",
        DATA_CRKYW_JSXX_DEFAULT.BizNo AS "BizNo",
        DATA_CRKYW_JSXX_DEFAULT.jsdh AS "jsdh",
        DATA_CRKYW_JSXX_DEFAULT.jsy AS "jsy",
        DATA_CRKYW_JSXX_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 DATA_CRKYW_CPZ_DEFAULT ON DATA_CRKYW_RMDJ_DEFAULT.BizNo = DATA_CRKYW_CPZ_DEFAULT.BizNo
        AND DATA_CRKYW_CPZ_DEFAULT.ShowOrder = DATA_CRKYW_CMZ_DEFAULT.ShowOrder
        LEFT JOIN DATA_CRKYW_JSXX_DEFAULT ON DATA_CRKYW_RMDJ_DEFAULT.BizNo = DATA_CRKYW_JSXX_DEFAULT.BizNo
        LEFT JOIN basic_enum b_3 ON DATA_CRKYW_RMDJ_DEFAULT.lspz = b_3.enumId
        WHERE
        1 = 1
        AND ifnull(
        DATA_CRKYW_JSXX_DEFAULT.SytelInfoID,
        ''
        ) = '4028814763a546b20163aa64378d0008'
        AND DATA_CRKYW_JSXX_DEFAULT.PeriodID = '11'
        AND DATA_CRKYW_JSXX_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.mxpz AS "mxpz",
        a.hfyhhb AS "hfyhhb",
        a.slrdh AS "slrdh",
        a.cph AS "cph",
        a.lsxz AS "lsxz",
        a.slrsfzh AS "slrsfzh",
        a.cd AS "cd",
        a.lspz AS "lspz",
        a.slr AS "slr",
        a.scnf AS "scnf",
        b.lsdj AS "lsdj",
        b.dj AS "dj",
        c.xzzl AS "xzzl",
        d.khhh AS "khhh",
        d.jsdj AS "jsdj",
        d.BizNo AS "BizNo",
        d.lldbh AS "lldbh",
        d.zjsjk AS "zjsjk",
        d.jszl AS "jszl",
        d.hhyhmc AS "hhyhmc",
        d.khzzh AS "khzzh",
        d.zsf AS "zsf",
        d.zsfzz AS "zsfzz",
        d.khmc AS "khmc",
        d.jsfs AS "jsfs",
        d.jssj AS "jssj",
        d.jsy AS "jsy",
        d.fpzt AS "fpzt",
        d.yfje AS "yfje",
        d.hfyhhb AS "hfyhhb",
        d.smlkj AS "smlkj",
        d.khlxdh AS "khlxdh",
        d.jsdh AS "jsdh",
        d.yfjedx AS "yfjedx",
        d.skr AS "skr",
        d.yhkh AS "yhkh",
        d.khmc AS "khmc",
        d.fphm AS "fphm",
        d.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_CPZ_DEFAULT c ON a.BizNo = c.BizNo
        LEFT JOIN DATA_CRKYW_JSXX_DEFAULT d ON a.BizNo = d.BizNo
        <where>
            <if test='id != null and id != ""'>
                d.DataID = #{id}
            </if>
            <if test='bizNo != null and bizNo != ""'>
              and  a.bizNo = #{bizNo}
            </if>
        </where>
    </select>
</mapper>