<?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="cn.com.countrygarden.bi.main.dao.bigholderAduit.BigholderAduitMapper">

	<resultMap id="BigholderAreaAuditMap"
		type="cn.com.countrygarden.bi.main.model.bigholderAduit.BigholderAreaAudit">
		<id column="id" jdbcType="INTEGER" property="id" />
		<result column="correspond_project" jdbcType="VARCHAR"
			property="correspondProject" />
		<result column="audit_status" jdbcType="VARCHAR" property="auditStatus" />
		<result column="rejected_message" jdbcType="VARCHAR" property="rejectedMessage" />
		<result column="exception_status" jdbcType="VARCHAR" property="exceptionStatus" />
		<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
		<result column="last_update_time" jdbcType="TIMESTAMP"
			property="lastUpdateTime" />
		<result column="create_by" jdbcType="VARCHAR" property="createBy" />
		<result column="last_update_by" jdbcType="VARCHAR" property="lastUpdateBy" />
		<result column="a41" jdbcType="VARCHAR" property="a41" />
		<result column="a42" jdbcType="VARCHAR" property="a42" />
		<result column="a43" jdbcType="VARCHAR" property="a43" />
		<result column="a44" jdbcType="VARCHAR" property="a44" />
		<result column="a51" jdbcType="VARCHAR" property="a51" />
		<result column="a52" jdbcType="VARCHAR" property="a52" />
		<result column="a53" jdbcType="VARCHAR" property="a53" />
		<result column="a54" jdbcType="VARCHAR" property="a54" />
		<result column="a61" jdbcType="VARCHAR" property="a61" />
		<result column="a62" jdbcType="VARCHAR" property="a62" />
		<result column="a71" jdbcType="VARCHAR" property="a71" />
		<result column="a72" jdbcType="VARCHAR" property="a72" />
		<result column="a73" jdbcType="VARCHAR" property="a73" />
		<result column="project_total" jdbcType="VARCHAR" property="projectTotal" />
		<result column="marketing_total" jdbcType="VARCHAR" property="marketingTotal" />
		<result column="open_satisfaction" jdbcType="VARCHAR" property="openSatisfaction" />
		<result column="area" jdbcType="VARCHAR" property="area" />
		<result column="year_mon" jdbcType="VARCHAR" property="yearMonth" />
		<result column="satisfaction_scores" jdbcType="VARCHAR"
			property="satisfactionScores" />
		<result column="push_perdata_status" jdbcType="VARCHAR"
			property="pushPerdataStruts" />
		<result column="version" jdbcType="VARCHAR" property="version" />
	</resultMap>

	<select id="getBigholderAreaAduits" parameterType="Map"
		resultMap="BigholderAreaAuditMap">
		SELECT * FROM bigholder_area_audit
		AS b
		<where>
			1=1
			<if test="yearMonth!=null">
				AND b.year_mon=#{yearMonth}
			</if>
			<if test="area!=null">
				AND b.area=#{area}
			</if>
			<if test="auditStatus!=null">
				AND b.audit_status=#{auditStatus}
			</if>
		</where>
	</select>
	
	<select id="findByMonthsOrArea" parameterType="Map"
		resultMap="BigholderAreaAuditMap">
		SELECT * FROM bigholder_area_audit
		AS b
		<where>
			1=1
			<if test="area!=null">
				AND b.area=#{area}
			</if>
			<if test="auditStatus!=null">
				AND b.audit_status=#{auditStatus}
			</if>
			AND b.year_mon IN 
			<foreach item="item" index="index" collection="yearMonth" open="("
				separator="," close=")">
				#{item}
			</foreach>
		</where>
	</select>

	<select id="getBigholderAreaAduits1" parameterType="Map"
		resultMap="BigholderAreaAuditMap">
		SELECT * FROM bigholder_area_audit
		AS b
		<where>
			1=1
			<if test="yearMonth!=null">
				AND b.year_mon=#{yearMonth}
			</if>
			<if test="area!=null">
				AND b.area=#{area}
			</if>
			<if test="auditStatus!=null">
				AND b.audit_status=#{auditStatus}
			</if>
		</where>
		order by b.area
	</select>

	<select id="getByAreaAduitsCommId" parameterType="Map"
		resultMap="BigholderAreaAuditMap">
		SELECT * FROM bigholder_area_audit
		AS b
		<where>
			1=1
			<if test="yearMonth!=null">
				AND b.year_mon=#{yearMonth}
			</if>
			<if test="area!=null">
				AND b.area=#{area}
			</if>
			<if test="commId!=null">
				AND b.correspond_project=#{commId}
			</if>
			<if test="auditStatus!=null">
				AND b.audit_status=#{auditStatus}
			</if>
		</where>
	</select>

	<select id="getBigholderAreaAuditAll" parameterType="String"
		resultMap="BigholderAreaAuditMap">
		SELECT * FROM bigholder_area_audit
		AS b 
		<where>
			 1=1
			<if test="yearMonth!=null">
				AND b.year_mon=#{yearMonth}
			</if>
		</where>
	</select>

	<select id="selectById" parameterType="String" resultMap="BigholderAreaAuditMap">
		SELECT
		* FROM bigholder_area_audit
		AS b where
		b.id=#{id}
	</select>

	<update id="updateBigholderAduit"
		parameterType="cn.com.countrygarden.bi.main.model.bigholderAduit.BigholderAreaAudit">
		UPDATE
		bigholder_area_audit b
		<trim prefix="set" suffixOverrides=",">
			<if test="auditStatus!=null">
				b.audit_status=#{auditStatus},
			</if>
			<if test="lastUpdateBy!=null">
				b.last_update_by=#{lastUpdateBy},
			</if>
			<if test="lastUpdateTime!=null">
				b.last_update_time=#{lastUpdateTime}
			</if>
		</trim>
		WHERE
		b.id = #{id}
	</update>
	
	<update id="updateAllStatus"
		parameterType="cn.com.countrygarden.bi.main.model.bigholderAduit.BigholderAreaAudit">
		UPDATE
		bigholder_area_audit b
		<trim prefix="set" suffixOverrides=",">
			<if test="auditStatus!=null">
				b.audit_status=#{auditStatus},
			</if>
			<if test="pushPerdataStruts!=null">
				b.push_perdata_status=#{pushPerdataStruts},
			</if>
			<if test="exceptionStatus!=null">
				b.exception_status=#{exceptionStatus},
			</if>
			<if test="lastUpdateBy!=null">
				b.last_update_by=#{lastUpdateBy},
			</if>
			<if test="lastUpdateTime!=null">
				b.last_update_time=#{lastUpdateTime}
			</if>
		</trim>
		WHERE
		b.id = #{id}
	</update>

	<update id="updateAuditIsPush"
		parameterType="cn.com.countrygarden.bi.main.model.bigholderAduit.BigholderAreaAudit">
		UPDATE
		bigholder_area_audit b
		SET
		b.push_perdata_status=#{pushPerdataStruts}
		WHERE
		b.id = #{id}
	</update>

	<update id="updateRejectedInfo"
		parameterType="cn.com.countrygarden.bi.main.model.bigholderAduit.BigholderAreaAudit">
		UPDATE
		bigholder_area_audit b

		<trim prefix="set" suffixOverrides=",">
			<if test="auditStatus!=null">
				b.audit_status=#{auditStatus},
			</if>
			<if test="lastUpdateBy!=null">
				b.last_update_by=#{lastUpdateBy},
			</if>
			<if test="lastUpdateTime!=null">
				b.last_update_time=#{lastUpdateTime},
			</if>
			<if test="rejectedMessage!=null">
				b.rejected_message=#{rejectedMessage},
			</if>
			<if test="exceptionStatus!=null">
				b.exception_status=#{exceptionStatus}
			</if>
		</trim>
		WHERE
		b.id = #{id}
	</update>
	
	<delete id="deleteBigholderAduit">
		delete from bigholder_area_audit where id=#{id} 
	</delete>

	<insert id="insertBigholderAduit" parameterType="java.util.List">
		INSERT INTO bigholder_area_audit(
		version,
		create_time,
		last_update_time,
		create_by,
		last_update_by,
		audit_status,
		rejected_message,
		exception_status,
		project_total,
		marketing_total,
		open_satisfaction,
		year_mon,
		area,
		satisfaction_scores,
		correspond_project,
		a41,
		a42,
		a43,
		a44,
		a51,
		a52,
		a53,
		a54,
		a61,
		a62,
		a71,
		a72,
		a73
		)
		VALUES
		<foreach collection="list" item="item" index="index"
			separator=",">
			(
			#{item.version},
			#{item.createTime},
			#{item.lastUpdateTime},
			#{item.createBy},
			#{item.lastUpdateBy},
			#{item.auditStatus},
			#{item.rejectedMessage},
			#{item.exceptionStatus},
			#{item.projectTotal},
			#{item.marketingTotal},
			#{item.openSatisfaction},
			#{item.yearMonth},
			#{item.area},
			#{item.satisfactionScores},
			#{item.correspondProject},
			#{item.a41},
			#{item.a42},
			#{item.a43},
			#{item.a44},
			#{item.a51},
			#{item.a52},
			#{item.a53},
			#{item.a54},
			#{item.a61},
			#{item.a62},
			#{item.a71},
			#{item.a72},
			#{item.a73}
			)
		</foreach>
	</insert>
</mapper>