<?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.qcck.mapper.DataCrkywCkcmzDefaultMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.unis.crk.business.qcck.entity.DataCrkywCkcmzDefault">
        <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="jjdh" property="jjdh" />
        <result column="sjckch" property="sjckch" />
        <result column="sjhwh" property="sjhwh" />
        <result column="xldd" property="xldd" />
        <result column="ckbzfs" property="ckbzfs" />
        <result column="bzwdjzl" property="bzwdjzl" />
        <result column="js" property="js" />
        <result column="bzwkl" property="bzwkl" />
        <result column="mz" property="mz" />
        <result column="klhjz" property="klhjz" />
        <result column="jmsj" property="jmsj" />
        <result column="mjy" property="mjy" />
        <result column="zyf" property="zyf" />
        <result column="zykssj" property="zykssj" />
        <result column="zyjssj" property="zyjssj" />
        <result column="ccbz" property="ccbz" />
        <result column="bgy" property="bgy" />
        <result column="xczl" property="xczl" />
        <result column="sjckchmc" property="sjckchmc" />
        <result column="sjhwhmc" property="sjhwhmc" />
        <result column="cktzdh_cmz" property="cktzdhCmz" />
        <result column="zcsj" property="zcsj" />
        <result column="zyd" property="zyd" />
        <result column="zyz" property="zyz" />
        <result column="ywdh" property="ywdh" />
        <result column="thdh" property="thdh" />
        <result column="khmc" property="khmc" />
        <result column="glhcph" property="glhcph" />
        <result column="lypz" property="lypz" />
        <result column="qcph" property="qcph" />
        <result column="cyr" property="cyr" />
        <result column="lxdh" property="lxdh" />
        <result column="cyrsfzh" property="cyrsfzh" />
        <result column="xzjs" property="xzjs" />
        <result column="thjs" property="thjs" />
        <result column="djr" property="djr" />
        <result column="zcrq" property="zcrq" />
        <result column="zt" property="zt" />
        <result column="hw" property="hw" />
        <result column="ggxh" property="ggxh" />
        <result column="djzl" property="djzl" />
        <result column="zcjs" property="zcjs" />
        <result column="zczl" property="zczl" />
        <result column="syjs" property="syjs" />
        <result column="rzdh" property="rzdh" />
        <result column="bz" property="bz" />
        <result column="bzbdbz" property="bzbdbz" />
        <result column="jhapbh" property="jhapbh" />
        <result column="jpyyj" property="jpyyj" />
        <result column="jpy" property="jpy" />
        <result column="cksxh" property="cksxh" />
        <result column="sglryy" property="sglryy" />
        <result column="lldbh" property="lldbh" />
    </resultMap>


    <select id="getPerData" resultType="java.util.Map">
SELECT DISTINCT
	DATA_CRKYW_CKRMDJ_DEFAULT.ModifyDate AS "ModifyDate",
	DATA_CRKYW_CKRMDJ_DEFAULT.cph AS "cph",
	DATA_CRKYW_CKRMDJ_DEFAULT.lspz AS "lspz",
	b_1.enumName AS "lspz_value",
	DATA_CRKYW_CKRMDJ_DEFAULT.cydw AS "cydw",
	DATA_CRKYW_CKRMDJ_DEFAULT.cyr AS "cyr",
	DATA_CRKYW_CKRMDJ_DEFAULT.cyrdh AS "cyrdh",
	DATA_CRKYW_CKCPZ_DEFAULT.BizNo AS "BizNo",
	DATA_CRKYW_CKRMDJ_DEFAULT.tzdbh AS "tzdbh",
	DATA_CRKYW_CKCPZ_DEFAULT.nchwbh AS "nchwbh",
	DATA_CRKYW_CKRMDJ_DEFAULT.slr AS "slr",
	DATA_CRKYW_CKCPZ_DEFAULT.ncchbh AS "ncchbh",
	x.*
FROM
	DATA_CRKYW_CKRMDJ_DEFAULT
LEFT JOIN DATA_CRKYW_CKCPZ_DEFAULT ON DATA_CRKYW_CKRMDJ_DEFAULT.BizNo = DATA_CRKYW_CKCPZ_DEFAULT.BizNo
LEFT JOIN basic_enum b_1 ON DATA_CRKYW_CKRMDJ_DEFAULT.lspz = b_1.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 = '3'
	AND d.FLOWTYPE = '04'
	AND a.UnitID = #{ew.unitId}
) x ON x.BillNo = DATA_CRKYW_CKRMDJ_DEFAULT.BizNo
AND DATA_CRKYW_CKCPZ_DEFAULT.ShowOrder = x.ShowOrder
WHERE
	1 = 1
