<?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.mosty.base.manager.mapper.TbJcglJzMapper">

    <resultMap id="BaseResultMap" type="com.mosty.base.model.vo.jcgl.TbJcglJzAllVo">
        <id column="id" property="id" jdbcType="VARCHAR"/>
        <result column="jz_mc" property="jzMc"/>
        <result column="jz_bh" property="jzBh"/>
        <result column="jz_fl" property="jzFl"/>
        <result column="jz_lx" property="jzLx"/>
        <result column="dd_mjid" property="ddMjid"/>
        <result column="dd_mjsfzh" property="ddMjsfzh"/>
        <result column="dd_mjxm" property="ddMjxm"/>
        <result column="dd_mjjh" property="ddMjjh"/>
        <result column="dd_dh" property="ddDh"/>
        <result column="ssbm" property="ssbm"/>
        <result column="ssbmdm" property="ssbmdm"/>
        <result column="ssxgaj" property="ssxgaj"/>
        <result column="ssxgajdm" property="ssxgajdm"/>
        <result column="sssgaj" property="sssgaj"/>
        <result column="sssgajdm" property="sssgajdm"/>
        <result column="bz" property="bz"/>
        <collection property="clList" ofType="com.mosty.base.model.entity.jcgl.TbJcglJzCl">
            <result column="cl_id" property="clId"/>
            <result column="qwjz_id" property="qwjzId"/>
            <result column="jdchphm" property="jdchphm"/>
            <result column="jdchpzldm" property="jdchpzldm"/>
        </collection>
        <collection property="jyqxList" ofType="com.mosty.base.model.entity.jcgl.TbJcglJzJyqx">
            <result column="qwjz_id" property="qwjzId"/>
            <result column="qx_id" property="qxId"/>
            <result column="qxmc" property="qxmc"/>
            <result column="qxlx" property="qxlx"/>
            <result column="qxsl" property="qxsl"/>
        </collection>
        <collection property="jzryList" ofType="com.mosty.base.model.entity.jcgl.TbJcglJzRy">
            <result column="ry_id" property="ryId"/>
            <result column="qwjz_id" property="qwjzId"/>
            <result column="jllx" property="jllx"/>
            <result column="jlxm" property="jlxm"/>
            <result column="jh" property="jh"/>
            <result column="xbdm" property="xbdm"/>
            <result column="sfzh" property="sfzh"/>
            <result column="lxdh" property="lxdh"/>
            <result column="nl" property="nl"/>
        </collection>
        <collection property="txzbList" ofType="com.mosty.base.model.entity.jcgl.TbJcglJzZnzb">
            <result column="zb_id" property="zbId"/>
            <result column="qwjz_id" property="qwjzId"/>
            <result column="sbmc" property="sbmc"/>
            <result column="txzblx" property="txzblx"/>
            <result column="hh" property="hh"/>
        </collection>
    </resultMap>

    <!--查询列表-->
    <select id="queryList" resultType="com.mosty.base.model.entity.jcgl.TbJcglJz">
        select a.* from tb_jcgl_jz a
        where a.xt_scbz = '0'
        <if test="dto.jzMc != null and dto.jzMc != ''">
            and a.jz_mc like concat('%',#{dto.jzMc,jdbcType=VARCHAR},'%')
        </if>
        <if test="dto.jzFl != null and dto.jzFl != ''">
            and a.jz_fl = #{dto.jzFl,jdbcType=VARCHAR}
        </if>
        <if test="dto.ddMjsfzh != null and dto.ddMjsfzh != ''">
            and a.dd_mjsfzh like concat('%',#{dto.ddMjsfzh,jdbcType=VARCHAR},'%')
        </if>
        <if test="dto.ddMjxm != null and dto.ddMjxm != ''">
            and a.dd_mjxm like concat('%',#{dto.ddMjxm,jdbcType=VARCHAR},'%')
        </if>
        <if test="dto.ssbmdm != null and dto.ssbmdm != ''">
            and a.ssbmdm like concat(#{dto.ssbmdm,jdbcType=VARCHAR},'%')
        </if>
<!--        <if test="dto.ssbmdm != null and dto.ssbmdm != ''">-->
<!--            and a.ssbmdm = #{dto.ssbmdm,jdbcType=VARCHAR}-->
<!--        </if>-->
<!--        <if test="dto.ssbmid != null and dto.ssbmid != ''">-->
<!--            and a.ssbmid = #{dto.ssbmid,jdbcType=VARCHAR}-->
<!--        </if>-->
        <!-- 数据范围过滤 -->
<!--        ${createSql}-->
        limit #{pageIndex},#{pageSize}
    </select>

    <!--查询列表-->
    <select id="queryCount" resultType="Integer">
        select count(1) from tb_jcgl_jz a
        where a.xt_scbz = '0'
        <if test="dto.jzMc != null and dto.jzMc != ''">
            and a.jz_mc like concat('%',#{dto.jzMc,jdbcType=VARCHAR},'%')
        </if>
        <if test="dto.jzFl != null and dto.jzFl != ''">
            and a.jz_fl = #{dto.jzFl,jdbcType=VARCHAR}
        </if>
        <if test="dto.ddMjsfzh != null and dto.ddMjsfzh != ''">
            and a.dd_mjsfzh like concat('%',#{dto.ddMjsfzh,jdbcType=VARCHAR},'%')
        </if>
        <if test="dto.ddMjxm != null and dto.ddMjxm != ''">
            and a.dd_mjxm like concat('%',#{dto.ddMjxm,jdbcType=VARCHAR},'%')
        </if>
        <if test="dto.ssbmdm != null and dto.ssbmdm != ''">
            and a.ssbmdm like concat(#{dto.ssbmdm,jdbcType=VARCHAR},'%')
        </if>
<!--        <if test="dto.ssbmid != null and dto.ssbmid != ''">-->
<!--            and a.ssbmid = #{dto.ssbmid,jdbcType=VARCHAR}-->
<!--        </if>-->
        <!-- 数据范围过滤 -->
<!--        ${createSql}-->
    </select>

    <!--id查询-->
    <select id="queryById" resultMap="BaseResultMap">
        select a.*, b.*, c.*, d.*, e.*
        from tb_jcgl_jz a
                 left join tb_jcgl_jz_cl b on a.id = b.qwjz_id
                 left join tb_jcgl_jz_jyqx c on a.id = c.qwjz_id
                 left join tb_jcgl_jz_ry d on a.id = d.qwjz_id
                 left join tb_jcgl_jz_znzb e on a.id = e.qwjz_id
        where a.xt_scbz = '0'
          and a.id = #{id,jdbcType=VARCHAR}
    </select>

    <!--批量删除-->
    <update id="deleteBatch">
        update tb_jcgl_jz set xt_scbz = '1' where id in
        <foreach collection="list" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
    </update>

</mapper>
