TInsSpotHazardRefMapper.xml 9.24 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<?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.TInsSpotHazardRefMapper">
    
    <resultMap type="TInsSpotHazardRef" id="TInsSpotHazardRefResult">
        <result property="fInsSpotHazardRefId"    column="f_ins_spot_hazard_ref_id"    />
        <result property="fHazardUniqueCode"    column="f_hazard_unique_code"    />
        <result property="fHazardOutUniqueCode"    column="f_hazard_out_unique_code"    />
        <result property="fInvolveEnterpriseCode"    column="f_involve_enterprise_code"    />
        <result property="fObjType"    column="f_obj_type"    />
        <result property="fObjCode"    column="f_obj_code"    />
        <result property="fObjBelongRegionId"    column="f_obj_belong_region_id"    />
        <result property="fCheckTime"    column="f_check_time"    />
        <result property="fHazardTypeLevelId"    column="f_hazard_type_level_id"    />
        <result property="fHazardDesc"    column="f_hazard_desc"    />
        <result property="fBeforePicture"    column="f_before_picture"    />
        <result property="fIsEnforcement"    column="f_is_enforcement"    />
        <result property="fRemark"    column="f_remark"    />
        <result property="fLastTime"    column="f_last_time"    />
22 23 24 25

        <result property="afterPicture"    column="f_after_picture"    />
        <result property="disposalDetails"    column="f_disposal_details"    />
        <result property="disposalTime"    column="f_disposal_time"    />
耿迪迪's avatar
耿迪迪 committed
26 27 28
    </resultMap>

    <sql id="selectTInsSpotHazardRefVo">
耿迪迪's avatar
耿迪迪 committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
       SELECT
            spot.f_ins_spot_hazard_ref_id,
            spot.f_hazard_unique_code,
            spot.f_hazard_out_unique_code,
            spot.f_involve_enterprise_code,
            spot.f_obj_type,
            spot.f_obj_code,
            spot.f_obj_belong_region_id,
            spot.f_check_time,
            spot.f_hazard_type_level_id,
            spot.f_hazard_desc,
            spot.f_before_picture,
            spot.f_is_enforcement,
            spot.f_remark,
            spot.f_last_time,
44 45 46
            spot.f_after_picture,
            spot.f_disposal_details,
            spot.f_disposal_time,
耿迪迪's avatar
耿迪迪 committed
47 48 49 50 51
            (select rec.f_name from t_county_level_region rec where rec.f_id = spot.f_obj_belong_region_id) AS countyName,
            (select en.enterprise_name from t_enterprise_info en where enterprise_id = spot.f_involve_enterprise_code)AS enterpriseName,
            (select inf.f_hazard_name from t_ins_sta_infor inf where inf.f_ins_sta_infor_id = spot.f_hazard_type_level_id)AS levelName
        FROM
            t_ins_spot_hazard_ref spot
耿迪迪's avatar
耿迪迪 committed
52 53 54 55 56
    </sql>

    <select id="selectTInsSpotHazardRefList" parameterType="TInsSpotHazardRef" resultMap="TInsSpotHazardRefResult">
        <include refid="selectTInsSpotHazardRefVo"/>
        <where>  
