<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~
  ~      Copyright (c) 2018-2025, lengleng All rights reserved.
  ~
  ~  Redistribution and use in source and binary forms, with or without
  ~  modification, are permitted provided that the following conditions are met:
  ~
  ~ Redistributions of source code must retain the above copyright notice,
  ~  this list of conditions and the following disclaimer.
  ~  Redistributions in binary form must reproduce the above copyright
  ~  notice, this list of conditions and the following disclaimer in the
  ~  documentation and/or other materials provided with the distribution.
  ~  Neither the name of the yifu4cloud.com developer nor the names of its
  ~  contributors may be used to endorse or promote products derived from
  ~  this software without specific prior written permission.
  ~  Author: lengleng (wangiegie@gmail.com)
  ~
  -->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.yifu.cloud.plus.v1.yifu.salary.mapper.TSalaryZeroMapper">

  <resultMap id="tSalaryZeroMap" type="com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryZero">
    <id property="id" column="ID"/>
    <result property="empName" column="EMP_NAME"/>
    <result property="empIdcard" column="EMP_IDCARD"/>
    <result property="empPhone" column="EMP_PHONE"/>
    <result property="deptId" column="DEPT_ID"/>
    <result property="deptName" column="DEPT_NAME"/>
    <result property="deptNo" column="DEPT_NO"/>
    <result property="settleMonth" column="SETTLE_MONTH"/>
    <result property="invoiceTitle" column="INVOICE_TITLE"/>
    <result property="costReduction" column="COST_REDUCTION"/>
    <result property="taxMonth" column="TAX_MONTH"/>
    <result property="dataSource" column="DATA_SOURCE"/>
    <result property="importerName" column="IMPORTER_NAME"/>
    <result property="deleteFlag" column="DELETE_FLAG"/>
    <result property="createTime" column="CREATE_TIME"/>
  </resultMap>

	<!-- 导出 -->
	<resultMap id="tSalaryZeroExportMap" type="com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryZeroExportVo">
    <result property="empName" column="EMP_NAME"/>
    <result property="empIdcard" column="EMP_IDCARD"/>
    <result property="empPhone" column="EMP_PHONE"/>
    <result property="deptName" column="DEPT_NAME"/>
    <result property="deptNo" column="DEPT_NO"/>
    <result property="settleMonth" column="SETTLE_MONTH"/>
    <result property="invoiceTitle" column="INVOICE_TITLE"/>
    <result property="costReduction" column="COST_REDUCTION"/>
    <result property="taxMonth" column="TAX_MONTH"/>
    <result property="dataSource" column="DATA_SOURCE"/>
    <result property="importerName" column="IMPORTER_NAME"/>
  </resultMap>
    <sql id="Base_Column_List">
			concat(id,'_',left(SETTLE_MONTH,4)) ID,
			a.EMP_NAME,
			a.EMP_IDCARD,
			a.EMP_PHONE,
			a.DEPT_ID,
			a.DEPT_NAME,
			a.DEPT_NO,
			a.SETTLE_MONTH,
			a.INVOICE_TITLE,
			a.COST_REDUCTION,
			a.TAX_MONTH,
			a.DATA_SOURCE,
			a.IMPORTER_NAME,
			a.DELETE_FLAG,
			a.CREATE_TIME
    </sql>
	<sql id="Base_Export_List">
                a.EMP_NAME,
                a.EMP_IDCARD,
                a.EMP_PHONE,
                a.DEPT_NAME,
                a.DEPT_NO,
                a.SETTLE_MONTH,
                a.INVOICE_TITLE,
                a.COST_REDUCTION,
                a.TAX_MONTH,
                case a.DATA_SOURCE when '1' then '项目' when '2' then '商险' when '3' then '导入' else '-' end as DATA_SOURCE,
                a.IMPORTER_NAME
    </sql>
    <sql id="tSalaryZero_where">
        <if test="tSalaryZero != null">
				<if test="tSalaryZero.id != null and tSalaryZero.id.trim() != ''">
					AND a.ID = #{tSalaryZero.id}
				</if>
				<if test="tSalaryZero.empName != null and tSalaryZero.empName.trim() != ''">
					AND a.EMP_NAME = #{tSalaryZero.empName}
				</if>
				<if test="tSalaryZero.empIdcard != null and tSalaryZero.empIdcard.trim() != ''">
					AND a.EMP_IDCARD = #{tSalaryZero.empIdcard}
				</if>
				<if test="tSalaryZero.empPhone != null and tSalaryZero.empPhone.trim() != ''">
					AND a.EMP_PHONE = #{tSalaryZero.empPhone}
				</if>
				<if test="tSalaryZero.deptId != null and tSalaryZero.deptId.trim() != ''">
					AND a.DEPT_ID = #{tSalaryZero.deptId}
				</if>
				<if test="tSalaryZero.deptName != null and tSalaryZero.deptName.trim() != ''">
					AND a.DEPT_NAME = #{tSalaryZero.deptName}
				</if>
				<if test="tSalaryZero.deptNo != null and tSalaryZero.deptNo.trim() != ''">
					AND a.DEPT_NO = #{tSalaryZero.deptNo}
				</if>
				<if test="tSalaryZero.settleMonth != null and tSalaryZero.settleMonth.trim() != ''">
					AND a.SETTLE_MONTH = #{tSalaryZero.settleMonth}
				</if>
				<if test="tSalaryZero.invoiceTitle != null and tSalaryZero.invoiceTitle.trim() != ''">
					AND a.INVOICE_TITLE = #{tSalaryZero.invoiceTitle}
				</if>
				<if test="tSalaryZero.costReduction != null">
					AND a.COST_REDUCTION = #{tSalaryZero.costReduction}
				</if>
				<if test="tSalaryZero.taxMonth != null and tSalaryZero.taxMonth.trim() != ''">
					AND a.TAX_MONTH = #{tSalaryZero.taxMonth}
				</if>
				<if test="tSalaryZero.dataSource != null and tSalaryZero.dataSource.trim() != ''">
					AND a.DATA_SOURCE = #{tSalaryZero.dataSource}
				</if>
				<if test="tSalaryZero.importerName != null and tSalaryZero.importerName.trim() != ''">
					AND a.IMPORTER_NAME = #{tSalaryZero.importerName}
				</if>
				<if test="tSalaryZero.deleteFlag != null">
					AND a.DELETE_FLAG = #{tSalaryZero.deleteFlag}
				</if>
				<if test="tSalaryZero.createTime != null">
					AND a.CREATE_TIME = #{tSalaryZero.createTime}
				</if>
				<if test="tSalaryZero.authSql != null and tSalaryZero.authSql.trim() != ''">
					${tSalaryZero.authSql}
				</if>
        </if>
    </sql>
	<!--查询详情-->
	<select id="getTSalaryZeroById" resultMap="tSalaryZeroMap">
		SELECT
			<include refid="Base_Column_List"/>
		FROM ${tableName} a
		where a.ID = #{id}
		limit 1
	</select>
	<!--删除-->
	<update id="deleteTSalaryZeroById">
		update ${tableName} a
		set a.DELETE_FLAG = 1
		where a.ID = #{id}
	</update>
	<!--批量删除-->
	<update id="deleteTSalaryZeroByIdList">
		update ${tableName} a
		set a.DELETE_FLAG = 1
		where a.ID in
		<foreach item="item" collection="idList" separator="," open="(" close=")" index="">
			#{item}
		</foreach>
	</update>
    <!--tSalaryZero简单分页查询-->
    <select id="getTSalaryZeroPage" resultMap="tSalaryZeroMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM ${tableName} a
        <where>
			a.DELETE_FLAG = 0
            <include refid="tSalaryZero_where"/>
        </where>
		order by a.CREATE_TIME desc
    </select>

    <!--tSalaryZero简单分页查询-->
    <select id="getTSalaryZeroCount" resultType="java.lang.Long">
        SELECT
        	count(1)
        FROM ${tableName} a
        <where>
			a.DELETE_FLAG = 0
			<include refid="tSalaryZero_where"/>
        </where>
    </select>


	<!--导出-->
	<select id="getTSalaryZeroExport" resultMap="tSalaryZeroExportMap">
		SELECT
		<include refid="Base_Export_List"/>
		FROM ${tableName} a
		<where>
			a.DELETE_FLAG = 0
			<include refid="tSalaryZero_where"/>
		</where>
		order by a.CREATE_TIME desc
		<if test="tSalaryZero != null">
			<if test="tSalaryZero.limitStart != null">
				limit #{tSalaryZero.limitStart},#{tSalaryZero.limitEnd}
			</if>
		</if>
	</select>

	<!--获取已存在的身份证去重-->
	<select id="getIdListByCardAndTitleAndMonth" resultType="java.lang.String">
		SELECT
			a.EMP_IDCARD
		FROM ${tableName} a
		where a.INVOICE_TITLE = #{invoiceTitle} and a.SETTLE_MONTH = #{settleMonth} and a.DELETE_FLAG=0
		and a.EMP_IDCARD in
		<foreach item="idStr" index="index" collection="cardList" open="(" separator="," close=")">
			#{idStr}
		</foreach>
	</select>

	<!-- 自动创建年度0申报表 -->
	<update id="createSalaryZeroYear" statementType="STATEMENT">
		CREATE TABLE IF NOT EXISTS ${tableName} (
			`ID` varchar(32) NOT NULL COMMENT '主键',
			`EMP_NAME` varchar(50) NOT NULL COMMENT '员工姓名',
			`EMP_IDCARD` varchar(25) NOT NULL COMMENT '身份证号',
			`EMP_PHONE` varchar(11) DEFAULT NULL COMMENT '手机号码',
			`DEPT_ID` varchar(32) NOT NULL COMMENT '项目ID',
			`DEPT_NAME` varchar(50) NOT NULL COMMENT '项目名称',
			`DEPT_NO` varchar(50) NOT NULL COMMENT '项目编码',
			`SETTLE_MONTH` varchar(6) NOT NULL COMMENT '结算月份',
			`INVOICE_TITLE` varchar(50) NOT NULL COMMENT '封面抬头',
			`COST_REDUCTION` decimal(11,0) NOT NULL COMMENT '减除费用',
			`TAX_MONTH` varchar(6) NOT NULL COMMENT '计税月份',
			`DATA_SOURCE` char(1) NOT NULL DEFAULT '1' COMMENT '数据来源：1：项目；2商险；3导入',
			`IMPORTER_NAME` varchar(10) DEFAULT NULL COMMENT '导入人',
			`DELETE_FLAG` int(1) unsigned zerofill NOT NULL DEFAULT '0' COMMENT '页面假删除0：正常；1：已删除；2存在报账假删除',
			`CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间',
			PRIMARY KEY (`ID`),
			KEY `SY_ZERO_DEPT_NO` (`DEPT_NO`),
			KEY `SY_ZERO_DEPT_ID` (`DEPT_ID`),
			KEY `SY_ZERO_SETTLE_MONTH` (`SETTLE_MONTH`),
			KEY `SY_ZERO_IDCARD` (`EMP_IDCARD`),
			KEY `SY_ZERO_UNION_QUERY` (`EMP_IDCARD`,`SETTLE_MONTH`,`INVOICE_TITLE`,`DELETE_FLAG`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='薪资0申报表'
	</update>

	<update id="clearTempZeroYear" statementType="STATEMENT">
		TRUNCATE t_salary_zero_tmp
	</update>
	<update id="clearTempZeroDay" statementType="STATEMENT">
		TRUNCATE t_salary_zero_day_tmp
	</update>
	<update id="deleteCurTempZeroDay" statementType="STATEMENT">
		DELETE d
		FROM t_salary_zero_day_tmp d
		INNER JOIN ${tableName} t
			ON t.EMP_IDCARD = d.EMP_IDCARD
			AND t.INVOICE_TITLE = d.INVOICE_TITLE
			AND t.SETTLE_MONTH = d.SETTLE_MONTH
			AND t.DELETE_FLAG in (0,2)
	</update>
	<!-- 自动创建临时表（1月创建含去年12月的计税月份）（2月更新成当年的上月的计税月份） （不含减除费用与）-->
	<update id="createTempZeroYearView" statementType="STATEMENT">
		CREATE OR REPLACE VIEW ${viewYearName} AS
		SELECT
				  REPLACE(UUID(),'-','') ID,
				  ep.EMP_NAME,
				  ep.EMP_IDCARD,
				  if(length(e.EMP_PHONE)=11,e.EMP_PHONE,null) EMP_PHONE,
				  ep.DEPT_ID,
				  ep.DEPT_NAME,
				  ep.DEPT_NO,
				  DATE_FORMAT(now(),'%Y%m') as SETTLE_MONTH,
				  d.INVOICE_TITLE_SALARY as INVOICE_TITLE, -- 需要根据项目关联的实际封面抬头调整
				  0 as COST_REDUCTION,
				  '200001' as TAX_MONTH,
				  '1' as DATA_SOURCE, -- 1:项目
				  NULL as IMPORTER_NAME,
				  0 as DELETE_FLAG,
				  NOW() as CREATE_TIME
			  FROM mvp_archives.t_employee_project ep
					   left join mvp_archives.t_employee_info e on e.EMP_IDCARD=ep.EMP_IDCARD
					   left join mvp_archives.t_settle_domain d on d.id=ep.DEPT_ID
			  WHERE ep.PROJECT_STATUS =0 -- 0草稿、1已审核
				AND ep.DELETE_FLAG = '0' and d.INVOICE_TITLE_SALARY is not null and d.INVOICE_TITLE_SALARY != ''
			  GROUP BY ep.EMP_IDCARD,d.INVOICE_TITLE_SALARY
			  union ALL
			  SELECT REPLACE(UUID(),'-','') ID,id.EMP_NAME,
				  id.EMP_IDCARD_NO as EMP_IDCARD,
				  NULL as EMP_PHONE,
				  id.DEPT_ID,
				  id.DEPT_NAME,
				  id.DEPT_NO,
				  DATE_FORMAT(now(),'%Y%m') as SETTLE_MONTH,
				  d.INVOICE_TITLE_SALARY as INVOICE_TITLE, -- 需要根据项目关联的实际封面抬头调整
					 0 as COST_REDUCTION,
					 '200001' as TAX_MONTH,
				  '2' as DATA_SOURCE, -- 2:商险
				  NULL as IMPORTER_NAME,
				  0 as DELETE_FLAG,
				  NOW() as CREATE_TIME
			  FROM mvp_insurances.t_insurance_detail id
				  left join mvp_archives.t_settle_domain d on d.id=id.DEPT_ID
			  WHERE id.BUY_HANDLE_STATUS = 3 -- 已投保
				AND id.IS_EFFECT = 0 -- 有效
				AND id.IS_OVERDUE = 0 -- 未过期
				AND (id.REDUCE_HANDLE_STATUS != 4 OR id.REDUCE_HANDLE_STATUS IS NULL) -- 非减员成功
				AND id.DELETE_FLAG = 0 and d.INVOICE_TITLE_SALARY is not null and d.INVOICE_TITLE_SALARY != ''
				AND NOT EXISTS (
				  SELECT 1
				  FROM mvp_archives.t_employee_project ep2
				  left join mvp_archives.t_settle_domain d2 on d2.id=ep2.DEPT_ID
				  WHERE ep2.EMP_IDCARD = id.EMP_IDCARD_NO and d2.INVOICE_TITLE_SALARY=d.INVOICE_TITLE_SALARY
				AND ep2.PROJECT_STATUS =0 AND ep2.DELETE_FLAG = '0'
				  )
			  GROUP BY id.EMP_IDCARD_NO,d.INVOICE_TITLE_SALARY
	</update>

	<!-- 自动创建临时表（1月创建含去年12月的计税月份）（2月更新成当年的上月的计税月份） （不含减除费用与）-->
	<update id="createTempZeroYear" statementType="STATEMENT">
		insert into t_salary_zero_tmp ( select * FROM ${viewYearName} )
	</update>

	<!-- 自动创建临时表（1月创建含去年12月的计税月份）（2月更新成当年的上月的计税月份） （不含减除费用与）-->
	<update id="createTempZeroDayView" statementType="STATEMENT">
		CREATE OR REPLACE VIEW ${viewDayName} AS
		SELECT
				  REPLACE(UUID(),'-','') ID,
				  ep.EMP_NAME,
				  ep.EMP_IDCARD,
				  if(length(e.EMP_PHONE)=11,e.EMP_PHONE,null) EMP_PHONE,
				  ep.DEPT_ID,
				  ep.DEPT_NAME,
				  ep.DEPT_NO,
				  DATE_FORMAT(now(),'%Y%m') as SETTLE_MONTH,
				  d.INVOICE_TITLE_SALARY as INVOICE_TITLE, -- 需要根据项目关联的实际封面抬头调整
				  0 as COST_REDUCTION,
				  '200001' as TAX_MONTH,
				  '1' as DATA_SOURCE, -- 1:项目
				  NULL as IMPORTER_NAME,
				  0 as DELETE_FLAG,
				  NOW() as CREATE_TIME
			  FROM mvp_archives.t_employee_project ep
					   left join mvp_archives.t_employee_info e on e.EMP_IDCARD=ep.EMP_IDCARD
					   left join mvp_archives.t_settle_domain d on d.id=ep.DEPT_ID
			  WHERE ep.PROJECT_STATUS =0 -- 0草稿、1已审核
				AND ep.DELETE_FLAG = '0' and d.INVOICE_TITLE_SALARY is not null and d.INVOICE_TITLE_SALARY != ''
		AND DATE_FORMAT(ep.UPDATE_TIME,'%Y%m%d')  = DATE_FORMAT(NOW(), '%Y%m%d')


			  GROUP BY ep.EMP_IDCARD,d.INVOICE_TITLE_SALARY
			  union ALL
			  SELECT REPLACE(UUID(),'-','') ID,id.EMP_NAME,
				  id.EMP_IDCARD_NO as EMP_IDCARD,
				  NULL as EMP_PHONE,
				  id.DEPT_ID,
				  id.DEPT_NAME,
				  id.DEPT_NO,
				  DATE_FORMAT(now(),'%Y%m') as SETTLE_MONTH,
				  d.INVOICE_TITLE_SALARY as INVOICE_TITLE, -- 需要根据项目关联的实际封面抬头调整
					 0 as COST_REDUCTION,
					 '200001' as TAX_MONTH,
				  '2' as DATA_SOURCE, -- 2:商险
				  NULL as IMPORTER_NAME,
				  0 as DELETE_FLAG,
				  NOW() as CREATE_TIME
			  FROM mvp_insurances.t_insurance_detail id
				  left join mvp_archives.t_settle_domain d on d.id=id.DEPT_ID
			  WHERE id.BUY_HANDLE_STATUS = 3 -- 已投保
				AND id.IS_EFFECT = 0 -- 有效
				AND id.IS_OVERDUE = 0 -- 未过期
				AND (id.REDUCE_HANDLE_STATUS != 4 OR id.REDUCE_HANDLE_STATUS IS NULL) -- 非减员成功
				AND id.DELETE_FLAG = 0 and d.INVOICE_TITLE_SALARY is not null and d.INVOICE_TITLE_SALARY != ''
				AND NOT EXISTS (
				  SELECT 1
				  FROM mvp_archives.t_employee_project ep2
				  left join mvp_archives.t_settle_domain d2 on d2.id=ep2.DEPT_ID
				  WHERE ep2.EMP_IDCARD = id.EMP_IDCARD_NO and d2.INVOICE_TITLE_SALARY=d.INVOICE_TITLE_SALARY
				AND ep2.PROJECT_STATUS =0 AND ep2.DELETE_FLAG = '0'
				  )
			  AND DATE_FORMAT(id.UPDATE_TIME,'%Y%m%d')  = DATE_FORMAT(NOW(), '%Y%m%d')
			  GROUP BY id.EMP_IDCARD_NO,d.INVOICE_TITLE_SALARY
	</update>

	<!-- 自动创建临时表（1月创建含去年12月的计税月份）（2月更新成当年的上月的计税月份） （不含减除费用与）-->
	<update id="createTempZeroDay" statementType="STATEMENT">
		insert into t_salary_zero_day_tmp ( select * FROM ${viewDayName} )
	</update>

	<!-- 自动创建临时表（1月创建含去年12月的计税月份）（2月更新成当年的上月的计税月份） （不含减除费用与）-->
	<update id="updateTempZeroYear" statementType="STATEMENT">
		update t_salary_zero_tmp t
			LEFT JOIN mvp_salary.t_salary_account a on a.EMP_IDCARD = t.EMP_IDCARD and a.DELETE_FLAG = 0 and a.INVOICE_TITLE=t.INVOICE_TITLE and a.SETTLEMENT_MONTH = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m')
			LEFT JOIN ${tableNameOrLastTable} z on z.EMP_IDCARD = t.EMP_IDCARD and z.DELETE_FLAG = 0 and z.INVOICE_TITLE=t.INVOICE_TITLE and z.SETTLE_MONTH = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m')
			set t.COST_REDUCTION=if(DATE_FORMAT(now(),'%m')='01',5000,ifnull(a.COST_REDUCTION,ifnull(z.COST_REDUCTION,0)) + 5000)
			,t.TAX_MONTH =ifnull(a.TAX_MONTH,ifnull(z.TAX_MONTH,DATE_FORMAT(now(),'%Y%m')))
	</update>

	<!-- 自动创建临时表（1月创建含去年12月的计税月份）（2月更新成当年的上月的计税月份） （不含减除费用与）-->
	<update id="updateTempZeroDay" statementType="STATEMENT">
		update t_salary_zero_day_tmp t
			LEFT JOIN mvp_salary.t_salary_account a on a.EMP_IDCARD = t.EMP_IDCARD and a.DELETE_FLAG = 0 and a.INVOICE_TITLE=t.INVOICE_TITLE and a.SETTLEMENT_MONTH = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m')
			LEFT JOIN ${tableNameOrLastTable} z on z.EMP_IDCARD = t.EMP_IDCARD and z.DELETE_FLAG = 0 and z.INVOICE_TITLE=t.INVOICE_TITLE and z.SETTLE_MONTH = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m')
			set t.COST_REDUCTION=if(DATE_FORMAT(now(),'%m')='01',5000,ifnull(a.COST_REDUCTION,ifnull(z.COST_REDUCTION,0)) + 5000)
			,t.TAX_MONTH =ifnull(a.TAX_MONTH,ifnull(z.TAX_MONTH,DATE_FORMAT(now(),'%Y%m')))
	</update>

	<update id="updateTempZeroDayDelete" statementType="STATEMENT">
		update t_salary_zero_day_tmp t
			LEFT JOIN mvp_salary.t_salary_account ac on ac.EMP_IDCARD = t.EMP_IDCARD and ac.DELETE_FLAG = 0 and ac.INVOICE_TITLE=t.INVOICE_TITLE and ac.SETTLEMENT_MONTH = DATE_FORMAT(now(),'%Y%m')
			set t.DELETE_FLAG=2 where ac.id is not null
	</update>

	<!-- 插入0申报表 -->
	<insert id="insertIntoSalaryZeroYear">
		insert into ${tableName}
		select * from t_salary_zero_tmp
	</insert>

	<!-- 插入0申报表 -->
	<insert id="insertIntoSalaryZeroDay">
		insert into ${tableName}
		select * from t_salary_zero_day_tmp
	</insert>

	<!-- 插入0申报表 -->
	<insert id="insertIntoSalaryZeroNowDay">
		insert into ${tableName} ( select * FROM ${viewDayName} )
	</insert>

	<!-- 批量更新状态(deleteFlag0,1,2：0：正常；1：已删除；2存在报账假删除) -->
	<update id="updateDeleteFlagByIdList" >
		update ${tableName} set delete_flag = #{deleteFlag}
		where INVOICE_TITLE = #{invoiceTitle} and SETTLE_MONTH = #{settleMonth} and EMP_IDCARD in
		<foreach item="item" collection="cardList" separator="," open="(" close=")" index="">
			#{item}
		</foreach>
	</update>

	<!-- 查询表是否存在-->
	<select id="getTableExists" resultType="java.lang.Integer">
		SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = #{tableName}
	</select>

</mapper>
