TPreEmpMainMapper.xml 27.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
<?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.TPreEmpMainMapper">

  <resultMap id="tPreEmpMainMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TPreEmpMain">
    <id property="id" column="ID"/>
    <result property="status" column="STATUS"/>
    <result property="empId" column="EMP_ID"/>
    <result property="empName" column="EMP_NAME"/>
    <result property="empIdcard" column="EMP_IDCARD"/>
    <result property="empPhone" column="EMP_PHONE"/>
    <result property="empWx" column="EMP_WX"/>
    <result property="unitId" column="UNIT_ID"/>
    <result property="unitName" column="UNIT_NAME"/>
    <result property="unitNo" column="UNIT_NO"/>
    <result property="deptId" column="DEPT_ID"/>
    <result property="deptName" column="DEPT_NAME"/>
    <result property="deptNo" column="DEPT_NO"/>
    <result property="businessPrimaryType" column="BUSINESS_PRIMARY_TYPE"/>
    <result property="businessSecondType" column="BUSINESS_SECOND_TYPE"/>
    <result property="businessThirdType" column="BUSINESS_THIRD_TYPE"/>
43
    <result property="businessType" column="BUSINESS_TYPE"/>
44 45 46 47 48 49 50 51 52 53
    <result property="empNatrue" column="EMP_NATRUE"/>
    <result property="auditId" column="AUDIT_ID"/>
    <result property="auditName" column="AUDIT_NAME"/>
    <result property="auditTime" column="AUDIT_TIME"/>
    <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"/>
54
    <result property="declarationId" column="DECLARATION_ID"/>
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
  </resultMap>
    <sql id="Base_Column_List">
                a.ID,
                a.STATUS,
                a.EMP_ID,
                a.EMP_NAME,
                a.EMP_IDCARD,
                a.EMP_PHONE,
                a.EMP_WX,
                a.UNIT_ID,
                a.UNIT_NAME,
                a.UNIT_NO,
                a.DEPT_ID,
                a.DEPT_NAME,
                a.DEPT_NO,
                a.BUSINESS_PRIMARY_TYPE,
                a.BUSINESS_SECOND_TYPE,
                a.BUSINESS_THIRD_TYPE,
73
                concat(a.BUSINESS_PRIMARY_TYPE,'-',ifnull(a.BUSINESS_SECOND_TYPE,''),'-',ifnull(a.BUSINESS_THIRD_TYPE,'')) BUSINESS_TYPE,
74 75
                a.EMP_NATRUE,
                a.AUDIT_ID,
76
                if(a.STATUS in ('3','4'),a.AUDIT_NAME,'') AUDIT_NAME,
77
                if(a.STATUS in ('3','4'),a.AUDIT_TIME,null) AUDIT_TIME,
78 79 80 81 82
                a.CREATE_BY,
                a.UPDATE_BY,
                a.CREATE_NAME,
                a.CREATE_TIME,
                a.UPDATE_TIME,
83 84
                a.SETTLE_DOMAIN,
                a.DECLARATION_ID
85 86 87
    </sql>
    <sql id="tPreEmpMain_where">
        <if test="tPreEmpMain != null">
88 89 90 91 92 93
			<if test="tPreEmpMain.statusList != null and tPreEmpMain.statusList.length>0">
				AND a.STATUS IN
				<foreach collection="tPreEmpMain.statusList" item="item" index="index" open="(" separator="," close=")">
					#{item}
				</foreach>
			</if>
94 95 96
                    <if test="tPreEmpMain.id != null and tPreEmpMain.id.trim() != ''">
                        AND a.ID = #{tPreEmpMain.id}
                    </if>
97 98 99 100 101 102
					<if test="tPreEmpMain.ids != null and tPreEmpMain.ids.length > 0">
						AND a.ID in
						<foreach item="idStr" index="index" collection="tPreEmpMain.ids" open="(" separator="," close=")">
							#{idStr}
						</foreach>
					</if>
103 104 105
                    <if test="tPreEmpMain.status != null and tPreEmpMain.status.trim() != ''">
                        AND a.STATUS = #{tPreEmpMain.status}
                    </if>
106 107 108 109 110 111 112

					<if test="tPreEmpMain.statusArray != null and tPreEmpMain.statusArray.length > 0">
						AND a.STATUS in
						<foreach item="idStr" index="index" collection="tPreEmpMain.statusArray" open="(" separator="," close=")">
							#{idStr}
						</foreach>
					</if>
