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

	<resultMap id="TSalaryStandardOriginalMap" type="com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal">
		<id property="id" column="ID"/>
		<result property="deptId" column="DEPT_ID"/>
		<result property="deptName" column="DEPT_NAME"/>
		<result property="deptNo" column="DEPT_NO"/>
		<result property="createBy" column="CREATE_BY"/>
		<result property="createName" column="CREATE_NAME"/>
		<result property="createTime" column="CREATE_TIME"/>
		<result property="updateBy" column="UPDATE_BY"/>
		<result property="updateTime" column="UPDATE_TIME"/>
		<result property="setName" column="SET_NAME"/>
		<result property="sheetName" column="SHEET_NAME"/>
		<result property="attaName" column="ATTA_NAME"/>
		<result property="attaSrc" column="ATTA_SRC"/>
		<result property="attaUrl" column="ATTA_URL"/>
		<result property="attaSize" column="ATTA_SIZE"/>
		<result property="attaType" column="ATTA_TYPE"/>
		<result property="dateNum" column="DATE_NUM"/>
		<result property="deleteFlag" column="DELETE_FLAG"/>
		<result property="isFixedColumn" column="IS_FIXED_COLUMN"/>
	</resultMap>

	<resultMap id="TSalaryOriginalExportMap" type="com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryOriginalExportVo">
		<result property="deptNo" column="DEPT_NO"/>
		<result property="deptName" column="DEPT_NAME"/>
		<result property="setName" column="SET_NAME"/>
		<result property="createName" column="CREATE_NAME"/>
		<result property="createTime" column="CREATE_TIME"/>
	</resultMap>
	<sql id="Base_Column_List">
		a.ID,
		a.DEPT_ID,
		a.DEPT_NAME,
		a.DEPT_NO,
		a.CREATE_BY,
		a.CREATE_NAME,
		a.CREATE_TIME,
		a.UPDATE_BY,
		a.UPDATE_TIME,
		a.SET_NAME,
		a.SHEET_NAME,
		a.ATTA_NAME,
		a.ATTA_SRC,
		a.ATTA_URL,
		a.ATTA_SIZE,
		a.ATTA_TYPE,
		a.DATE_NUM,
		a.DELETE_FLAG,
		a.IS_FIXED_COLUMN
	</sql>
	<sql id="TSalaryStandardOriginal_where">
		<if test="tSalaryStandardOriginal != null">
			<if test="tSalaryStandardOriginal.id != null and tSalaryStandardOriginal.id.trim() != ''">
				AND a.ID != #{tSalaryStandardOriginal.id}
			</if>
			<if test="tSalaryStandardOriginal.deptId != null and tSalaryStandardOriginal.deptId.trim() != ''">
				AND a.DEPT_ID = #{tSalaryStandardOriginal.deptId}
			</if>
			<if test="tSalaryStandardOriginal.deptName != null and tSalaryStandardOriginal.deptName.trim() != ''">
				AND a.DEPT_NAME like concat('%',#{tSalaryStandardOriginal.deptName},'%')
			</if>
			<if test="tSalaryStandardOriginal.deptNo != null and tSalaryStandardOriginal.deptNo.trim() != ''">
				AND a.DEPT_NO = #{tSalaryStandardOriginal.deptNo}
			</if>
			<if test="tSalaryStandardOriginal.setName != null and tSalaryStandardOriginal.setName.trim() != ''">
				AND a.SET_NAME like concat('%',#{tSalaryStandardOriginal.setName},'%')
			</if>
			<if test="tSalaryStandardOriginal.sheetName != null and tSalaryStandardOriginal.sheetName.trim() != ''">
				AND a.SHEET_NAME like concat('%',#{tSalaryStandardOriginal.sheetName},'%')
			</if>
			<if test="tSalaryStandardOriginal.attaName != null and tSalaryStandardOriginal.attaName.trim() != ''">
				AND ATTA_NAME = #{tSalaryStandardOriginal.attaName}
			</if>
			<if test="tSalaryStandardOriginal.attaSrc != null and tSalaryStandardOriginal.attaSrc.trim() != ''">
				AND ATTA_SRC = #{tSalaryStandardOriginal.attaSrc}
			</if>
			<if test="tSalaryStandardOriginal.attaUrl != null and tSalaryStandardOriginal.attaUrl.trim() != ''">
				AND ATTA_URL = #{tSalaryStandardOriginal.attaUrl}
			</if>
			<if test="tSalaryStandardOriginal.attaSize != null and tSalaryStandardOriginal.attaSize.trim() != ''">
				AND ATTA_SIZE = #{tSalaryStandardOriginal.attaSize}
			</if>
			<if test="tSalaryStandardOriginal.attaType != null and tSalaryStandardOriginal.attaType.trim() != ''">
				AND ATTA_TYPE = #{tSalaryStandardOriginal.attaType}
			</if>
			<if test="tSalaryStandardOriginal.createName != null and tSalaryStandardOriginal.createName.trim() != ''">
				and a.CREATE_NAME like concat('%',#{tSalaryStandardOriginal.createName},'%')
			</if>
		</if>
	</sql>
	<!--TSalaryStandardOriginal简单分页查询-->
	<select id="getTSalaryStandardOriginalPage" resultMap="TSalaryStandardOriginalMap">
		SELECT
			<include refid="Base_Column_List"/>
		FROM
			t_salary_standard_original a
		<where> a.DELETE_FLAG = 0
			<include refid="TSalaryStandardOriginal_where"/>
		</where>
		ORDER BY a.CREATE_TIME desc
	</select>

	<select id="exportListCount" resultType="java.lang.Integer">
		SELECT
			count(1)
		FROM
			t_salary_standard_original a
		<where> a.DELETE_FLAG = 0
			<if test="idsStr != null and idsStr.size > 0">
				AND a.ID in
				<foreach item="items" index="index" collection="idsStr" open="(" separator="," close=")">
					#{items}
				</foreach>
			</if>
			<include refid="TSalaryStandardOriginal_where"/>
		</where>
	</select>

	<select id="getTSalaryOriginalExportVoList" resultMap="TSalaryOriginalExportMap">
		SELECT
			a.DEPT_NO,a.DEPT_NAME,a.SET_NAME,a.CREATE_NAME,a.CREATE_TIME
		FROM
			t_salary_standard_original a
		<where> a.DELETE_FLAG = 0
			<if test="idsStr != null and idsStr.size > 0">
				AND a.ID in
				<foreach item="items" index="index" collection="idsStr" open="(" separator="," close=")">
					#{items}
				</foreach>
			</if>
			<include refid="TSalaryStandardOriginal_where"/>
		</where>
		ORDER BY a.CREATE_TIME desc
		<if test="tSalaryStandardOriginal != null">
			<if test="tSalaryStandardOriginal.limitStart != null">
				limit #{tSalaryStandardOriginal.limitStart},#{tSalaryStandardOriginal.limitEnd}
			</if>
		</if>

	</select>
	<!--导入工资时的获取识别配置列表-->
	<select id="getTSalaryStandardOriginalList" resultMap="TSalaryStandardOriginalMap">
		SELECT
			<include refid="Base_Column_List"/>
		FROM
			t_salary_standard_original a
		<where> a.DELETE_FLAG = 0
			<if test="tSalaryStandardOriginal != null">
				<if test="tSalaryStandardOriginal.id != null and tSalaryStandardOriginal.id.trim() != ''">
					AND a.ID != #{tSalaryStandardOriginal.id}
				</if>
				<if test="tSalaryStandardOriginal.deptId != null and tSalaryStandardOriginal.deptId.trim() != ''">
					AND a.DEPT_ID = #{tSalaryStandardOriginal.deptId}
				</if>
				<if test="tSalaryStandardOriginal.deptName != null and tSalaryStandardOriginal.deptName.trim() != ''">
					AND a.DEPT_NAME = #{tSalaryStandardOriginal.deptName}
				</if>
				<if test="tSalaryStandardOriginal.deptNo != null and tSalaryStandardOriginal.deptNo.trim() != ''">
					AND a.DEPT_NO = #{tSalaryStandardOriginal.deptNo}
				</if>
				<if test="tSalaryStandardOriginal.setName != null and tSalaryStandardOriginal.setName.trim() != ''">
					AND a.SET_NAME = #{tSalaryStandardOriginal.setName}
				</if>
			</if>
		</where>
		ORDER BY a.CREATE_TIME asc
	</select>

	<!-- 特殊身份证允许识别为数据行 -->
	<select id="getSpecialIdCardList" resultType="java.lang.String">
		SELECT a.ID_CARD FROM t_salary_standard_original_special_idcard a
	</select>

</mapper>
