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

  <resultMap id="tEmployeeContractPreNewMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeContractPreNew">
    <id property="id" column="id"/>
    <result property="deptName" column="dept_name"/>
    <result property="deptNo" column="dept_no"/>
    <result property="deptId" column="dept_id"/>
    <result property="employeeName" column="employee_name"/>
    <result property="empIdcard" column="emp_idcard"/>
    <result property="empPhone" column="emp_phone"/>
    <result property="employeeNature" column="employee_nature"/>
    <result property="position" column="position"/>
    <result property="joinLeaveDate" column="join_leave_date"/>
    <result property="customerUsername" column="customer_username"/>
    <result property="customerUserLoginname" column="customer_user_loginname"/>
    <result property="signType" column="sign_type"/>
    <result property="contractContent" column="contract_content"/>
    <result property="fadadaTemplate" column="fadada_template"/>
    <result property="dataSource" column="data_source"/>
    <result property="processStatus" column="process_status"/>
    <result property="configName" column="config_name"/>
    <result property="updateFlag" column="update_flag"/>
    <result property="contractType" column="contract_type"/>
    <result property="signatory" column="signatory"/>
    <result property="expectedConfirmTime" column="expected_confirm_time"/>
    <result property="expectedCollectionTime" column="expected_collection_time"/>
    <result property="situation" column="situation"/>
    <result property="contractTerm" column="contract_term"/>
    <result property="contractStart" column="contract_start"/>
    <result property="contractEnd" column="contract_end"/>
    <result property="postType" column="post_type"/>
    <result property="post" column="post"/>
    <result property="workingDept" column="working_dept"/>
    <result property="workAddress" column="work_address"/>
    <result property="workingHours" column="working_hours"/>
    <result property="salaryType" column="salary_type"/>
    <result property="otherWage" column="other_wage"/>
    <result property="defaultAmount" column="default_amount"/>
    <result property="contractDurationYear" column="contract_duration_year"/>
    <result property="contractDurationMonth" column="contract_duration_month"/>
    <result property="laborCost" column="labor_cost"/>
    <result property="riskBuyDesc" column="risk_buy_desc"/>
    <result property="salaryStandardPerHour" column="salary_standard_per_hour"/>
    <result property="salaryStandardPerPiece" column="salary_standard_per_piece"/>
    <result property="configId" column="config_id"/>
    <result property="workType" column="work_type"/>
    <result property="workDayCount" column="work_day_count"/>
    <result property="workDay" column="work_day"/>
    <result property="workHours" column="work_hours"/>
    <result property="settlementCycle" column="settlement_cycle"/>
    <result property="paymentTime" column="payment_time"/>
    <result property="paymentType" column="payment_type"/>
    <result property="workingCompany" column="working_company"/>
    <result property="dispatchPeriodYear" column="dispatch_period_year"/>
    <result property="dispatchPeriodMonth" column="dispatch_period_month"/>
    <result property="dispatchPeriodStart" column="dispatch_period_start"/>
    <result property="dispatchPeriodEnd" column="dispatch_period_end"/>
    <result property="otherWorkDay" column="other_work_day"/>
    <result property="internshipPeriod" column="internship_period"/>
    <result property="internshipPeriodStart" column="internship_period_start"/>
    <result property="internshipPeriodEnd" column="internship_period_end"/>
    <result property="signFlag" column="sign_flag"/>
    <result property="errorInfo" column="error_info"/>
    <result property="contractId" column="contract_id"/>
    <result property="revokeReason" column="revoke_reason"/>
	<result property="revokeTime" column="revoke_time"/>
    <result property="errorTime" column="error_time"/>
    <result property="contractEndType" column="contract_end_type"/>
    <result property="confirmEmpSelect" column="confirm_emp_select"/>
    <result property="timeoutElecSign" column="timeout_elec_sign"/>
    <result property="task" column="task"/>
    <result property="taskType" column="task_type"/>
    <result property="taskEndStandard" column="task_end_standard"/>
    <result property="contractFlag" column="contract_flag"/>
    <result property="contractSubName" column="CONTRACT_SUB_NAME"/>
    <result property="fadadaTemplateId" column="fadada_template_id"/>
    <result property="requestId" column="request_id"/>
    <result property="requestMsg" column="request_msg"/>
    <result property="overFlag" column="over_flag"/>
    <result property="changeTypeReason" column="change_type_reason"/>
    <result property="changeTypeUser" column="change_type_user"/>
    <result property="changeTypeTime" column="change_type_time"/>
    <result property="isUrg" column="is_urg"/>
    <result property="workingReward" column="working_reward"/>
    <result property="updateTime" column="update_time"/>
    <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="salaryDay" column="SALARY_DAY"/>
  </resultMap>
    <sql id="Base_Column_List">
                a.id,
                a.dept_name,
                a.dept_no,
                a.dept_id,
                a.employee_name,
                a.emp_idcard,
                a.emp_phone,
                a.employee_nature,
                a.position,
                a.join_leave_date,
                a.customer_username,
                a.customer_user_loginname,
                a.sign_type,
                a.contract_content,
                a.fadada_template,
                a.data_source,
                a.process_status,
                a.config_name,
                a.update_flag,
                a.contract_type,
                a.signatory,
                a.expected_confirm_time,
                a.expected_collection_time,
                a.situation,
                a.contract_term,
                a.contract_start,
                a.contract_end,
                a.post_type,
                a.post,
                a.working_dept,
                a.work_address,
                a.working_hours,
                a.salary_type,
                a.other_wage,
                a.default_amount,
                a.contract_duration_year,
                a.contract_duration_month,
                a.labor_cost,
                a.risk_buy_desc,
                a.salary_standard_per_hour,
                a.salary_standard_per_piece,
                a.config_id,
                a.work_type,
                a.work_day_count,
                a.work_day,
                a.work_hours,
                a.settlement_cycle,
                a.payment_time,
                a.payment_type,
                a.working_company,
                a.dispatch_period_year,
                a.dispatch_period_month,
                a.dispatch_period_start,
                a.dispatch_period_end,
                a.other_work_day,
                a.internship_period,
                a.internship_period_start,
                a.internship_period_end,
                a.sign_flag,
                a.error_info,
                a.contract_id,
                a.revoke_reason,
                a.error_time,
                a.contract_end_type,
                a.confirm_emp_select,
                a.timeout_elec_sign,
                a.task,
                a.task_type,
                a.task_end_standard,
                a.contract_flag,
                a.CONTRACT_SUB_NAME,
                a.fadada_template_id,
                a.request_id,
                a.request_msg,
                a.over_flag,
                a.change_type_reason,
                a.change_type_user,
                a.change_type_time,
                a.is_urg,
                a.working_reward,
                a.update_time,
                a.create_by,
                a.create_name,
                a.create_time,
                a.update_by,
                a.SALARY_DAY
    </sql>
	<sql id="tEmpContractAlert_where">
		<if test="tEmpContractAlert != null">
			<if test="tEmpContractAlert.id != null and tEmpContractAlert.id.trim() != ''">
				AND a.ID = #{tEmpContractAlert.id}
			</if>
			<if test="tEmpContractAlert.empName != null and tEmpContractAlert.empName.trim() != ''">
				AND a.EMP_NAME = #{tEmpContractAlert.empName}
			</if>
			<if test="tEmpContractAlert.empId != null and tEmpContractAlert.empId.trim() != ''">
				AND a.EMP_ID = #{tEmpContractAlert.empId}
			</if>
			<if test="tEmpContractAlert.deptId != null and tEmpContractAlert.deptId.trim() != ''">
				AND a.DEPT_ID = #{tEmpContractAlert.deptId}
			</if>
			<if test="tEmpContractAlert.project != null and tEmpContractAlert.project.trim() != ''">
				AND a.PROJECT = #{tEmpContractAlert.project}
			</if>
			<if test="tEmpContractAlert.deptNoList != null and tEmpContractAlert.deptNoList.size > 0">
				AND a.PROJECT in
				<foreach item="idStr" index="index" collection="tEmpContractAlert.deptNoList" open="(" separator="," close=")">
					#{idStr}
				</foreach>
			</if>
			<if test="tEmpContractAlert.idList != null and tEmpContractAlert.idList.size > 0">
				AND a.id in
				<foreach item="id" index="index" collection="tEmpContractAlert.idList" open="(" separator="," close=")">
					#{id}
				</foreach>
			</if>
			<if test="tEmpContractAlert.projectNo != null and tEmpContractAlert.projectNo.trim() != ''">
				AND a.PROJECT_NO = #{tEmpContractAlert.projectNo}
			</if>
			<if test="tEmpContractAlert.empIdcard != null and tEmpContractAlert.empIdcard.trim() != ''">
				AND a.EMP_IDCARD = #{tEmpContractAlert.empIdcard}
			</if>
			<if test="tEmpContractAlert.empCode != null and tEmpContractAlert.empCode.trim() != ''">
				AND a.EMP_CODE = #{tEmpContractAlert.empCode}
			</if>
			<if test="tEmpContractAlert.contractStart != null">
				AND a.CONTRACT_START = #{tEmpContractAlert.contractStart}
			</if>
			<if test="tEmpContractAlert.contractEnd != null">
				AND a.CONTRACT_END = #{tEmpContractAlert.contractEnd}
			</if>
			<if test="tEmpContractAlert.fileProvince != null and tEmpContractAlert.fileProvince.trim() != ''">
				AND a.FILE_PROVINCE = #{tEmpContractAlert.fileProvince}
			</if>
			<if test="tEmpContractAlert.fileCity != null and tEmpContractAlert.fileCity.trim() != ''">
				AND a.FILE_CITY = #{tEmpContractAlert.fileCity}
			</if>
			<if test="tEmpContractAlert.fileTown != null and tEmpContractAlert.fileTown.trim() != ''">
				AND a.FILE_TOWN = #{tEmpContractAlert.fileTown}
			</if>
			<if test="tEmpContractAlert.empType != null and tEmpContractAlert.empType.trim() != ''">
				AND a.EMP_TYPE = #{tEmpContractAlert.empType}
			</if>
			<if test="tEmpContractAlert.contractType != null and tEmpContractAlert.contractType.trim() != ''">
				AND a.CONTRACT_TYPE = #{tEmpContractAlert.contractType}
			</if>
			<if test="tEmpContractAlert.contractTerm != null and tEmpContractAlert.contractTerm.trim() != ''">
				AND a.CONTRACT_TERM = #{tEmpContractAlert.contractTerm}
			</if>
			<if test="tEmpContractAlert.daysDue != null">
				AND a.DAYS_DUE = #{tEmpContractAlert.daysDue}
			</if>
			<if test="tEmpContractAlert.dueFlag != null and tEmpContractAlert.dueFlag.trim() != ''">
				AND a.DUE_FLAG = #{tEmpContractAlert.dueFlag}
			</if>
			<if test="tEmpContractAlert.daysOver != null">
				AND a.DAYS_OVER = #{tEmpContractAlert.daysOver}
			</if>
			<if test="tEmpContractAlert.firstAlertTime != null">
				AND a.FIRST_ALERT_TIME = #{tEmpContractAlert.firstAlertTime}
			</if>
			<if test="tEmpContractAlert.alertPerson != null and tEmpContractAlert.alertPerson.trim() != ''">
				AND a.ALERT_PERSON = #{tEmpContractAlert.alertPerson}
			</if>
			<if test="tEmpContractAlert.createBy != null and tEmpContractAlert.createBy.trim() != ''">
				AND a.CREATE_BY = #{tEmpContractAlert.createBy}
			</if>
			<if test="tEmpContractAlert.updateBy != null and tEmpContractAlert.updateBy.trim() != ''">
				AND a.UPDATE_BY = #{tEmpContractAlert.updateBy}
			</if>
			<if test="tEmpContractAlert.createName != null and tEmpContractAlert.createName.trim() != ''">
				AND a.CREATE_NAME = #{tEmpContractAlert.createName}
			</if>
			<if test="tEmpContractAlert.createTime != null">
				AND a.CREATE_TIME = #{tEmpContractAlert.createTime}
			</if>
			<if test="tEmpContractAlert.updateTime != null">
				AND a.UPDATE_TIME = #{tEmpContractAlert.updateTime}
			</if>
			<if test="tEmpContractAlert.handleStatus != null and tEmpContractAlert.handleStatus.trim() != ''">
				AND a.HANDLE_STATUS = #{tEmpContractAlert.handleStatus}
			</if>
			<if test="tEmpContractAlert.contractId != null and tEmpContractAlert.contractId.trim() != ''">
				AND a.CONTRACT_ID = #{tEmpContractAlert.contractId}
			</if>
			<if test="tEmpContractAlert.auditTime != null">
				AND a.AUDIT_TIME = #{tEmpContractAlert.auditTime}
			</if>
			<if test="tEmpContractAlert.unitId != null and tEmpContractAlert.unitId.trim() != ''">
				AND a.UNIT_ID = #{tEmpContractAlert.unitId}
			</if>
			<if test="tEmpContractAlert.unitName != null and tEmpContractAlert.unitName.trim() != ''">
				AND a.UNIT_NAME = #{tEmpContractAlert.unitName}
			</if>
			<if test="tEmpContractAlert.unitNo != null and tEmpContractAlert.unitNo.trim() != ''">
				AND a.UNIT_NO = #{tEmpContractAlert.unitNo}
			</if>
			<if test="tEmpContractAlert.empPhone != null and tEmpContractAlert.empPhone.trim() != ''">
				AND a.EMP_PHONE = #{tEmpContractAlert.empPhone}
			</if>
			<if test="tEmpContractAlert.isFeedback != null">
				AND a.IS_FEEDBACK = #{tEmpContractAlert.isFeedback}
			</if>
			<if test="tEmpContractAlert.feedbackPerson != null and tEmpContractAlert.feedbackPerson.trim() != ''">
				AND a.FEEDBACK_PERSON = #{tEmpContractAlert.feedbackPerson}
			</if>
			<if test="tEmpContractAlert.feedbackTime != null">
				AND a.FEEDBACK_TIME = #{tEmpContractAlert.feedbackTime}
			</if>
			<if test="tEmpContractAlert.feedbackReason != null and tEmpContractAlert.feedbackReason.trim() != ''">
				AND a.FEEDBACK_REASON = #{tEmpContractAlert.feedbackReason}
			</if>
			<if test="tEmpContractAlert.feedbackDetail != null and tEmpContractAlert.feedbackDetail.trim() != ''">
				AND a.FEEDBACK_DETAIL = #{tEmpContractAlert.feedbackDetail}
			</if>
			<if test="tEmpContractAlert.applyNo != null and tEmpContractAlert.applyNo.trim() != ''">
				AND a.APPLY_NO = #{tEmpContractAlert.applyNo}
			</if>
			<if test="tEmpContractAlert.post != null and tEmpContractAlert.post.trim() != ''">
				AND a.POST = #{tEmpContractAlert.post}
			</if>
			<if test="tEmpContractAlert.workingHours != null and tEmpContractAlert.workingHours.trim() != ''">
				AND a.WORKING_HOURS = #{tEmpContractAlert.workingHours}
			</if>
			<if test="tEmpContractAlert.expectedCollectionTime != null">
				AND b.EXPECTED_COLLECTION_TIME = #{tEmpContractAlert.expectedCollectionTime}
			</if>
			<if test="tEmpContractAlert.signType != null">
				AND b.SIGN_TYPE = #{tEmpContractAlert.signType}
			</if>
			<if test="tEmpContractAlert.processStatus != null and tEmpContractAlert.processStatus.trim() != ''">
				AND IFNULL(b.PROCESS_STATUS,'0') = #{tEmpContractAlert.processStatus}
			</if>

			<if test="tEmpContractAlert.processStatusList != null and tEmpContractAlert.processStatusList.size>0">
				AND IFNULL(b.PROCESS_STATUS,'0') IN
				<foreach collection="tEmpContractAlert.processStatusList" item="item" index="index" open="(" separator="," close=")">
					#{item}
				</foreach>
			</if>
			<if test="tEmpContractAlert.csName != null and tEmpContractAlert.csName.trim() != ''">
				AND a.CS_NAME like CONCAT('%',#{tEmpContractAlert.csName},'%')
			</if>

			<if test="tEmpContractAlert.expectedCollectionTimeStart != null">
				AND b.EXPECTED_COLLECTION_TIME <![CDATA[ >= ]]> #{tEmpContractAlert.expectedCollectionTimeStart}
			</if>
			<if test="tEmpContractAlert.expectedCollectionTimeEnd != null">
				AND b.EXPECTED_COLLECTION_TIME <![CDATA[ <= ]]> #{tEmpContractAlert.expectedCollectionTimeEnd}
			</if>
			<if test="tEmpContractAlert.contractEndStart != null">
				AND a.CONTRACT_END <![CDATA[ >= ]]> #{tEmpContractAlert.contractEndStart}
			</if>
			<if test="tEmpContractAlert.contractEndEnd != null">
				AND a.CONTRACT_END <![CDATA[ <= ]]> #{tEmpContractAlert.contractEndEnd}
			</if>
			<if test="tEmpContractAlert.csLoginName != null and tEmpContractAlert.csLoginName.trim() != ''">
				AND a.CS_LOGIN_NAME = #{tEmpContractAlert.csLoginName}
			</if>
			<if test="tEmpContractAlert.autoFlag != null and tEmpContractAlert.autoFlag.trim() != ''">
				AND a.AUTO_FLAG = #{tEmpContractAlert.autoFlag}
			</if>
		</if>
	</sql>
    <sql id="tEmployeeContractPreNew_where">
        <if test="tEmployeeContractPreNew != null">
                    <if test="tEmployeeContractPreNew.id != null and tEmployeeContractPreNew.id.trim() != ''">
                        AND a.id = #{tEmployeeContractPreNew.id}
                    </if>
                    <if test="tEmployeeContractPreNew.deptName != null and tEmployeeContractPreNew.deptName.trim() != ''">
                        AND a.dept_name = #{tEmployeeContractPreNew.deptName}
                    </if>
                    <if test="tEmployeeContractPreNew.deptNo != null and tEmployeeContractPreNew.deptNo.trim() != ''">
                        AND a.dept_no = #{tEmployeeContractPreNew.deptNo}
                    </if>
                    <if test="tEmployeeContractPreNew.deptId != null and tEmployeeContractPreNew.deptId.trim() != ''">
                        AND a.dept_id = #{tEmployeeContractPreNew.deptId}
                    </if>
                    <if test="tEmployeeContractPreNew.employeeName != null and tEmployeeContractPreNew.employeeName.trim() != ''">
                        AND a.employee_name = #{tEmployeeContractPreNew.employeeName}
                    </if>
                    <if test="tEmployeeContractPreNew.empIdcard != null and tEmployeeContractPreNew.empIdcard.trim() != ''">
                        AND a.emp_idcard = #{tEmployeeContractPreNew.empIdcard}
                    </if>
                    <if test="tEmployeeContractPreNew.empPhone != null and tEmployeeContractPreNew.empPhone.trim() != ''">
                        AND a.emp_phone = #{tEmployeeContractPreNew.empPhone}
                    </if>
                    <if test="tEmployeeContractPreNew.employeeNature != null and tEmployeeContractPreNew.employeeNature.trim() != ''">
                        AND a.employee_nature = #{tEmployeeContractPreNew.employeeNature}
                    </if>
                    <if test="tEmployeeContractPreNew.position != null and tEmployeeContractPreNew.position.trim() != ''">
                        AND a.position = #{tEmployeeContractPreNew.position}
                    </if>
                    <if test="tEmployeeContractPreNew.joinLeaveDate != null">
                        AND a.join_leave_date = #{tEmployeeContractPreNew.joinLeaveDate}
                    </if>
                    <if test="tEmployeeContractPreNew.customerUsername != null and tEmployeeContractPreNew.customerUsername.trim() != ''">
                        AND a.customer_username = #{tEmployeeContractPreNew.customerUsername}
                    </if>
                    <if test="tEmployeeContractPreNew.customerUserLoginname != null and tEmployeeContractPreNew.customerUserLoginname.trim() != ''">
                        AND a.customer_user_loginname = #{tEmployeeContractPreNew.customerUserLoginname}
                    </if>
                    <if test="tEmployeeContractPreNew.signType != null and tEmployeeContractPreNew.signType.trim() != ''">
                        AND a.sign_type = #{tEmployeeContractPreNew.signType}
                    </if>
                    <if test="tEmployeeContractPreNew.contractContent != null and tEmployeeContractPreNew.contractContent.trim() != ''">
                        AND a.contract_content = #{tEmployeeContractPreNew.contractContent}
                    </if>
                    <if test="tEmployeeContractPreNew.fadadaTemplate != null and tEmployeeContractPreNew.fadadaTemplate.trim() != ''">
                        AND a.fadada_template = #{tEmployeeContractPreNew.fadadaTemplate}
                    </if>
                    <if test="tEmployeeContractPreNew.dataSource != null and tEmployeeContractPreNew.dataSource.trim() != ''">
                        AND a.data_source = #{tEmployeeContractPreNew.dataSource}
                    </if>
                    <if test="tEmployeeContractPreNew.processStatus != null and tEmployeeContractPreNew.processStatus.trim() != ''">
                        AND a.process_status = #{tEmployeeContractPreNew.processStatus}
                    </if>
					<if test="tEmployeeContractPreNew.statusList != null and tEmployeeContractPreNew.statusList.size>0">
						AND a.process_status IN
						<foreach collection="tEmployeeContractPreNew.statusList" item="item" index="index" open="(" separator="," close=")">
							#{item}
						</foreach>
					</if>
                    <if test="tEmployeeContractPreNew.configName != null and tEmployeeContractPreNew.configName.trim() != ''">
                        AND a.config_name = #{tEmployeeContractPreNew.configName}
                    </if>
                    <if test="tEmployeeContractPreNew.updateFlag != null and tEmployeeContractPreNew.updateFlag.trim() != ''">
                        AND a.update_flag = #{tEmployeeContractPreNew.updateFlag}
                    </if>
                    <if test="tEmployeeContractPreNew.contractType != null and tEmployeeContractPreNew.contractType.trim() != ''">
                        AND a.contract_type = #{tEmployeeContractPreNew.contractType}
                    </if>
                    <if test="tEmployeeContractPreNew.signatory != null and tEmployeeContractPreNew.signatory.trim() != ''">
                        AND a.signatory = #{tEmployeeContractPreNew.signatory}
                    </if>
                    <if test="tEmployeeContractPreNew.expectedConfirmTime != null">
                        AND a.expected_confirm_time = #{tEmployeeContractPreNew.expectedConfirmTime}
                    </if>
                    <if test="tEmployeeContractPreNew.expectedCollectionTime != null">
                        AND a.expected_collection_time = #{tEmployeeContractPreNew.expectedCollectionTime}
                    </if>
                    <if test="tEmployeeContractPreNew.situation != null and tEmployeeContractPreNew.situation.trim() != ''">
                        AND a.situation = #{tEmployeeContractPreNew.situation}
                    </if>
                    <if test="tEmployeeContractPreNew.contractTerm != null and tEmployeeContractPreNew.contractTerm.trim() != ''">
                        AND a.contract_term = #{tEmployeeContractPreNew.contractTerm}
                    </if>
                    <if test="tEmployeeContractPreNew.contractStart != null">
                        AND a.contract_start = #{tEmployeeContractPreNew.contractStart}
                    </if>
                    <if test="tEmployeeContractPreNew.contractEnd != null">
                        AND a.contract_end = #{tEmployeeContractPreNew.contractEnd}
                    </if>
                    <if test="tEmployeeContractPreNew.postType != null and tEmployeeContractPreNew.postType.trim() != ''">
                        AND a.post_type = #{tEmployeeContractPreNew.postType}
                    </if>
                    <if test="tEmployeeContractPreNew.post != null and tEmployeeContractPreNew.post.trim() != ''">
                        AND a.post = #{tEmployeeContractPreNew.post}
                    </if>
                    <if test="tEmployeeContractPreNew.workingDept != null and tEmployeeContractPreNew.workingDept.trim() != ''">
                        AND a.working_dept = #{tEmployeeContractPreNew.workingDept}
                    </if>
                    <if test="tEmployeeContractPreNew.workAddress != null and tEmployeeContractPreNew.workAddress.trim() != ''">
                        AND a.work_address = #{tEmployeeContractPreNew.workAddress}
                    </if>
                    <if test="tEmployeeContractPreNew.workingHours != null and tEmployeeContractPreNew.workingHours.trim() != ''">
                        AND a.working_hours = #{tEmployeeContractPreNew.workingHours}
                    </if>
                    <if test="tEmployeeContractPreNew.salaryType != null and tEmployeeContractPreNew.salaryType.trim() != ''">
                        AND a.salary_type = #{tEmployeeContractPreNew.salaryType}
                    </if>
                    <if test="tEmployeeContractPreNew.otherWage != null and tEmployeeContractPreNew.otherWage.trim() != ''">
                        AND a.other_wage = #{tEmployeeContractPreNew.otherWage}
                    </if>
                    <if test="tEmployeeContractPreNew.defaultAmount != null and tEmployeeContractPreNew.defaultAmount.trim() != ''">
                        AND a.default_amount = #{tEmployeeContractPreNew.defaultAmount}
                    </if>
                    <if test="tEmployeeContractPreNew.contractDurationYear != null and tEmployeeContractPreNew.contractDurationYear.trim() != ''">
                        AND a.contract_duration_year = #{tEmployeeContractPreNew.contractDurationYear}
                    </if>
                    <if test="tEmployeeContractPreNew.contractDurationMonth != null and tEmployeeContractPreNew.contractDurationMonth.trim() != ''">
                        AND a.contract_duration_month = #{tEmployeeContractPreNew.contractDurationMonth}
                    </if>
                    <if test="tEmployeeContractPreNew.laborCost != null and tEmployeeContractPreNew.laborCost.trim() != ''">
                        AND a.labor_cost = #{tEmployeeContractPreNew.laborCost}
                    </if>
                    <if test="tEmployeeContractPreNew.riskBuyDesc != null and tEmployeeContractPreNew.riskBuyDesc.trim() != ''">
                        AND a.risk_buy_desc = #{tEmployeeContractPreNew.riskBuyDesc}
                    </if>
                    <if test="tEmployeeContractPreNew.salaryStandardPerHour != null and tEmployeeContractPreNew.salaryStandardPerHour.trim() != ''">
                        AND a.salary_standard_per_hour = #{tEmployeeContractPreNew.salaryStandardPerHour}
                    </if>
                    <if test="tEmployeeContractPreNew.salaryStandardPerPiece != null and tEmployeeContractPreNew.salaryStandardPerPiece.trim() != ''">
                        AND a.salary_standard_per_piece = #{tEmployeeContractPreNew.salaryStandardPerPiece}
                    </if>
                    <if test="tEmployeeContractPreNew.configId != null and tEmployeeContractPreNew.configId.trim() != ''">
                        AND a.config_id = #{tEmployeeContractPreNew.configId}
                    </if>
                    <if test="tEmployeeContractPreNew.workType != null and tEmployeeContractPreNew.workType.trim() != ''">
                        AND a.work_type = #{tEmployeeContractPreNew.workType}
                    </if>
                    <if test="tEmployeeContractPreNew.workDayCount != null and tEmployeeContractPreNew.workDayCount.trim() != ''">
                        AND a.work_day_count = #{tEmployeeContractPreNew.workDayCount}
                    </if>
                    <if test="tEmployeeContractPreNew.workDay != null and tEmployeeContractPreNew.workDay.trim() != ''">
                        AND a.work_day = #{tEmployeeContractPreNew.workDay}
                    </if>
                    <if test="tEmployeeContractPreNew.workHours != null and tEmployeeContractPreNew.workHours.trim() != ''">
                        AND a.work_hours = #{tEmployeeContractPreNew.workHours}
                    </if>
                    <if test="tEmployeeContractPreNew.settlementCycle != null and tEmployeeContractPreNew.settlementCycle.trim() != ''">
                        AND a.settlement_cycle = #{tEmployeeContractPreNew.settlementCycle}
                    </if>
                    <if test="tEmployeeContractPreNew.paymentTime != null and tEmployeeContractPreNew.paymentTime.trim() != ''">
                        AND a.payment_time = #{tEmployeeContractPreNew.paymentTime}
                    </if>
                    <if test="tEmployeeContractPreNew.paymentType != null and tEmployeeContractPreNew.paymentType.trim() != ''">
                        AND a.payment_type = #{tEmployeeContractPreNew.paymentType}
                    </if>
                    <if test="tEmployeeContractPreNew.workingCompany != null and tEmployeeContractPreNew.workingCompany.trim() != ''">
                        AND a.working_company = #{tEmployeeContractPreNew.workingCompany}
                    </if>
                    <if test="tEmployeeContractPreNew.dispatchPeriodYear != null and tEmployeeContractPreNew.dispatchPeriodYear.trim() != ''">
                        AND a.dispatch_period_year = #{tEmployeeContractPreNew.dispatchPeriodYear}
                    </if>
                    <if test="tEmployeeContractPreNew.dispatchPeriodMonth != null and tEmployeeContractPreNew.dispatchPeriodMonth.trim() != ''">
                        AND a.dispatch_period_month = #{tEmployeeContractPreNew.dispatchPeriodMonth}
                    </if>
                    <if test="tEmployeeContractPreNew.dispatchPeriodStart != null">
                        AND a.dispatch_period_start = #{tEmployeeContractPreNew.dispatchPeriodStart}
                    </if>
                    <if test="tEmployeeContractPreNew.dispatchPeriodEnd != null">
                        AND a.dispatch_period_end = #{tEmployeeContractPreNew.dispatchPeriodEnd}
                    </if>
                    <if test="tEmployeeContractPreNew.otherWorkDay != null and tEmployeeContractPreNew.otherWorkDay.trim() != ''">
                        AND a.other_work_day = #{tEmployeeContractPreNew.otherWorkDay}
                    </if>
                    <if test="tEmployeeContractPreNew.internshipPeriod != null and tEmployeeContractPreNew.internshipPeriod.trim() != ''">
                        AND a.internship_period = #{tEmployeeContractPreNew.internshipPeriod}
                    </if>
                    <if test="tEmployeeContractPreNew.internshipPeriodStart != null">
                        AND a.internship_period_start = #{tEmployeeContractPreNew.internshipPeriodStart}
                    </if>
                    <if test="tEmployeeContractPreNew.internshipPeriodEnd != null">
                        AND a.internship_period_end = #{tEmployeeContractPreNew.internshipPeriodEnd}
                    </if>
                    <if test="tEmployeeContractPreNew.signFlag != null and tEmployeeContractPreNew.signFlag.trim() != ''">
                        AND a.sign_flag = #{tEmployeeContractPreNew.signFlag}
                    </if>
                    <if test="tEmployeeContractPreNew.errorInfo != null and tEmployeeContractPreNew.errorInfo.trim() != ''">
                        AND a.error_info = #{tEmployeeContractPreNew.errorInfo}
                    </if>
                    <if test="tEmployeeContractPreNew.contractId != null and tEmployeeContractPreNew.contractId.trim() != ''">
                        AND a.contract_id = #{tEmployeeContractPreNew.contractId}
                    </if>
                    <if test="tEmployeeContractPreNew.revokeReason != null and tEmployeeContractPreNew.revokeReason.trim() != ''">
                        AND a.revoke_reason = #{tEmployeeContractPreNew.revokeReason}
                    </if>
                    <if test="tEmployeeContractPreNew.errorTime != null">
                        AND a.error_time = #{tEmployeeContractPreNew.errorTime}
                    </if>
                    <if test="tEmployeeContractPreNew.contractEndType != null and tEmployeeContractPreNew.contractEndType.trim() != ''">
                        AND a.contract_end_type = #{tEmployeeContractPreNew.contractEndType}
                    </if>
                    <if test="tEmployeeContractPreNew.confirmEmpSelect != null and tEmployeeContractPreNew.confirmEmpSelect.trim() != ''">
                        AND a.confirm_emp_select = #{tEmployeeContractPreNew.confirmEmpSelect}
                    </if>
                    <if test="tEmployeeContractPreNew.timeoutElecSign != null and tEmployeeContractPreNew.timeoutElecSign.trim() != ''">
                        AND a.timeout_elec_sign = #{tEmployeeContractPreNew.timeoutElecSign}
                    </if>
                    <if test="tEmployeeContractPreNew.task != null and tEmployeeContractPreNew.task.trim() != ''">
                        AND a.task = #{tEmployeeContractPreNew.task}
                    </if>
                    <if test="tEmployeeContractPreNew.taskType != null and tEmployeeContractPreNew.taskType.trim() != ''">
                        AND a.task_type = #{tEmployeeContractPreNew.taskType}
                    </if>
                    <if test="tEmployeeContractPreNew.taskEndStandard != null and tEmployeeContractPreNew.taskEndStandard.trim() != ''">
                        AND a.task_end_standard = #{tEmployeeContractPreNew.taskEndStandard}
                    </if>
                    <if test="tEmployeeContractPreNew.contractFlag != null and tEmployeeContractPreNew.contractFlag.trim() != ''">
                        AND a.contract_flag = #{tEmployeeContractPreNew.contractFlag}
                    </if>
                    <if test="tEmployeeContractPreNew.contractSubName != null and tEmployeeContractPreNew.contractSubName.trim() != ''">
                        AND a.CONTRACT_SUB_NAME = #{tEmployeeContractPreNew.contractSubName}
                    </if>
                    <if test="tEmployeeContractPreNew.fadadaTemplateId != null and tEmployeeContractPreNew.fadadaTemplateId.trim() != ''">
                        AND a.fadada_template_id = #{tEmployeeContractPreNew.fadadaTemplateId}
                    </if>
                    <if test="tEmployeeContractPreNew.requestId != null and tEmployeeContractPreNew.requestId.trim() != ''">
                        AND a.request_id = #{tEmployeeContractPreNew.requestId}
                    </if>
                    <if test="tEmployeeContractPreNew.requestMsg != null and tEmployeeContractPreNew.requestMsg.trim() != ''">
                        AND a.request_msg = #{tEmployeeContractPreNew.requestMsg}
                    </if>
                    <if test="tEmployeeContractPreNew.overFlag != null and tEmployeeContractPreNew.overFlag.trim() != ''">
                        AND a.over_flag = #{tEmployeeContractPreNew.overFlag}
                    </if>
                    <if test="tEmployeeContractPreNew.changeTypeReason != null and tEmployeeContractPreNew.changeTypeReason.trim() != ''">
                        AND a.change_type_reason = #{tEmployeeContractPreNew.changeTypeReason}
                    </if>
                    <if test="tEmployeeContractPreNew.changeTypeUser != null and tEmployeeContractPreNew.changeTypeUser.trim() != ''">
                        AND a.change_type_user = #{tEmployeeContractPreNew.changeTypeUser}
                    </if>
                    <if test="tEmployeeContractPreNew.changeTypeTime != null">
                        AND a.change_type_time = #{tEmployeeContractPreNew.changeTypeTime}
                    </if>
                    <if test="tEmployeeContractPreNew.isUrg != null and tEmployeeContractPreNew.isUrg.trim() != ''">
                        AND a.is_urg = #{tEmployeeContractPreNew.isUrg}
                    </if>
                    <if test="tEmployeeContractPreNew.workingReward != null and tEmployeeContractPreNew.workingReward.trim() != ''">
                        AND a.working_reward = #{tEmployeeContractPreNew.workingReward}
                    </if>
                    <if test="tEmployeeContractPreNew.updateTime != null">
                        AND a.update_time = #{tEmployeeContractPreNew.updateTime}
                    </if>
                    <if test="tEmployeeContractPreNew.createBy != null and tEmployeeContractPreNew.createBy.trim() != ''">
                        AND a.create_by = #{tEmployeeContractPreNew.createBy}
                    </if>
                    <if test="tEmployeeContractPreNew.createName != null and tEmployeeContractPreNew.createName.trim() != ''">
                        AND a.create_name = #{tEmployeeContractPreNew.createName}
                    </if>
                    <if test="tEmployeeContractPreNew.createTime != null">
                        AND a.create_time = #{tEmployeeContractPreNew.createTime}
                    </if>
                    <if test="tEmployeeContractPreNew.updateBy != null and tEmployeeContractPreNew.updateBy.trim() != ''">
                        AND a.update_by = #{tEmployeeContractPreNew.updateBy}
                    </if>
                    <if test="tEmployeeContractPreNew.salaryDay != null and tEmployeeContractPreNew.salaryDay.trim() != ''">
                        AND a.SALARY_DAY = #{tEmployeeContractPreNew.salaryDay}
                    </if>
        </if>
    </sql>
    <!--tEmployeeContractPreNew简单分页查询-->
    <select id="getTEmployeeContractPreNewPage" resultMap="tEmployeeContractPreNewMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_employee_contract_pre_new a
        <where>
            1=1
            <include refid="tEmployeeContractPreNew_where"/>
        </where>
    </select>

	<select id="getDisPatcherContractListRenew" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeContractVO">
		SELECT
		(@i :=@i+1) as rowIndex,
		a.employee_name empName,
		a.emp_idcard empIdcard,
		a.dept_no deptNo,
		a.situation,
		a.contract_name contractName,
		a.CONTRACT_SUB_NAME contractSubName,
		null reason,
		a.signatory contractParty,
		if(a.CONTRACT_TERM = '' or a.CONTRACT_TERM is null,'2',a.CONTRACT_TERM) contractType,
		a.CONTRACT_START as contractStart,
		if(a.contract_type = '实习协议',a.CONTRACT_END,if(a.CONTRACT_TERM ='1' ,a.CONTRACT_END,null)) as contractEnd,
		a.post,
		if(a.working_hours = '' or a.working_hours is null,'4',a.working_hours) as workingHours,
		null contractNo,
		null fileCabinetNo,
		null leaveDate,
		null reduceReason,
		null remark,
		a.sign_type signType,
		null changeContractAndEmployee,
		'无' as tryPeriod,
		a.id preNewId,a.contract_id contractId,
		if(#{type} = '1',concat('自动化手动-',a.customer_username),concat('自动化自动-',a.customer_username)) preName
		FROM t_employee_contract_pre_new a,(select @i:=0) as itable
		<where>
			1=1
			AND a.id in
			<foreach item="idStr" index="index" collection="idList" open="(" separator="," close=")">
				#{idStr}
			</foreach>
			AND a.process_status in
			<foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
				#{status}
			</foreach>
		</where>
	</select>

	<!--tEmployeeContractPreNew简单分页查询-->
	<select id="getUnDispatchList" resultType="java.lang.String">
		SELECT
		a.id
		FROM t_employee_contract_pre_new a
		where a.process_status in('1','5') and (a.expected_collection_time   <![CDATA[ <= ]]> now())
	</select>

	<!--tEmployeeContractPreNew简单分页查询-->
	<select id="getDetailList" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TEmployeeContractPreNewDetailVo">
		SELECT
		b.id,
		b.dept_name,
		b.dept_no,
		b.dept_id,
		b.employee_name,
		b.emp_idcard,
		b.emp_phone,
		b.employee_nature,
		b.post as  'position',
		b.customer_username,
		b.customer_user_loginname,
		b.sign_type,
		b.contract_content,
		b.fadada_template,
		b.data_source,
		b.process_status,
		b.config_name,
		b.update_flag,
		b.contract_type,
		b.signatory,
		b.expected_confirm_time,
		b.expected_collection_time,
		b.situation,
		b.contract_term,
		case when b.CONTRACT_TYPE = 5 then b.internship_period_start
		else b.contract_start  end  as "CONTRACT_START",
		case when b.CONTRACT_TYPE = 5 then b.internship_period_end
		else b.contract_end  end  as "CONTRACT_END",
		b.post_type,
		b.post,
		b.working_dept,
		b.work_address,
		b.working_hours,
		b.salary_type,
		b.other_wage,
		b.default_amount,
		b.contract_duration_year,
		b.contract_duration_month,
		b.labor_cost,
		b.risk_buy_desc,
		b.salary_standard_per_hour,
		b.salary_standard_per_piece,
		b.config_id,
		b.work_type,
		b.work_day_count,
		b.work_day,
		b.work_hours,
		b.settlement_cycle,
		b.payment_time,
		b.payment_type,
		b.working_company,
		b.dispatch_period_year,
		b.dispatch_period_month,
		b.dispatch_period_start,
		b.dispatch_period_end,
		b.other_work_day,
		b.internship_period,
		b.internship_period_start,
		b.internship_period_end,
		b.sign_flag,
		b.error_info,
		b.contract_id,
		b.revoke_reason,
		b.error_time,
		b.contract_end_type,
		b.confirm_emp_select,
		b.timeout_elec_sign,
		b.task,
		b.task_type,
		b.task_end_standard,
		b.contract_flag,
		b.CONTRACT_SUB_NAME,
		b.fadada_template_id,
		b.request_id,
		b.request_msg,
		b.over_flag,
		b.change_type_reason,
		b.change_type_user,
		b.change_type_time,
		b.is_urg,
		b.working_reward,
		b.update_time,
		b.create_by,
		b.create_name,
		b.create_time,
		b.update_by,
		a.CONTRACT_START as "CONTRACT_START_PRE",
		a.CONTRACT_END as "CONTRACT_END_PRE"
		FROM t_employee_contract_pre_new b
		LEFT JOIN t_emp_contract_alert a on b.contract_id=a.contract_id
		<where>
			1=1 AND (b.expected_collection_time is null  or  b.expected_collection_time <![CDATA[ <= ]]> concat(DATE_FORMAT(curdate(),'%Y-%m-%d'), ' 23:59:59'))
			<if test="tEmpContractAlert != null">
				<if test="tEmpContractAlert.statusList != null and tEmpContractAlert.statusList.size>0">
					AND b.process_status IN
					<foreach collection="tEmpContractAlert.statusList" item="item" index="index" open="(" separator="," close=")">
						#{item}
					</foreach>
				</if>
				<if test="tEmpContractAlert.customerUserLoginname != null and tEmpContractAlert.customerUserLoginname.trim() != ''">
					AND a.CS_LOGIN_NAME = #{tEmpContractAlert.customerUserLoginname}
				</if>
				<if test="tEmpContractAlert.idList != null and tEmpContractAlert.idList.size > 0">
					AND a.id in
					<foreach item="id" index="index" collection="tEmpContractAlert.idList" open="(" separator=","
							 close=")">
						#{id}
					</foreach>
				</if>

				<if test="tEmpContractAlert.preIdList != null and tEmpContractAlert.preIdList.size > 0">
					AND b.id in
					<foreach item="preId" index="index" collection="tEmpContractAlert.preIdList" open="(" separator=","
							 close=")">
						#{preId}
					</foreach>
				</if>
			</if>
			<include refid="tEmpContractAlert_where"/>
		</where>
		limit 2000
	</select>

	<select id="getDetailListCount" resultType="java.lang.Integer">
		SELECT
		count(1)
		FROM t_employee_contract_pre_new b
		LEFT JOIN t_emp_contract_alert a on b.contract_id=a.contract_id
		<where>
			1=1 AND (b.expected_collection_time is null  or  b.expected_collection_time <![CDATA[ <= ]]> concat(DATE_FORMAT(curdate(),'%Y-%m-%d'), ' 23:59:59'))
			<if test="tEmpContractAlert != null">
				<if test="tEmpContractAlert.statusList != null and tEmpContractAlert.statusList.size>0">
					AND b.process_status IN
					<foreach collection="tEmpContractAlert.statusList" item="item" index="index" open="(" separator="," close=")">
						#{item}
					</foreach>
				</if>
				<if test="tEmpContractAlert.customerUserLoginname != null and tEmpContractAlert.customerUserLoginname.trim() != ''">
					AND a.CS_LOGIN_NAME = #{tEmpContractAlert.customerUserLoginname}
				</if>
				<if test="tEmpContractAlert.idList != null and tEmpContractAlert.idList.size > 0">
					AND a.id in
					<foreach item="id" index="index" collection="tEmpContractAlert.idList" open="(" separator=","
							 close=")">
						#{id}
					</foreach>
				</if>
			</if>
			<include refid="tEmpContractAlert_where"/>
		</where>
	</select>
</mapper>
