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

	<resultMap id="tGzEmpInfoMap" type="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzEmpInfoSearchVo">
		<id property="id" column="id"/>
		<result property="bizId" column="biz_id"/>
		<result property="offerId" column="offer_id"/>
		<result property="empPushStatus" column="emp_push_status"/>
		<result property="contractPushStatus" column="contract_push_status"/>
		<result property="contractAttaPushStatus" column="contract_atta_push_status"/>
		<result property="delFlag" column="del_flag"/>
		<result property="createTime" column="create_time"/>
		<result property="createBy" column="create_by"/>
		<result property="createName" column="create_name"/>
		<result property="updateBy" column="update_by"/>
		<result property="updateTime" column="update_time"/>
		<result property="name" column="name"/>
		<result property="nameAc" column="name_ac"/>
		<result property="birthdate" column="birthdate"/>
		<result property="sex" column="sex"/>
		<result property="constel" column="constel"/>
		<result property="bloodType" column="blood_type"/>
		<result property="startDate" column="start_date"/>
		<result property="country" column="country"/>
		<result property="nativePlace" column="native_place"/>
		<result property="ethnicGrpCd" column="ethnic_grp_cd"/>
		<result property="marStatus" column="mar_status"/>
		<result property="politicalSta" column="political_sta"/>
		<result property="insuranceSta" column="insurance_sta"/>
		<result property="driverType" column="driver_type"/>
		<result property="driverLicenExp" column="driver_licen_exp"/>
		<result property="nationalIdType" column="national_id_type"/>
		<result property="nationalId" column="national_id"/>
		<result property="persistFlag" column="persist_flag"/>
		<result property="nidStartDate" column="nid_start_date"/>
		<result property="nidExpiryDate" column="nid_expiry_date"/>
		<result property="phone" column="phone"/>
		<result property="mail" column="mail"/>
		<result property="addressType" column="address_type"/>
		<result property="stateId" column="state_id"/>
		<result property="cityId" column="city_id"/>
		<result property="countyId" column="county_id"/>
		<result property="address" column="address"/>
		<result property="sginatureMethod" column="sginature_method"/>
		<result property="contractNum" column="contract_num"/>
		<result property="contractType" column="contract_type"/>
		<result property="sginatureType" column="sginature_type"/>
		<result property="probation" column="probation"/>
		<result property="sginatureDt" column="sginature_dt"/>
		<result property="contractBeginDt" column="contract_begin_dt"/>
		<result property="contractExpEndDt" column="contract_exp_end_dt"/>
		<result property="contractEndDt" column="contract_end_dt"/>
		<result property="probationDt" column="probation_dt"/>
		<result property="prcExpDt" column="prc_exp_dt"/>
		<result property="neeProviderId" column="nee_provider_id"/>
		<result property="workLocation" column="work_location"/>
		<result property="workLocationDescr" column="work_location_descr"/>
		<result property="contractState" column="contract_state"/>
		<result property="hukouType" column="hukou_type"/>
		<result property="hukouProvince" column="hukou_province"/>
		<result property="hukouCity" column="hukou_city"/>
		<result property="hukouCounty" column="hukou_county"/>
		<result property="hukouDetail" column="hukou_detail"/>
		<result property="accountType" column="account_type"/>
		<result property="accountStatus" column="account_status"/>
		<result property="accountCountry" column="account_country"/>
		<result property="bankCd" column="bank_cd"/>
		<result property="cnapsId" column="cnaps_id"/>
		<result property="bankName" column="bank_name"/>
		<result property="accountProvince" column="account_province"/>
		<result property="accountCity" column="account_city"/>
		<result property="accountEcId" column="account_ec_id"/>
		<result property="accountName" column="account_name"/>
		<result property="nativePlaceAreaId" column="native_place_area_id"/>
		<result property="stateAreaId" column="state_area_id"/>
		<result property="cityAreaId" column="city_area_id"/>
		<result property="countyAreaId" column="county_area_id"/>
		<result property="hukouProvinceAreaId" column="hukou_province_area_id"/>
		<result property="hukouCityAreaId" column="hukou_city_area_id"/>
		<result property="hukouCountyAreaId" column="hukou_county_area_id"/>
		<result property="accountProvinceAreaId" column="account_province_area_id"/>
		<result property="accountCityAreaId" column="account_city_area_id"/>
		<result property="empStatus" column="emp_status"/>
		<result property="submitTime" column="submit_time"/>
	</resultMap>
	<sql id="Base_Column_List">
                a.id,
                a.biz_id,
                a.offer_id,
                a.emp_push_status,
                a.contract_push_status,
                a.contract_atta_push_status,
                a.del_flag,
                a.create_time,
                a.create_by,
                a.create_name,
                a.update_by,
                a.update_time,
                a.name,
                a.name_ac,
                a.birthdate,
                a.sex,
                a.constel,
                a.blood_type,
                a.start_date,
                a.country,
                a.native_place,
                a.ethnic_grp_cd,
                a.mar_status,
                a.political_sta,
                a.insurance_sta,
                a.driver_type,
                a.driver_licen_exp,
                a.national_id_type,
                a.national_id,
                a.persist_flag,
                a.nid_start_date,
                a.nid_expiry_date,
                a.phone,
                a.mail,
                a.address_type,
                a.state_id,
                a.city_id,
                a.county_id,
                a.address,
                a.sginature_method,
                a.contract_num,
                a.contract_type,
                a.sginature_type,
                a.probation,
                a.sginature_dt,
                a.contract_begin_dt,
                a.contract_exp_end_dt,
                a.contract_end_dt,
                a.probation_dt,
                a.prc_exp_dt,
                a.nee_provider_id,
                a.work_location,
                a.work_location_descr,
                a.contract_state,
                a.hukou_type,
                a.hukou_province,
                a.hukou_city,
                a.hukou_county,
                a.hukou_detail,
                a.account_type,
                a.account_status,
                a.account_country,
                a.bank_cd,
                a.cnaps_id,
                a.bank_name,
                a.account_province,
                a.account_city,
                a.account_ec_id,
                a.account_name,
                a.native_place_area_id,
                a.state_area_id,
                a.city_area_id,
                a.county_area_id,
                a.hukou_province_area_id,
                a.hukou_city_area_id,
                a.hukou_county_area_id,
                a.account_province_area_id,
                a.account_city_area_id,
                a.emp_status,
                a.submit_time
    </sql>
	<sql id="tGzEmpInfo_where">
		<if test="tGzEmpInfo != null">
			<if test="tGzEmpInfo.id != null and tGzEmpInfo.id.trim() != ''">
				AND a.id = #{tGzEmpInfo.id}
			</if>
			<if test="tGzEmpInfo.bizId != null and tGzEmpInfo.bizId.trim() != ''">
				AND a.biz_id = #{tGzEmpInfo.bizId}
			</if>
			<if test="tGzEmpInfo.offerId != null ">
				AND a.offer_id = #{tGzEmpInfo.offerId}
			</if>
			<if test="tGzEmpInfo.empStatus != null and tGzEmpInfo.empStatus.trim() != ''">
				AND a.emp_status = #{tGzEmpInfo.empStatus}
			</if>
			<if test="tGzEmpInfo.empPushStatus != null and tGzEmpInfo.empPushStatus.trim() != ''">
				AND a.emp_push_status = #{tGzEmpInfo.empPushStatus}
			</if>
			<if test="tGzEmpInfo.contractPushStatus != null and tGzEmpInfo.contractPushStatus.trim() != ''">
				AND a.contract_push_status = #{tGzEmpInfo.contractPushStatus}
			</if>
			<if test="tGzEmpInfo.contractAttaPushStatus != null and tGzEmpInfo.contractAttaPushStatus.trim() != ''">
				AND a.contract_atta_push_status = #{tGzEmpInfo.contractAttaPushStatus}
			</if>
			<if test="tGzEmpInfo.delFlag != null and tGzEmpInfo.delFlag.trim() != ''">
				AND a.del_flag = #{tGzEmpInfo.delFlag}
			</if>
			<if test="tGzEmpInfo.createTime != null">
				AND a.create_time = #{tGzEmpInfo.createTime}
			</if>
			<!--查询提交档案时间-->
			<if test="tGzEmpInfo.createTimeStart != null ">
				AND a.submit_time &gt;= #{tGzEmpInfo.createTimeStart}
			</if>
			<if test="tGzEmpInfo.createTimeEnd != null ">
				AND a.submit_time &lt;= #{tGzEmpInfo.createTimeEnd}
			</if>
			<if test="tGzEmpInfo.createBy != null and tGzEmpInfo.createBy.trim() != ''">
				AND a.create_by = #{tGzEmpInfo.createBy}
			</if>
			<if test="tGzEmpInfo.createName != null and tGzEmpInfo.createName.trim() != ''">
				AND a.create_name = #{tGzEmpInfo.createName}
			</if>
			<if test="tGzEmpInfo.updateBy != null and tGzEmpInfo.updateBy.trim() != ''">
				AND a.update_by = #{tGzEmpInfo.updateBy}
			</if>
			<if test="tGzEmpInfo.updateTime != null">
				AND a.update_time = #{tGzEmpInfo.updateTime}
			</if>
			<if test="tGzEmpInfo.name != null and tGzEmpInfo.name.trim() != ''">
				AND a.name like concat('%',#{tGzEmpInfo.name},'%')
			</if>
			<if test="tGzEmpInfo.nameAc != null and tGzEmpInfo.nameAc.trim() != ''">
				AND a.name_ac = #{tGzEmpInfo.nameAc}
			</if>
			<if test="tGzEmpInfo.birthdate != null">
				AND a.birthdate = #{tGzEmpInfo.birthdate}
			</if>
			<if test="tGzEmpInfo.sex != null and tGzEmpInfo.sex.trim() != ''">
				AND a.sex = #{tGzEmpInfo.sex}
			</if>
			<if test="tGzEmpInfo.constel != null and tGzEmpInfo.constel.trim() != ''">
				AND a.constel = #{tGzEmpInfo.constel}
			</if>
			<if test="tGzEmpInfo.bloodType != null and tGzEmpInfo.bloodType.trim() != ''">
				AND a.blood_type = #{tGzEmpInfo.bloodType}
			</if>
			<if test="tGzEmpInfo.startDate != null">
				AND a.start_date = #{tGzEmpInfo.startDate}
			</if>
			<if test="tGzEmpInfo.country != null and tGzEmpInfo.country.trim() != ''">
				AND a.country = #{tGzEmpInfo.country}
			</if>
			<if test="tGzEmpInfo.nativePlace != null and tGzEmpInfo.nativePlace.trim() != ''">
				AND a.native_place = #{tGzEmpInfo.nativePlace}
			</if>
			<if test="tGzEmpInfo.ethnicGrpCd != null and tGzEmpInfo.ethnicGrpCd.trim() != ''">
				AND a.ethnic_grp_cd = #{tGzEmpInfo.ethnicGrpCd}
			</if>
			<if test="tGzEmpInfo.marStatus != null and tGzEmpInfo.marStatus.trim() != ''">
				AND a.mar_status = #{tGzEmpInfo.marStatus}
			</if>
			<if test="tGzEmpInfo.politicalSta != null and tGzEmpInfo.politicalSta.trim() != ''">
				AND a.political_sta = #{tGzEmpInfo.politicalSta}
			</if>
			<if test="tGzEmpInfo.insuranceSta != null and tGzEmpInfo.insuranceSta.trim() != ''">
				AND a.insurance_sta = #{tGzEmpInfo.insuranceSta}
			</if>
			<if test="tGzEmpInfo.driverType != null and tGzEmpInfo.driverType.trim() != ''">
				AND a.driver_type = #{tGzEmpInfo.driverType}
			</if>
			<if test="tGzEmpInfo.driverLicenExp != null">
				AND a.driver_licen_exp = #{tGzEmpInfo.driverLicenExp}
			</if>
			<if test="tGzEmpInfo.nationalIdType != null and tGzEmpInfo.nationalIdType.trim() != ''">
				AND a.national_id_type = #{tGzEmpInfo.nationalIdType}
			</if>
			<if test="tGzEmpInfo.nationalId != null and tGzEmpInfo.nationalId.trim() != ''">
				AND a.national_id like concat('%',#{tGzEmpInfo.nationalId},'%')
			</if>
			<if test="tGzEmpInfo.persistFlag != null and tGzEmpInfo.persistFlag.trim() != ''">
				AND a.persist_flag = #{tGzEmpInfo.persistFlag}
			</if>
			<if test="tGzEmpInfo.nidStartDate != null">
				AND a.nid_start_date = #{tGzEmpInfo.nidStartDate}
			</if>
			<if test="tGzEmpInfo.nidExpiryDate != null">
				AND a.nid_expiry_date = #{tGzEmpInfo.nidExpiryDate}
			</if>
			<if test="tGzEmpInfo.phone != null and tGzEmpInfo.phone.trim() != ''">
				AND a.phone = #{tGzEmpInfo.phone}
			</if>
			<if test="tGzEmpInfo.mail != null and tGzEmpInfo.mail.trim() != ''">
				AND a.mail = #{tGzEmpInfo.mail}
			</if>
			<if test="tGzEmpInfo.addressType != null and tGzEmpInfo.addressType.trim() != ''">
				AND a.address_type = #{tGzEmpInfo.addressType}
			</if>
			<if test="tGzEmpInfo.stateId != null and tGzEmpInfo.stateId.trim() != ''">
				AND a.state_id = #{tGzEmpInfo.stateId}
			</if>
			<if test="tGzEmpInfo.cityId != null and tGzEmpInfo.cityId.trim() != ''">
				AND a.city_id = #{tGzEmpInfo.cityId}
			</if>
			<if test="tGzEmpInfo.countyId != null and tGzEmpInfo.countyId.trim() != ''">
				AND a.county_id = #{tGzEmpInfo.countyId}
			</if>
			<if test="tGzEmpInfo.address != null and tGzEmpInfo.address.trim() != ''">
				AND a.address = #{tGzEmpInfo.address}
			</if>
			<if test="tGzEmpInfo.sginatureMethod != null and tGzEmpInfo.sginatureMethod.trim() != ''">
				AND a.sginature_method = #{tGzEmpInfo.sginatureMethod}
			</if>
			<if test="tGzEmpInfo.contractNum != null and tGzEmpInfo.contractNum.trim() != ''">
				AND a.contract_num = #{tGzEmpInfo.contractNum}
			</if>
			<if test="tGzEmpInfo.contractType != null and tGzEmpInfo.contractType.trim() != ''">
				AND a.contract_type = #{tGzEmpInfo.contractType}
			</if>
			<if test="tGzEmpInfo.sginatureType != null and tGzEmpInfo.sginatureType.trim() != ''">
				AND a.sginature_type = #{tGzEmpInfo.sginatureType}
			</if>
			<if test="tGzEmpInfo.probation != null and tGzEmpInfo.probation.trim() != ''">
				AND a.probation = #{tGzEmpInfo.probation}
			</if>
			<if test="tGzEmpInfo.sginatureDt != null">
				AND a.sginature_dt = #{tGzEmpInfo.sginatureDt}
			</if>
			<if test="tGzEmpInfo.contractBeginDt != null">
				AND a.contract_begin_dt = #{tGzEmpInfo.contractBeginDt}
			</if>
			<if test="tGzEmpInfo.contractExpEndDt != null">
				AND a.contract_exp_end_dt = #{tGzEmpInfo.contractExpEndDt}
			</if>
			<if test="tGzEmpInfo.contractEndDt != null">
				AND a.contract_end_dt = #{tGzEmpInfo.contractEndDt}
			</if>
			<if test="tGzEmpInfo.probationDt != null">
				AND a.probation_dt = #{tGzEmpInfo.probationDt}
			</if>
			<if test="tGzEmpInfo.prcExpDt != null">
				AND a.prc_exp_dt = #{tGzEmpInfo.prcExpDt}
			</if>
			<if test="tGzEmpInfo.workLocation != null and tGzEmpInfo.workLocation.trim() != ''">
				AND a.work_location = #{tGzEmpInfo.workLocation}
			</if>
			<if test="tGzEmpInfo.contractState != null and tGzEmpInfo.contractState.trim() != ''">
				AND a.contract_state = #{tGzEmpInfo.contractState}
			</if>
			<if test="tGzEmpInfo.hukouType != null and tGzEmpInfo.hukouType.trim() != ''">
				AND a.hukou_type = #{tGzEmpInfo.hukouType}
			</if>
			<if test="tGzEmpInfo.hukouProvince != null and tGzEmpInfo.hukouProvince.trim() != ''">
				AND a.hukou_province = #{tGzEmpInfo.hukouProvince}
			</if>
			<if test="tGzEmpInfo.hukouCity != null and tGzEmpInfo.hukouCity.trim() != ''">
				AND a.hukou_city = #{tGzEmpInfo.hukouCity}
			</if>
			<if test="tGzEmpInfo.hukouCounty != null and tGzEmpInfo.hukouCounty.trim() != ''">
				AND a.hukou_county = #{tGzEmpInfo.hukouCounty}
			</if>
			<if test="tGzEmpInfo.hukouDetail != null and tGzEmpInfo.hukouDetail.trim() != ''">
				AND a.hukou_detail = #{tGzEmpInfo.hukouDetail}
			</if>
			<if test="tGzEmpInfo.accountType != null and tGzEmpInfo.accountType.trim() != ''">
				AND a.account_type = #{tGzEmpInfo.accountType}
			</if>
			<if test="tGzEmpInfo.accountStatus != null and tGzEmpInfo.accountStatus.trim() != ''">
				AND a.account_status = #{tGzEmpInfo.accountStatus}
			</if>
			<if test="tGzEmpInfo.accountCountry != null and tGzEmpInfo.accountCountry.trim() != ''">
				AND a.account_country = #{tGzEmpInfo.accountCountry}
			</if>
			<if test="tGzEmpInfo.bankCd != null and tGzEmpInfo.bankCd.trim() != ''">
				AND a.bank_cd = #{tGzEmpInfo.bankCd}
			</if>
			<if test="tGzEmpInfo.cnapsId != null and tGzEmpInfo.cnapsId.trim() != ''">
				AND a.cnaps_id = #{tGzEmpInfo.cnapsId}
			</if>
			<if test="tGzEmpInfo.bankName != null and tGzEmpInfo.bankName.trim() != ''">
				AND a.bank_name = #{tGzEmpInfo.bankName}
			</if>
			<if test="tGzEmpInfo.accountProvince != null and tGzEmpInfo.accountProvince.trim() != ''">
				AND a.account_province = #{tGzEmpInfo.accountProvince}
			</if>
			<if test="tGzEmpInfo.accountCity != null and tGzEmpInfo.accountCity.trim() != ''">
				AND a.account_city = #{tGzEmpInfo.accountCity}
			</if>
			<if test="tGzEmpInfo.accountEcId != null and tGzEmpInfo.accountEcId.trim() != ''">
				AND a.account_ec_id = #{tGzEmpInfo.accountEcId}
			</if>
			<if test="tGzEmpInfo.accountName != null and tGzEmpInfo.accountName.trim() != ''">
				AND a.account_name = #{tGzEmpInfo.accountName}
			</if>
		</if>
	</sql>
	<!--查信息-->
	<select id="getInfoByOfferId" resultMap="tGzEmpInfoMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_gz_emp_info a
		where a.del_flag = '0' and a.offer_id = #{offerId} limit 1
	</select>
	<!--tGzEmpInfo简单分页查询-->
	<select id="getTGzEmpInfoPage" resultMap="tGzEmpInfoMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_gz_emp_info a
		<where>
			a.del_flag = '0'
			<include refid="tGzEmpInfo_where"/>
		</where>
		ORDER by a.emp_status,a.submit_time desc,a.id desc
	</select>

	<!--count-->
	<select id="getTGzEmpInfoCount" resultType="java.lang.Integer">
		SELECT
		count(1)
		FROM t_gz_emp_info a
		<where>
			a.del_flag = '0'
			<include refid="tGzEmpInfo_where"/>
		</where>
	</select>

	<!--导出-->
	<select id="getTGzEmpInfoList" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzEmpInfoExportMain">
		SELECT
			a.id,
			a.biz_id,
			a.offer_id,
			a.emp_status,
			a.emp_push_status,
			a.contract_push_status,
			a.contract_atta_push_status,
			date_format(a.submit_time, '%Y-%m-%d %H:%i:%s') create_time,
			a.create_by,
			a.create_name,
			a.update_by,
			a.update_time,
			a.name,
			a.name_ac,
			date_format(a.birthdate, '%Y-%m-%d') birthdate,
			a.sex,
			a.constel,
			a.blood_type,
		date_format(a.start_date, '%Y-%m-%d') start_date,
			a.country,
			a.native_place,
			a.ethnic_grp_cd,
			a.mar_status,
			a.political_sta,
			a.insurance_sta,
			a.driver_type,
		date_format(a.driver_licen_exp, '%Y-%m-%d') driver_licen_exp,
			a.national_id_type,
			a.national_id,
			a.persist_flag,
		date_format(a.nid_start_date, '%Y-%m-%d') nid_start_date,
		if ( a.nid_expiry_date = '9999-12-31', '长期', date_format(a.nid_expiry_date, '%Y-%m-%d')) nid_expiry_date,
			a.phone,
			a.mail,
			a.address_type,
			a.state_id,
			a.city_id,
			a.county_id,
			a.address,
			a.sginature_method,
			a.contract_num,
			a.contract_type,
			a.sginature_type,
			a.probation,
		date_format(a.sginature_dt, '%Y-%m-%d') sginature_dt,
		date_format(a.contract_begin_dt, '%Y-%m-%d') contract_begin_dt,
		date_format(a.contract_exp_end_dt, '%Y-%m-%d') contract_exp_end_dt,
		date_format(a.contract_end_dt, '%Y-%m-%d') contract_end_dt,
		date_format(a.probation_dt, '%Y-%m-%d') probation_dt,
		date_format(a.prc_exp_dt, '%Y-%m-%d') prc_exp_dt,
			a.nee_provider_id,
			a.work_location,
		    a.work_location_descr,
			a.contract_state,
			a.hukou_type,
			a.hukou_province,
			a.hukou_city,
			a.hukou_county,
			a.hukou_detail,
			a.account_type,
			a.account_status,
			a.account_country,
			a.bank_cd,
			a.cnaps_id,
			a.bank_name,
			a.account_province,
			a.account_city,
			a.account_ec_id,
			a.account_name,
			a.native_place_area_id,
			a.state_area_id,
			a.city_area_id,
			a.county_area_id,
			a.hukou_province_area_id,
			a.hukou_city_area_id,
			a.hukou_county_area_id,
			a.account_province_area_id,
			a.account_city_area_id,
			b.emerg_name,
			b.emerg_relation,
			b.emerg_phone,
			b.emerg_address,
			b.primary_nid
		FROM t_gz_emp_info a
		left join t_gz_emp_contact_info b on a.id = b.emp_id
		<where>
			a.del_flag = '0'
			<include refid="tGzEmpInfo_where"/>
		</where>
		group by a.id
		ORDER by a.emp_status,a.submit_time desc,a.id desc
		<if test="tGzEmpInfo.limitStart != null">
			limit #{tGzEmpInfo.limitStart},#{tGzEmpInfo.limitEnd}
		</if>
	</select>

	<!--导出瓜子档案之教育-->
	<select id="getTGzEmpInfoCountEducation" resultType="java.lang.Integer">
		SELECT
			count(1)
		FROM t_gz_emp_education b left join t_gz_emp_info a on a.id=b.emp_id
		where a.del_flag = '0' and b.del_flag = '0'
		<include refid="tGzEmpInfo_where"/>
	</select>

	<!--导出瓜子档案之教育-->
	<select id="getTGzEmpInfoListEducation" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzEmpInfoExportEducation">
		SELECT
		a.biz_id,
		a.name,
		a.national_id,
			b.edu_qual,
			b.edu_degree,
			b.edu_type,
			b.school,
		date_format(b.edu_start_date, '%Y-%m-%d') edu_start_date,
		date_format(b.edu_end_date, '%Y-%m-%d') edu_end_date,
			b.gradution_type,
			b.major,
			b.high_edu_qual_flag,
			b.high_edu_degree_flag,
			b.first_degree_flag
		FROM t_gz_emp_education b left join t_gz_emp_info a on a.id=b.emp_id
		where a.del_flag = '0' and b.del_flag = '0'
		<include refid="tGzEmpInfo_where"/>
		group by b.id
		order by b.create_time desc,b.id desc
		<if test="tGzEmpInfo.limitStart != null">
			limit #{tGzEmpInfo.limitStart},#{tGzEmpInfo.limitEnd}
		</if>
	</select>

	<!--导出瓜子档案之工作-->
	<select id="getTGzEmpInfoCountWork" resultType="java.lang.Integer">
		SELECT
			count(1)
		FROM t_gz_emp_work b left join t_gz_emp_info a on a.id=b.emp_id
		where a.del_flag = '0' and b.del_flag = '0'
		<include refid="tGzEmpInfo_where"/>
	</select>

	<!--导出瓜子档案之工作-->
	<select id="getTGzEmpInfoListWork" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzEmpInfoExportWork">
		SELECT
			a.biz_id,
			a.name,
			a.national_id,
		    b.work_unit,
		date_format(b.work_start_date, '%Y-%m-%d') work_start_date,
		date_format(b.work_end_date, '%Y-%m-%d') work_end_date,
			b.work_dept,
			b.work_job,
			b.certifier_name,
			b.certifier_phone
		FROM t_gz_emp_work b left join t_gz_emp_info a on a.id=b.emp_id
		where a.del_flag = '0' and b.del_flag = '0'
		<include refid="tGzEmpInfo_where"/>
		group by b.id
		order by b.create_time desc,b.id desc
		<if test="tGzEmpInfo.limitStart != null">
			limit #{tGzEmpInfo.limitStart},#{tGzEmpInfo.limitEnd}
		</if>
	</select>

	<!--导出瓜子档案之家庭-->
	<select id="getTGzEmpInfoCountFamily" resultType="java.lang.Integer">
		SELECT
		count(1)
		FROM t_gz_emp_family b left join t_gz_emp_info a on a.id=b.emp_id
		where a.del_flag = '0' and b.del_flag = '0'
		<include refid="tGzEmpInfo_where"/>
	</select>

	<!--导出瓜子档案之家庭-->
	<select id="getTGzEmpInfoListFamily" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzEmpInfoExportFamily">
		SELECT
			a.biz_id,
			a.name,
			a.national_id,
			b.family_relation,
			b.family_name,
			b.family_phone,
			b.family_address,
			b.family_company,
			b.gz_eme_flag,
			b.job_code
		FROM t_gz_emp_family b left join t_gz_emp_info a on a.id=b.emp_id
		where a.del_flag = '0' and b.del_flag = '0'
		<include refid="tGzEmpInfo_where"/>
		group by b.id
		order by b.create_time desc,b.id desc
		<if test="tGzEmpInfo.limitStart != null">
			limit #{tGzEmpInfo.limitStart},#{tGzEmpInfo.limitEnd}
		</if>
	</select>

	<!--导出瓜子档案之家庭-->
	<select id="getTGzEmpInfoCountSkill" resultType="java.lang.Integer">
		SELECT
		count(1)
		FROM t_gz_emp_skill b left join t_gz_emp_info a on a.id=b.emp_id
		where a.del_flag = '0' and b.del_flag = '0'
		<include refid="tGzEmpInfo_where"/>
	</select>

	<!--导出瓜子档案之家庭-->
	<select id="getTGzEmpInfoListSkill" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzEmpInfoExportSkill">
		SELECT
			a.biz_id,
			a.name,
			a.national_id,
			b.skill_name,
		date_format(b.skill_date, '%Y-%m-%d') skill_date,
			b.skill_org,
			b.skill_level
		FROM t_gz_emp_skill b left join t_gz_emp_info a on a.id=b.emp_id
		where a.del_flag = '0' and b.del_flag = '0'
		<include refid="tGzEmpInfo_where"/>
		group by b.id
		order by b.create_time desc,b.id desc
		<if test="tGzEmpInfo.limitStart != null">
			limit #{tGzEmpInfo.limitStart},#{tGzEmpInfo.limitEnd}
		</if>
	</select>

	<!--推送瓜子的瓜子档案信息-->
	<select id="getGzEmpInfoToPushGzById" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzEmpInfoPushGzVo">
		SELECT
			a.biz_id AS bizId,
			a.name AS name,
			DATE_FORMAT(a.birthdate,'%Y-%m-%d') AS birthdate,
			a.sex AS sex,
			DATE_FORMAT(a.start_date,'%Y-%m-%d') AS startDate,
			a.country AS country,
			a.ethnic_grp_cd AS ethnicGrpCd,
			a.native_place AS nativePlace,
			a.blood_type AS blooeType,
			a.constel,
			a.phone AS phone,
			a.mail AS email,
			a.mar_status AS marStatus,
			a.political_sta AS politicalSta,
			a.insurance_sta AS insuranceSta,
			a.driver_type AS driverType,
			DATE_FORMAT(a.driver_licen_exp,'%Y-%m-%d')  AS driverLicenExp,
			a.national_id AS nationalId,
			a.national_id_type AS nationalIdType,
			DATE_FORMAT(a.nid_start_date,'%Y-%m-%d') AS nidStartDate,
			DATE_FORMAT(a.nid_expiry_date,'%Y-%m-%d') AS nidExpiryDate,
			a.persist_flag AS persistFlag,
			a.hukou_type AS hukouType,
			a.hukou_province AS hukouProvince,
			a.hukou_city AS hukouCity,
			a.hukou_county AS hukouCounty,
			a.hukou_detail AS hukouDetail
		FROM t_gz_emp_info a
		where a.del_flag = '0' and a.id = #{gzEmpId}
		ORDER BY a.create_time desc limit 1
	</select>

	<!--推送瓜子的瓜子档案信息Adress-->
	<select id="getGzEmpInfoToPushGzByIdAdress" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzEmpInfoPushGzVoAdress">
		SELECT
			a.address_type AS addressType,
			a.state_id AS stateId,
			a.city_id AS cityId,
			a.county_id AS countyId,
			a.address AS address
		FROM t_gz_emp_info a
		where a.del_flag = '0' and a.id = #{gzEmpId}
		ORDER BY a.create_time desc limit 1
	</select>

	<!--推送瓜子的瓜子档案信息Bank-->
	<select id="getGzEmpInfoToPushGzByIdBank" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzEmpInfoPushGzVoBank">
		SELECT
			a.account_type AS accountType,
			a.bank_cd AS bankCd,
			a.cnaps_id AS cnapsId,
			a.bank_name AS bankName,
			a.account_ec_id AS accountEcId,
			a.account_name AS accountName,
			a.account_country AS country
		FROM t_gz_emp_info a
		where a.del_flag = '0' and a.id = #{gzEmpId}
		ORDER BY a.create_time desc limit 1
	</select>

	<!--推送瓜子的瓜子档案信息Family-->
	<select id="getGzEmpInfoToPushGzByIdFamily" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzEmpInfoPushGzVoFamily">
		SELECT
			b.family_relation famMemRelation,
			b.family_name name,
			b.family_phone phone,
			b.family_address address,
			b.family_company company,
			b.gz_eme_flag gzEmeFlag,
			b.job_code jobCode
		FROM t_gz_emp_family b left join t_gz_emp_info a on a.id=b.emp_id
		where a.del_flag = '0' and b.del_flag = '0' and a.id = #{gzEmpId}
	</select>

	<!--推送瓜子的瓜子档案信息Family-->
	<select id="getGzEmpInfoToPushGzByIdContact" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzEmpInfoPushGzVoContact">
		SELECT
			b.emerg_name emergName,
			b.emerg_relation emergRelation,
			b.emerg_phone phone,
			b.emerg_address address,
			b.primary_nid primaryNid
		FROM t_gz_emp_contact_info b left join t_gz_emp_info a on a.id=b.emp_id
		where a.del_flag = '0' and b.del_flag = '0' and a.id = #{gzEmpId}
	</select>
	<!--推送瓜子的瓜子档案信息Work-->
	<select id="getGzEmpInfoToPushGzByIdWork" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzEmpInfoPushGzVoWork">
		SELECT
			b.work_unit employer,
			date_format(b.work_start_date, '%Y-%m-%d') startDate,
			date_format(b.work_end_date, '%Y-%m-%d') endDate,
			b.work_dept deptDescr,
			b.work_job endingTitle,
			b.certifier_name adminName,
			b.certifier_phone phone,
			'' email,
			'' comment
		FROM t_gz_emp_work b left join t_gz_emp_info a on a.id=b.emp_id
		where a.del_flag = '0' and b.del_flag = '0' and a.id = #{gzEmpId}
		ORDER BY b.create_time desc
	</select>
	<!--推送瓜子的瓜子档案信息Education-->
	<select id="getGzEmpInfoToPushGzByIdEducation" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzEmpInfoPushGzVoEducation">
		SELECT
			b.edu_qual eduQual,
			b.edu_degree eduDergee,
			b.edu_type eduType,
			b.school school,
			date_format(b.edu_start_date, '%Y-%m-%d') startDate,
			date_format(b.edu_end_date, '%Y-%m-%d') endDate,
			b.gradution_type graduateType,
			b.major,
			b.high_edu_qual_flag highEduQualFlag,
			b.high_edu_degree_flag highEduDegreeFlag,
			b.first_degree_flag firstDegreeFlag
		FROM t_gz_emp_education b left join t_gz_emp_info a on a.id=b.emp_id
		where a.del_flag = '0' and b.del_flag = '0' and a.id = #{gzEmpId}
	</select>
	<!--推送瓜子的瓜子档案信息Skill-->
	<select id="getGzEmpInfoToPushGzByIdSkill" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzEmpInfoPushGzVoSkill">
		SELECT
			@row_num := @row_num + 1 AS orderId,
			b.skill_name skillName,
			date_format(b.skill_date, '%Y-%m-%d') skillDate,
			b.skill_org skillOrg,
			b.skill_level skillLevel
		FROM t_gz_emp_skill b left join t_gz_emp_info a on a.id=b.emp_id,(SELECT @row_num := 0) AS t
		where a.del_flag = '0' and b.del_flag = '0' and a.id = #{gzEmpId} and b.skill_date is not null and b.skill_name != ''
	</select>
	<!--推送瓜子的瓜子档案信息Atta-->
	<select id="getGzEmpInfoToPushGzByIdAtta" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzEmpInfoPushGzVoAtta">
		SELECT
			a.RELATION_TYPE attachType,
			a.id fileId,
			a.ATTA_NAME fileName
		FROM t_atta_info a
		where a.RELATION_TYPE not in ('41','42','43') and a.domain_id =  #{gzEmpId}
	</select>
	<!--推送瓜子的瓜子档案信息-合同   注意：2025年7月17号，瓜子接口变更了，取值时：试用期预计结束日期 和 预计转正日期，调换了-->
	<select id="getGzEmpInfoToPushGzByIdContract" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzEmpInfoPushGzContractVo">
		SELECT
			a.biz_id bizId,
			a.contract_num contractNum,
			a.sginature_method sginatureMethod,
			a.contract_type contractType,
			a.sginature_type sginatureType,
			date_format(a.sginature_dt, '%Y-%m-%d') sginatureDt,
			date_format(a.contract_begin_dt, '%Y-%m-%d') contractBeginDt,
			date_format(a.contract_end_dt, '%Y-%m-%d') contractEndDt,
			date_format(a.contract_exp_end_dt, '%Y-%m-%d') contrctExpEndDt,
			a.probation probation,
			if(a.probation='0','1900-01-01',date_format(a.prc_exp_dt, '%Y-%m-%d')) probationDt,
			if(a.probation='0','1900-01-01',date_format(a.probation_dt, '%Y-%m-%d')) prcExpDt,
			a.nee_provider_id neeProviderId,
			a.work_location workLocation,
			'' fileId,
			'' fileName
		FROM t_gz_emp_info a
		where a.del_flag = '0' and a.id = #{gzEmpId}
		ORDER BY a.create_time desc limit 1
	</select>

</mapper>
