<?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.archives.mapper.TEmpEducationMapper">

  <resultMap id="tEmpEducationMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpEducation">
    <id property="id" column="ID"/>
    <result property="empId" column="EMP_ID"/>
    <result property="empName" column="EMP_NAME"/>
    <result property="empCode" column="EMP_CODE"/>
    <result property="empIdcard" column="EMP_IDCARD"/>
    <result property="entryDate" column="ENTRY_DATE"/>
    <result property="educationName" column="EDUCATION_NAME"/>
    <result property="gradutionDate" column="GRADUTION_DATE"/>
    <result property="school" column="SCHOOL"/>
    <result property="educationSystem" column="EDUCATION_SYSTEM"/>
    <result property="highIdentification" column="HIGH_IDENTIFICATION"/>
    <result property="type" column="TYPE"/>
    <result property="collageSystem" column="COLLAGE_SYSTEM"/>
    <result property="deleteFlag" column="DELETE_FLAG"/>
    <result property="dispatchFlag" column="DISPATCH_FLAG"/>
	<result property="settleDomain" column="SETTLE_DOMAIN"/>
    <result property="createBy" column="CREATE_BY"/>
    <result property="updateBy" column="UPDATE_BY"/>
    <result property="createName" column="CREATE_NAME"/>
    <result property="createTime" column="CREATE_TIME"/>
    <result property="updateTime" column="UPDATE_TIME"/>
	  <result property="major" column="MAJOR"/>
	  <result property="remark" column="REMARK"/>
	  <result property="certificationName" column="CERTIFICATION_NAME"/>

  </resultMap>
	<resultMap id="tEmpEducationExportMap" type="com.yifu.cloud.plus.v1.yifu.archives.vo.TEmpEducationExportVo">
		<id property="id" column="ID"/>
		<result property="empName" column="EMP_NAME"/>
		<result property="empIdcard" column="EMP_IDCARD"/>
		<result property="entryDate" column="ENTRY_DATE"/>
		<result property="educationName" column="EDUCATION_NAME"/>
		<result property="gradutionDate" column="GRADUTION_DATE"/>
		<result property="school" column="SCHOOL"/>
		<result property="educationSystem" column="EDUCATION_SYSTEM"/>
		<result property="highIdentification" column="HIGH_IDENTIFICATION"/>
		<result property="type" column="TYPE"/>
		<result property="collageSystem" column="COLLAGE_SYSTEM"/>
		<result property="major" column="MAJOR"/>
		<result property="remark" column="REMARK"/>
		<result property="certificationName" column="CERTIFICATION_NAME"/>

	</resultMap>

	<sql id="Base_Column_List">
		a.ID,
		a.EMP_ID,
		a.EMP_NAME,
		a.EMP_CODE,
		a.EMP_IDCARD,
		a.ENTRY_DATE,
		a.EDUCATION_NAME,
		a.GRADUTION_DATE,
		a.SCHOOL,
		a.EDUCATION_SYSTEM,
		a.HIGH_IDENTIFICATION,
		a.TYPE,
		a.COLLAGE_SYSTEM,
		a.DELETE_FLAG,
		a.SETTLE_DOMAIN,
		a.DISPATCH_FLAG,
		a.CREATE_BY,
		a.UPDATE_BY,
		a.CREATE_NAME,
		a.CREATE_TIME,
		a.UPDATE_TIME,
		a.REMARK,
		a.CERTIFICATION_NAME,
		a.MAJOR
	</sql>

	<update id="updateHighIdentification" parameterType="java.lang.String">
		update t_emp_education
		set HIGH_IDENTIFICATION='1'
		WHERE EMP_IDCARD=#{empIdcard}
	</update>
	<!--人员学历导出查询count fxj 2023-01-16-->
	<select id="noPageDiy" resultMap="tEmpEducationExportMap">
		select
		a.id,
		a.EMP_NAME,
		a.EMP_IDCARD,
		a.ENTRY_DATE,
		a.EDUCATION_NAME,
		a.GRADUTION_DATE,
		a.SCHOOL,
		a.EDUCATION_SYSTEM,
		case when a.HIGH_IDENTIFICATION = 0 then "是"
		when a.HIGH_IDENTIFICATION = 1 then "否"
		else null  end  as  "HIGH_IDENTIFICATION" ,
		a.type,
		a.COLLAGE_SYSTEM,
		a.MAJOR,
		a.REMARK,
		a.CERTIFICATION_NAME
		from t_emp_education a

		<where>
			a.DELETE_FLAG = '0'
			<include refid="education_where_export"/>
		</where>
		order by a.CREATE_TIME desc
		<if test="searchVo != null">
			<if test="searchVo.limitStart != null">
				limit #{searchVo.limitStart},#{searchVo.limitEnd}
			</if>
		</if>
	</select>

	<!--人员学历导出查询count fxj 2023-01-16-->
	<select id="noPageCountDiy" resultType="java.lang.Integer">
		select
		count(1)
		from t_emp_education a
		<where>
			a.DELETE_FLAG = '0'
			<include refid="education_where_export"/>
		</where>
	</select>
	<sql id="education_where_export">
		<if test="searchVo != null">
			<if test="idList != null">
				AND a.id in
				<foreach item="idStr" index="index" collection="idList" open="(" separator="," close=")">
					#{idStr}
				</foreach>
			</if>
			<if test="idList == null">
				<if test="searchVo.createTimeStart != null">
					AND a.CREATE_TIME >= #{searchVo.createTimeStart}
				</if>
				<if test="searchVo.createTimeEnd != null">
					AND a.CREATE_TIME <![CDATA[ <= ]]> #{searchVo.createTimeEnd}
				</if>
				<if test="searchVo.empName != null and searchVo.empName.trim() != ''">
					AND a.EMP_NAME like concat(#{searchVo.empName},'%')
				</if>
				<if test="searchVo.empIdcard != null and searchVo.empIdcard.trim() != ''">
					AND a.EMP_IDCARD like concat('%',#{searchVo.empIdcard},'%')
				</if>
				<if test="searchVo.createName != null and searchVo.createName.trim() != ''">
					AND a.CREATE_NAME = #{searchVo.createName}
				</if>
			</if>
		</if>
	</sql>

	<select id="getTEmpEducationByIdCard" resultMap="tEmpEducationMap">
		SELECT
			<include refid="Base_Column_List"/>
		FROM t_emp_education a
		where a.HIGH_IDENTIFICATION = '0' and a.EMP_IDCARD in
		<foreach item="item" index="index" collection="idCardList" open="(" separator="," close=")">
			#{item}
		</foreach>
		GROUP BY a.EMP_IDCARD
	</select>

</mapper>
