<?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.ruoyi.project.zjsgfa.mapper.SjDzfcMapper">
    
    <resultMap type="SjDzfc" id="SjDzfcResult">
        <result property="id"    column="id"    />
        <result property="dcJ"    column="dc_j"    />
        <result property="dcX"    column="dc_x"    />
        <result property="dcT"    column="dc_t"    />
        <result property="dcZ"    column="dc_z"    />
        <result property="dcD"    column="dc_d"    />
        <result property="sjjh"    column="sjjh"    />
        <result property="sjdcs"    column="sjdcs"    />
        <result property="sjjcgx"    column="sjjcgx"    />
        <result property="sjhd"    column="sjhd"    />
        <result property="sjddsd"    column="sjddsd"    />
        <result property="yjjh1"    column="yjjh1"    />
        <result property="yjdcs1"    column="yjdcs1"    />
        <result property="yjjcgx1"    column="yjjcgx1"    />
        <result property="yjhyjd1"    column="yjhyjd1"    />
        <result property="yjddsd1"    column="yjddsd1"    />
        <result property="yjjh2"    column="yjjh2"    />
        <result property="yjdcs2"    column="yjdcs2"    />
        <result property="yjjcgx2"    column="yjjcgx2"    />
        <result property="yjhyjd2"    column="yjhyjd2"    />
        <result property="yjddsd2"    column="yjddsd2"    />
        <result property="createdBy"    column="created_by"    />
        <result property="createdTime"    column="created_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="yjyxts1"    column="yjyxts1"    />
        <result property="yjyxts2"    column="yjyxts2"    />
        <result property="sjyxts"    column="sjyxts"    />
    </resultMap>

    <sql id="selectSjDzfcVo">
        select id, dc_j, dc_x, dc_t, dc_z, dc_d, sjjh, sjdcs, sjjcgx, sjhd, sjddsd, yjjh1, yjdcs1, yjjcgx1, yjhyjd1, yjddsd1, yjjh2, yjdcs2, yjjcgx2, yjhyjd2, yjddsd2, created_by,
               created_time, update_by, update_time,yjyxts1,yjyxts2,sjyxts from sj_dzfc
    </sql>

    <select id="selectSjDzfcList" parameterType="SjDzfc" resultMap="SjDzfcResult">
        <include refid="selectSjDzfcVo"/>
        <where>  
            <if test="dcJ != null  and dcJ != ''"> and dc_j = #{dcJ}</if>
            <if test="dcX != null  and dcX != ''"> and dc_x = #{dcX}</if>
            <if test="dcT != null  and dcT != ''"> and dc_t = #{dcT}</if>
            <if test="dcZ != null  and dcZ != ''"> and dc_z = #{dcZ}</if>
            <if test="dcD != null  and dcD != ''"> and dc_d = #{dcD}</if>
            <if test="sjjh != null  and sjjh != ''"> and sjjh = #{sjjh}</if>
            <if test="sjdcs != null "> and sjdcs = #{sjdcs}</if>
            <if test="sjjcgx != null  and sjjcgx != ''"> and sjjcgx = #{sjjcgx}</if>
            <if test="sjhd != null "> and sjhd = #{sjhd}</if>
            <if test="sjddsd != null "> and sjddsd = #{sjddsd}</if>
            <if test="yjjh1 != null  and yjjh1 != ''"> and yjjh1 = #{yjjh1}</if>
            <if test="yjdcs1 != null "> and yjdcs1 = #{yjdcs1}</if>
            <if test="yjjcgx1 != null  and yjjcgx1 != ''"> and yjjcgx1 = #{yjjcgx1}</if>
            <if test="yjhyjd1 != null  and yjhyjd1 != ''"> and yjhyjd1 = #{yjhyjd1}</if>
            <if test="yjddsd1 != null "> and yjddsd1 = #{yjddsd1}</if>
            <if test="yjjh2 != null  and yjjh2 != ''"> and yjjh2 = #{yjjh2}</if>
            <if test="yjdcs2 != null "> and yjdcs2 = #{yjdcs2}</if>
            <if test="yjjcgx2 != null  and yjjcgx2 != ''"> and yjjcgx2 = #{yjjcgx2}</if>
            <if test="yjhyjd2 != null  and yjhyjd2 != ''"> and yjhyjd2 = #{yjhyjd2}</if>
            <if test="yjddsd2 != null "> and yjddsd2 = #{yjddsd2}</if>
            <if test="createdBy != null  and createdBy != ''"> and created_by = #{createdBy}</if>
            <if test="createdTime != null "> and created_time = #{createdTime}</if>
            <if test="jhs!=null">
                and sjjh in
                <foreach item="jh" collection="jhs"
                         open="(" separator="," close=")">
                    #{jh}
                </foreach>
            </if>
        </where>
        order by sjjh,sjdcs is null  ,sjdcs
    </select>
    
    <select id="selectSjDzfcById" parameterType="Long" resultMap="SjDzfcResult">
        <include refid="selectSjDzfcVo"/>
        where id = #{id}
    </select>

    <insert id="insertSjDzfc" parameterType="SjDzfc" useGeneratedKeys="true" keyProperty="id">
        insert into sj_dzfc
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dcJ != null">dc_j,</if>
            <if test="dcX != null">dc_x,</if>
            <if test="dcT != null">dc_t,</if>
            <if test="dcZ != null">dc_z,</if>
            <if test="dcD != null">dc_d,</if>
            <if test="sjjh != null">sjjh,</if>
            <if test="sjdcs != null">sjdcs,</if>
            <if test="sjjcgx != null">sjjcgx,</if>
            <if test="sjhd != null">sjhd,</if>
            <if test="sjddsd != null">sjddsd,</if>
            <if test="yjjh1 != null">yjjh1,</if>
            <if test="yjdcs1 != null">yjdcs1,</if>
            <if test="yjjcgx1 != null">yjjcgx1,</if>
            <if test="yjhyjd1 != null">yjhyjd1,</if>
            <if test="yjddsd1 != null">yjddsd1,</if>
            <if test="yjjh2 != null">yjjh2,</if>
            <if test="yjdcs2 != null">yjdcs2,</if>
            <if test="yjjcgx2 != null">yjjcgx2,</if>
            <if test="yjhyjd2 != null">yjhyjd2,</if>
            <if test="yjddsd2 != null">yjddsd2,</if>
            <if test="createdBy != null">created_by,</if>
            <if test="createdTime != null">created_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="yjyxts1 != null">yjyxts1,</if>
            <if test="yjyxts2 != null">yjyxts2,</if>
            <if test="sjyxts != null">sjyxts,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dcJ != null">#{dcJ},</if>
            <if test="dcX != null">#{dcX},</if>
            <if test="dcT != null">#{dcT},</if>
            <if test="dcZ != null">#{dcZ},</if>
            <if test="dcD != null">#{dcD},</if>
            <if test="sjjh != null">#{sjjh},</if>
            <if test="sjdcs != null">#{sjdcs},</if>
            <if test="sjjcgx != null">#{sjjcgx},</if>
            <if test="sjhd != null">#{sjhd},</if>
            <if test="sjddsd != null">#{sjddsd},</if>
            <if test="yjjh1 != null">#{yjjh1},</if>
            <if test="yjdcs1 != null">#{yjdcs1},</if>
            <if test="yjjcgx1 != null">#{yjjcgx1},</if>
            <if test="yjhyjd1 != null">#{yjhyjd1},</if>
            <if test="yjddsd1 != null">#{yjddsd1},</if>
            <if test="yjjh2 != null">#{yjjh2},</if>
            <if test="yjdcs2 != null">#{yjdcs2},</if>
            <if test="yjjcgx2 != null">#{yjjcgx2},</if>
            <if test="yjhyjd2 != null">#{yjhyjd2},</if>
            <if test="yjddsd2 != null">#{yjddsd2},</if>
            <if test="createdBy != null">#{createdBy},</if>
            <if test="createdTime != null">#{createdTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="yjyxts1 != null">#{yjyxts1},</if>
            <if test="yjyxts2 != null">#{yjyxts2},</if>
            <if test="sjyxts != null">#{sjyxts},</if>
         </trim>
    </insert>
    <insert id="insertSjDzfcBatch">

        INSERT INTO sj_dzfc
        (
        dc_j, dc_x, dc_t, dc_z, dc_d,
        sjjh, sjdcs, sjjcgx, sjhd, sjddsd,
        yjjh1, yjdcs1, yjjcgx1, yjhyjd1, yjddsd1,
        yjjh2, yjdcs2, yjjcgx2, yjhyjd2, yjddsd2,
        yjyxts1, yjyxts2, sjyxts
        )
        VALUES
        <foreach collection="list" item="item" separator=",">
            (
            #{item.dcJ},
            #{item.dcX},
            #{item.dcT},
            #{item.dcZ},
            #{item.dcD},
            #{item.sjjh},
            #{item.sjdcs},
            #{item.sjjcgx},
            #{item.sjhd},
            #{item.sjddsd},
            #{item.yjjh1},
            #{item.yjdcs1},
            #{item.yjjcgx1},
            #{item.yjhyjd1},
            #{item.yjddsd1},
            #{item.yjjh2},
            #{item.yjdcs2},
            #{item.yjjcgx2},
            #{item.yjhyjd2},
            #{item.yjddsd2},
            #{item.yjyxts1},
            #{item.yjyxts2},
            #{item.sjyxts}
            )
        </foreach>

    </insert>

    <update id="updateSjDzfc" parameterType="SjDzfc">
        update sj_dzfc
        <trim prefix="SET" suffixOverrides=",">
            <if test="dcJ != null">dc_j = #{dcJ},</if>
            <if test="dcX != null">dc_x = #{dcX},</if>
            <if test="dcT != null">dc_t = #{dcT},</if>
            <if test="dcZ != null">dc_z = #{dcZ},</if>
            <if test="dcD != null">dc_d = #{dcD},</if>
            <if test="sjjh != null">sjjh = #{sjjh},</if>
            <if test="sjdcs != null">sjdcs = #{sjdcs},</if>
            <if test="sjjcgx != null">sjjcgx = #{sjjcgx},</if>
            <if test="sjhd != null">sjhd = #{sjhd},</if>
            <if test="sjddsd != null">sjddsd = #{sjddsd},</if>
            <if test="yjjh1 != null">yjjh1 = #{yjjh1},</if>
            <if test="yjdcs1 != null">yjdcs1 = #{yjdcs1},</if>
            <if test="yjjcgx1 != null">yjjcgx1 = #{yjjcgx1},</if>
            <if test="yjhyjd1 != null">yjhyjd1 = #{yjhyjd1},</if>
            <if test="yjddsd1 != null">yjddsd1 = #{yjddsd1},</if>
            <if test="yjjh2 != null">yjjh2 = #{yjjh2},</if>
            <if test="yjdcs2 != null">yjdcs2 = #{yjdcs2},</if>
            <if test="yjjcgx2 != null">yjjcgx2 = #{yjjcgx2},</if>
            <if test="yjhyjd2 != null">yjhyjd2 = #{yjhyjd2},</if>
            <if test="yjddsd2 != null">yjddsd2 = #{yjddsd2},</if>
            <if test="createdBy != null">created_by = #{createdBy},</if>
            <if test="createdTime != null">created_time = #{createdTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="sjyxts != null">sjyxts = #{sjyxts},</if>
            <if test="yjyxts1 != null">yjyxts1 = #{yjyxts1},</if>
            <if test="yjyxts2 != null">yjyxts2 = #{yjyxts2},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSjDzfcById" parameterType="Long">
        delete from sj_dzfc where id = #{id}
    </delete>

    <delete id="deleteSjDzfcByIds" parameterType="String">
        delete from sj_dzfc where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deleteSjDzfcByJh">
        delete from sj_dzfc where sjjh = #{jh}
    </delete>
</mapper>