<?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.zcloud.mapper.datasource.risk.RiskpointAnalysisLogMapper">

	<!--表名 -->
	<sql id="tableName">
		BUS_RISKPOINT_ANALYSIS_LOG
	</sql>

	<!--数据字典表名 -->
	<sql id="dicTableName">
		SYS_DICTIONARIES
	</sql>

	<!-- 字段 -->
	<sql id="Field">
		f.RISKPOINT_ID,
		f.HIDDEN_ID,
		f.RISK_UNIT_ID,
		f.CORPINFO_ID,
		f.IDENTIFICATION_ID,
		f.RISK_DESCR,
		f.RISK_POSITION_ID,
		f.LEVELID,
		f.MEASURES,
		f.ACCIDENTS,
		f.EME_MEASURES,
		f.DEPARTMENT_ID,
		f.USER_ID,
		f.ISDELETE,
		f.CREATOR,
		f.CREATTIME,
		f.OPERATOR,
		f.OPERATTIME,
		f.LONGITUDE,
		f.LATITUDE,
		f.ACCIDENTS_NAME,
		f.SORT,
		f.RES_ISDELETE,
		f.LIKELIHOOD,
		f.EXPOSURE,
		f.CONSEQUENCE,
		f.DANGER,
		f.STATUS,
		f.IS_NEW,
		f.RISKPOINT_ANALYSIS_LOG_ID,
		f.TYEP
	</sql>

	<!-- 字段用于新增 -->
	<sql id="Field2">
		RISKPOINT_ID,
		HIDDEN_ID,
		RISK_UNIT_ID,
		CORPINFO_ID,
		IDENTIFICATION_ID,
		RISK_DESCR,
		RISK_POSITION_ID,
		LEVELID,
		MEASURES,
		ACCIDENTS,
		EME_MEASURES,
		DEPARTMENT_ID,
		USER_ID,
		ISDELETE,
		CREATOR,
		CREATTIME,
		OPERATOR,
		OPERATTIME,
		LONGITUDE,
		LATITUDE,
		ACCIDENTS_NAME,
		SORT,
		RES_ISDELETE,
		LIKELIHOOD,
		EXPOSURE,
		CONSEQUENCE,
		DANGER,
		STATUS,
		IS_NEW,
		RISKPOINT_ANALYSIS_LOG_ID,
		TYPE
	</sql>

	<!-- 字段值 -->
	<sql id="FieldValue">
		#{RISKPOINT_ID},
		#{HIDDEN_ID},
		#{RISK_UNIT_ID},
		#{CORPINFO_ID},
		#{IDENTIFICATION_ID},
		#{RISK_DESCR},
		#{RISK_POSITION_ID},
		#{LEVELID},
		#{MEASURES},
		#{ACCIDENTS},
		#{EME_MEASURES},
		#{DEPARTMENT_ID},
		#{USER_ID},
		#{ISDELETE},
		#{CREATOR},
		#{CREATTIME},
		#{OPERATOR},
		#{OPERATTIME},
		#{LONGITUDE},
		#{LATITUDE},
		#{ACCIDENTS_NAME},
		#{SORT},
		#{RES_ISDELETE},
		#{LIKELIHOOD},
		#{EXPOSURE},
		#{CONSEQUENCE},
		#{DANGER},
		#{STATUS},
		#{IS_NEW},
		#{RISKPOINT_ANALYSIS_LOG_ID},
		#{TYPE}
	</sql>

	<!-- 新增-->
	<insert id="save" parameterType="pd">
		insert into
	<include refid="tableName"></include>
		(
	<include refid="Field2"></include>
		) values (
	<include refid="FieldValue"></include>
		)
	</insert>

	<!-- 删除-->
	<delete id="delete" parameterType="pd">
		update
		<include refid="tableName"></include>
		set
			ISDELETE = '1'
		where
			RISKPOINT_ANALYSIS_LOG_ID = #{RISKPOINT_ANALYSIS_LOG_ID}
	</delete>
	<!-- 批量删除 -->
	<delete id="deleteAll" parameterType="String">
		update
		<include refid="tableName"></include>
		set
		ISDELETE = '1'
		where
		RISKPOINT_ANALYSIS_LOG_ID in
		<foreach item="item" index="index" collection="ArrayDATA_IDS" open="(" separator="," close=")">
			#{item}
		</foreach>
	</delete>

	<!-- 修改 -->
	<update id="edit" parameterType="pd">
		update
		<include refid="tableName"></include>
		set
			RISKPOINT_ID = #{RISKPOINT_ID},
			HIDDEN_ID = #{HIDDEN_ID},
			RISK_UNIT_ID = #{RISK_UNIT_ID},
			CORPINFO_ID = #{CORPINFO_ID},
			IDENTIFICATION_ID = #{IDENTIFICATION_ID},
			RISK_DESCR = #{RISK_DESCR},
			RISK_POSITION_ID = #{RISK_POSITION_ID},
			LEVELID = #{LEVELID},
			MEASURES = #{MEASURES},
			ACCIDENTS = #{ACCIDENTS},
			EME_MEASURES = #{EME_MEASURES},
			DEPARTMENT_ID = #{DEPARTMENT_ID},
			USER_ID = #{USER_ID},
			ISDELETE = #{ISDELETE},
			CREATOR = #{CREATOR},
			CREATTIME = #{CREATTIME},
			OPERATOR = #{OPERATOR},
			OPERATTIME = #{OPERATTIME},
			LONGITUDE = #{LONGITUDE},
			LATITUDE = #{LATITUDE},
			ACCIDENTS_NAME = #{ACCIDENTS_NAME},
			SORT = #{SORT},
			RES_ISDELETE = #{RES_ISDELETE},
			LIKELIHOOD = #{LIKELIHOOD},
			EXPOSURE = #{EXPOSURE},
			CONSEQUENCE = #{CONSEQUENCE},
			DANGER = #{DANGER},
			STATUS = #{STATUS},
			IS_NEW = #{IS_NEW},
			TYPE = #{TYPE},
			RISKPOINT_ANALYSIS_LOG_ID = RISKPOINT_ANALYSIS_LOG_ID
		where
			RISKPOINT_ANALYSIS_LOG_ID = #{RISKPOINT_ANALYSIS_LOG_ID}
	</update>

	<update id="updateByHiddenId">
		update
		<include refid="tableName"></include>
		set
		IS_NEW = #{IS_NEW}
		where
		HIDDEN_ID = #{HIDDEN_ID}
	</update>

	<!-- 通过ID获取数据 -->
	<select id="findById" parameterType="pd" resultType="pd">
		select
		<include refid="Field"></include>
		from
		<include refid="tableName"></include> f
		where
			f.RISKPOINT_ANALYSIS_LOG_ID = #{RISKPOINT_ANALYSIS_LOG_ID}
	</select>

	<!-- 列表 -->
	<select id="datalistPage" parameterType="page" resultType="pd">
		select
		<include refid="Field"></include>
		from
		<include refid="tableName"></include> f
		where f.ISDELETE = '0'
		<if test="pd.KEYWORDS != null and pd.KEYWORDS != ''"><!-- 关键词检索 -->
			and
				(
				<!--	根据需求自己加检索条件
					字段1 LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
					 or
					字段2 LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
				-->
				)
		</if>
	</select>

	<!-- 列表(全部) -->
	<select id="listAll" parameterType="pd" resultType="pd">
		select
		<include refid="Field"></include>
		from
		<include refid="tableName"></include> f
	</select>
	<select id="findByConditionslistPage" resultType="com.zcloud.entity.PageData">
		select * from bus_riskpoint_analysis_log a
		where a.ISDELETE = '0'
		<if test="pd.HIDDEN_ID != '' and pd.HIDDEN_ID != null">
			and a.HIDDEN_ID = #{pd.HIDDEN_ID};
		</if>

	</select>

</mapper>