AND DATA_CRKYW_CKRMDJ_DEFAULT.PeriodID = '11'
AND DATA_CRKYW_CKRMDJ_DEFAULT.UnitId = #{ew.unitId}
AND DATA_CRKYW_CKRMDJ_DEFAULT.RoundId = 0
ORDER BY
	DATA_CRKYW_CKRMDJ_DEFAULT.ModifyDate DESC
    </select>
    <select id="selectMyMapsPage" resultType="java.util.Map">
        SELECT DISTINCT
        DATA_CRKYW_CKCMZ_DEFAULT.ModifyDate AS "ModifyDate",
        DATA_CRKYW_CKCMZ_DEFAULT.BizNo AS "BizNo",
        DATA_CRKYW_CKCMZ_DEFAULT.sjckchmc AS "sjckchmc",
        DATA_CRKYW_CKCMZ_DEFAULT.sjhwhmc AS "sjhwhmc",
        DATA_CRKYW_CKCMZ_DEFAULT.klhjz AS "klhjz",
        DATA_CRKYW_CKCMZ_DEFAULT.jmsj AS "jmsj",
        DATA_CRKYW_CKCMZ_DEFAULT.sglryy AS "sglryy",
        DATA_CRKYW_CKCMZ_DEFAULT.mjy AS "mjy",
        DATA_CRKYW_CKCMZ_DEFAULT.mz AS "mz",
        DATA_CRKYW_CKRMDJ_DEFAULT.cyr AS "cyr",
        DATA_CRKYW_CKRMDJ_DEFAULT.cydw AS "cydw",
        DATA_CRKYW_CKRMDJ_DEFAULT.lspz AS "lspz",
        b_10.enumName AS "lspz_value",
        DATA_CRKYW_CKRMDJ_DEFAULT.slr AS "slr",
        DATA_CRKYW_CKRMDJ_DEFAULT.cph AS "cph",
        DATA_CRKYW_CKCPZ_DEFAULT.pz AS "pz",
        DATA_CRKYW_CKCMZ_DEFAULT.DataID AS DataID
        FROM
        DATA_CRKYW_CKCMZ_DEFAULT
        LEFT JOIN DATA_CRKYW_CKRMDJ_DEFAULT ON DATA_CRKYW_CKRMDJ_DEFAULT.BizNo = DATA_CRKYW_CKCMZ_DEFAULT.BizNo
        LEFT JOIN DATA_CRKYW_CKCPZ_DEFAULT ON DATA_CRKYW_CKCPZ_DEFAULT.BizNo = DATA_CRKYW_CKCMZ_DEFAULT.BizNo
        LEFT JOIN basic_enum b_10 ON DATA_CRKYW_CKRMDJ_DEFAULT.lspz = b_10.enumId
        WHERE
        ifnull(
        DATA_CRKYW_CKCMZ_DEFAULT.SytelInfoID,
        ''
        ) = '4028814763a546b20163ab30b98f0024'
        AND DATA_CRKYW_CKCMZ_DEFAULT.PeriodID = '11'
        AND DATA_CRKYW_CKCMZ_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.slr AS "slr",
        a.tzdID AS "tzdID",
        a.cph AS "cph",
        a.cyr AS "cyr",
        a.tzdbh AS "tzdbh",
        a.cydw AS "cydw",
        a.cllx AS "cllx",
        a.lspz AS "lspz",
        b.jjdh AS "jjdh",
        b.ycchID AS "ycchID",
        b.pz AS "pz",
        b.ncchbh AS "ncchbh",
        b.ychwID AS "ychwID",
        b.nchwbh AS "nchwbh",
        c.jpy AS "jpy",
        c.sglryy AS "sglryy",
        c.xczl AS "xczl",
        c.bgy AS "bgy",
        c.zyz AS "zyz",
        c.mz AS "mz",
        c.bz AS "bz",
        c.ckbzfs AS "ckbzfs",
        c.zyjssj AS "zyjssj",
        c.klhjz AS "klhjz",
        c.cksxh AS "cksxh",
        c.zykssj AS "zykssj",
        c.lldbh AS "lldbh",
        c.cktzdh_cmz AS "cktzdh_cmz",
        c.jhapbh AS "jhapbh",
        c.BizNo AS "BizNo",
        c.zyd AS "zyd",
        c.bzwkl AS "bzwkl",
        c.sjckchmc AS "sjckchmc",
        c.sjckch AS "sjckch",
        c.bzbdbz AS "bzbdbz",
        c.jmsj AS "jmsj",
        c.sjhwh AS "sjhwh",
        c.js AS "js",
        c.sjhwhmc AS "sjhwhmc",
        c.jpyyj AS "jpyyj",
        c.mjy AS "mjy",
        b_5.enumName AS "cllx_value",
        c.DataID AS "DataID"
        FROM
        DATA_CRKYW_CKRMDJ_DEFAULT a
        LEFT JOIN DATA_CRKYW_CKCPZ_DEFAULT b ON a.BizNo = b.BizNo
        LEFT JOIN DATA_CRKYW_CKCMZ_DEFAULT c ON a.BizNo = c.BizNo
        LEFT JOIN basic_enum b_5 ON a.cllx = b_5.enumId
        <where>
            <if test='id != null and id != ""'>
                c.DataID = #{id}
            </if>
            <if test='bizNo != null and bizNo != ""'>
               and a.bizNo = #{bizNo}
            </if>

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