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

  <resultMap id="tPreEmpBadRecordMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TPreEmpBadRecord">
    <id property="id" column="ID"/>
    <result property="preMainId" column="PRE_MAIN_ID"/>
    <result property="empName" column="EMP_NAME"/>
    <result property="empId" column="EMP_ID"/>
    <result property="empIdcard" column="EMP_IDCARD"/>
    <result property="project" column="PROJECT"/>
    <result property="projectCode" column="PROJECT_CODE"/>
    <result property="happenTime" column="HAPPEN_TIME"/>
    <result property="remark" column="REMARK"/>
    <result property="loseFee" column="LOSE_FEE"/>
    <result property="loseFeeOther" column="LOSE_FEE_OTHER"/>
    <result property="createBy" column="CREATE_BY"/>
    <result property="updateBy" column="UPDATE_BY"/>
    <result property="createName" column="CREATE_NAME"/>
    <result property="createTime" column="CREATE_TIME"/>
    <result property="updateTime" column="UPDATE_TIME"/>
    <result property="settleDomain" column="SETTLE_DOMAIN"/>
	  <result property="oldId" column="OLD_ID"/>
  </resultMap>
    <sql id="Base_Column_List">
                a.ID,
                a.PRE_MAIN_ID,
                a.EMP_NAME,
                a.EMP_ID,
                a.EMP_IDCARD,
                a.PROJECT,
                a.PROJECT_CODE,
                a.HAPPEN_TIME,
                a.REMARK,
                a.LOSE_FEE,
                a.LOSE_FEE_OTHER,
                a.CREATE_BY,
                a.UPDATE_BY,
                a.CREATE_NAME,
                a.CREATE_TIME,
                a.UPDATE_TIME,
                a.OLD_ID,
                a.SETTLE_DOMAIN
    </sql>
    <sql id="tPreEmpBadRecord_where">
        <if test="tPreEmpBadRecord != null">
                    <if test="tPreEmpBadRecord.id != null and tPreEmpBadRecord.id.trim() != ''">
                        AND a.ID = #{tPreEmpBadRecord.id}
                    </if>
                    <if test="tPreEmpBadRecord.preMainId != null and tPreEmpBadRecord.preMainId.trim() != ''">
                        AND a.PRE_MAIN_ID = #{tPreEmpBadRecord.preMainId}
                    </if>
                    <if test="tPreEmpBadRecord.empName != null and tPreEmpBadRecord.empName.trim() != ''">
                        AND a.EMP_NAME = #{tPreEmpBadRecord.empName}
                    </if>
                    <if test="tPreEmpBadRecord.empId != null and tPreEmpBadRecord.empId.trim() != ''">
                        AND a.EMP_ID = #{tPreEmpBadRecord.empId}
                    </if>
                    <if test="tPreEmpBadRecord.empIdcard != null and tPreEmpBadRecord.empIdcard.trim() != ''">
                        AND a.EMP_IDCARD = #{tPreEmpBadRecord.empIdcard}
                    </if>
                    <if test="tPreEmpBadRecord.project != null and tPreEmpBadRecord.project.trim() != ''">
                        AND a.PROJECT = #{tPreEmpBadRecord.project}
                    </if>
                    <if test="tPreEmpBadRecord.projectCode != null and tPreEmpBadRecord.projectCode.trim() != ''">
                        AND a.PROJECT_CODE = #{tPreEmpBadRecord.projectCode}
                    </if>
                    <if test="tPreEmpBadRecord.happenTime != null">
                        AND a.HAPPEN_TIME = #{tPreEmpBadRecord.happenTime}
                    </if>
                    <if test="tPreEmpBadRecord.remark != null and tPreEmpBadRecord.remark.trim() != ''">
                        AND a.REMARK = #{tPreEmpBadRecord.remark}
                    </if>
                    <if test="tPreEmpBadRecord.loseFee != null">
                        AND a.LOSE_FEE = #{tPreEmpBadRecord.loseFee}
                    </if>
                    <if test="tPreEmpBadRecord.loseFeeOther != null">
                        AND a.LOSE_FEE_OTHER = #{tPreEmpBadRecord.loseFeeOther}
                    </if>
                    <if test="tPreEmpBadRecord.createBy != null and tPreEmpBadRecord.createBy.trim() != ''">
                        AND a.CREATE_BY = #{tPreEmpBadRecord.createBy}
                    </if>
                    <if test="tPreEmpBadRecord.updateBy != null and tPreEmpBadRecord.updateBy.trim() != ''">
                        AND a.UPDATE_BY = #{tPreEmpBadRecord.updateBy}
                    </if>
                    <if test="tPreEmpBadRecord.createName != null and tPreEmpBadRecord.createName.trim() != ''">
                        AND a.CREATE_NAME = #{tPreEmpBadRecord.createName}
                    </if>
                    <if test="tPreEmpBadRecord.createTime != null">
                        AND a.CREATE_TIME = #{tPreEmpBadRecord.createTime}
                    </if>
                    <if test="tPreEmpBadRecord.updateTime != null">
                        AND a.UPDATE_TIME = #{tPreEmpBadRecord.updateTime}
                    </if>
                    <if test="tPreEmpBadRecord.settleDomain != null and tPreEmpBadRecord.settleDomain.trim() != ''">
                        AND a.SETTLE_DOMAIN = #{tPreEmpBadRecord.settleDomain}
                    </if>
        </if>
    </sql>
    <!--tPreEmpBadRecord简单分页查询-->
    <select id="getTPreEmpBadRecordList" resultMap="tPreEmpBadRecordMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_pre_emp_bad_record a
		where PRE_MAIN_ID = #{preMainId} order by a.create_time desc
		limit 1
    </select>
</mapper>