<?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.majordangersource.MajordangersourceStoragetankLogMapper">

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

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

	<!-- 字段 -->
	<sql id="Field">
		f.STORAGETANK1_LIQUIDLEVEL,
		f.STORAGETANK1_TEMPERATURE,
		f.STORAGETANK1_OPERATTIME,
		f.STORAGETANK2_LIQUIDLEVEL,
		f.STORAGETANK2_TEMPERATURE,
		f.STORAGETANK2_OPERATTIME,
		f.STORAGETANK3_LIQUIDLEVEL,
		f.STORAGETANK3_TEMPERATURE,
		f.STORAGETANK3_OPERATTIME,
		f.STORAGETANK4_LIQUIDLEVEL,
		f.STORAGETANK4_TEMPERATURE,
		f.STORAGETANK4_OPERATTIME,
		f.STORAGETANK5_LIQUIDLEVEL,
		f.STORAGETANK5_TEMPERATURE,
		f.STORAGETANK5_OPERATTIME,
		f.STORAGETANK6_LIQUIDLEVEL,
		f.STORAGETANK6_TEMPERATURE,
		f.STORAGETANK6_OPERATTIME,
		f.STORAGETANK7_LIQUIDLEVEL,
		f.STORAGETANK7_TEMPERATURE,
		f.STORAGETANK7_OPERATTIME,
		f.STORAGETANK8_LIQUIDLEVEL,
		f.STORAGETANK8_TEMPERATURE,
		f.STORAGETANK8_OPERATTIME,
		f.STORAGETANK9_LIQUIDLEVEL,
		f.STORAGETANK9_TEMPERATURE,
		f.STORAGETANK9_OPERATTIME,
		f.CREATTIME,
		f.MAJORDANGERSOURCE_STORAGETANKLOG_ID
	</sql>

	<!-- 字段用于新增 -->
	<sql id="Field2">
		STORAGETANK1_LIQUIDLEVEL,
		STORAGETANK1_TEMPERATURE,
		STORAGETANK1_OPERATTIME,
		STORAGETANK2_LIQUIDLEVEL,
		STORAGETANK2_TEMPERATURE,
		STORAGETANK2_OPERATTIME,
		STORAGETANK3_LIQUIDLEVEL,
		STORAGETANK3_TEMPERATURE,
		STORAGETANK3_OPERATTIME,
		STORAGETANK4_LIQUIDLEVEL,
		STORAGETANK4_TEMPERATURE,
		STORAGETANK4_OPERATTIME,
		STORAGETANK5_LIQUIDLEVEL,
		STORAGETANK5_TEMPERATURE,
		STORAGETANK5_OPERATTIME,
		STORAGETANK6_LIQUIDLEVEL,
		STORAGETANK6_TEMPERATURE,
		STORAGETANK6_OPERATTIME,
		STORAGETANK7_LIQUIDLEVEL,
		STORAGETANK7_TEMPERATURE,
		STORAGETANK7_OPERATTIME,
		STORAGETANK8_LIQUIDLEVEL,
		STORAGETANK8_TEMPERATURE,
		STORAGETANK8_OPERATTIME,
		STORAGETANK9_LIQUIDLEVEL,
		STORAGETANK9_TEMPERATURE,
		STORAGETANK9_OPERATTIME,
		CREATTIME,
		MAJORDANGERSOURCE_STORAGETANKLOG_ID
	</sql>

	<!-- 字段值 -->
	<sql id="FieldValue">
		#{STORAGETANK1_LIQUIDLEVEL},
		#{STORAGETANK1_TEMPERATURE},
		#{STORAGETANK1_OPERATTIME},
		#{STORAGETANK2_LIQUIDLEVEL},
		#{STORAGETANK2_TEMPERATURE},
		#{STORAGETANK2_OPERATTIME},
		#{STORAGETANK3_LIQUIDLEVEL},
		#{STORAGETANK3_TEMPERATURE},
		#{STORAGETANK3_OPERATTIME},
		#{STORAGETANK4_LIQUIDLEVEL},
		#{STORAGETANK4_TEMPERATURE},
		#{STORAGETANK4_OPERATTIME},
		#{STORAGETANK5_LIQUIDLEVEL},
		#{STORAGETANK5_TEMPERATURE},
		#{STORAGETANK5_OPERATTIME},
		#{STORAGETANK6_LIQUIDLEVEL},
		#{STORAGETANK6_TEMPERATURE},
		#{STORAGETANK6_OPERATTIME},
		#{STORAGETANK7_LIQUIDLEVEL},
		#{STORAGETANK7_TEMPERATURE},
		#{STORAGETANK7_OPERATTIME},
		#{STORAGETANK8_LIQUIDLEVEL},
		#{STORAGETANK8_TEMPERATURE},
		#{STORAGETANK8_OPERATTIME},
		#{STORAGETANK9_LIQUIDLEVEL},
		#{STORAGETANK9_TEMPERATURE},
		#{STORAGETANK9_OPERATTIME},
		#{CREATTIME},
		#{MAJORDANGERSOURCE_STORAGETANKLOG_ID}
	</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">
		DELETE FROM
		<include refid="tableName"></include>
		where
		MAJORDANGERSOURCE_STORAGETANKLOG_ID = #{MAJORDANGERSOURCE_STORAGETANKLOG_ID}
	</delete>

	<!-- 修改 -->
	<update id="edit" parameterType="pd">
		update
		<include refid="tableName"></include>
		set
		STORAGETANK1_LIQUIDLEVEL = #{STORAGETANK1_LIQUIDLEVEL},
		STORAGETANK1_TEMPERATURE = #{STORAGETANK1_TEMPERATURE},
		STORAGETANK1_OPERATTIME = #{STORAGETANK1_OPERATTIME},
		STORAGETANK2_LIQUIDLEVEL = #{STORAGETANK2_LIQUIDLEVEL},
		STORAGETANK2_TEMPERATURE = #{STORAGETANK2_TEMPERATURE},
		STORAGETANK2_OPERATTIME = #{STORAGETANK2_OPERATTIME},
		STORAGETANK3_LIQUIDLEVEL = #{STORAGETANK3_LIQUIDLEVEL},
		STORAGETANK3_TEMPERATURE = #{STORAGETANK3_TEMPERATURE},
		STORAGETANK3_OPERATTIME = #{STORAGETANK3_OPERATTIME},
		STORAGETANK4_LIQUIDLEVEL = #{STORAGETANK4_LIQUIDLEVEL},
		STORAGETANK4_TEMPERATURE = #{STORAGETANK4_TEMPERATURE},
		STORAGETANK4_OPERATTIME = #{STORAGETANK4_OPERATTIME},
		STORAGETANK5_LIQUIDLEVEL = #{STORAGETANK5_LIQUIDLEVEL},
		STORAGETANK5_TEMPERATURE = #{STORAGETANK5_TEMPERATURE},
		STORAGETANK5_OPERATTIME = #{STORAGETANK5_OPERATTIME},
		STORAGETANK6_LIQUIDLEVEL = #{STORAGETANK6_LIQUIDLEVEL},
		STORAGETANK6_TEMPERATURE = #{STORAGETANK6_TEMPERATURE},
		STORAGETANK6_OPERATTIME = #{STORAGETANK6_OPERATTIME},
		STORAGETANK7_LIQUIDLEVEL = #{STORAGETANK7_LIQUIDLEVEL},
		STORAGETANK7_TEMPERATURE = #{STORAGETANK7_TEMPERATURE},
		STORAGETANK7_OPERATTIME = #{STORAGETANK7_OPERATTIME},
		STORAGETANK8_LIQUIDLEVEL = #{STORAGETANK8_LIQUIDLEVEL},
		STORAGETANK8_TEMPERATURE = #{STORAGETANK8_TEMPERATURE},
		STORAGETANK8_OPERATTIME = #{STORAGETANK8_OPERATTIME},
		STORAGETANK9_LIQUIDLEVEL = #{STORAGETANK9_LIQUIDLEVEL},
		STORAGETANK9_TEMPERATURE = #{STORAGETANK9_TEMPERATURE},
		STORAGETANK9_OPERATTIME = #{STORAGETANK9_OPERATTIME},
		MAJORDANGERSOURCE_STORAGETANKLOG_ID = MAJORDANGERSOURCE_STORAGETANKLOG_ID
		where
		MAJORDANGERSOURCE_STORAGETANKLOG_ID = #{MAJORDANGERSOURCE_STORAGETANKLOG_ID}
	</update>

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

	<!-- 列表 -->
	<select id="datalistPage" parameterType="page" resultType="pd">
		select
		<include refid="Field"></include>
		from
		<include refid="tableName"></include> f
		 where 1=1
		<if test="pd.STORAGETANK_OPERATTIME != null and pd.STORAGETANK_OPERATTIME != ''"><!-- 重大危险源类型检索 -->
			and f.${pd.STORAGETANK_OPERATTIME} IS NOT NULL
		</if>
		ORDER BY f.CREATTIME DESC
	</select>

	<!-- 列表(全部) -->
	<select id="listAll" parameterType="pd" resultType="pd">
		select
		<include refid="Field"></include>
		from
		<include refid="tableName"></include> f
		ORDER BY f.CREATTIME DESC
	</select>

	<!-- 批量删除 -->
	<delete id="deleteAll" parameterType="pd">
		DELETE FROM
		<include refid="tableName"></include>
		where
		MAJORDANGERSOURCE_STORAGETANKLOG_ID in
		<foreach item="item" index="index" collection="ArrayDATA_IDS" open="(" separator="," close=")">
			#{item}
		</foreach>
	</delete>

	<!-- 列表(根据所选ID获取数据) -->
	<select id="findByIds" parameterType="pd" resultType="pd">
		select
		<include refid="Field"></include>
		from
		<include refid="tableName"></include> f
		where
		MAJORDANGERSOURCE_STORAGETANKLOG_ID in
		<foreach item="item" index="index" collection="ArrayDATA_IDS" open="(" separator="," close=")">
			#{item}
		</foreach>
	</select>

</mapper>
