<?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.commitment.CommitmentWorkshopMapper">

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

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

	<!-- 字段 -->
	<sql id="Field">
		f.DEPARTMENT_ID,
		f.CORPINFO_ID,
		f.SIGN_TIME,
		f.SIGN_USER,
		f.SIGN_PATH,
		f.INPUT1,
		f.INPUT2,
		f.INPUT3,
		f.INPUT4,
		f.INPUT5,
		f.INPUT6,
		f.INPUT7,
		f.INPUT8,
		f.INPUT9,
		f.INPUT10,
		f.INPUT11,
		f.INPUT12,
		f.INPUT13,
		f.INPUT14,
		f.INPUT15,
		f.INPUT16,
		f.INPUT17,
		f.INPUT18,
		f.INPUT19,
		f.RADIO1,
		f.RADIO2,
		f.RADIO3,
		f.RADIO4,
		f.RADIO5,
		f.RADIO6,
		f.RADIO7,
		f.RADIO8,
		f.RADIO9,
		f.RADIO10,
		f.RADIO11,
		f.RADIO12,
		f.RADIO13,
		f.RADIO14,
		f.RADIO15,
		f.START_TIME,
		f.END_TIME,
		f.COMMITMENTWORKSHOP_ID
	</sql>

	<!-- 字段用于新增 -->
	<sql id="Field2">
		DEPARTMENT_ID,
		CORPINFO_ID,
		SIGN_TIME,
		SIGN_USER,
		SIGN_PATH,
		INPUT1,
		INPUT2,
		INPUT3,
		INPUT4,
		INPUT5,
		INPUT6,
		INPUT7,
		INPUT8,
		INPUT9,
		INPUT10,
		INPUT11,
		INPUT12,
		INPUT13,
		INPUT14,
		INPUT15,
		INPUT16,
		INPUT17,
		INPUT18,
		INPUT19,
		RADIO1,
		RADIO2,
		RADIO3,
		RADIO4,
		RADIO5,
		RADIO6,
		RADIO7,
		RADIO8,
		RADIO9,
		RADIO10,
		RADIO11,
		RADIO12,
		RADIO13,
		RADIO14,
		RADIO15,
		START_TIME,
		END_TIME,
		COMMITMENTWORKSHOP_ID
	</sql>

	<!-- 字段值 -->
	<sql id="FieldValue">
		#{DEPARTMENT_ID},
		#{CORPINFO_ID},
		#{SIGN_TIME},
		#{SIGN_USER},
		#{SIGN_PATH},
		#{INPUT1},
		#{INPUT2},
		#{INPUT3},
		#{INPUT4},
		#{INPUT5},
		#{INPUT6},
		#{INPUT7},
		#{INPUT8},
		#{INPUT9},
		#{INPUT10},
		#{INPUT11},
		#{INPUT12},
		#{INPUT13},
		#{INPUT14},
		#{INPUT15},
		#{INPUT16},
		#{INPUT17},
		#{INPUT18},
		#{INPUT19},
		#{RADIO1},
		#{RADIO2},
		#{RADIO3},
		#{RADIO4},
		#{RADIO5},
		#{RADIO6},
		#{RADIO7},
		#{RADIO8},
		#{RADIO9},
		#{RADIO10},
		#{RADIO11},
		#{RADIO12},
		#{RADIO13},
		#{RADIO14},
		#{RADIO15},
		#{START_TIME},
		#{END_TIME},
		#{COMMITMENTWORKSHOP_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'
		where
			COMMITMENTWORKSHOP_ID = #{COMMITMENTWORKSHOP_ID}
	</delete>

	<!-- 修改 -->
	<update id="edit" parameterType="pd">
		update
		<include refid="tableName"></include>
		set
			DEPARTMENT_ID = #{DEPARTMENT_ID},
			CORPINFO_ID = #{CORPINFO_ID},
			SIGN_TIME = #{SIGN_TIME},
			SIGN_USER = #{SIGN_USER},
			SIGN_PATH = #{SIGN_PATH},
			INPUT1 = #{INPUT1},
			INPUT2 = #{INPUT2},
			INPUT3 = #{INPUT3},
			INPUT4 = #{INPUT4},
			INPUT5 = #{INPUT5},
			INPUT6 = #{INPUT6},
			INPUT7 = #{INPUT7},
			INPUT8 = #{INPUT8},
			INPUT9 = #{INPUT9},
			INPUT10 = #{INPUT10},
			INPUT11 = #{INPUT11},
			INPUT12 = #{INPUT12},
			INPUT13 = #{INPUT13},
			INPUT14 = #{INPUT14},
			INPUT15 = #{INPUT15},
			INPUT16 = #{INPUT16},
			INPUT17 = #{INPUT17},
			INPUT18 = #{INPUT18},
			INPUT19=#{INPUT19},
			RADIO1 = #{RADIO1},
			RADIO2 = #{RADIO2},
			RADIO3 = #{RADIO3},
			RADIO4 = #{RADIO4},
			RADIO5 = #{RADIO5},
			RADIO6 = #{RADIO6},
			RADIO7 = #{RADIO7},
			RADIO8 = #{RADIO8},
			RADIO9 = #{RADIO9},
			RADIO10 = #{RADIO10},
			RADIO11 = #{RADIO11},
			RADIO12 = #{RADIO12},
			RADIO13 = #{RADIO13},
			RADIO14 = #{RADIO14},
			RADIO15=#{RADIO15},
			START_TIME = #{START_TIME},
			END_TIME = #{END_TIME},
			COMMITMENTWORKSHOP_ID = COMMITMENTWORKSHOP_ID
		where
			COMMITMENTWORKSHOP_ID = #{COMMITMENTWORKSHOP_ID}
	</update>

	<!-- 通过ID获取数据 -->
	<select id="findById" parameterType="pd" resultType="pd">
		select
		<include refid="Field"></include>,
		c.CORP_NAME,u.NAME as SIGN_USER_NAME,d.NAME as DEPARTMENT_NAME
		from
		<include refid="tableName"></include> f
		left join BUS_CORP_INFO c on c.CORPINFO_ID = f.CORPINFO_ID
		left join SYS_USER u on u.USER_ID = f.SIGN_USER
		left join OA_DEPARTMENT d on d.DEPARTMENT_ID = f.DEPARTMENT_ID
		where
			f.COMMITMENTWORKSHOP_ID = #{COMMITMENTWORKSHOP_ID}
	</select>

	<!-- 列表 -->
	<select id="datalistPage" parameterType="page" resultType="pd">
		select
		<include refid="Field"></include>,
		c.CORP_NAME,u.NAME as SIGN_USER_NAME,d.NAME as DEPARTMENT_NAME
		from
		<include refid="tableName"></include> f
		left join BUS_CORP_INFO c on c.CORPINFO_ID = f.CORPINFO_ID
		left join SYS_USER u on u.USER_ID = f.SIGN_USER
		left join OA_DEPARTMENT d on d.DEPARTMENT_ID = f.DEPARTMENT_ID
		where 1=1
		<if test="pd.KEYWORDS != null and pd.KEYWORDS != ''"><!-- 关键词检索 -->
			and
			(
			u.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
			)
		</if>
		<if test="pd.CORPINFO_ID != null and pd.CORPINFO_ID != ''"><!-- 关键词检索 -->
			and f.CORPINFO_ID = #{pd.CORPINFO_ID}
		</if>
		<if test="pd.DEPARTMENT_ID != null and pd.DEPARTMENT_ID != ''"><!-- 关键词检索 -->
			and f.DEPARTMENT_ID = #{pd.DEPARTMENT_ID}
		</if>
		order by f.SIGN_TIME desc
	</select>

	<!-- 列表(全部) -->
	<select id="listAll" parameterType="pd" resultType="pd">
		select
		<include refid="Field"></include>
		from
		<include refid="tableName"></include> f
		where 1=1
		<if test="CORPINFO_ID != null and CORPINFO_ID != ''"><!-- 关键词检索 -->
			and f.CORPINFO_ID = #{CORPINFO_ID}
		</if>
		<if test="DEPARTMENT_ID != null and DEPARTMENT_ID != ''"><!-- 关键词检索 -->
			and f.DEPARTMENT_ID = #{DEPARTMENT_ID}
		</if>
		<if test="SIGN_TIME != null and SIGN_TIME != ''"><!-- 关键词检索 -->
			and DATE_FORMAT( NOW(), '%Y-%m-%d' ) between DATE_FORMAT( f.SIGN_TIME, '%Y-%m-%d' ) and DATE_FORMAT( f.END_TIME, '%Y-%m-%d' )
		</if>
	</select>

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

</mapper>
