<?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.bigholderSatisfy.BigholderSatisfyMapper1">

	<resultMap id="BigholderSatisfyMap"
		type="cn.com.countrygarden.bi.main.model.BigholderSatisfacationInfo">
		<id column="id" jdbcType="INTEGER" property="id" />
		<result column="answer_finish_time" jdbcType="TIMESTAMP"
			property="answerFinishTime" />
		<result column="correspond_project" jdbcType="VARCHAR"
			property="correspondProject" />
		<result column="answer_use_time" jdbcType="VARCHAR" property="answerUseTime" />
		<result column="answer_source" jdbcType="VARCHAR" property="answerSource" />
		<result column="answer_source_info" jdbcType="VARCHAR"
			property="answerSourceInfo" />
		<result column="answer_source_ip" jdbcType="VARCHAR" property="answerSourceIp" />
		<result column="a1" jdbcType="VARCHAR" property="a1" />
		<result column="a2" jdbcType="INTEGER" property="a2" />
		<result column="a3" jdbcType="VARCHAR" property="a3" />
		<result column="a41" jdbcType="INTEGER" property="a41" />
		<result column="a42" jdbcType="INTEGER" property="a42" />
		<result column="a43" jdbcType="INTEGER" property="a43" />
		<result column="a44" jdbcType="INTEGER" property="a44" />
		<result column="a51" jdbcType="INTEGER" property="a51" />
		<result column="a52" jdbcType="INTEGER" property="a52" />
		<result column="a53" jdbcType="INTEGER" property="a53" />
		<result column="a54" jdbcType="INTEGER" property="a54" />
		<result column="a61" jdbcType="INTEGER" property="a61" />
		<result column="a62" jdbcType="INTEGER" property="a62" />
		<result column="a71" jdbcType="INTEGER" property="a71" />
		<result column="a72" jdbcType="INTEGER" property="a72" />
		<result column="a8" jdbcType="VARCHAR" property="a8" />
		<result column="a9" jdbcType="VARCHAR" property="a9" />
		<result column="a10" jdbcType="VARCHAR" property="a10" />
		<result column="area" jdbcType="VARCHAR" property="area" />
		<result column="project_name" jdbcType="VARCHAR" property="projectName" />
		<result column="name" jdbcType="VARCHAR" property="name" />
		<result column="job" jdbcType="VARCHAR" property="job" />
		<result column="estate_area" jdbcType="VARCHAR" property="estateArea" />
		<result column="create_by" jdbcType="VARCHAR" property="createBy" />
		<result column="last_update_by" jdbcType="VARCHAR" property="lastUpdateBy" />
		<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
		<result column="last_update_date" jdbcType="TIMESTAMP"
			property="lastUpdateDate" />
		<result column="exception_struts" jdbcType="VARCHAR" property="exceptionStruts" />
		<result column="audit_status" jdbcType="VARCHAR" property="auditStatus" />
		<result column="exception_message" jdbcType="VARCHAR" property="exceptionMessage" />
		<result column="tb_user_code" jdbcType="VARCHAR" property="tbUserCode" />
		<result column="rejected_message" jdbcType="VARCHAR" property="rejectedMessage" />
		<result column="estate_area_isred" jdbcType="VARCHAR" property="estateAreaIsRed" />
		<result column="push_perdata_status" jdbcType="VARCHAR"
			property="pushPerdataStruts" />
	</resultMap>
	<select id="importTime" resultMap="BigholderSatisfyMap">
		select * from
		bigholder_satisfaction_info b
		where DATE_FORMAT(b.create_date,'%Y-%m')=#{yearMonth}  order by b.create_date desc
	</select>

	<select id="selectByErpCommunity" parameterType="String"
		resultMap="BigholderSatisfyMap">
		select * from bigholder_satisfaction_info as b
		where
		b.correspond_project=#{commId} and
		b.estate_area=#{area} and
		DATE_FORMAT(b.create_date,'%Y-%m')=#{yearMon}
	</select>

	<select id="getByProNameOrYear" parameterType="Map"
		resultMap="BigholderSatisfyMap">
		select * from
		bigholder_satisfaction_info as b
		where 1=1
		<if test="projectName!=null">
			and b.project_name=#{projectName}
		</if>
		<if test="area!=null">
			and b.estate_area=#{area}
		</if>
		and DATE_FORMAT(b.create_date,'%Y') IN
		<foreach item="item" index="index" collection="year" open="("
			separator="," close=")">
			#{item}
		</foreach>
	</select>

	<select id="getBSByProNameOrMonYear" parameterType="Map"
		resultMap="BigholderSatisfyMap">
		select * from
		bigholder_satisfaction_info as b
		where 1=1
		<if test="projectName!=null">
			and b.correspond_project=#{projectName}
		</if>
		<if test="area!=null">
			and b.estate_area=#{area}
		</if>
		and DATE_FORMAT(b.create_date,'%Y-%m') IN
		<foreach item="item" index="index" collection="yearMonth"
			open="(" separator="," close=")">
			#{item}
		</foreach>
	</select>

	<select id="findAll" parameterType="String" resultMap="BigholderSatisfyMap">
		select *
		from bigholder_satisfaction_info b where
		DATE_FORMAT(b.create_date,'%Y-%m')=#{yearMonth}
	</select>

	<select id="findAllByArea" parameterType="String" resultMap="BigholderSatisfyMap">
		select *
		from bigholder_satisfaction_info where
		1=1
		<if test="area!=null">
			and b.estate_area=#{area}
		</if>
	</select>

	<select id="getSfInfoByAreaOProject" parameterType="Map"
		resultMap="BigholderSatisfyMap">
		select * from bigholder_satisfaction_info as b
		where
		b.correspond_project=#{correspondProject} and b.estate_area=#{area}
		and DATE_FORMAT(b.create_date,'%Y-%m')=#{yearMonth}
	</select>

	<select id="getSelectByMonAndArea" resultMap="BigholderSatisfyMap">
		SELECT * FROM bigholder_satisfaction_info As b
		<where>
			1=1
			<if test="yearMonth!=null">
				AND DATE_FORMAT(b.create_date,'%Y-%m')=#{yearMonth}
			</if>
			<if test="area!=null">
				AND b.estate_area=#{area}
			</if>
		</where>
	</select>

	<select id="getSelectByYearAndArea" resultMap="BigholderSatisfyMap">
		SELECT * FROM bigholder_satisfaction_info As b
		<where>
			1=1
			<if test="year!=null">
				AND DATE_FORMAT(b.create_date,'%Y') IN
				<foreach item="item" index="index" collection="year" open="("
					separator="," close=")">
					#{item}
				</foreach>
			</if>
			<if test="area!=null">
				AND b.estate_area=#{area}
			</if>
		</where>
	</select>
	<select id="getByMonsAndArea" resultMap="BigholderSatisfyMap">
		SELECT * FROM bigholder_satisfaction_info As b
		<where>
			1=1
			<if test="yearMonth!=null">
				AND DATE_FORMAT(b.create_date,'%Y-%m')IN
				<foreach item="item" index="index" collection="yearMonth"
					open="(" separator="," close=")">
					#{item}
				</foreach>
			</if>
			<if test="area!=null">
				AND b.estate_area=#{area}
			</if>
		</where>
	</select>

	<select id="getByAreaOrProName" resultMap="BigholderSatisfyMap">
		SELECT * FROM bigholder_satisfaction_info As b
		<where>
			1=1
			<if test="area!=null">
				AND b.estate_area=#{area}
			</if>
			<if test="projectName!=null">
				AND b.project_name=#{projectName}
			</if>
		</where>
	</select>

	<select id="getSelectByMonAndAreas" resultMap="BigholderSatisfyMap">
		SELECT * FROM bigholder_satisfaction_info As b
		<where>
			1=1
			<if test="yearMonth!=null">
				AND DATE_FORMAT(b.create_date,'%Y-%m')=#{yearMonth}
			</if>
			<if test="areas!=null">
				AND b.estate_area IN
				<foreach item="item" index="index" collection="areas" open="("
					separator="," close=")">
					#{item}
				</foreach>
			</if>
		</where>
		order by b.estate_area
	</select>

	<select id="selectByNoThisId" parameterType="Map"
		resultMap="BigholderSatisfyMap">
		select * from bigholder_satisfaction_info as b
		where 
		<![CDATA[
		b.id<>#{id} 
		]]>
		and DATE_FORMAT(b.create_date,'%Y-%m')=#{yearMonth}
		and
		b.estate_area=#{area} and b.correspond_project=#{correspondProject}
	</select>

	<select id="getSelectByMonAreaAduit" resultMap="BigholderSatisfyMap">
		SELECT * FROM bigholder_satisfaction_info As b
		<where>
			1=1
			<if test="yearMonth!=null">
				AND DATE_FORMAT(b.create_date,'%Y-%m')=#{yearMonth}
			</if>
			<if test="area!=null">
				AND b.estate_area=#{area}
			</if>
			<if test="aduitStruts!=null">
				AND b.audit_status IN
				<foreach item="item" index="index" collection="aduitStruts"
					open="(" separator="," close=")">
					#{item}
				</foreach>
			</if>
		</where>
	</select>

	<select id="getSelectByMonAreasAduit" resultMap="BigholderSatisfyMap">
		SELECT * FROM bigholder_satisfaction_info As b
		<where>
			1=1
			<if test="yearMonth!=null">
				AND DATE_FORMAT(b.create_date,'%Y-%m')=#{yearMonth}
			</if>
			<if test="areas!=null">
				AND b.estate_area IN
				<foreach item="item" index="index" collection="areas" open="("
					separator="," close=")">
					#{item}
				</foreach>
			</if>
			<if test="aduitStruts!=null">
				AND b.audit_status IN
				<foreach item="item" index="index" collection="aduitStruts"
					open="(" separator="," close=")">
					#{item}
				</foreach>
			</if>
		</where>
	</select>

	<select id="getViewInfo" parameterType="String" resultMap="BigholderSatisfyMap">
		SELECT * FROM bigholder_satisfaction_info As b where
		b.id=#{id}
		order by b.estate_area
	</select>

	<update id="updateExceptionStatus" parameterType="Map">
		UPDATE
		bigholder_satisfaction_info b
		SET
		b.exception_struts=#{exceptionStruts},
		b.exception_message=#{exceptionMessage}
		WHERE
		b.id=#{id}
	</update>

	<update id="updateAuditStatus"
		parameterType="cn.com.countrygarden.bi.main.model.BigholderSatisfacationInfo">
		UPDATE
		bigholder_satisfaction_info b
		<trim prefix="set" suffixOverrides=",">
			<if test="auditStatus">
				b.audit_status=#{auditStatus},
			</if>
			<if test="lastUpdateBy">
				b.last_update_by=#{lastUpdateBy},
			</if>
			<if test="lastUpdateDate">
				b.last_update_date=#{lastUpdateDate},
			</if>
		</trim>
		WHERE
		b.id=#{id}
	</update>

	<update id="updateBigholderSatisfy">
		UPDATE
		bigholder_satisfaction_info b
		SET
		<if test="commName!=null">
			b.project_name=#{commName},
		</if>
		b.correspond_project=#{correspondProject}
		WHERE
		b.id=#{id}
	</update>

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

	<update id="updateAreaOrProjectName">
		UPDATE
		bigholder_satisfaction_info b
		<trim prefix="set" suffixOverrides=",">
			<if test="exceptionStruts!=null">
				b.exception_struts=#{exceptionStruts},
			</if>
			<if test="estateArea!=null">
				b.estate_area=#{estateArea},
			</if>
			<if test="exceptionMessage!=null">
				b.exception_message=#{exceptionMessage},
			</if>
			    b.correspond_project=#{correspondProject}
		</trim>
		WHERE
		b.id=#{id}
	</update>

	<update id="updateRejectedInfo"
		parameterType="cn.com.countrygarden.bi.main.model.BigholderSatisfacationInfo">
		UPDATE
		bigholder_satisfaction_info b
		<trim prefix="set" suffixOverrides=",">
			<if test="auditStatus">
				b.audit_status=#{auditStatus},
			</if>
			<if test="rejectedMessage">
				b.rejected_message=#{rejectedMessage},
			</if>
			<if test="exceptionStruts">
				b.exception_struts=#{exceptionStruts},
			</if>
			<if test="lastUpdateDate">
				b.last_update_date=#{lastUpdateDate},
			</if>
			<if test="lastUpdateBy">
				b.last_update_by=#{lastUpdateBy}
			</if>
		</trim>
		WHERE
		b.id = #{id}
	</update>
	
	<update id="updateAllStatus"
		parameterType="cn.com.countrygarden.bi.main.model.BigholderSatisfacationInfo">
		UPDATE
		bigholder_satisfaction_info b
		<trim prefix="set" suffixOverrides=",">
			<if test="auditStatus">
				b.audit_status=#{auditStatus},
			</if>
			<if test="pushPerdataStruts">
				b.push_perdata_status=#{pushPerdataStruts},
			</if>
			<if test="exceptionStruts">
				b.exception_struts=#{exceptionStruts},
			</if>
			<if test="lastUpdateDate">
				b.last_update_date=#{lastUpdateDate},
			</if>
			<if test="lastUpdateBy">
				b.last_update_by=#{lastUpdateBy}
			</if>
		</trim>
		WHERE
		b.id = #{id}
	</update>

	<delete id="deleteExceptionStatus">
		DELETE FROM bigholder_satisfaction_info
		WHERE
		id=#{id}
	</delete>
	<delete id="deleteById" parameterType="java.util.List">
		delete from bigholder_satisfaction_info where id in
		<foreach collection="list1" item="item" separator="," open="("
			close=")">
			#{item.id}
		</foreach>
	</delete>
</mapper>