<?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="lingtao.net.dao.Finance3Mapper">

	<!-- 查询列表 -->
	<select id="getFinance" parameterType="Finance" resultType="Finance">
		select * from tbl_sys_finance3
		<where>
			<if test="creator != null and creator != ''">
				and creator = #{creator}
			</if>
			<if test="filename != null and filename != ''">
				and filename = #{filename}
			</if>
			<if test="orderNumber != null and orderNumber != ''">
				and order_number like "%${orderNumber}%"
			</if>
		</where>
		ORDER BY create_date DESC,id ASC 
	</select>
	
	<select id="getAllFilename" parameterType="String" resultType="String">
		SELECT 
		  	DISTINCT filename 
		FROM
		  	tbl_sys_finance3 
		WHERE creator = #{creator}
		ORDER BY create_date DESC 
	</select>

   	<!-- 批量插入 -->
  	<insert id="insertForeach" parameterType="java.util.List">
	    insert into tbl_sys_finance3 (
	      id, add_time, supplier, 
	      shopname, kind, kind2, 
	      order_number, filename, count, 
	      number, zhang,remark, creator)
	    values 
	    <foreach collection="list" item="item" index="index" separator=",">
	     (
	      null,#{item.addTime},#{item.supplier},#{item.shopname},#{item.kind},
	      #{item.kind2},#{item.orderNumber},#{item.filename},#{item.count},#{item.number},
	      #{item.zhang},#{item.remark},#{item.creator})
	    </foreach>		
  	</insert>
  	
  	<!-- 导入数据前查询数据是否已存在，存在就不插入 -->
  	<select id="checkAccountNumber" parameterType="String" resultType="String">
		SELECT 
		  order_number 
		FROM
		  tbl_sys_finance3 
		WHERE order_number = #{orderNumber} 
  	</select>
  	
  	<!-- 拼版计算4开始 -->
  	<select id="getFinance4" parameterType="Finance" resultType="Finance">
		select * from tbl_sys_finance4
		<where>
			<if test="creator != null and creator != ''">
				and creator = #{creator}
			</if>
			<if test="filename != null and filename != ''">
				and filename = #{filename}
			</if>
			<if test="orderNumber != null and orderNumber != ''">
				and order_number like "%${orderNumber}%"
			</if>
		</where>
		ORDER BY create_date DESC,id ASC 
	</select>
	
	<select id="getAllFilename4" parameterType="String" resultType="String">
		SELECT 
		  	DISTINCT filename 
		FROM
		  	tbl_sys_finance4 
		WHERE creator = #{creator}
		ORDER BY create_date DESC 
	</select>
	
	<insert id="insertForeach4" parameterType="java.util.List">
	    insert into tbl_sys_finance4 (
	      id, add_time, supplier, 
	      shopname, kind, kind2, 
	      order_number, filename, count, 
	      number, zhang,remark, creator)
	    values 
	    <foreach collection="list" item="item" index="index" separator=",">
	     (
	      null,#{item.addTime},#{item.supplier},#{item.shopname},#{item.kind},
	      #{item.kind2},#{item.orderNumber},#{item.filename},#{item.count},#{item.number},
	      #{item.zhang},#{item.remark},#{item.creator})
	    </foreach>		
  	</insert>
  	
  	<select id="checkAccountNumber4" parameterType="String" resultType="String">
		SELECT 
		  order_number 
		FROM
		  tbl_sys_finance4 
		WHERE order_number = #{orderNumber} 
  	</select>
  	<!-- 拼版计算4结束 -->
  	<!-- 拼版计算5开始 -->
  	<select id="getFinance5" parameterType="Finance" resultType="Finance">
		select * from tbl_sys_finance5
		<where>
			<if test="creator != null and creator != ''">
				and creator = #{creator}
			</if>
			<if test="filename != null and filename != ''">
				and filename = #{filename}
			</if>
			<if test="orderNumber != null and orderNumber != ''">
				and order_number like "%${orderNumber}%"
			</if>
		</where>
		ORDER BY create_date DESC,id ASC 
	</select>
	
	<select id="getAllFilename5" parameterType="String" resultType="String">
		SELECT 
		  	DISTINCT filename 
		FROM
		  	tbl_sys_finance5 
		WHERE creator = #{creator}
		ORDER BY create_date DESC 
	</select>
	
	<insert id="insertForeach5" parameterType="java.util.List">
	    insert into tbl_sys_finance5 (
	      id, add_time, supplier, 
	      shopname, kind, kind2, 
	      order_number, filename, count, 
	      number, zhang,remark, creator)
	    values 
	    <foreach collection="list" item="item" index="index" separator=",">
	     (
	      null,#{item.addTime},#{item.supplier},#{item.shopname},#{item.kind},
	      #{item.kind2},#{item.orderNumber},#{item.filename},#{item.count},#{item.number},
	      #{item.zhang},#{item.remark},#{item.creator})
	    </foreach>		
  	</insert>
  	
  	<select id="checkAccountNumber5" parameterType="String" resultType="String">
		SELECT 
		  order_number 
		FROM
		  tbl_sys_finance5 
		WHERE order_number = #{orderNumber} 
  	</select>
  	<!-- 拼版计算5结束 -->
  	<!-- 拼版计算6开始 -->
  	<select id="getFinance6" parameterType="Finance" resultType="Finance">
		select * from tbl_sys_finance6
		<where>
			<if test="creator != null and creator != ''">
				and creator = #{creator}
			</if>
			<if test="filename != null and filename != ''">
				and filename = #{filename}
			</if>
			<if test="orderNumber != null and orderNumber != ''">
				and order_number like "%${orderNumber}%"
			</if>
		</where>
		ORDER BY create_date DESC,id ASC 
	</select>
	
	<select id="getAllFilename6" parameterType="String" resultType="String">
		SELECT 
		  	DISTINCT filename 
		FROM
		  	tbl_sys_finance6
		WHERE creator = #{creator}
		ORDER BY create_date DESC 
	</select>
	
	<insert id="insertForeach6" parameterType="java.util.List">
	    insert into tbl_sys_finance6 (
	      id, add_time, supplier, 
	      shopname, kind, kind2, 
	      order_number, filename, count, 
	      number, zhang,remark, creator)
	    values 
	    <foreach collection="list" item="item" index="index" separator=",">
	     (
	      null,#{item.addTime},#{item.supplier},#{item.shopname},#{item.kind},
	      #{item.kind2},#{item.orderNumber},#{item.filename},#{item.count},#{item.number},
	      #{item.zhang},#{item.remark},#{item.creator})
	    </foreach>		
  	</insert>
  	
  	<select id="checkAccountNumber6" parameterType="String" resultType="String">
		SELECT 
		  order_number 
		FROM
		  tbl_sys_finance6
		WHERE order_number = #{orderNumber} 
  	</select>
  	<!-- 拼版计算6结束 -->
  	<!-- 拼版计算7开始 -->
  	<select id="getFinance7" parameterType="Finance" resultType="Finance">
		select * from tbl_sys_finance7
		<where>
			<if test="creator != null and creator != ''">
				and creator = #{creator}
			</if>
			<if test="filename != null and filename != ''">
				and filename = #{filename}
			</if>
			<if test="orderNumber != null and orderNumber != ''">
				and order_number like "%${orderNumber}%"
			</if>
		</where>
		ORDER BY create_date DESC,id ASC 
	</select>
	
	<select id="getAllFilename7" parameterType="String" resultType="String">
		SELECT 
		  	DISTINCT filename 
		FROM
		  	tbl_sys_finance7
		WHERE creator = #{creator}
		ORDER BY create_date DESC 
	</select>
	
	<insert id="insertForeach7" parameterType="java.util.List">
	    insert into tbl_sys_finance7 (
	      id, add_time, supplier, 
	      shopname, kind, kind2, 
	      order_number, filename, count, 
	      number, zhang,remark, creator)
	    values 
	    <foreach collection="list" item="item" index="index" separator=",">
	     (
	      null,#{item.addTime},#{item.supplier},#{item.shopname},#{item.kind},
	      #{item.kind2},#{item.orderNumber},#{item.filename},#{item.count},#{item.number},
	      #{item.zhang},#{item.remark},#{item.creator})
	    </foreach>		
  	</insert>
  	
  	<select id="checkAccountNumber7" parameterType="String" resultType="String">
		SELECT 
		  order_number 
		FROM
		  tbl_sys_finance7
		WHERE order_number = #{orderNumber} 
  	</select>
  	<!-- 拼版计算7结束 -->
</mapper>