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

  <resultMap id="tPreEmpDisabilityInfoMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TPreEmpDisabilityInfo">
    <id property="id" column="ID"/>
    <result property="preMainId" column="PRE_MAIN_ID"/>
	  <result property="empId" column="EMP_ID"/>
	  <result property="empName" column="EMP_NAME"/>
	  <result property="empCode" column="EMP_CODE"/>
	  <result property="empIdcard" column="EMP_IDCARD"/>
	  <result property="disabilityName" column="DISABILITY_NAME"/>
	  <result property="disabilityLevel" column="DISABILITY_LEVEL"/>
	  <result property="injuryIdentification" column="INJURY_IDENTIFICATION"/>
	  <result property="startTime" column="START_TIME"/>
	  <result property="endTime" column="END_TIME"/>
	  <result property="occupationalDisease" column="OCCUPATIONAL_DISEASE"/>
	  <result property="settleDomain" column="SETTLE_DOMAIN"/>
	  <result property="deleteFlag" column="DELETE_FLAG"/>
	  <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="remark" column="REMARK"/>
	  <result property="occupationalDiseaseFlag" column="OCCUPATIONAL_DISEASE_FLAG"/>
	  <result property="infectiousDiseaseFlag" column="INFECTIOUS_DISEASE_FLAG"/>
	  <result property="infectiousName" column="INFECTIOUS_NAME"/>
	  <result property="disabilityFlag" column="DISABILITY_FLAG"/>
	  <result property="otherFlag" column="OTHER_FLAG"/>
	  <result property="oldId" column="OLD_ID"/>
  </resultMap>
    <sql id="Base_Column_List">
                a.ID,
                a.PRE_MAIN_ID,
                a.EMP_ID,
				a.EMP_NAME,
				a.EMP_CODE,
				a.EMP_IDCARD,
				a.DISABILITY_NAME,
				a.DISABILITY_LEVEL,
				a.INJURY_IDENTIFICATION,
				a.START_TIME,
				a.END_TIME,
				a.OCCUPATIONAL_DISEASE,
				a.DELETE_FLAG,
				a.SETTLE_DOMAIN,
				a.CREATE_BY,
				a.UPDATE_BY,
				a.CREATE_NAME,
				a.CREATE_TIME,
				a.UPDATE_TIME,
				a.REMARK,
				a.OCCUPATIONAL_DISEASE_FLAG,
				a.INFECTIOUS_DISEASE_FLAG,
				a.INFECTIOUS_NAME,
				a.DISABILITY_FLAG,
				a.OTHER_FLAG,
                a.OLD_ID
    </sql>
    <sql id="tPreEmpDisabilityInfo_where">
        <if test="tPreEmpDisabilityInfo != null">
                    <if test="tPreEmpDisabilityInfo.id != null and tPreEmpDisabilityInfo.id.trim() != ''">
                        AND a.ID = #{tPreEmpDisabilityInfo.id}
                    </if>
                    <if test="tPreEmpDisabilityInfo.preMainId != null and tPreEmpDisabilityInfo.preMainId.trim() != ''">
                        AND a.PRE_MAIN_ID = #{tPreEmpDisabilityInfo.preMainId}
                    </if>
                    <if test="tPreEmpDisabilityInfo.empId != null and tPreEmpDisabilityInfo.empId.trim() != ''">
                        AND a.EMP_ID = #{tPreEmpDisabilityInfo.empId}
                    </if>
                    <if test="tPreEmpDisabilityInfo.empName != null and tPreEmpDisabilityInfo.empName.trim() != ''">
                        AND a.EMP_NAME = #{tPreEmpDisabilityInfo.empName}
                    </if>
                    <if test="tPreEmpDisabilityInfo.empCode != null and tPreEmpDisabilityInfo.empCode.trim() != ''">
                        AND a.EMP_CODE = #{tPreEmpDisabilityInfo.empCode}
                    </if>
                    <if test="tPreEmpDisabilityInfo.empIdcard != null and tPreEmpDisabilityInfo.empIdcard.trim() != ''">
                        AND a.EMP_IDCARD = #{tPreEmpDisabilityInfo.empIdcard}
                    </if>
                    <if test="tPreEmpDisabilityInfo.disabilityName != null and tPreEmpDisabilityInfo.disabilityName.trim() != ''">
                        AND a.DISABILITY_NAME = #{tPreEmpDisabilityInfo.disabilityName}
                    </if>
                    <if test="tPreEmpDisabilityInfo.disabilityLevel != null and tPreEmpDisabilityInfo.disabilityLevel.trim() != ''">
                        AND a.DISABILITY_LEVEL = #{tPreEmpDisabilityInfo.disabilityLevel}
                    </if>
                    <if test="tPreEmpDisabilityInfo.injuryIdentification != null and tPreEmpDisabilityInfo.injuryIdentification.trim() != ''">
                        AND a.INJURY_IDENTIFICATION = #{tPreEmpDisabilityInfo.injuryIdentification}
                    </if>
                    <if test="tPreEmpDisabilityInfo.startTime != null">
                        AND a.START_TIME = #{tPreEmpDisabilityInfo.startTime}
                    </if>
                    <if test="tPreEmpDisabilityInfo.endTime != null">
                        AND a.END_TIME = #{tPreEmpDisabilityInfo.endTime}
                    </if>
                    <if test="tPreEmpDisabilityInfo.occupationalDisease != null and tPreEmpDisabilityInfo.occupationalDisease.trim() != ''">
                        AND a.OCCUPATIONAL_DISEASE = #{tPreEmpDisabilityInfo.occupationalDisease}
                    </if>
                    <if test="tPreEmpDisabilityInfo.deleteFlag != null and tPreEmpDisabilityInfo.deleteFlag.trim() != ''">
                        AND a.DELETE_FLAG = #{tPreEmpDisabilityInfo.deleteFlag}
                    </if>
                    <if test="tPreEmpDisabilityInfo.settleDomain != null and tPreEmpDisabilityInfo.settleDomain.trim() != ''">
                        AND a.SETTLE_DOMAIN = #{tPreEmpDisabilityInfo.settleDomain}
                    </if>
                    <if test="tPreEmpDisabilityInfo.createBy != null and tPreEmpDisabilityInfo.createBy.trim() != ''">
                        AND a.CREATE_BY = #{tPreEmpDisabilityInfo.createBy}
                    </if>
                    <if test="tPreEmpDisabilityInfo.updateBy != null and tPreEmpDisabilityInfo.updateBy.trim() != ''">
                        AND a.UPDATE_BY = #{tPreEmpDisabilityInfo.updateBy}
                    </if>
                    <if test="tPreEmpDisabilityInfo.createName != null and tPreEmpDisabilityInfo.createName.trim() != ''">
                        AND a.CREATE_NAME = #{tPreEmpDisabilityInfo.createName}
                    </if>
                    <if test="tPreEmpDisabilityInfo.createTime != null">
                        AND a.CREATE_TIME = #{tPreEmpDisabilityInfo.createTime}
                    </if>
                    <if test="tPreEmpDisabilityInfo.updateTime != null">
                        AND a.UPDATE_TIME = #{tPreEmpDisabilityInfo.updateTime}
                    </if>
                    <if test="tPreEmpDisabilityInfo.remark != null and tPreEmpDisabilityInfo.remark.trim() != ''">
                        AND a.REMARK = #{tPreEmpDisabilityInfo.remark}
                    </if>
        </if>
    </sql>
    <!--tPreEmpDisabilityInfo简单分页查询-->
    <select id="getTPreEmpDisabilityInfoList" resultMap="tPreEmpDisabilityInfoMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_pre_emp_disability_info a
		where PRE_MAIN_ID = #{preMainId} order by a.create_time desc
		limit 1
    </select>
</mapper>
