<?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.sjzx.mapper.TbSjCyjlMapper">
    <resultMap type="com.mosty.base.model.entity.sjzx.TbSjCyjl" id="TbSjCyjlMap">
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="sjId" column="sj_id" jdbcType="VARCHAR"/>
        <result property="jlId" column="jl_id" jdbcType="VARCHAR"/>
        <result property="jlSfzh" column="jl_sfzh" jdbcType="VARCHAR"/>
        <result property="jlXm" column="jl_xm" jdbcType="VARCHAR"/>
        <result property="jlLxdh" column="jl_lxdh" jdbcType="VARCHAR"/>
        <result property="sdzlsj" column="sdzlsj" jdbcType="TIMESTAMP"/>
        <result property="qszlsj" column="qszlsj" jdbcType="TIMESTAMP"/>
        <result property="ddxcsj" column="ddxcsj" jdbcType="TIMESTAMP"/>
        <result property="jssj" column="jssj" jdbcType="TIMESTAMP"/>
        <result property="mjfj" column="mjfj" jdbcType="VARCHAR"/>
        <result property="sfzyjz" column="sfzyjz" jdbcType="VARCHAR"/>
        <result property="zybqdm" column="zybqdm" jdbcType="VARCHAR"/>
        <result property="zybq" column="zybq" jdbcType="VARCHAR"/>
        <result property="dqwz" column="dqwz" jdbcType="VARCHAR"/>
        <result property="jd" column="jd" jdbcType="NUMERIC"/>
        <result property="wd" column="wd" jdbcType="NUMERIC"/>
        <result property="zb" column="zb" typeHandler="com.mosty.base.feign.handle.PolygonTypeHandler"/>
        <result property="zbhash" column="zbhash" jdbcType="VARCHAR"/>
        <result property="zbsj" column="zbsj" jdbcType="TIMESTAMP"/>
        <result property="jlzt" column="jlzt" jdbcType="VARCHAR"/>
        <result property="tpId" column="tp_id" jdbcType="VARCHAR"/>
        <result property="ssbm" column="ssbm" jdbcType="VARCHAR"/>
        <result property="ssbmdm" column="ssbmdm" jdbcType="VARCHAR"/>
        <result property="ssxgaj" column="ssxgaj" jdbcType="VARCHAR"/>
        <result property="ssxgajdm" column="ssxgajdm" jdbcType="VARCHAR"/>
        <result property="sssgaj" column="sssgaj" jdbcType="VARCHAR"/>
        <result property="sssgajdm" column="sssgajdm" jdbcType="VARCHAR"/>
        <result property="sssgajid" column="sssgajid" jdbcType="VARCHAR"/>
        <result property="ssxgajid" column="ssxgajid" jdbcType="VARCHAR"/>
        <result property="ssbmid" column="ssbmid" jdbcType="VARCHAR"/>
        <result property="xtSjly" column="xt_sjly" jdbcType="VARCHAR"/>
        <result property="xtSjzt" column="xt_sjzt" jdbcType="VARCHAR"/>
        <result property="xtScbz" column="xt_scbz" jdbcType="VARCHAR"/>
        <result property="xtCjip" column="xt_cjip" jdbcType="VARCHAR"/>
        <result property="xtCjsj" column="xt_cjsj" jdbcType="VARCHAR"/>
        <result property="xtCjrId" column="xt_cjr_id" jdbcType="VARCHAR"/>
        <result property="xtCjr" column="xt_cjr" jdbcType="VARCHAR"/>
        <result property="xtCjbmdm" column="xt_cjbmdm" jdbcType="VARCHAR"/>
        <result property="xtCjbmmc" column="xt_cjbm" jdbcType="VARCHAR"/>
        <result property="xtZhgxip" column="xt_zhgxip" jdbcType="VARCHAR"/>
        <result property="xtZhgxsj" column="xt_zhgxsj" jdbcType="VARCHAR"/>
        <result property="xtZhgxrid" column="xt_zhgxrid" jdbcType="VARCHAR"/>
        <result property="xtZhgxr" column="xt_zhgxr" jdbcType="VARCHAR"/>
        <result property="xtZhgxbmdm" column="xt_zhgxbmdm" jdbcType="VARCHAR"/>
        <result property="xtZhgxbm" column="xt_zhgxbm" jdbcType="VARCHAR"/>
        <result property="bz" column="bz" jdbcType="VARCHAR"/>
    </resultMap>

    <!--查询所有-->
    <select id="queryAll" resultMap="TbSjCyjlMap">
        select * from tb_sj_cyjl where xt_sjzt = '1' and xt_scbz = '0'
        ${useSql}
    </select>

    <!--查询单个-->
    <select id="queryById" resultMap="TbSjCyjlMap">
        select * from tb_sj_cyjl where xt_sjzt = '1' and xt_scbz = '0'
        and id = #{id}
    </select>

    <select id="joinCopCount" resultType="java.util.Map">
        SELECT COUNT(*)allsl,
        (SELECT COUNT(*) from tb_sj_cyjl where xt_sjzt='1' and mjfj='01'
        <if test="t.sjId !=null and t.sjId!=''">
            and sj_id=#{t.sjId}
        </if>
        ) mjsl,
        (SELECT COUNT(*) from tb_sj_cyjl where xt_sjzt='1' and mjfj='02'
        <if test="t.sjId !=null and t.sjId!=''">
            and sj_id=#{t.sjId}
        </if>
        )fjsl,
        (SELECT COUNT(*) from tb_sj_cyjl where xt_sjzt='1' and sfzyjz='1'
        <if test="t.sjId !=null and t.sjId!=''">
            and sj_id=#{t.sjId}
        </if>
        )tsjz
        from tb_sj_cyjl where xt_sjzt='1'
        <if test="t.sjId !=null and t.sjId!=''">
            and sj_id=#{t.sjId}
        </if>
    </select>

</mapper>


