<?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.BigholderPushPerdataMapper">

	<resultMap id="BigholderPushPerdataMap"
		type="cn.com.countrygarden.bi.main.model.bigholderAduit.BigholderPushPerdata">
		<id column="id" jdbcType="INTEGER" property="id" />
		<result column="area_aduit_id" jdbcType="VARCHAR" property="areaAduitId" />
		<result column="year_mon" jdbcType="VARCHAR" property="yearMon" />
		<result column="correspond_project" jdbcType="VARCHAR"
			property="correspondProject" />
		<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="satisfaction_scores" jdbcType="VARCHAR"
			property="satisfactionScores" />
		<result column="push_status" jdbcType="VARCHAR"
			property="pushStatus" />
		<result column="version" jdbcType="VARCHAR"
			property="version" />
	</resultMap>
	<select id="getAll" parameterType="Map" resultMap="BigholderPushPerdataMap">
		select * from bigholder_push_perdata b where
		b.year_mon=#{yearMonth} and b.push_status=#{pushStatus} 
		and b.version=(select max(version) from bigholder_push_perdata)
	</select>
	
	<update id="updatePushStatus" parameterType="cn.com.countrygarden.bi.main.model.bigholderAduit.BigholderPushPerdata">
		UPDATE
		bigholder_push_perdata b
		SET
		b.push_status=#{pushStatus}
		WHERE
		b.id=#{id}
	</update>
	
	<delete id="deleteAll" parameterType="java.util.List">
		delete from bigholder_push_perdata where id in
		<foreach collection="bigholderPushPerdatas" item="item" separator="," open="(" close=")">
			#{item.id}			
		</foreach>
	</delete>

	<insert id="insertBigholderPushPerdata" parameterType="java.util.List">
		INSERT INTO bigholder_push_perdata(
		version,
		area_aduit_id,
		year_mon,
		push_status,
		correspond_project,
		project_total,
		marketing_total,
		open_satisfaction,
		area,
		satisfaction_scores,
		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.areaAduitId},
			#{item.yearMon},
			#{item.pushStatus},
			#{item.correspondProject},
			#{item.projectTotal},
			#{item.marketingTotal},
			#{item.openSatisfaction},
			#{item.area},
			#{item.satisfactionScores},
			#{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>