113 114 115 116
                    <if test="tPreEmpMain.empId != null and tPreEmpMain.empId.trim() != ''">
                        AND a.EMP_ID = #{tPreEmpMain.empId}
                    </if>
                    <if test="tPreEmpMain.empName != null and tPreEmpMain.empName.trim() != ''">
117
                        AND a.EMP_NAME like concat('%',#{tPreEmpMain.empName},'%')
118 119
                    </if>
                    <if test="tPreEmpMain.empIdcard != null and tPreEmpMain.empIdcard.trim() != ''">
120
                        AND a.EMP_IDCARD like concat('%',#{tPreEmpMain.empIdcard},'%')
121 122 123 124 125 126 127 128 129 130 131
                    </if>
                    <if test="tPreEmpMain.empPhone != null and tPreEmpMain.empPhone.trim() != ''">
                        AND a.EMP_PHONE = #{tPreEmpMain.empPhone}
                    </if>
                    <if test="tPreEmpMain.empWx != null and tPreEmpMain.empWx.trim() != ''">
                        AND a.EMP_WX = #{tPreEmpMain.empWx}
                    </if>
                    <if test="tPreEmpMain.unitId != null and tPreEmpMain.unitId.trim() != ''">
                        AND a.UNIT_ID = #{tPreEmpMain.unitId}
                    </if>
                    <if test="tPreEmpMain.unitName != null and tPreEmpMain.unitName.trim() != ''">
132
                        AND a.UNIT_NAME like concat('%',#{tPreEmpMain.unitName},'%')
133 134 135 136 137 138 139 140
                    </if>
                    <if test="tPreEmpMain.unitNo != null and tPreEmpMain.unitNo.trim() != ''">
                        AND a.UNIT_NO = #{tPreEmpMain.unitNo}
                    </if>
                    <if test="tPreEmpMain.deptId != null and tPreEmpMain.deptId.trim() != ''">
                        AND a.DEPT_ID = #{tPreEmpMain.deptId}
                    </if>
                    <if test="tPreEmpMain.deptName != null and tPreEmpMain.deptName.trim() != ''">
141
                        AND a.DEPT_NAME like concat('%',#{tPreEmpMain.deptName},'%')
142 143 144 145 146
                    </if>
                    <if test="tPreEmpMain.deptNo != null and tPreEmpMain.deptNo.trim() != ''">
                        AND a.DEPT_NO = #{tPreEmpMain.deptNo}
                    </if>
                    <if test="tPreEmpMain.businessPrimaryType != null and tPreEmpMain.businessPrimaryType.trim() != ''">
147
                        AND a.BUSINESS_PRIMARY_TYPE like concat('%',#{tPreEmpMain.businessPrimaryType},'%')
148 149
                    </if>
                    <if test="tPreEmpMain.businessSecondType != null and tPreEmpMain.businessSecondType.trim() != ''">
150
                        AND a.BUSINESS_SECOND_TYPE like concat('%',#{tPreEmpMain.businessSecondType},'%')
151 152
                    </if>
                    <if test="tPreEmpMain.businessThirdType != null and tPreEmpMain.businessThirdType.trim() != ''">
153
                        AND a.BUSINESS_THIRD_TYPE like concat('%',#{tPreEmpMain.businessThirdType},'%')
154 155 156 157
                    </if>
                    <if test="tPreEmpMain.empNatrue != null and tPreEmpMain.empNatrue.trim() != ''">
                        AND a.EMP_NATRUE = #{tPreEmpMain.empNatrue}
                    </if>
158 159 160 161 162 163
					<if test="tPreEmpMain.empNatureArray != null and tPreEmpMain.empNatureArray.length > 0">
						AND a.EMP_NATRUE in
						<foreach item="idStr" index="index" collection="tPreEmpMain.empNatureArray" open="(" separator="," close=")">
							#{idStr}
						</foreach>
					</if>
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
                    <if test="tPreEmpMain.auditId != null and tPreEmpMain.auditId.trim() != ''">
                        AND a.AUDIT_ID = #{tPreEmpMain.auditId}
                    </if>
                    <if test="tPreEmpMain.auditName != null and tPreEmpMain.auditName.trim() != ''">
                        AND a.AUDIT_NAME = #{tPreEmpMain.auditName}
                    </if>
                    <if test="tPreEmpMain.auditTime != null">
                        AND a.AUDIT_TIME = #{tPreEmpMain.auditTime}
                    </if>
                    <if test="tPreEmpMain.createBy != null and tPreEmpMain.createBy.trim() != ''">
                        AND a.CREATE_BY = #{tPreEmpMain.createBy}
                    </if>
                    <if test="tPreEmpMain.updateBy != null and tPreEmpMain.updateBy.trim() != ''">
                        AND a.UPDATE_BY = #{tPreEmpMain.updateBy}
                    </if>
                    <if test="tPreEmpMain.createName != null and tPreEmpMain.createName.trim() != ''">
                        AND a.CREATE_NAME = #{tPreEmpMain.createName}
                    </if>
                    <if test="tPreEmpMain.createTime != null">
                        AND a.CREATE_TIME = #{tPreEmpMain.createTime}
                    </if>
                    <if test="tPreEmpMain.updateTime != null">
                        AND a.UPDATE_TIME = #{tPreEmpMain.updateTime}
                    </if>
                    <if test="tPreEmpMain.settleDomain != null and tPreEmpMain.settleDomain.trim() != ''">
                        AND a.SETTLE_DOMAIN = #{tPreEmpMain.settleDomain}
                    </if>
191 192 193 194 195 196
                    <if test="tPreEmpMain.createTimeStart != null">
                        AND a.CREATE_TIME >= #{tPreEmpMain.createTimeStart}
                    </if>
                    <if test="tPreEmpMain.createTimeEnd != null">
                        AND a.CREATE_TIME <![CDATA[ <= ]]> #{tPreEmpMain.createTimeEnd}
                    </if>
197 198 199 200 201 202 203 204
        </if>
    </sql>
    <!--tPreEmpMain简单分页查询-->
    <select id="getTPreEmpMainPage" resultMap="tPreEmpMainMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_pre_emp_main a
        <where>
205
            a.STATUS != '5'
206 207 208 209 210 211 212
            <include refid="tPreEmpMain_where"/>
			<if test="tPreEmpMain != null">
				<if test="tPreEmpMain.authSql != null and tPreEmpMain.authSql.trim() != ''">
					${tPreEmpMain.authSql}
				</if>
			</if>
        </where>
213
		order by a.create_time desc
214
    </select>
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255

    <select id="getTPreEmpMainCount" resultType="java.lang.Integer">
        SELECT
        	count(1)
        FROM t_pre_emp_main a
        <where>
            a.STATUS != '5'
            <include refid="tPreEmpMain_where"/>
			<if test="tPreEmpMain != null">
				<if test="tPreEmpMain.authSql != null and tPreEmpMain.authSql.trim() != ''">
					${tPreEmpMain.authSql}
				</if>
			</if>
        </where>
    </select>

	<!--list-->
	<select id="getTPreEmpMainList" resultMap="tPreEmpMainMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_pre_emp_main a
		<where>
			a.STATUS != '5'
			<include refid="tPreEmpMain_where"/>
			<if test="tPreEmpMain != null">
				<if test="tPreEmpMain.authSql != null and tPreEmpMain.authSql.trim() != ''">
					${tPreEmpMain.authSql}
				</if>
			</if>
			<if test="tPreEmpMain != null">
				<if test="tPreEmpMain.limitStart != null">
					limit #{tPreEmpMain.limitStart},#{tPreEmpMain.limitEnd}
				</if>
			</if>
		</where>
	</select>

    <select id="getTPreEmpMainAllCount" resultType="java.lang.Integer">
        SELECT
        	count(1)
        FROM t_pre_emp_main a
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
		left join t_pre_employee_info e on a.id=e.PRE_MAIN_ID
		left join view_sys_dict_item emp_natrue on emp_natrue.value=a.emp_Natrue and emp_natrue.type='emp_natrue'
		left join view_sys_dict_item emp_married on emp_married.value=e.EMP_MARRI_STATUS and emp_married.type='emp_married'
		left join view_sys_dict_item nation on nation.value=e.EMP_NATIONAL and nation.type='emp_national'
		left join view_sys_dict_item registype on registype.value=e.EMP_REGIS_TYPE and registype.type='emp_registype'
		left join view_sys_dict_item politicalStatus on politicalStatus.value=e.POLITICAL_STATUS and politicalStatus.type='emp_political'
		left join sys_area pi on pi.id=e.ID_PROVINCE
		left join sys_area ci on ci.id=e.ID_CITY
		left join sys_area ti on ti.id=e.ID_TOWN
		left join sys_area pf on pf.id=e.FILE_PROVINCE
		left join sys_area cf on cf.id=e.FILE_CITY
		left join sys_area tf on tf.id=e.FILE_TOWN
		left join t_pre_employee_project p on a.id=p.PRE_MAIN_ID
		left join view_sys_dict_item contractType on contractType.value=p.CONTRACT_TYPE and contractType.type='employee_contract_type'
		left join view_sys_dict_item workingHours on workingHours.value=p.WORKING_HOURS and workingHours.type='working_hours'
		left join t_pre_emp_contact_info ec on a.id=ec.PRE_MAIN_ID
		left join t_pre_emp_education ee on a.id=ee.PRE_MAIN_ID
		left join view_sys_dict_item education on education.value=ee.EDUCATION_NAME and education.type='education'
		left join t_pre_emp_work_recording ew on a.id=ew.PRE_MAIN_ID
		left join t_pre_emp_family ef on a.id=ef.PRE_MAIN_ID
		left join t_pre_emp_professional_qualification ep on a.id=ep.PRE_MAIN_ID
		left join view_sys_dict_item qualification_type on qualification_type.value=ep.QUALIFICATION_TYPE and qualification_type.type='qualification_type'
		left join t_pre_emp_disability_info ed on a.id=ed.PRE_MAIN_ID
		left join t_pre_emp_bad_record eb on a.id=eb.PRE_MAIN_ID
280 281 282 283 284 285 286 287 288 289 290 291 292 293
        <where>
            a.STATUS != '5'
            <include refid="tPreEmpMain_where"/>
			<if test="tPreEmpMain != null">
				<if test="tPreEmpMain.authSql != null and tPreEmpMain.authSql.trim() != ''">
					${tPreEmpMain.authSql}
				</if>
			</if>
        </where>
    </select>

	<!--list-->
	<select id="getTPreEmpMainAllList" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TPreMainExportAllVO">
		SELECT
hongguangwu's avatar
hongguangwu committed
294
			case a.STATUS when '0' then '草稿' when '1' then '待完善' when '2' then '待审核' when '3' then '审核不通过' when '4' then '审核通过' else '-' end field1
295
			,DATE_FORMAT(a.create_time,'%Y-%m-%d %H:%i:%s') field2,if(a.STATUS in ('3','4'),a.AUDIT_NAME,'') field64,if(a.STATUS in ('3','4'),DATE_FORMAT(a.AUDIT_TIME,'%Y-%m-%d %H:%i:%s'),'') field65
hongguangwu's avatar
hongguangwu committed
296
		     ,e.EMP_CODE field3,emp_natrue.label field4,a.emp_name field5,a.emp_idcard field6
hongguangwu's avatar
hongguangwu committed
297
			,if(e.EMP_SEX='2','女',if(e.EMP_SEX='1','男','-')) field7
298 299
			,if(e.VALIDITY_END is null,'-',if(e.VALIDITY_END > '2999-12-30','长期','固定')) field8	,e.VALIDITY_START field9
			,if(e.VALIDITY_END > '2999-12-30','长期',e.VALIDITY_END) field10,e.EMP_BIRTHDAY field11,e.EMP_AGE field12	,emp_married.label field13,nation.label field14
hongguangwu's avatar
hongguangwu committed
300 301
			,politicalStatus.label field15,e.EMP_PHONE field16,e.EMP_EMAIL field17
			,concat(ifnull(pi.AREA_NAME,''),ifnull(ci.AREA_NAME,''),ifnull(ti.AREA_NAME,'')) field18	,registype.label field19
302 303 304 305 306
			,concat(ifnull(pf.AREA_NAME,''),ifnull(cf.AREA_NAME,''),ifnull(tf.AREA_NAME,'')) field20	,if(e.status=0,'草稿','已审核') field21,
			cp.AREA_NAME as "field66",
			cc.AREA_NAME as "field67",
			ct.AREA_NAME as "field68"
		     ,e.CONTACT_ADDRESS field22,p.UNIT_NAME field23,p.DEPT_NAME field24
307
			,concat(p.BUSINESS_PRIMARY_TYPE,'-',ifnull(p.BUSINESS_SECOND_TYPE,''),'-',ifnull(p.BUSINESS_THIRD_TYPE,'')) field25
308
			,contractType.label field26	,workingHours.label field27,p.POST field28,p.ENJOIN_DATE field29
hongguangwu's avatar
hongguangwu committed
309 310 311
			,p.TRY_PERIOD field30,p.EMP_LABEL field31
			,ec.EMP_NAME field32,ec.RELATION_TYPE field33,ec.ADDRESS field34,ec.TEL field35
			,ee.SCHOOL field36,ee.MAJOR field37,education.label field38,if(e.IS_COLLEGE=0,'否','是') field39
312
			,educationEmp.label field40	,ee.ENTRY_DATE field41,ee.GRADUTION_DATE field42
313

314
			,if(e.FIRST_WORK_FLAG is null,'',if(e.FIRST_WORK_FLAG=0,'是','否')) field43,ew.WORK_UNIT field44,ew.WORK_JOB field45,ew.START_DATE field46,ew.END_DATE field47
315
			,ef.FAMILY_NAME field48,family_relation.label field49,ef.CONTRACT_TEL field50
316
			,if(e.HAVE_QUALIFICATION is null,'',if(e.HAVE_QUALIFICATION=0,'是','否')) field51,ep.DECLARE_YEAR field52,qualification_type.label field53
317

hongguangwu's avatar
hongguangwu committed
318 319
			,if(ed.INJURY_IDENTIFICATION=0,'是','否') field54,if(ed.OCCUPATIONAL_DISEASE_FLAG=0,'是','否') field55	,ed.OCCUPATIONAL_DISEASE field56
			,if(ed.INFECTIOUS_DISEASE_FLAG=0,'是','否') field57	,ed.INFECTIOUS_NAME field58	,if(ed.DISABILITY_FLAG=0,'是','否') field59
320
			,ed.DISABILITY_NAME field60,disability_grade.label field61,if(ed.OTHER_FLAG=0,'是','否') field62,eb.REMARK field63
321
		FROM t_pre_emp_main a
hongguangwu's avatar
hongguangwu committed
322 323
		left join t_pre_employee_info e on a.id=e.PRE_MAIN_ID
		left join view_sys_dict_item emp_natrue on emp_natrue.value=a.emp_Natrue and emp_natrue.type='emp_natrue'
324
		left join view_sys_dict_item educationEmp on educationEmp.value=e.HIGN_EDUCATION and educationEmp.type='education'
hongguangwu's avatar
hongguangwu committed
325 326 327 328 329 330 331 332 333 334
		left join view_sys_dict_item emp_married on emp_married.value=e.EMP_MARRI_STATUS and emp_married.type='emp_married'
		left join view_sys_dict_item nation on nation.value=e.EMP_NATIONAL and nation.type='emp_national'
		left join view_sys_dict_item registype on registype.value=e.EMP_REGIS_TYPE and registype.type='emp_registype'
		left join view_sys_dict_item politicalStatus on politicalStatus.value=e.POLITICAL_STATUS and politicalStatus.type='emp_political'
		left join sys_area pi on pi.id=e.ID_PROVINCE
		left join sys_area ci on ci.id=e.ID_CITY
		left join sys_area ti on ti.id=e.ID_TOWN
		left join sys_area pf on pf.id=e.FILE_PROVINCE
		left join sys_area cf on cf.id=e.FILE_CITY
		left join sys_area tf on tf.id=e.FILE_TOWN
335 336 337 338 339

		left join sys_area cp on cp.id=e.CONTACT_PROVINCE
		left join sys_area cc on cc.id=e.CONTACT_CITY
		left join sys_area ct on ct.id=e.CONTACT_TOWN

hongguangwu's avatar
hongguangwu committed
340
		left join t_pre_employee_project p on a.id=p.PRE_MAIN_ID
341
		left join view_sys_dict_item contractType on contractType.value=p.CONTRACT_TYPE and contractType.type='personnel_type'
hongguangwu's avatar
hongguangwu committed
342 343 344 345
		left join view_sys_dict_item workingHours on workingHours.value=p.WORKING_HOURS and workingHours.type='working_hours'
		left join t_pre_emp_contact_info ec on a.id=ec.PRE_MAIN_ID
		left join t_pre_emp_education ee on a.id=ee.PRE_MAIN_ID
		left join view_sys_dict_item education on education.value=ee.EDUCATION_NAME and education.type='education'
346 347 348 349 350 351 352 353 354
		left join (
		select
		SUBSTRING_INDEX(GROUP_CONCAT(ee.PRE_MAIN_ID ORDER BY ee.create_time desc),',',1) PRE_MAIN_ID
		,SUBSTRING_INDEX(GROUP_CONCAT(ee.WORK_UNIT ORDER BY ee.create_time desc),',',1) WORK_UNIT
		,SUBSTRING_INDEX(GROUP_CONCAT(ee.WORK_JOB ORDER BY ee.create_time desc),',',1) WORK_JOB
		,SUBSTRING_INDEX(GROUP_CONCAT(ee.START_DATE ORDER BY ee.create_time desc),',',1) START_DATE
		,SUBSTRING_INDEX(GROUP_CONCAT(ee.END_DATE ORDER BY ee.create_time desc),',',1) END_DATE
		from t_pre_emp_work_recording ee
		GROUP BY ee.PRE_MAIN_ID
355
		) ew on a.id=ew.PRE_MAIN_ID
356 357 358 359 360 361 362 363
		left join (
		select
		SUBSTRING_INDEX(GROUP_CONCAT(ee.PRE_MAIN_ID ORDER BY ee.create_time desc),',',1) PRE_MAIN_ID
		,SUBSTRING_INDEX(GROUP_CONCAT(ee.FAMILY_NAME ORDER BY ee.create_time desc),',',1) FAMILY_NAME
		,SUBSTRING_INDEX(GROUP_CONCAT(ee.RELATIONSHIP_SELF ORDER BY ee.create_time desc),',',1) RELATIONSHIP_SELF
		,SUBSTRING_INDEX(GROUP_CONCAT(ee.CONTRACT_TEL ORDER BY ee.create_time desc),',',1) CONTRACT_TEL
		from t_pre_emp_family ee
		GROUP BY ee.PRE_MAIN_ID
364
		) ef on a.id=ef.PRE_MAIN_ID
365
		left join view_sys_dict_item family_relation on family_relation.value=ef.RELATIONSHIP_SELF and family_relation.type='family_relation'
366 367 368 369 370 371 372
		left join (
		select
		SUBSTRING_INDEX(GROUP_CONCAT(ee.PRE_MAIN_ID ORDER BY ee.create_time desc),',',1) PRE_MAIN_ID
		,SUBSTRING_INDEX(GROUP_CONCAT(ee.DECLARE_YEAR ORDER BY ee.create_time desc),',',1) DECLARE_YEAR
		,SUBSTRING_INDEX(GROUP_CONCAT(ee.QUALIFICATION_TYPE ORDER BY ee.create_time desc),',',1) QUALIFICATION_TYPE
		from t_pre_emp_professional_qualification ee
		GROUP BY ee.PRE_MAIN_ID
373
		) ep on a.id=ep.PRE_MAIN_ID
374 375

		    left join view_sys_dict_item qualification_type on qualification_type.value=ep.QUALIFICATION_TYPE and qualification_type.type='qualification_type'
hongguangwu's avatar
hongguangwu committed
376
		left join t_pre_emp_disability_info ed on a.id=ed.PRE_MAIN_ID
377
		left join view_sys_dict_item disability_grade on disability_grade.value=ed.DISABILITY_LEVEL and disability_grade.type='disability_grade'
hongguangwu's avatar
hongguangwu committed
378
		left join t_pre_emp_bad_record eb on a.id=eb.PRE_MAIN_ID
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394
		<where>
			a.STATUS != '5'
			<include refid="tPreEmpMain_where"/>
			<if test="tPreEmpMain != null">
				<if test="tPreEmpMain.authSql != null and tPreEmpMain.authSql.trim() != ''">
					${tPreEmpMain.authSql}
				</if>
			</if>
			<if test="tPreEmpMain != null">
				<if test="tPreEmpMain.limitStart != null">
					limit #{tPreEmpMain.limitStart},#{tPreEmpMain.limitEnd}
				</if>
			</if>
		</where>
	</select>

395 396 397 398 399 400 401

	<!-- 数量 -->
	<select id="getTEmpMainAllCountOneWork" resultType="java.lang.Integer">
		SELECT
		count(1)
		FROM t_pre_emp_main a
		left join t_pre_employee_info e on a.id=e.PRE_MAIN_ID
402
		left join t_pre_emp_work_recording ew on a.id=ew.PRE_MAIN_ID
403 404
		<where>
			a.STATUS != '5' and ew.id is not null and EXISTS (
405
			select 1 from (select a.EMP_IDCARD from t_pre_emp_work_recording a left join t_pre_emp_main p on a.PRE_MAIN_ID=p.id where p.STATUS != '5' and p.id is not null GROUP BY a.EMP_IDCARD HAVING count(1)>1) ea where ea.EMP_IDCARD=ew.EMP_IDCARD
406 407 408 409 410 411 412 413 414 415 416 417
			)
			<include refid="tPreEmpMain_where"/>
		</where>
	</select>

	<!--导出统计list1主要工作经历-->
	<select id="getTEmpMainAllListOneWork" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TPreMainExportAllVO">
		SELECT
		e.emp_idcard field6
		,if(e.FIRST_WORK_FLAG is null,'',if(e.FIRST_WORK_FLAG=0,'是','否')) field43,ew.WORK_UNIT field44,ew.WORK_JOB field45,ew.START_DATE field46,ew.END_DATE field47
		FROM t_pre_emp_main a
		left join t_pre_employee_info e on a.id=e.PRE_MAIN_ID
418
		left join t_pre_emp_work_recording ew on a.id=ew.PRE_MAIN_ID
419 420
		<where>
			a.STATUS != '5' and ew.id is not null and EXISTS (
421
			select 1 from (select a.EMP_IDCARD from t_pre_emp_work_recording a left join t_pre_emp_main p on a.PRE_MAIN_ID=p.id where p.STATUS != '5' and p.id is not null GROUP BY a.EMP_IDCARD HAVING count(1)>1) ea where ea.EMP_IDCARD=ew.EMP_IDCARD
422 423 424
			)
			<include refid="tPreEmpMain_where"/>
		</where>
425
		ORDER BY a.emp_idcard DESC
426 427 428 429 430 431 432 433 434 435 436 437 438
		<if test="tPreEmpMain != null">
			<if test="tPreEmpMain.limitStart != null">
				limit #{tPreEmpMain.limitStart},#{tPreEmpMain.limitEnd}
			</if>
		</if>
	</select>

	<!-- 数量 -->
	<select id="getTEmpMainAllCountTwoFamily" resultType="java.lang.Integer">
		SELECT
		count(1)
		FROM t_pre_emp_main a
		left join t_pre_employee_info e on a.id=e.PRE_MAIN_ID
439
		left join t_pre_emp_family ef on a.id=ef.PRE_MAIN_ID
440 441
		<where>
			a.STATUS != '5' and ef.id is not null and EXISTS (
442
			select 1 from (select a.EMP_IDCARD from t_pre_emp_family a left join t_pre_emp_main p on a.PRE_MAIN_ID=p.id where p.STATUS != '5' and p.id is not null GROUP BY a.EMP_IDCARD HAVING count(1)>1) ea where ea.EMP_IDCARD=ef.EMP_IDCARD
443 444 445 446 447 448 449 450
			)
			<include refid="tPreEmpMain_where"/>
		</where>
	</select>
	<!--导出统计list2主要家庭成员信息-->
	<select id="getTEmpMainAllListTwoFamily" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TPreMainExportAllVO">
		SELECT
		e.emp_idcard field6
451
		,ef.FAMILY_NAME field48,family_relation.label field49,ef.CONTRACT_TEL field50
452 453
		FROM t_pre_emp_main a
		left join t_pre_employee_info e on a.id=e.PRE_MAIN_ID
454
		left join t_pre_emp_family ef on a.id=ef.PRE_MAIN_ID
455
		left join view_sys_dict_item family_relation on family_relation.value=ef.RELATIONSHIP_SELF and family_relation.type='family_relation'
456 457
		<where>
			a.STATUS != '5' and ef.id is not null and EXISTS (
458
			select 1 from (select a.EMP_IDCARD from t_pre_emp_family a left join t_pre_emp_main p on a.PRE_MAIN_ID=p.id where p.STATUS != '5' and p.id is not null GROUP BY a.EMP_IDCARD HAVING count(1)>1) ea where ea.EMP_IDCARD=ef.EMP_IDCARD
459 460 461
			)
			<include refid="tPreEmpMain_where"/>
		</where>
462
		ORDER BY a.emp_idcard DESC
463 464 465 466 467 468 469 470 471 472 473 474 475
		<if test="tPreEmpMain != null">
			<if test="tPreEmpMain.limitStart != null">
				limit #{tPreEmpMain.limitStart},#{tPreEmpMain.limitEnd}
			</if>
		</if>
	</select>

	<!-- 数量 -->
	<select id="getTEmpMainAllCountThreeProfessional" resultType="java.lang.Integer">
		SELECT
		count(1)
		FROM t_pre_emp_main a
		left join t_pre_employee_info e on a.id=e.PRE_MAIN_ID
476
		left join t_pre_emp_professional_qualification ep on a.id=ep.PRE_MAIN_ID
477 478
		<where>
			a.STATUS != '5' and ep.id is not null and EXISTS (
479
			select 1 from (select a.EMP_IDCARD from t_pre_emp_professional_qualification a left join t_pre_emp_main p on a.PRE_MAIN_ID=p.id where p.STATUS != '5' and p.id is not null GROUP BY a.EMP_IDCARD HAVING count(1)>1) ea where ea.EMP_IDCARD=ep.EMP_IDCARD
480 481 482 483 484 485 486 487 488 489 490
			)
			<include refid="tPreEmpMain_where"/>
		</where>
	</select>
	<!--导出统计list3职业资格信息-->
	<select id="getTEmpMainAllListThreeProfessional" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TPreMainExportAllVO">
		SELECT
		e.emp_idcard field6
		,if(e.HAVE_QUALIFICATION is null,'',if(e.HAVE_QUALIFICATION=0,'是','否')) field51,ep.DECLARE_YEAR field52,qualification_type.label field53
		FROM t_pre_emp_main a
		left join t_pre_employee_info e on a.id=e.PRE_MAIN_ID
491
		left join t_pre_emp_professional_qualification ep on a.id=ep.PRE_MAIN_ID
492 493 494
		left join view_sys_dict_item qualification_type on qualification_type.value=ep.QUALIFICATION_TYPE and qualification_type.type='qualification_type'
		<where>
			a.STATUS != '5' and ep.id is not null and EXISTS (
495
			select 1 from (select a.EMP_IDCARD from t_pre_emp_professional_qualification a left join t_pre_emp_main p on a.PRE_MAIN_ID=p.id where p.STATUS != '5' and p.id is not null GROUP BY a.EMP_IDCARD HAVING count(1)>1) ea where ea.EMP_IDCARD=ep.EMP_IDCARD
496 497 498
			)
			<include refid="tPreEmpMain_where"/>
		</where>
499
		ORDER BY a.emp_idcard DESC
500 501 502 503 504 505 506 507
		<if test="tPreEmpMain != null">
			<if test="tPreEmpMain.limitStart != null">
				limit #{tPreEmpMain.limitStart},#{tPreEmpMain.limitEnd}
			</if>
		</if>
	</select>
	

508 509 510 511 512 513 514 515
    <!--tPreEmpMain简单分页查询-->
    <select id="getTPreEmpMainByCardAndDept" resultMap="tPreEmpMainMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_pre_emp_main a
        where  a.EMP_IDCARD = #{empIdCard} AND a.DEPT_ID = #{deptId}
		limit 1
    </select>
516 517 518 519 520 521 522 523 524 525

    <!--tPreEmpMain简单分页查询-->
    <select id="getTPreEmpMainByCardAndDeptNo" resultMap="tPreEmpMainMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_pre_emp_main a
        where  a.EMP_IDCARD = #{empIdCard} AND a.DEPT_NO = #{deptNo}
		limit 1
    </select>

526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547
	<delete id="deleteBadByMainId">
		delete from t_pre_emp_bad_record where PRE_MAIN_ID = #{preMainId}
	</delete>
	<delete id="deleteContactByMainId">
		delete from t_pre_emp_contact_info where PRE_MAIN_ID = #{preMainId}
	</delete>
	<delete id="deleteDisabilityByMainId">
		delete from t_pre_emp_disability_info where PRE_MAIN_ID = #{preMainId}
	</delete>
	<delete id="deleteEducationByMainId">
		delete from t_pre_emp_education where PRE_MAIN_ID = #{preMainId}
	</delete>
	<delete id="deleteFamilyByMainId">
		delete from t_pre_emp_family where PRE_MAIN_ID = #{preMainId}
	</delete>
	<delete id="deleteEmployeeByMainId">
		delete from t_pre_employee_info where PRE_MAIN_ID = #{preMainId}
	</delete>
	<delete id="deleteProjectByMainId">
		delete from t_pre_employee_project where PRE_MAIN_ID = #{preMainId}
	</delete>

548
</mapper>