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

  <resultMap id="tPersonnelRosterMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TPersonnelRoster">
    <id property="id" column="ID"/>
    <result property="customerName" column="CUSTOMER_NAME"/>
    <result property="departName" column="DEPART_NAME"/>
    <result property="departNo" column="DEPART_NO"/>
    <result property="businessPrimary" column="BUSINESS_PRIMARY"/>
    <result property="businessSecond" column="BUSINESS_SECOND"/>
    <result property="businessThird" column="BUSINESS_THIRD"/>
    <result property="label" column="LABEL"/>
    <result property="businessType" column="BUSINESS_TYPE"/>
    <result property="buBelong" column="BU_BELONG"/>
    <result property="empType" column="EMP_TYPE"/>
    <result property="empName" column="EMP_NAME"/>
    <result property="empSex" column="EMP_SEX"/>
    <result property="empBirthDate" column="EMP_BIRTH_DATE"/>
    <result property="empAge" column="EMP_AGE"/>
    <result property="empIdcard" column="EMP_IDCARD"/>
    <result property="bankNo" column="BANK_NO"/>
    <result property="bankName" column="BANK_NAME"/>
    <result property="bankProvince" column="BANK_PROVINCE"/>
    <result property="bankCity" column="BANK_CITY"/>
    <result property="bankNameSub" column="BANK_NAME_SUB"/>
    <result property="empPhone" column="EMP_PHONE"/>
    <result property="empProvince" column="EMP_PROVINCE"/>
    <result property="empCity" column="EMP_CITY"/>
    <result property="empTown" column="EMP_TOWN"/>
    <result property="socialProvince" column="SOCIAL_PROVINCE"/>
	<result property="socialCity" column="SOCIAL_CITY"/>
	<result property="socialTown" column="SOCIAL_TOWN"/>
    <result property="contractApplyNo" column="CONTRACT_APPLY_NO"/>
    <result property="contractStart" column="CONTRACT_START"/>
    <result property="contractEnd" column="CONTRACT_END"/>
    <result property="contractType" column="CONTRACT_TYPE"/>
    <result property="businessDetail" column="BUSINESS_DETAIL"/>
    <result property="signType" column="SIGN_TYPE"/>
    <result property="signTerm" column="SIGN_TERM"/>
    <result property="contractPartyA" column="CONTRACT_PARTY_A"/>
    <result property="contractPost" column="CONTRACT_POST"/>
    <result property="contractTaskTime" column="CONTRACT_TASK_TIME"/>
    <result property="contractCode" column="CONTRACT_CODE"/>
    <result property="contractCreater" column="CONTRACT_CREATER"/>
    <result property="contractCreateTime" column="CONTRACT_CREATE_TIME"/>
    <result property="dataCreateMonth" column="DATA_CREATE_MONTH"/>
	<result property="settleDomain" column="SETTLE_DOMAIN"/>

  </resultMap>
	<resultMap id="tPersonnelRosterExportMap" type="com.yifu.cloud.plus.v1.yifu.archives.vo.TPersonnelRosterExportVo">
		<id property="id" column="ID"/>
		<result property="customerName" column="CUSTOMER_NAME"/>
		<result property="departName" column="DEPART_NAME"/>
		<result property="departNo" column="DEPART_NO"/>
		<result property="businessPrimary" column="BUSINESS_PRIMARY"/>
		<result property="businessSecond" column="BUSINESS_SECOND"/>
		<result property="businessThird" column="BUSINESS_THIRD"/>
		<result property="label" column="LABEL"/>
		<result property="businessType" column="BUSINESS_TYPE"/>
		<result property="buBelong" column="BU_BELONG"/>
		<result property="empType" column="EMP_TYPE"/>
		<result property="empName" column="EMP_NAME"/>
		<result property="empSex" column="EMP_SEX"/>
		<result property="empBirthDate" column="EMP_BIRTH_DATE"/>
		<result property="empAge" column="EMP_AGE"/>
		<result property="empIdcard" column="EMP_IDCARD"/>
		<result property="bankNo" column="BANK_NO"/>
		<result property="bankName" column="BANK_NAME"/>
		<result property="bankProvince" column="BANK_PROVINCE"/>
		<result property="bankCity" column="BANK_CITY"/>
		<result property="bankNameSub" column="BANK_NAME_SUB"/>
		<result property="empPhone" column="EMP_PHONE"/>
		<result property="empProvince" column="EMP_PROVINCE"/>
		<result property="empCity" column="EMP_CITY"/>
		<result property="empTown" column="EMP_TOWN"/>
		<result property="socialProvince" column="SOCIAL_PROVINCE"/>
		<result property="socialCity" column="SOCIAL_CITY"/>
		<result property="socialTown" column="SOCIAL_TOWN"/>
		<result property="contractApplyNo" column="CONTRACT_APPLY_NO"/>
		<result property="contractStart" column="CONTRACT_START"/>
		<result property="contractEnd" column="CONTRACT_END"/>
		<result property="contractType" column="CONTRACT_TYPE"/>
		<result property="businessDetail" column="BUSINESS_DETAIL"/>
		<result property="signType" column="SIGN_TYPE"/>
		<result property="signTerm" column="SIGN_TERM"/>
		<result property="contractPartyA" column="CONTRACT_PARTY_A"/>
		<result property="contractPost" column="CONTRACT_POST"/>
		<result property="contractTaskTime" column="CONTRACT_TASK_TIME"/>
		<result property="contractCode" column="CONTRACT_CODE"/>
		<result property="contractCreater" column="CONTRACT_CREATER"/>
		<result property="contractCreateTime" column="CONTRACT_CREATE_TIME"/>
		<result property="dataCreateMonth" column="DATA_CREATE_MONTH"/>

	</resultMap>
    <sql id="Base_Column_List">
                a.ID,
                a.CUSTOMER_NAME,
                a.DEPART_NAME,
                a.DEPART_NO,
                a.BUSINESS_PRIMARY,
                a.BUSINESS_SECOND,
                a.BUSINESS_THIRD,
                a.LABEL,
                a.BUSINESS_TYPE,
                a.BU_BELONG,
                a.EMP_TYPE,
                a.EMP_NAME,
                a.EMP_SEX,
                a.EMP_BIRTH_DATE,
                a.EMP_AGE,
                a.EMP_IDCARD,
                a.BANK_NO,
                a.BANK_NAME,
                a.BANK_PROVINCE,
                a.BANK_CITY,
                a.BANK_NAME_SUB,
                a.EMP_PHONE,
                a.EMP_PROVINCE,
                a.EMP_CITY,
                a.EMP_TOWN,
                a.SOCIAL_PROVINCE,
				a.SOCIAL_CITY,
				a.SOCIAL_TOWN,
                a.CONTRACT_APPLY_NO,
                a.CONTRACT_START,
                a.CONTRACT_END,
                a.CONTRACT_TYPE,
                a.BUSINESS_DETAIL,
                a.SIGN_TYPE,
                a.SIGN_TERM,
                a.CONTRACT_PARTY_A,
                a.CONTRACT_POST,
                a.CONTRACT_TASK_TIME,
                a.CONTRACT_CODE,
                a.CONTRACT_CREATER,
                a.CONTRACT_CREATE_TIME,
                a.DATA_CREATE_MONTH,
				a.SETTLE_DOMAIN
    </sql>
    <sql id="tPersonnelRoster_where">
        <if test="tPersonnelRoster != null">
                    <if test="tPersonnelRoster.id != null and tPersonnelRoster.id.trim() != ''">
                        AND a.ID = #{tPersonnelRoster.id}
                    </if>
                    <if test="tPersonnelRoster.customerName != null and tPersonnelRoster.customerName.trim() != ''">
                        AND a.CUSTOMER_NAME like CONCAT(#{tPersonnelRoster.customerName},'%')
                    </if>
                    <if test="tPersonnelRoster.departName != null and tPersonnelRoster.departName.trim() != ''">
                        AND a.DEPART_NAME = #{tPersonnelRoster.departName}
                    </if>
                    <if test="tPersonnelRoster.departNo != null and tPersonnelRoster.departNo.trim() != ''">
                        AND a.DEPART_NO like CONCAT(#{tPersonnelRoster.departNo},'%')
                    </if>
                    <if test="tPersonnelRoster.businessPrimary != null and tPersonnelRoster.businessPrimary.trim() != ''">
                        AND a.BUSINESS_PRIMARY = #{tPersonnelRoster.businessPrimary}
                    </if>
                    <if test="tPersonnelRoster.businessSecond != null and tPersonnelRoster.businessSecond.trim() != ''">
                        AND a.BUSINESS_SECOND = #{tPersonnelRoster.businessSecond}
                    </if>
                    <if test="tPersonnelRoster.businessThird != null and tPersonnelRoster.businessThird.trim() != ''">
                        AND a.BUSINESS_THIRD = #{tPersonnelRoster.businessThird}
                    </if>
                    <if test="tPersonnelRoster.label != null and tPersonnelRoster.label.trim() != ''">
                        AND a.LABEL like CONCAT(#{tPersonnelRoster.label},'%')
                    </if>
                    <if test="tPersonnelRoster.businessType != null and tPersonnelRoster.businessType.trim() != ''">
                        AND a.BUSINESS_TYPE = #{tPersonnelRoster.businessType}
                    </if>
                    <if test="tPersonnelRoster.buBelong != null and tPersonnelRoster.buBelong.trim() != ''">
                        AND a.BU_BELONG = #{tPersonnelRoster.buBelong}
                    </if>
                    <if test="tPersonnelRoster.empType != null and tPersonnelRoster.empType.trim() != ''">
                        AND a.EMP_TYPE = #{tPersonnelRoster.empType}
                    </if>
                    <if test="tPersonnelRoster.empName != null and tPersonnelRoster.empName.trim() != ''">
                        AND a.EMP_NAME like CONCAT(#{tPersonnelRoster.empName},'%')
                    </if>
                    <if test="tPersonnelRoster.empSex != null and tPersonnelRoster.empSex.trim() != ''">
                        AND a.EMP_SEX = #{tPersonnelRoster.empSex}
                    </if>
                    <if test="tPersonnelRoster.empBirthDate != null">
                        AND a.EMP_BIRTH_DATE = #{tPersonnelRoster.empBirthDate}
                    </if>
                    <if test="tPersonnelRoster.empAge != null and tPersonnelRoster.empAge.trim() != ''">
                        AND a.EMP_AGE = #{tPersonnelRoster.empAge}
                    </if>
                    <if test="tPersonnelRoster.empIdcard != null and tPersonnelRoster.empIdcard.trim() != ''">
                        AND a.EMP_IDCARD like CONCAT(#{tPersonnelRoster.empIdcard},'%')
                    </if>
                    <if test="tPersonnelRoster.bankNo != null and tPersonnelRoster.bankNo.trim() != ''">
                        AND a.BANK_NO = #{tPersonnelRoster.bankNo}
                    </if>
                    <if test="tPersonnelRoster.bankName != null and tPersonnelRoster.bankName.trim() != ''">
                        AND a.BANK_NAME = #{tPersonnelRoster.bankName}
                    </if>
                    <if test="tPersonnelRoster.bankProvince != null and tPersonnelRoster.bankProvince.trim() != ''">
                        AND a.BANK_PROVINCE = #{tPersonnelRoster.bankProvince}
                    </if>
                    <if test="tPersonnelRoster.bankCity != null and tPersonnelRoster.bankCity.trim() != ''">
                        AND a.BANK_CITY = #{tPersonnelRoster.bankCity}
                    </if>
                    <if test="tPersonnelRoster.bankNameSub != null and tPersonnelRoster.bankNameSub.trim() != ''">
                        AND a.BANK_NAME_SUB = #{tPersonnelRoster.bankNameSub}
                    </if>
                    <if test="tPersonnelRoster.empPhone != null and tPersonnelRoster.empPhone.trim() != ''">
                        AND a.EMP_PHONE = #{tPersonnelRoster.empPhone}
                    </if>
                    <if test="tPersonnelRoster.empProvince != null and tPersonnelRoster.empProvince.trim() != ''">
                        AND a.EMP_PROVINCE = #{tPersonnelRoster.empProvince}
                    </if>
                    <if test="tPersonnelRoster.empCity != null and tPersonnelRoster.empCity.trim() != ''">
                        AND a.EMP_CITY = #{tPersonnelRoster.empCity}
                    </if>
                    <if test="tPersonnelRoster.empTown != null and tPersonnelRoster.empTown.trim() != ''">
                        AND a.EMP_TOWN = #{tPersonnelRoster.empTown}
                    </if>
					<if test="tPersonnelRoster.socialProvince != null and tPersonnelRoster.socialProvince.trim() != ''">
						AND a.SOCIAL_PROVINCE = #{tPersonnelRoster.socialProvince}
					</if>
					<if test="tPersonnelRoster.socialCity != null and tPersonnelRoster.socialCity.trim() != ''">
						AND a.SOCIAL_CITY = #{tPersonnelRoster.socialCity}
					</if>
					<if test="tPersonnelRoster.socialTown != null and tPersonnelRoster.socialTown.trim() != ''">
						AND a.SOCIAL_TOWN = #{tPersonnelRoster.socialTown}
					</if>
                    <if test="tPersonnelRoster.contractApplyNo != null and tPersonnelRoster.contractApplyNo.trim() != ''">
                        AND a.CONTRACT_APPLY_NO = #{tPersonnelRoster.contractApplyNo}
                    </if>
                    <if test="tPersonnelRoster.contractStart != null and tPersonnelRoster.contractStart.trim() != ''">
                        AND a.CONTRACT_START = #{tPersonnelRoster.contractStart}
                    </if>
                    <if test="tPersonnelRoster.contractEnd != null and tPersonnelRoster.contractEnd.trim() != ''">
                        AND a.CONTRACT_END = #{tPersonnelRoster.contractEnd}
                    </if>
                    <if test="tPersonnelRoster.contractType != null and tPersonnelRoster.contractType.trim() != ''">
                        AND a.CONTRACT_TYPE = #{tPersonnelRoster.contractType}
                    </if>
                    <if test="tPersonnelRoster.businessDetail != null and tPersonnelRoster.businessDetail.trim() != ''">
                        AND a.BUSINESS_DETAIL = #{tPersonnelRoster.businessDetail}
                    </if>
                    <if test="tPersonnelRoster.signType != null and tPersonnelRoster.signType.trim() != ''">
                        AND a.SIGN_TYPE = #{tPersonnelRoster.signType}
                    </if>
                    <if test="tPersonnelRoster.signTerm != null and tPersonnelRoster.signTerm.trim() != ''">
                        AND a.SIGN_TERM = #{tPersonnelRoster.signTerm}
                    </if>
                    <if test="tPersonnelRoster.contractPartyA != null and tPersonnelRoster.contractPartyA.trim() != ''">
                        AND a.CONTRACT_PARTY_A = #{tPersonnelRoster.contractPartyA}
                    </if>
                    <if test="tPersonnelRoster.contractPost != null and tPersonnelRoster.contractPost.trim() != ''">
                        AND a.CONTRACT_POST = #{tPersonnelRoster.contractPost}
                    </if>
                    <if test="tPersonnelRoster.contractTaskTime != null and tPersonnelRoster.contractTaskTime.trim() != ''">
                        AND a.CONTRACT_TASK_TIME = #{tPersonnelRoster.contractTaskTime}
                    </if>
                    <if test="tPersonnelRoster.contractCode != null and tPersonnelRoster.contractCode.trim() != ''">
                        AND a.CONTRACT_CODE = #{tPersonnelRoster.contractCode}
                    </if>
                    <if test="tPersonnelRoster.contractCreater != null and tPersonnelRoster.contractCreater.trim() != ''">
                        AND a.CONTRACT_CREATER = #{tPersonnelRoster.contractCreater}
                    </if>
                    <if test="tPersonnelRoster.contractCreateTime != null and tPersonnelRoster.contractCreateTime.trim() != ''">
                        AND a.CONTRACT_CREATE_TIME = #{tPersonnelRoster.contractCreateTime}
                    </if>
                    <if test="tPersonnelRoster.dataCreateMonth != null and tPersonnelRoster.dataCreateMonth.trim() != ''">
                        AND a.DATA_CREATE_MONTH = #{tPersonnelRoster.dataCreateMonth}
                    </if>
					<if test="tPersonnelRoster.authSql != null and tPersonnelRoster.authSql.trim() != ''">
						${tPersonnelRoster.authSql}
					</if>

					<if test="tPersonnelRoster.businessTypes != null and tPersonnelRoster.businessTypes.size() > 0">
						AND a.BUSINESS_TYPE in
						<foreach item="item" index="index" collection="tPersonnelRoster.businessTypes" open="(" separator="," close=")">
							#{item}
						</foreach>
					</if>

					<if test="tPersonnelRoster.buBelongs != null and tPersonnelRoster.buBelongs.size() > 0">
						AND a.BU_BELONG in
						<foreach item="item" index="index" collection="tPersonnelRoster.buBelongs" open="(" separator="," close=")">
							#{item}
						</foreach>
					</if>
					<if test="tPersonnelRoster.empTypes != null and tPersonnelRoster.empTypes.size() > 0">
						AND a.EMP_TYPE in
						<foreach item="item" index="index" collection="tPersonnelRoster.empTypes" open="(" separator="," close=")">
							#{item}
						</foreach>
					</if>

        </if>
    </sql>
    <!--tPersonnelRoster简单分页查询-->
    <select id="getTPersonnelRosterPage" resultMap="tPersonnelRosterMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_personnel_roster a
        <where>
            1=1
            <include refid="tPersonnelRoster_where"/>
        </where>
		order by a.CONTRACT_CREATE_TIME ASC
    </select>
	<select id="getTPersonnelRoster" resultMap="tPersonnelRosterMap">
		select c1.SUBJECT_UNIT as 'CUSTOMER_NAME',c1.SUBJECT_DEPART as 'DEPART_NAME',c1.DEPT_NO as 'DEPART_NO',
		d.BUSINESS_PRIMARY_TYPE as 'BUSINESS_PRIMARY',d.BUSINESS_SECOND_TYPE as 'BUSINESS_SECOND',d.BUSINESS_THIRD_TYPE as 'BUSINESS_THIRD',
		p.EMP_LABEL as 'LABEL',d.LINE_TYPE as 'BUSINESS_TYPE',d.BU_BELONG as 'BU_BELONG',c1.EMP_NATRUE as 'EMP_TYPE',
		c1.EMP_NAME as 'EMP_NAME',e.EMP_SEX as 'EMP_SEX',DATE_FORMAT(e.EMP_BIRTHDAY ,"%Y-%m-%d")  as 'EMP_BIRTH_DATE',e.EMP_AGE as 'EMP_AGE',c1.EMP_IDCARD as 'EMP_IDCARD',
		e.EMP_PHONE as 'EMP_PHONE',c1.FILE_PROVINCE as 'EMP_PROVINCE',c1.FILE_CITY as 'EMP_CITY',c1.FILE_TOWN as 'EMP_TOWN',
		p.SOCIAL_PROVINCE as 'SOCIAL_PROVINCE',p.SOCIAL_CITY as 'SOCIAL_CITY',p.SOCIAL_TOWN as 'SOCIAL_TOWN',c1.APPLY_NO as 'CONTRACT_APPLY_NO',
		c1.CONTRACT_START as 'CONTRACT_START',c1.CONTRACT_END as 'CONTRACT_END',c1.CONTRACT_NAME as 'CONTRACT_TYPE',c1.CONTRACT_SUB_NAME as 'BUSINESS_DETAIL',
		c1.SITUATION as 'SIGN_TYPE',c1.CONTRACT_TYPE as 'SIGN_TERM',
		c1.CONTRACT_PARTY as 'CONTRACT_PARTY_A',c1.POST as 'CONTRACT_POST',c1.WORKING_HOURS as 'CONTRACT_TASK_TIME',
		c1.CONTRACT_NO as 'CONTRACT_CODE',c1.CREATE_NAME as 'CONTRACT_CREATER',c1.CREATE_TIME as 'CONTRACT_CREATE_TIME',
		d.id as "SETTLE_DOMAIN"
		from
		(select  MAX(c.CREATE_TIME) as "CREATE_TIME",c.id,c.EMP_IDCARD,c.DEPT_NO from t_employee_contract_info c WHERE c.IN_USE = 0 and c.DELETE_FLAG='0'
		GROUP BY c.DEPT_NO,c.EMP_IDCARD) t
		LEFT JOIN t_employee_info e on e.EMP_IDCARD=t.EMP_IDCARD
		LEFT JOIN t_employee_project p on p.EMP_IDCARD=t.EMP_IDCARD and p.DEPT_NO=t.DEPT_NO
		LEFT JOIN t_settle_domain d on d.DEPART_NO=t.DEPT_NO
		INNER JOIN t_employee_contract_info c1 on c1.EMP_IDCARD=t.EMP_IDCARD and c1.DEPT_NO=t.DEPT_NO and c1.CREATE_TIME=t.CREATE_TIME
		GROUP BY t.DEPT_NO,t.EMP_IDCARD
		<if test="tPersonnelRoster != null">
			<if test="tPersonnelRoster.limitStart != null">
				limit #{tPersonnelRoster.limitStart},#{tPersonnelRoster.limitEnd}
			</if>
		</if>
	</select>
	<select id="getTPersonnelRosterCount" resultType="java.lang.Integer">
		select count(1)
		from (
				 select count(1)
				 from (select MAX(c.CREATE_TIME) as "CREATE_TIME", c.id, c.EMP_IDCARD, c.DEPT_NO
					   from t_employee_contract_info c
					   WHERE c.IN_USE = 0
						 and c.DELETE_FLAG = '0'
					   GROUP BY c.DEPT_NO, c.EMP_IDCARD) t
						  LEFT JOIN t_employee_info e on e.EMP_IDCARD = t.EMP_IDCARD
						  LEFT JOIN t_employee_project p on p.EMP_IDCARD = t.EMP_IDCARD and p.DEPT_NO = t.DEPT_NO
						  LEFT JOIN t_settle_domain d on d.DEPART_NO = t.DEPT_NO
						  INNER JOIN t_employee_contract_info c1 on c1.EMP_IDCARD=t.EMP_IDCARD and c1.DEPT_NO=t.DEPT_NO and c1.CREATE_TIME=t.CREATE_TIME
				 GROUP BY t.DEPT_NO, t.EMP_IDCARD
			 ) a
	</select>
	<select id="noPageCountDiy" resultType="java.lang.Integer">
		select
		count(1)
		from t_personnel_roster a
		<where>
			1=1
			<include refid="tPersonnelRoster_where"/>
		</where>
	</select>

	<!--tEmployeeInfo人员档案导出查询改造 fxj 2022-11-02-->
	<select id="noPageDiy" resultMap="tPersonnelRosterExportMap">
		SELECT
		a.ID,
		a.CUSTOMER_NAME,
		a.DEPART_NAME,
		a.DEPART_NO,
		a.BUSINESS_PRIMARY,
		a.BUSINESS_SECOND,
		a.BUSINESS_THIRD,
		a.LABEL,
		a.BUSINESS_TYPE,
		a.BU_BELONG,
		a.EMP_TYPE,
		a.EMP_NAME,
		CASE WHEN a.EMP_SEX=1 THEN "男" WHEN a.EMP_SEX=2 THEN "女" ELSE "" END as "EMP_SEX",
		a.EMP_BIRTH_DATE,
		a.EMP_AGE,
		a.EMP_IDCARD,
		a.BANK_NO,
		a.BANK_NAME,
		a1.AREA_NAME as "BANK_PROVINCE",
		a1.AREA_NAME as "BANK_CITY",
		a.BANK_NAME_SUB,
		a.EMP_PHONE,
		a6.AREA_NAME as "EMP_PROVINCE",
		a7.AREA_NAME as "EMP_CITY",
		a8.AREA_NAME as "EMP_TOWN",
		a3.AREA_NAME as "SOCIAL_PROVINCE",
		a4.AREA_NAME as "SOCIAL_CITY",
		a5.AREA_NAME as "SOCIAL_TOWN",
		a.CONTRACT_APPLY_NO,
		a.CONTRACT_START,
		a.CONTRACT_END,
		a.CONTRACT_TYPE,
		a.BUSINESS_DETAIL,
		a.SIGN_TYPE,
		a.SIGN_TERM,
		a.CONTRACT_PARTY_A,
		a.CONTRACT_POST,
		a.CONTRACT_TASK_TIME,
		a.CONTRACT_CODE,
		a.CONTRACT_CREATER,
		a.CONTRACT_CREATE_TIME,
		a.DATA_CREATE_MONTH,
		a.SETTLE_DOMAIN
		FROM
		t_personnel_roster a
		LEFT JOIN sys_area a1 on a1.id=a.BANK_PROVINCE
		LEFT JOIN sys_area a2 on a2.id=a.BANK_CITY

		LEFT JOIN sys_area a3 on a3.id=a.SOCIAL_PROVINCE
		LEFT JOIN sys_area a4 on a4.id=a.SOCIAL_CITY
		LEFT JOIN sys_area a5 on a5.id=a.SOCIAL_TOWN
		LEFT JOIN sys_area a6 on a6.id=a.EMP_PROVINCE
		LEFT JOIN sys_area a7 on a7.id=a.EMP_CITY
		LEFT JOIN sys_area a8 on a8.id=a.EMP_TOWN
		<where>
			1=1
			<include refid="tPersonnelRoster_where"/>
		</where>
		order by a.CONTRACT_CREATE_TIME ASC
		<if test="tPersonnelRoster != null">
			<if test="tPersonnelRoster.limitStart != null">
				limit #{tPersonnelRoster.limitStart},#{tPersonnelRoster.limitEnd}
			</if>
		</if>
	</select>
</mapper>