耿迪迪's avatar
耿迪迪 committed
57 58 59
            <if test="fHazardUniqueCode != null  and fHazardUniqueCode != ''"> and spot.f_hazard_unique_code like concat('%', #{fHazardUniqueCode}, '%')</if>
            <if test="fObjType != null  and fObjType != ''"> and spot.f_obj_type = #{fObjType}</if>
            <if test="fIsEnforcement != null  and fIsEnforcement != ''"> and spot.f_is_enforcement = #{fIsEnforcement}</if>
耿迪迪's avatar
耿迪迪 committed
60
        </where>
耿迪迪's avatar
耿迪迪 committed
61
        ORDER BY f_last_time DESC
耿迪迪's avatar
耿迪迪 committed
62 63 64 65
    </select>
    
    <select id="selectTInsSpotHazardRefById" parameterType="Long" resultMap="TInsSpotHazardRefResult">
        <include refid="selectTInsSpotHazardRefVo"/>
耿迪迪's avatar
耿迪迪 committed
66
        where spot.f_ins_spot_hazard_ref_id = #{fInsSpotHazardRefId}
耿迪迪's avatar
耿迪迪 committed
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
    </select>
        
    <insert id="insertTInsSpotHazardRef" parameterType="TInsSpotHazardRef" useGeneratedKeys="true" keyProperty="fInsSpotHazardRefId">
        insert into t_ins_spot_hazard_ref
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fHazardUniqueCode != null">f_hazard_unique_code,</if>
            <if test="fHazardOutUniqueCode != null">f_hazard_out_unique_code,</if>
            <if test="fInvolveEnterpriseCode != null">f_involve_enterprise_code,</if>
            <if test="fObjType != null">f_obj_type,</if>
            <if test="fObjCode != null">f_obj_code,</if>
            <if test="fObjBelongRegionId != null">f_obj_belong_region_id,</if>
            <if test="fCheckTime != null">f_check_time,</if>
            <if test="fHazardTypeLevelId != null">f_hazard_type_level_id,</if>
            <if test="fHazardDesc != null">f_hazard_desc,</if>
            <if test="fBeforePicture != null">f_before_picture,</if>
            <if test="fIsEnforcement != null">f_is_enforcement,</if>
            <if test="fRemark != null">f_remark,</if>
            <if test="fLastTime != null">f_last_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fHazardUniqueCode != null">#{fHazardUniqueCode},</if>
            <if test="fHazardOutUniqueCode != null">#{fHazardOutUniqueCode},</if>
            <if test="fInvolveEnterpriseCode != null">#{fInvolveEnterpriseCode},</if>
            <if test="fObjType != null">#{fObjType},</if>
            <if test="fObjCode != null">#{fObjCode},</if>
            <if test="fObjBelongRegionId != null">#{fObjBelongRegionId},</if>
            <if test="fCheckTime != null">#{fCheckTime},</if>
            <if test="fHazardTypeLevelId != null">#{fHazardTypeLevelId},</if>
            <if test="fHazardDesc != null">#{fHazardDesc},</if>
            <if test="fBeforePicture != null">#{fBeforePicture},</if>
            <if test="fIsEnforcement != null">#{fIsEnforcement},</if>
            <if test="fRemark != null">#{fRemark},</if>
            <if test="fLastTime != null">#{fLastTime},</if>
         </trim>
    </insert>

    <update id="updateTInsSpotHazardRef" parameterType="TInsSpotHazardRef">
        update t_ins_spot_hazard_ref
        <trim prefix="SET" suffixOverrides=",">
            <if test="fHazardUniqueCode != null">f_hazard_unique_code = #{fHazardUniqueCode},</if>
            <if test="fHazardOutUniqueCode != null">f_hazard_out_unique_code = #{fHazardOutUniqueCode},</if>
            <if test="fInvolveEnterpriseCode != null">f_involve_enterprise_code = #{fInvolveEnterpriseCode},</if>
            <if test="fObjType != null">f_obj_type = #{fObjType},</if>
            <if test="fObjCode != null">f_obj_code = #{fObjCode},</if>
            <if test="fObjBelongRegionId != null">f_obj_belong_region_id = #{fObjBelongRegionId},</if>
            <if test="fCheckTime != null">f_check_time = #{fCheckTime},</if>
            <if test="fHazardTypeLevelId != null">f_hazard_type_level_id = #{fHazardTypeLevelId},</if>
            <if test="fHazardDesc != null">f_hazard_desc = #{fHazardDesc},</if>
            <if test="fBeforePicture != null">f_before_picture = #{fBeforePicture},</if>
            <if test="fIsEnforcement != null">f_is_enforcement = #{fIsEnforcement},</if>
            <if test="fRemark != null">f_remark = #{fRemark},</if>
            <if test="fLastTime != null">f_last_time = #{fLastTime},</if>
        </trim>
        where f_ins_spot_hazard_ref_id = #{fInsSpotHazardRefId}
    </update>
122 123 124 125 126 127 128 129 130
    <update id="disposeOfInsSpotHazardRef" parameterType="TInsSpotHazardRef">
        update t_ins_spot_hazard_ref
        <trim prefix="SET" suffixOverrides=",">
            <if test="afterPicture != null and afterPicture != ''">f_after_picture = #{afterPicture},</if>
            <if test="disposalDetails != null and disposalDetails != ''">f_disposal_details = #{disposalDetails},</if>
            <if test="disposalTime != null">f_disposal_time = #{disposalTime},</if>
        </trim>
        where f_ins_spot_hazard_ref_id = #{fInsSpotHazardRefId}
    </update>
耿迪迪's avatar
耿迪迪 committed
131 132 133 134 135 136 137 138 139 140 141

    <delete id="deleteTInsSpotHazardRefById" parameterType="Long">
        delete from t_ins_spot_hazard_ref where f_ins_spot_hazard_ref_id = #{fInsSpotHazardRefId}
    </delete>

    <delete id="deleteTInsSpotHazardRefByIds" parameterType="String">
        delete from t_ins_spot_hazard_ref where f_ins_spot_hazard_ref_id in 
        <foreach item="fInsSpotHazardRefId" collection="array" open="(" separator="," close=")">
            #{fInsSpotHazardRefId}
        </foreach>
    </delete>
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176

    <insert id="batchInsertTInsSpotHazardRef" parameterType="TInsSpotHazardRef" useGeneratedKeys="true" keyProperty="fInsSpotHazardRefId">
        insert into t_ins_spot_hazard_ref(
            f_hazard_unique_code,
            f_hazard_out_unique_code,
            f_involve_enterprise_code,
            f_obj_type,
            f_obj_code,
            f_obj_belong_region_id,
            f_check_time,
            f_hazard_type_level_id,
            f_hazard_desc,
            f_before_picture,
            f_is_enforcement,
            f_remark,
            f_last_time
        )VALUES
        <foreach collection="list" separator="," item="item">
            (
                #{item.fHazardUniqueCode},
                #{item.fHazardOutUniqueCode},
                #{item.fInvolveEnterpriseCode},
                #{item.fObjType},
                #{item.fObjCode},
                #{item.fObjBelongRegionId},
                #{item.fCheckTime},
                #{item.fHazardTypeLevelId},
                #{item.fHazardDesc},
                #{item.fBeforePicture},
                #{item.fIsEnforcement},
                #{item.fRemark},
                #{item.fLastTime}
            )
        </foreach>
    </insert>
耿迪迪's avatar
耿迪迪 committed
177
</mapper>