<?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.ehsRisk.mapper.EhsRiskMapper">

    <resultMap type="EhsRisk" id="EhsRiskResult">
            <result property="riskId"    column="risk_id"    />
            <result property="riskGrade"    column="risk_grade"    />
            <result property="reportAddressType"    column="report_address_type"    />
            <result property="riskLocation"    column="risk_location"    />
            <result property="riskDesc"    column="risk_desc"    />
            <result property="peopleQuantity"    column="people_quantity"    />
            <result property="materialsAddr"    column="materials_addr"    />
            <result property="materialsQuantity"    column="materials_quantity"    />
            <result property="lifeAddr"    column="life_addr"    />
            <result property="resettleAddr"    column="resettle_addr"    />
            <result property="villageName"    column="village_name"    />
            <result property="villageDuties"    column="village_duties"    />
            <result property="villageTel"    column="village_tel"    />
            <result property="villageName1"    column="village_name1"    />
            <result property="villageDuties1"    column="village_duties1"    />
            <result property="villageTel1"    column="village_tel1"    />
            <result property="createBy"    column="create_by"    />
            <result property="createTime"    column="create_time"    />
            <result property="updateBy"    column="update_by"    />
            <result property="updateTime"    column="update_time"    />
            <result property="remark"    column="remark"    />
            <result property="deptId"    column="dept_id"    />
            <result property="createUserId"    column="create_user_id"    />
            <result property="updateUserId"    column="update_user_id"    />
            <result property="inspectionName"    column="inspection_name"    />
            <result property="inspectionDuties"    column="inspection_duties"    />
            <result property="inspectionTel"    column="inspection_tel"    />
    </resultMap>

    <sql id="selectEhsRiskVo">
        select risk_id, risk_grade, report_address_type, risk_location, risk_desc, people_quantity, materials_addr, materials_quantity, life_addr, resettle_addr, village_name, village_duties, village_tel, village_name1, village_duties1, village_tel1, create_by, create_time, update_by, update_time, remark, dept_id, create_user_id, update_user_id, inspection_name, inspection_duties, inspection_tel from ehs_risk
    </sql>

    <select id="selectEhsRiskList" parameterType="EhsRisk" resultMap="EhsRiskResult">
        <include refid="selectEhsRiskVo"/>
        <where>
                        <if test="riskGrade != null "> and risk_grade = #{riskGrade}</if>
                        <if test="reportAddressType != null  and reportAddressType != ''"> and report_address_type = #{reportAddressType}</if>
                        <if test="riskLocation != null  and riskLocation != ''"> and risk_location like concat('%', #{riskLocation}, '%')</if>
                        <if test="riskDesc != null  and riskDesc != ''"> and risk_desc like concat('%', #{riskDesc}, '%')</if>
                        <if test="peopleQuantity != null  and peopleQuantity != ''"> and people_quantity like concat('%', #{peopleQuantity}, '%')</if>
                        <if test="materialsAddr != null  and materialsAddr != ''"> and materials_addr like concat('%', #{materialsAddr}, '%')</if>
                        <if test="params.beginMaterialsQuantity != null and params.beginMaterialsQuantity != '' and params.endMaterialsQuantity != null and params.endMaterialsQuantity != ''"> and materials_quantity between #{params.beginMaterialsQuantity} and #{params.endMaterialsQuantity}</if>
                        <if test="lifeAddr != null  and lifeAddr != ''"> and life_addr like concat('%', #{lifeAddr}, '%')</if>
                        <if test="resettleAddr != null  and resettleAddr != ''"> and resettle_addr like concat('%', #{resettleAddr}, '%')</if>
                        <if test="villageName != null  and villageName != ''"> and village_name like concat('%', #{villageName}, '%')</if>
                        <if test="villageDuties != null  and villageDuties != ''"> and village_duties like concat('%', #{villageDuties}, '%')</if>
                        <if test="villageTel != null  and villageTel != ''"> and village_tel like concat('%', #{villageTel}, '%')</if>
                        <if test="villageName1 != null  and villageName1 != ''"> and village_name1 like concat('%', #{villageName1}, '%')</if>
                        <if test="villageDuties1 != null  and villageDuties1 != ''"> and village_duties1 like concat('%', #{villageDuties1}, '%')</if>
                        <if test="villageTel1 != null  and villageTel1 != ''"> and village_tel1 like concat('%', #{villageTel1}, '%')</if>
                        <if test="deptId != null "> and dept_id = #{deptId}</if>
                        <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
                        <if test="updateUserId != null "> and update_user_id = #{updateUserId}</if>
                        <if test="inspectionName != null  and inspectionName != ''"> and inspection_name like concat('%', #{inspectionName}, '%')</if>
                        <if test="inspectionDuties != null  and inspectionDuties != ''"> and inspection_duties like concat('%', #{inspectionDuties}, '%')</if>
                        <if test="inspectionTel != null  and inspectionTel != ''"> and inspection_tel like concat('%', #{inspectionTel}, '%')</if>
        </where>
    </select>

    <select id="selectEhsRiskByRiskId" parameterType="Long" resultMap="EhsRiskResult">
            <include refid="selectEhsRiskVo"/>
            where risk_id = #{riskId}
    </select>




</mapper>