<?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.zehong.system.mapper.TInsStaInforMapper">
    
    <resultMap type="TInsStaInfor" id="TInsStaInforResult">
        <result property="fInsStaInforId"    column="f_ins_sta_infor_id"    />
        <result property="fHazardName"    column="f_hazard_name"    />
        <result property="fHazardCode"    column="f_hazard_code"    />
        <result property="fHazardDescribe"    column="f_hazard_describe"    />
        <result property="fObjectType"    column="f_object_type"    />
        <result property="fHazardCategory"    column="f_hazard_category"    />
        <result property="fHazardLink"    column="f_hazard_link"    />
        <result property="fHazardLevel"    column="f_hazard_level"    />
        <result property="fHazardDefinitionSourceCode"    column="f_hazard_definition_source_code"    />
        <result property="fOwnerResponse"    column="f_owner_response"    />
        <result property="fAdministrativeSysOrganizationId"    column="f_administrative_sys_organization_id"    />
        <result property="fAdministrativeDepartmentName"    column="f_administrative_department_name"    />
        <result property="fIsEnforcement"    column="f_is_enforcement"    />
        <result property="fEnforcementSysOrganizationId"    column="f_enforcement_sys_organization_id"    />
        <result property="fEnforcementDepartmentName"    column="f_enforcement_department_name"    />
        <result property="fSupervisionSysOrganizationId"    column="f_supervision_sys_organization_id"    />
        <result property="fSupervisionDepartmentName"    column="f_supervision_department_name"    />
        <result property="fRectRequire"    column="f_rect_require"    />
        <result property="fRectDeadline"    column="f_rect_deadline"    />
        <result property="fHazardCheckBasis"    column="f_hazard_check_basis"    />
        <result property="fCheckItemId"    column="f_check_item_id"    />
        <result property="fCheckDept"    column="f_check_dept"    />
        <result property="fCheckMethod"    column="f_check_method"    />
        <result property="fEnforcementAccording"    column="f_enforcement_according"    />
        <result property="fCreateBy"    column="f_create_by"    />
        <result property="fCreateTime"    column="f_create_time"    />
        <result property="fUpdateBy"    column="f_update_by"    />
        <result property="fUpdateTime"    column="f_update_time"    />
        <result property="fDeleteFlag"    column="f_delete_flag"    />
    </resultMap>

    <sql id="selectTInsStaInforVo">
        select f_ins_sta_infor_id, f_hazard_name, f_hazard_code, f_hazard_describe, f_object_type, f_hazard_category, f_hazard_link, f_hazard_level, f_hazard_definition_source_code, f_owner_response, f_administrative_sys_organization_id, f_administrative_department_name, f_is_enforcement, f_enforcement_sys_organization_id, f_enforcement_department_name, f_supervision_sys_organization_id, f_supervision_department_name, f_rect_require, f_rect_deadline, f_hazard_check_basis, f_check_item_id, f_check_dept, f_check_method, f_enforcement_according, f_create_by, f_create_time, f_update_by, f_update_time, f_delete_flag from t_ins_sta_infor
    </sql>

    <select id="selectTInsStaInforList" parameterType="TInsStaInfor" resultMap="TInsStaInforResult">
        <include refid="selectTInsStaInforVo"/>
        <where>  
            <if test="fHazardName != null  and fHazardName != ''"> and f_hazard_name like concat('%', #{fHazardName}, '%')</if>
            <if test="fHazardCode != null  and fHazardCode != ''"> and f_hazard_code like concat('%', #{fHazardCode}, '%')</if>
            <if test="fHazardCategory != null "> and f_hazard_category = #{fHazardCategory}</if>
            <if test="fHazardLevel != null  and fHazardLevel != ''"> and f_hazard_level = #{fHazardLevel}</if>
        </where>
    </select>
    
    <select id="selectTInsStaInforById" parameterType="Long" resultMap="TInsStaInforResult">
        <include refid="selectTInsStaInforVo"/>
        where f_ins_sta_infor_id = #{fInsStaInforId}
    </select>
        
    <insert id="insertTInsStaInfor" parameterType="TInsStaInfor" useGeneratedKeys="true" keyProperty="fInsStaInforId">
        insert into t_ins_sta_infor
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fHazardName != null">f_hazard_name,</if>
            <if test="fHazardCode != null">f_hazard_code,</if>
            <if test="fHazardDescribe != null">f_hazard_describe,</if>
            <if test="fObjectType != null">f_object_type,</if>
            <if test="fHazardCategory != null">f_hazard_category,</if>
            <if test="fHazardLink != null">f_hazard_link,</if>
            <if test="fHazardLevel != null">f_hazard_level,</if>
            <if test="fHazardDefinitionSourceCode != null">f_hazard_definition_source_code,</if>
            <if test="fOwnerResponse != null">f_owner_response,</if>
            <if test="fAdministrativeSysOrganizationId != null">f_administrative_sys_organization_id,</if>
            <if test="fAdministrativeDepartmentName != null">f_administrative_department_name,</if>
            <if test="fIsEnforcement != null">f_is_enforcement,</if>
            <if test="fEnforcementSysOrganizationId != null">f_enforcement_sys_organization_id,</if>
            <if test="fEnforcementDepartmentName != null">f_enforcement_department_name,</if>
            <if test="fSupervisionSysOrganizationId != null">f_supervision_sys_organization_id,</if>
            <if test="fSupervisionDepartmentName != null">f_supervision_department_name,</if>
            <if test="fRectRequire != null">f_rect_require,</if>
            <if test="fRectDeadline != null">f_rect_deadline,</if>
            <if test="fHazardCheckBasis != null">f_hazard_check_basis,</if>
            <if test="fCheckItemId != null">f_check_item_id,</if>
            <if test="fCheckDept != null">f_check_dept,</if>
            <if test="fCheckMethod != null">f_check_method,</if>
            <if test="fEnforcementAccording != null">f_enforcement_according,</if>
            <if test="fCreateBy != null">f_create_by,</if>
            <if test="fCreateTime != null">f_create_time,</if>
            <if test="fUpdateBy != null">f_update_by,</if>
            <if test="fUpdateTime != null">f_update_time,</if>
            <if test="fDeleteFlag != null">f_delete_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fHazardName != null">#{fHazardName},</if>
            <if test="fHazardCode != null">#{fHazardCode},</if>
            <if test="fHazardDescribe != null">#{fHazardDescribe},</if>
            <if test="fObjectType != null">#{fObjectType},</if>
            <if test="fHazardCategory != null">#{fHazardCategory},</if>
            <if test="fHazardLink != null">#{fHazardLink},</if>
            <if test="fHazardLevel != null">#{fHazardLevel},</if>
            <if test="fHazardDefinitionSourceCode != null">#{fHazardDefinitionSourceCode},</if>
            <if test="fOwnerResponse != null">#{fOwnerResponse},</if>
            <if test="fAdministrativeSysOrganizationId != null">#{fAdministrativeSysOrganizationId},</if>
            <if test="fAdministrativeDepartmentName != null">#{fAdministrativeDepartmentName},</if>
            <if test="fIsEnforcement != null">#{fIsEnforcement},</if>
            <if test="fEnforcementSysOrganizationId != null">#{fEnforcementSysOrganizationId},</if>
            <if test="fEnforcementDepartmentName != null">#{fEnforcementDepartmentName},</if>
            <if test="fSupervisionSysOrganizationId != null">#{fSupervisionSysOrganizationId},</if>
            <if test="fSupervisionDepartmentName != null">#{fSupervisionDepartmentName},</if>
            <if test="fRectRequire != null">#{fRectRequire},</if>
            <if test="fRectDeadline != null">#{fRectDeadline},</if>
            <if test="fHazardCheckBasis != null">#{fHazardCheckBasis},</if>
            <if test="fCheckItemId != null">#{fCheckItemId},</if>
            <if test="fCheckDept != null">#{fCheckDept},</if>
            <if test="fCheckMethod != null">#{fCheckMethod},</if>
            <if test="fEnforcementAccording != null">#{fEnforcementAccording},</if>
            <if test="fCreateBy != null">#{fCreateBy},</if>
            <if test="fCreateTime != null">#{fCreateTime},</if>
            <if test="fUpdateBy != null">#{fUpdateBy},</if>
            <if test="fUpdateTime != null">#{fUpdateTime},</if>
            <if test="fDeleteFlag != null">#{fDeleteFlag},</if>
         </trim>
    </insert>

    <update id="updateTInsStaInfor" parameterType="TInsStaInfor">
        update t_ins_sta_infor
        <trim prefix="SET" suffixOverrides=",">
            <if test="fHazardName != null">f_hazard_name = #{fHazardName},</if>
            <if test="fHazardCode != null">f_hazard_code = #{fHazardCode},</if>
            <if test="fHazardDescribe != null">f_hazard_describe = #{fHazardDescribe},</if>
            <if test="fObjectType != null">f_object_type = #{fObjectType},</if>
            <if test="fHazardCategory != null">f_hazard_category = #{fHazardCategory},</if>
            <if test="fHazardLink != null">f_hazard_link = #{fHazardLink},</if>
            <if test="fHazardLevel != null">f_hazard_level = #{fHazardLevel},</if>
            <if test="fHazardDefinitionSourceCode != null">f_hazard_definition_source_code = #{fHazardDefinitionSourceCode},</if>
            <if test="fOwnerResponse != null">f_owner_response = #{fOwnerResponse},</if>
            <if test="fAdministrativeSysOrganizationId != null">f_administrative_sys_organization_id = #{fAdministrativeSysOrganizationId},</if>
            <if test="fAdministrativeDepartmentName != null">f_administrative_department_name = #{fAdministrativeDepartmentName},</if>
            <if test="fIsEnforcement != null">f_is_enforcement = #{fIsEnforcement},</if>
            <if test="fEnforcementSysOrganizationId != null">f_enforcement_sys_organization_id = #{fEnforcementSysOrganizationId},</if>
            <if test="fEnforcementDepartmentName != null">f_enforcement_department_name = #{fEnforcementDepartmentName},</if>
            <if test="fSupervisionSysOrganizationId != null">f_supervision_sys_organization_id = #{fSupervisionSysOrganizationId},</if>
            <if test="fSupervisionDepartmentName != null">f_supervision_department_name = #{fSupervisionDepartmentName},</if>
            <if test="fRectRequire != null">f_rect_require = #{fRectRequire},</if>
            <if test="fRectDeadline != null">f_rect_deadline = #{fRectDeadline},</if>
            <if test="fHazardCheckBasis != null">f_hazard_check_basis = #{fHazardCheckBasis},</if>
            <if test="fCheckItemId != null">f_check_item_id = #{fCheckItemId},</if>
            <if test="fCheckDept != null">f_check_dept = #{fCheckDept},</if>
            <if test="fCheckMethod != null">f_check_method = #{fCheckMethod},</if>
            <if test="fEnforcementAccording != null">f_enforcement_according = #{fEnforcementAccording},</if>
            <if test="fCreateBy != null">f_create_by = #{fCreateBy},</if>
            <if test="fCreateTime != null">f_create_time = #{fCreateTime},</if>
            <if test="fUpdateBy != null">f_update_by = #{fUpdateBy},</if>
            <if test="fUpdateTime != null">f_update_time = #{fUpdateTime},</if>
            <if test="fDeleteFlag != null">f_delete_flag = #{fDeleteFlag},</if>
        </trim>
        where f_ins_sta_infor_id = #{fInsStaInforId}
    </update>

    <delete id="deleteTInsStaInforById" parameterType="Long">
        delete from t_ins_sta_infor where f_ins_sta_infor_id = #{fInsStaInforId}
    </delete>

    <delete id="deleteTInsStaInforByIds" parameterType="String">
        delete from t_ins_sta_infor where f_ins_sta_infor_id in 
        <foreach item="fInsStaInforId" collection="array" open="(" separator="," close=")">
            #{fInsStaInforId}
        </foreach>
    </delete>


    <insert id="batchInsertTInsStaInfor" parameterType="TInsStaInfor" useGeneratedKeys="true" keyProperty="fInsStaInforId">
        insert into t_ins_sta_infor(
            f_hazard_name,
            f_hazard_code,
            f_hazard_describe,
            f_object_type,
            f_hazard_category,
            f_hazard_link,
            f_hazard_level,
            f_hazard_definition_source_code,
            f_owner_response,
            f_administrative_sys_organization_id,
            f_administrative_department_name,
            f_is_enforcement,
            f_enforcement_sys_organization_id,
            f_enforcement_department_name,
            f_supervision_sys_organization_id,
            f_supervision_department_name,
            f_rect_require,
            f_rect_deadline,
            f_hazard_check_basis,
            f_check_item_id,
            f_check_dept,
            f_check_method,
            f_enforcement_according,
            f_create_by,
            f_create_time,
            f_update_by,
            f_update_time,
            f_delete_flag
        )VALUES
        <foreach collection="list" separator="," item="item">
            (
                #{item.fHazardName},
                #{item.fHazardCode},
                #{item.fHazardDescribe},
                #{item.fObjectType},
                #{item.fHazardCategory},
                #{item.fHazardLink},
                #{item.fHazardLevel},
                #{item.fHazardDefinitionSourceCode},
                #{item.fOwnerResponse},
                #{item.fAdministrativeSysOrganizationId},
                #{item.fAdministrativeDepartmentName},
                #{item.fIsEnforcement},
                #{item.fEnforcementSysOrganizationId},
                #{item.fEnforcementDepartmentName},
                #{item.fSupervisionSysOrganizationId},
                #{item.fSupervisionDepartmentName},
                #{item.fRectRequire},
                #{item.fRectDeadline},
                #{fHazardCheckBasis},
                #{item.fCheckItemId},
                #{item.fCheckDept},
                #{item.fCheckMethod},
                #{item.fEnforcementAccording},
                #{item.fCreateBy},
                #{item.fCreateTime},
                #{item.fUpdateBy},
                #{item.fUpdateTime},
                #{item.fDeleteFlag}
            )
        </foreach>
    </insert>
</mapper>