<?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.speEquip.SpecialEquipmentChangeMapper">

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

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

	<!-- 字段 -->
	<sql id="Field">
		f.SPECIALEQUIPMENT_ID,
		f.OPERATETYPE,
		f.CREATOR,
		f.CREATTIME,
		f.OPERATOR,
		f.OPERATTIME,
		f.ISDELETE,
		f.CORPINFO_ID,
		f.EQUIPMENTNAME_BEFORE,
		f.EQUIPMENTNAME_AFTER,
		f.EQUIPMENTMODEL_BEFORE,
		f.EQUIPMENTMODEL_AFTER,
		f.EQUIPMENTCODE_BEFORE,
		f.EQUIPMENTCODE_AFTER,
		f.FACTORYCODE_BEFORE,
		f.FACTORYCODE_AFTER,
		f.EQUIPMENTTYPE_BEFORE,
		f.EQUIPMENTTYPE_AFTER,
		f.EQUIPMENTSTATE_BEFORE,
		f.EQUIPMENTSTATE_AFTER,
		f.EQUIPMENTUSEPLACE_BEFORE,
		f.EQUIPMENTUSEPLACE_AFTER,
		f.RESPONSIBLEUNIT_BEFORE,
		f.RESPONSIBLEUNIT_AFTER,
		f.PERSONCHARGE_BEFORE,
		f.PERSONCHARGE_AFTER,
		f.PERSONCHARGEPHONE_BEFORE,
		f.PERSONCHARGEPHONE_AFTER,
		f.NEXTINSPECTIONDATE_BEFORE,
		f.NEXTINSPECTIONDATE_AFTER,
		f.PERIOD_BEFORE,
		f.PERIOD_AFTER,
		f.TECHNICALFILENAME_BEFORE,
		f.TECHNICALFILENAME_AFTER,
		f.TECHNICALFILEPATH_BEFORE,
		f.TECHNICALFILEPATH_AFTER,
		f.REMARKS_BEFORE,
		f.REMARKS_AFTER,
		f.SPECIALEQUIPMENTCHANGE_ID
	</sql>

	<!-- 字段用于新增 -->
	<sql id="Field2">
		SPECIALEQUIPMENT_ID,
		OPERATETYPE,
		CREATOR,
		CREATTIME,
		OPERATOR,
		OPERATTIME,
		ISDELETE,
		CORPINFO_ID,
		EQUIPMENTNAME_BEFORE,
		EQUIPMENTNAME_AFTER,
		EQUIPMENTMODEL_BEFORE,
		EQUIPMENTMODEL_AFTER,
		EQUIPMENTCODE_BEFORE,
		EQUIPMENTCODE_AFTER,
		FACTORYCODE_BEFORE,
		FACTORYCODE_AFTER,
		EQUIPMENTTYPE_BEFORE,
		EQUIPMENTTYPE_AFTER,
		EQUIPMENTSTATE_BEFORE,
		EQUIPMENTSTATE_AFTER,
		EQUIPMENTUSEPLACE_BEFORE,
		EQUIPMENTUSEPLACE_AFTER,
		RESPONSIBLEUNIT_BEFORE,
		RESPONSIBLEUNIT_AFTER,
		PERSONCHARGE_BEFORE,
		PERSONCHARGE_AFTER,
		PERSONCHARGEPHONE_BEFORE,
		PERSONCHARGEPHONE_AFTER,
		NEXTINSPECTIONDATE_BEFORE,
		NEXTINSPECTIONDATE_AFTER,
		TECHNICALFILENAME_BEFORE,
		TECHNICALFILENAME_AFTER,
		TECHNICALFILEPATH_BEFORE,
		TECHNICALFILEPATH_AFTER,
		REMARKS_BEFORE,
		REMARKS_AFTER,
		SPECIALEQUIPMENTCHANGE_ID
	</sql>

	<!-- 字段值 -->
	<sql id="FieldValue">
		#{SPECIALEQUIPMENT_ID},
		#{OPERATETYPE},
		#{CREATOR},
		#{CREATTIME},
		#{OPERATOR},
		#{OPERATTIME},
		#{ISDELETE},
		#{CORPINFO_ID},
		#{EQUIPMENTNAME_BEFORE},
		#{EQUIPMENTNAME_AFTER},
		#{EQUIPMENTMODEL_BEFORE},
		#{EQUIPMENTMODEL_AFTER},
		#{EQUIPMENTCODE_BEFORE},
		#{EQUIPMENTCODE_AFTER},
		#{FACTORYCODE_BEFORE},
		#{FACTORYCODE_AFTER},
		#{EQUIPMENTTYPE_BEFORE},
		#{EQUIPMENTTYPE_AFTER},
		#{EQUIPMENTSTATE_BEFORE},
		#{EQUIPMENTSTATE_AFTER},
		#{EQUIPMENTUSEPLACE_BEFORE},
		#{EQUIPMENTUSEPLACE_AFTER},
		#{RESPONSIBLEUNIT_BEFORE},
		#{RESPONSIBLEUNIT_AFTER},
		#{PERSONCHARGE_BEFORE},
		#{PERSONCHARGE_AFTER},
		#{PERSONCHARGEPHONE_BEFORE},
		#{PERSONCHARGEPHONE_AFTER},
		#{NEXTINSPECTIONDATE_BEFORE},
		#{NEXTINSPECTIONDATE_AFTER},
		#{TECHNICALFILENAME_BEFORE},
		#{TECHNICALFILENAME_AFTER},
		#{TECHNICALFILEPATH_BEFORE},
		#{TECHNICALFILEPATH_AFTER},
		#{REMARKS_BEFORE},
		#{REMARKS_AFTER},
		#{SPECIALEQUIPMENTCHANGE_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">
		update
		<include refid="tableName"></include>
		set
		ISDELETE = '1',
		OPERATOR = #{OPERATOR},
		OPERATTIME = #{OPERATTIME}
		where
		SPECIALEQUIPMENTCHANGE_ID = #{SPECIALEQUIPMENTCHANGE_ID}
	</delete>

	<!-- 修改 -->
	<update id="edit" parameterType="pd">
		update
		<include refid="tableName"></include>
		set
		SPECIALEQUIPMENT_ID = #{SPECIALEQUIPMENT_ID},
		OPERATETYPE = #{OPERATETYPE},
		OPERATOR = #{OPERATOR},
		OPERATTIME = #{OPERATTIME},
		EQUIPMENTNAME_BEFORE = #{EQUIPMENTNAME_BEFORE},
		EQUIPMENTNAME_AFTER = #{EQUIPMENTNAME_AFTER},
		EQUIPMENTMODEL_BEFORE = #{EQUIPMENTMODEL_BEFORE},
		EQUIPMENTMODEL_AFTER = #{EQUIPMENTMODEL_AFTER},
		EQUIPMENTCODE_BEFORE = #{EQUIPMENTCODE_BEFORE},
		EQUIPMENTCODE_AFTER = #{EQUIPMENTCODE_AFTER},
		FACTORYCODE_BEFORE = #{FACTORYCODE_BEFORE},
		FACTORYCODE_AFTER = #{FACTORYCODE_AFTER},
		EQUIPMENTTYPE_BEFORE = #{EQUIPMENTTYPE_BEFORE},
		EQUIPMENTTYPE_AFTER = #{EQUIPMENTTYPE_AFTER},
		EQUIPMENTSTATE_BEFORE = #{EQUIPMENTSTATE_BEFORE},
		EQUIPMENTSTATE_AFTER = #{EQUIPMENTSTATE_AFTER},
		EQUIPMENTUSEPLACE_BEFORE = #{EQUIPMENTUSEPLACE_BEFORE},
		EQUIPMENTUSEPLACE_AFTER = #{EQUIPMENTUSEPLACE_AFTER},
		RESPONSIBLEUNIT_BEFORE = #{RESPONSIBLEUNIT_BEFORE},
		RESPONSIBLEUNIT_AFTER = #{RESPONSIBLEUNIT_AFTER},
		PERSONCHARGE_BEFORE = #{PERSONCHARGE_BEFORE},
		PERSONCHARGE_AFTER = #{PERSONCHARGE_AFTER},
		PERSONCHARGEPHONE_BEFORE = #{PERSONCHARGEPHONE_BEFORE},
		PERSONCHARGEPHONE_AFTER = #{PERSONCHARGEPHONE_AFTER},
		NEXTINSPECTIONDATE_BEFORE = #{NEXTINSPECTIONDATE_BEFORE},
		NEXTINSPECTIONDATE_AFTER = #{NEXTINSPECTIONDATE_AFTER},
		TECHNICALFILENAME_BEFORE = #{TECHNICALFILENAME_BEFORE},
		TECHNICALFILENAME_AFTER = #{TECHNICALFILENAME_AFTER},
		TECHNICALFILEPATH_BEFORE = #{TECHNICALFILEPATH_BEFORE},
		TECHNICALFILEPATH_AFTER = #{TECHNICALFILEPATH_AFTER},
		REMARKS_BEFORE = #{REMARKS_BEFORE},
		REMARKS_AFTER = #{REMARKS_AFTER},
		SPECIALEQUIPMENTCHANGE_ID = SPECIALEQUIPMENTCHANGE_ID
		where
		SPECIALEQUIPMENTCHANGE_ID = #{SPECIALEQUIPMENTCHANGE_ID}
	</update>

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

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

	<!-- 列表(全部) -->
	<select id="listAll" parameterType="pd" resultType="pd">
		select
		<include refid="Field"></include>
		from
		<include refid="tableName"></include> f
		where f.ISDELETE = '0' and f.CORPINFO_ID = #{pd.CORPINFO_ID}
	</select>

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

</mapper>
