<?xml version="1.0" encoding="UTF-8" ?>    
<!DOCTYPE mapper    
PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"    
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">

<mapper namespace="com.platform.dao.DataInfoMoveTmpDao">
	<resultMap id="getEntityByText" type="com.platform.entities.DataInfoEntityMoveTmp">
		<id property="id" column="id" javaType="int" jdbcType="INTEGER" />
		<result property="regionalismCode" column="regionalism_code"
			javaType="string" jdbcType="VARCHAR" />
		<result property="cityName" column="city_name" javaType="string"
			jdbcType="VARCHAR" />
		<result property="districtName" column="district_name"
			javaType="string" jdbcType="VARCHAR" />
		<result property="systemCode" column="system_code" javaType="int"
			jdbcType="INTEGER" />
		<result property="systemName" column="system_name" javaType="string"
			jdbcType="VARCHAR" />
		<result property="dataType" column="data_type" javaType="string"
			jdbcType="VARCHAR" />
		<result property="dataVersion" column="data_version" javaType="int"
			jdbcType="INTEGER" />
		<result property="submittedBatch" column="submitted_batch"
			javaType="string" jdbcType="VARCHAR" />
		<result property="dataPath" column="data_path" javaType="string"
			jdbcType="VARCHAR" />
		<result property="charset" column="data_charset" javaType="string"
			jdbcType="VARCHAR" />
		<result property="collectingTime" column="collection_time"
			javaType="string" jdbcType="DATE" />
		<result property="collectorContacts" column="collector_contacts"
			javaType="string" jdbcType="VARCHAR" />
		<result property="collectorName" column="collector_name"
			javaType="string" jdbcType="VARCHAR" />
		<result property="year" column="data_year" javaType="string"
			jdbcType="VARCHAR" />
			
		<result property="dstPath" column="dst_path" javaType="string"
		jdbcType="VARCHAR" />
		<result property="completeStatus" column="complete_status" javaType="string"
		jdbcType="VARCHAR" />
		<result property="rate" column="rate" javaType="int"
		jdbcType="INTEGER" />
		<result property="lastTime" column="lasttime"
			javaType="string" jdbcType="VARCHAR" />
			
			<result property="fkid" column="fkid" javaType="int" jdbcType="INTEGER" />
	</resultMap>
	
	<sql id="Base_Column_List">
		regionalism_code,system_code,dst_path,lasttime,fkid
	</sql>
	
	<!-- 获取数据全部记录信息 -->
	<select id="findAll" resultType="com.platform.entities.DataInfoEntityMoveTmp">
		SELECT
		a.id id,a.regionalism_code regionalismCode,b.city_name cityName,b.district_name districtName,
		 a.system_code systemCode,b.system_name systemName,b.data_type dataType,b.data_version dataVersion,
		 b.submitted_batch submittedBatch,b.data_path dataPath,b.data_charset charset,b.collection_time collectingTime,
		 b.collector_name collectorName,b.collector_contacts collectorContacts,b.data_year dataYear,a.dst_path dstPath,
		 a.complete_status completeStatus,a.rate rate, a.lasttime lastTime
		FROM 
		move_data_tmp a LEFT JOIN data_details b 
		ON a.system_code = b.system_code AND a.regionalism_code = b.regionalism_code AND a.fkid = b.id
		ORDER BY a.id
	</select>
	
	<update id="update" parameterType="com.platform.entities.DataInfoEntityMoveTmp">
		UPDATE
		move_data_tmp
		<set >
			<trim suffixOverrides=",">
				<if test="dstPath != null and dstPath != ''">
					dst_path= #{dstPath},
				</if>
				<if test="completeStatus != null and completeStatus != ''">
					complete_status= #{completeStatus},
				</if>
				<if test="rate > 0">
					rate= #{rate},
				</if>
				<if test="lastTime != null and lastTime != ''">
					lasttime= #{lastTime},
				</if>
			</trim>
		</set>
		<where>
			id = #{id}
		</where>
	</update>
	
	<insert id="save" parameterType="com.platform.entities.DataInfoEntityMoveTmp">
		INSERT INTO
		move_data_tmp(
		<trim suffixOverrides=",">
			<if test="id > 0">
				id,
			</if>
			<if test="regionalismCode != null and regionalismCode != ''">
				regionalism_code,
			</if>
			<if test="systemCode != null">
				system_code,
			</if>
			<if test="dstPath != null and dstPath != ''">
				dst_path,
			</if>
			<if test="completeStatus != null and completeStatus != ''">
				complete_status,
			</if>
			<if test="rate > 0">
				rate,
			</if>
			<if test="lastTime != null and lastTime != ''">
				lasttime,
			</if>
			<if test="fkid > 0 ">
				fkid,
			</if>
		</trim>
		)
		VALUES(
		<trim suffixOverrides=",">
			<if test="id > 0">
				id,
			</if>
			<if test="regionalismCode != null and regionalismCode != ''">
				#{regionalismCode},
			</if>
			<if test="systemCode != null and systemCode != ''">
				#{systemCode},
			</if>
			<if test="dstPath != null and dstPath != ''">
				#{dstPath},
			</if>
			<if test="completeStatus != null and completeStatus != ''">
				#{completeStatus},
			</if>
			<if test="rate > 0">
				#{rate}
			</if>
			<if test="lastTime != null and lastTime != ''">
				#{lastTime},
			</if>
			<if test="fkid > 0 ">
				#{fkid),
			</if>
		</trim>
		)
	</insert>
	
	<select id="insertBatch" parameterType="java.util.List">
	    INSERT INTO move_data_tmp ( <include refid="Base_Column_List" /> ) 
	    VALUES 
	    <foreach collection="list" item="item" index="index" separator=",">
	        (#{item.regionalismCode,jdbcType=VARCHAR},#{item.systemCode,jdbcType=INTEGER},#{item.dstPath,jdbcType=VARCHAR},#{item.lastTime,jdbcType=VARCHAR},#{item.fkid})
	    </foreach>
	</select> 
	
	<delete id="remove" parameterType="java.lang.Integer">
		DELETE FROM
			move_data_tmp 
		WHERE
			id = #{id}
	</delete>
<!-- 获取数据符合筛选条件的总记录条数 -->
	<!-- 
	<select id="getLimitedDataCount" resultType="java.lang.Integer"
		parameterType="PagerOptions">
		SELECT COUNT(id) FROM move_data_tmp
		<if test="PagerOptions!=null">
			<where>
				<include refid="conditionsFilters" />
			</where>
		</if>

	</select>

	获取数据查询的起始di
	<select id="getLimitedBeginId" resultType="java.lang.Integer"
		parameterType="PagerOptions">
		SELECT MAX(idx) FROM (SELECT id idx FROM move_data_tmp
		ORDER BY id LIMIT 0,#{PagerOptions.totalLimit}) AS TEMP
	</select> -->

</mapper>  