123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.jeeplus.modules.workstaff.dao.WorkStaffBasicInfoDao">
-
- <sql id="workStaffBasicInfoColumns">
- a.id AS "id",
- a.create_by AS "createBy.id",
- a.create_date AS "createDate",
- a.update_by AS "updateBy.id",
- a.update_date AS "updateDate",
- a.remarks AS "remarks",
- a.del_flag AS "delFlag",
- a.office_id AS "office.id",
- a.company_id AS "company.id",
- a.no AS "no",
- a.name AS "name",
- a.gender AS "gender",
- a.nation AS "nation",
- a.id_card AS "idCard",
- a.age AS "age",
- a.birthday AS "birthday",
- a.calendar AS "calendar",
- a.email AS "email",
- a.mobile AS "mobile",
- a.marriage AS "marriage",
- a.politics AS "politics",
- a.ex_soldier AS "exSoldier",
- a.address AS "address",
- a.native_place AS "nativePlace.id",
- a.household AS "household",
- a.duty AS "duty",
- a.job_grade AS "jobGrade.id",
- a.status AS "status",
- a.entry_date AS "entryDate",
- a.work_date AS "workDate",
- a.bank_name AS "bankName",
- a.bank_card AS "bankCard",
- a.industry_date AS "industryDate",
- a.ts AS "ts",
- a.picture AS "picture",
- o.top_company AS "office.name",
- a.user_id AS "userId",
- a.branch_office AS "branchOffice.id",
- branch.name AS "branchOffice.name",
- s.name AS "company.name",
- jg.name AS "jobGrade.name",
- jg.pay AS "salary",
- a.achive_id AS "achiveId",
- nativePlace.name AS "nativePlace.name",
- a.try_end_time AS "tryEndTime"
- -- ur.role_id AS "roleId",
- -- r.name AS "roleName"
- </sql>
-
- <sql id="workStaffBasicInfoJoins">
- LEFT JOIN sys_office o ON o.id = a.office_id
- LEFT JOIN sys_office branch ON branch.id = a.branch_office
- LEFT JOIN sys_office s ON s.id = a.company_id
- LEFT JOIN sys_user u ON u.id = a.create_by
- LEFT JOIN sys_area nativePlace ON nativePlace.id = a.native_place
- LEFT JOIN work_job_grade jg ON jg.id = a.job_grade
- -- LEFT JOIN sys_user_role ur ON a.user_id = ur.user_id
- -- LEFT JOIN sys_role r ON ur.role_id = r.id
- </sql>
- <select id="get" resultType="WorkStaffBasicInfo" >
- SELECT
- <include refid="workStaffBasicInfoColumns"/>
- FROM work_staff_basic_info a
- <include refid="workStaffBasicInfoJoins"/>
- WHERE a.id = #{id}
- </select>
- <select id="getByCompany" resultType="java.lang.Integer" >
- select count(*) FROM work_staff_basic_info
- where
- user_id = #{userId}
- AND company_id = #{company.id}
- AND `status` IN ('试用','正式','劳务')
- AND del_flag = '0'
- </select>
- <select id="getByCompanyInfo" resultType="WorkStaffBasicInfo" >
- select
- <include refid="workStaffBasicInfoColumns"/>
- FROM work_staff_basic_info
- <include refid="workStaffBasicInfoJoins"/>
- where
- a.user_id = #{userId}
- AND a.company_id = #{company.id}
- AND a.`status` IN ('试用','正式','劳务')
- AND a.del_flag = '0'
- </select>
- <select id="findListByRoleList" resultType="WorkStaffBasicInfo">
- select
- <include refid="workStaffBasicInfoColumns"/>
- FROM work_staff_basic_info a
- <include refid="workStaffBasicInfoJoins"/>
- LEFT JOIN sys_user_role ur ON ur.user_id = a.user_id
- LEFT JOIN sys_role r ON ur.role_id = r.id
- WHERE
- a.del_flag = #{DEL_FLAG_NORMAL} AND r.id = #{roleId}
- <if test="company != null and company.id != null and company.id != ''">
- AND a.company_id = #{company.id}
- </if>
- <if test="office != null and office.id != null and office.id != ''">
- AND a.office_id = #{office.id}
- </if>
- <if test="no != null and no != ''">
- AND a.no = #{no}
- </if>
- <if test="name != null and name != ''">
- AND a.name LIKE
- <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
- </if>
- <if test="idCard != null and idCard != ''">
- AND a.id_card = #{idCard}
- </if>
- <if test="mobile != null and mobile != ''">
- AND a.mobile = #{mobile}
- </if>
- <if test="jobGrade != null and jobGrade.id !=null and jobGrade.id != ''">
- AND a.job_grade = #{jobGrade.id}
- </if>
- <if test="status != null and status != ''">
- AND a.status = #{status}
- </if>
- <if test="beginEntryDate != null">
- AND a.entry_date >= #{beginEntryDate}
- </if>
- <if test="endEntryDate != null">
- AND a.entry_date <= #{endEntryDate}
- </if>
- <if test="achiveId != null and achiveId !=''">
- AND a.achive_id = #{achiveId}
- </if>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY a.update_date DESC
- </otherwise>
- </choose>
- </select>
- <select id="findList" resultType="WorkStaffBasicInfo" >
- SELECT
- <include refid="workStaffBasicInfoColumns"/>
- FROM work_staff_basic_info a
- <include refid="workStaffBasicInfoJoins"/>
- <where>
- a.del_flag = #{DEL_FLAG_NORMAL}
- <if test="company != null and company.id != null and company.id != ''">
- AND a.company_id = #{company.id}
- </if>
- <if test="office != null and office.id != null and office.id != ''">
- AND a.office_id = #{office.id}
- </if>
- <if test="no != null and no != ''">
- AND a.no = #{no}
- </if>
- <if test="name != null and name != ''">
- AND a.name LIKE
- <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
- </if>
- <if test="idCard != null and idCard != ''">
- AND a.id_card = #{idCard}
- </if>
- <if test="mobile != null and mobile != ''">
- AND a.mobile = #{mobile}
- </if>
- <if test="jobGrade != null and jobGrade.id !=null and jobGrade.id != ''">
- AND a.job_grade = #{jobGrade.id}
- </if>
- <if test="status != null and status != ''">
- AND a.status = #{status}
- </if>
- <if test="beginEntryDate != null">
- AND a.entry_date >= #{beginEntryDate}
- </if>
- <if test="endEntryDate != null">
- AND a.entry_date <= #{endEntryDate}
- </if>
- <if test="achiveId != null and achiveId !=''">
- AND a.achive_id = #{achiveId}
- </if>
- <if test="sqlMap.dsf !=null and sqlMap.dsf !=''">
- AND ((a.user_id = #{currentUser.id} AND a.branch_office = #{currentUser.branchOffice.id})${sqlMap.dsf} )
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY a.entry_date DESC
- </otherwise>
- </choose>
- </select>
-
- <select id="findAllList" resultType="WorkStaffBasicInfo" >
- SELECT
- <include refid="workStaffBasicInfoColumns"/>
- FROM work_staff_basic_info a
- <include refid="workStaffBasicInfoJoins"/>
- <where>
- a.del_flag = #{DEL_FLAG_NORMAL}
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY a.update_date DESC
- </otherwise>
- </choose>
- </select>
-
- <insert id="insert">
- INSERT INTO work_staff_basic_info(
- id,
- create_by,
- create_date,
- update_by,
- update_date,
- remarks,
- del_flag,
- office_id,
- company_id,
- no,
- name,
- gender,
- nation,
- id_card,
- age,
- birthday,
- calendar,
- email,
- mobile,
- marriage,
- politics,
- ex_soldier,
- address,
- native_place,
- household,
- duty,
- job_grade,
- status,
- entry_date,
- work_date,
- bank_name,
- bank_card,
- industry_date,
- ts,
- picture,
- user_id,
- branch_office,
- achive_id,
- try_end_time
- ) VALUES (
- #{id},
- #{createBy.id},
- #{createDate},
- #{updateBy.id},
- #{updateDate},
- #{remarks},
- #{delFlag},
- #{office.id},
- #{company.id},
- #{no},
- #{name},
- #{gender},
- #{nation},
- #{idCard},
- #{age},
- #{birthday},
- #{calendar},
- #{email},
- #{mobile},
- #{marriage},
- #{politics},
- #{exSoldier},
- #{address},
- #{nativePlace.id},
- #{household},
- #{duty},
- #{jobGrade.id},
- #{status},
- #{entryDate},
- #{workDate},
- #{bankName},
- #{bankCard},
- #{industryDate},
- #{ts},
- #{picture},
- #{userId},
- #{branchOffice.id},
- #{achiveId},
- #{tryEndTime}
- )
- </insert>
-
- <update id="update">
- UPDATE work_staff_basic_info SET
- update_by = #{updateBy.id},
- update_date = #{updateDate},
- remarks = #{remarks},
- office_id = #{office.id},
- company_id = #{company.id},
- no = #{no},
- name = #{name},
- gender = #{gender},
- nation = #{nation},
- id_card = #{idCard},
- age = #{age},
- birthday = #{birthday},
- calendar = #{calendar},
- email = #{email},
- mobile = #{mobile},
- marriage = #{marriage},
- politics = #{politics},
- ex_soldier = #{exSoldier},
- address = #{address},
- native_place = #{nativePlace.id},
- household = #{household},
- duty = #{duty},
- job_grade = #{jobGrade.id},
- status = #{status},
- entry_date = #{entryDate},
- work_date = #{workDate},
- bank_name = #{bankName},
- bank_card = #{bankCard},
- industry_date = #{industryDate},
- ts = #{ts},
- picture = #{picture},
- user_id = #{userId},
- branch_office = #{branchOffice.id},
- achive_id = #{achiveId},
- try_end_time = #{tryEndTime}
- WHERE id = #{id}
- </update>
-
-
- <!--物理删除-->
- <update id="delete">
- DELETE FROM work_staff_basic_info
- WHERE id = #{id}
- </update>
-
- <!--逻辑删除-->
- <update id="deleteByLogic">
- UPDATE work_staff_basic_info SET
- del_flag = #{DEL_FLAG_DELETE}
- WHERE id = #{id}
- </update>
-
- <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
- <select id="findUniqueByProperty" resultType="WorkStaffBasicInfo" statementType="STATEMENT">
- select * FROM work_staff_basic_info where ${propertyName} = '${value}'
- </select>
- <!--根据userId获取入职信息-->
- <select id="getWorkStaffBasicInfo" resultType="WorkStaffBasicInfo" parameterType="java.lang.String">
- select a.* ,
- o.name as "office.name",
- jg.name AS "jobGrade.name",
- jg.pay AS "salary"
- FROM work_staff_basic_info a
- LEFT JOIN sys_office o on o.id=a.office_id
- LEFT JOIN work_job_grade jg ON jg.id = a.job_grade
- where a.id=#{id}
- </select>
- <!-- 根据userId,获取workStaffBasicInfo信息-->
- <select id="getWorkStaffBasicInfoByUserId" resultType="WorkStaffBasicInfo" parameterType="java.lang.String">
- select a.* ,
- o.name as "office.name",
- jg.name AS "jobGrade.name",
- jg.id AS "jobGrade.id",
- jg.pay AS "salary"
- FROM work_staff_basic_info a
- LEFT JOIN sys_office o on o.id=a.office_id
- LEFT JOIN work_job_grade jg ON jg.id = a.job_grade
- where a.user_id=#{userId,jdbcType=VARCHAR}
- and a.status = "试用"
- </select>
- <select id="queryMaxNoWithCompany" resultType="String">
- SELECT max(SUBSTR(no,5)+0) FROM work_staff_achives where branch_office=#{branchOffice.id} and del_flag='0'
- </select>
- <select id="findUserList" resultType="WorkStaffBasicInfo" >
- SELECT
- <include refid="workStaffBasicInfoColumns"/>
- FROM work_staff_basic_info a
- <include refid="workStaffBasicInfoJoins"/>
- /*left join work_relationship wrp on a.id = wrp.staff_info_id*/
- <where>
- a.del_flag = #{DEL_FLAG_NORMAL}
- <if test="name != null and name != ''">
- AND a.name LIKE
- <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
- <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
- <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
- </if>
- <if test="office != null and office.id != null and office.id !=''">
- AND a.office_id= #{office.id}
- </if>
- <if test="no != null and no != ''">
- AND a.no = #{no}
- </if>
- <!--<if test="relationshipStatus != null and relationshipStatus != ''">
- AND (wrp.del_flag ='0' or wrp.del_flag is null) AND (wrp.status = #{relationshipStatus} or wrp.status is null)
- </if>-->
- <if test="gender != null and gender != ''">
- AND a.gender = #{gender}
- </if>
- <if test="jobGrade != null and jobGrade != ''">
- AND a.job_grade = #{jobGrade}
- </if>
- <if test="status != null and status != ''">
- AND a.status = #{status}
- </if>
- and a.office_id in (${sqlStr})
- </where>
- </select>
- <select id="findListByIdCard" resultType="WorkStaffBasicInfo">
- SELECT
- a.*
- FROM work_staff_basic_info a
- <where>
- a.del_flag = #{DEL_FLAG_NORMAL}
- <if test="company != null and company.id != null and company.id != ''">
- AND a.company_id = #{company.id}
- </if>
- <if test="idCard != null and idCard != ''">
- AND a.id_card = #{idCard}
- </if>
- </where>
- </select>
- <select id="findListByAchiveId" resultType="WorkStaffBasicInfo">
- SELECT
- a.*
- FROM work_staff_basic_info a
- <where>
- a.del_flag = #{DEL_FLAG_NORMAL}
- <if test="achiveId != null and achiveId != ''">
- AND a.achive_id = #{achiveId}
- </if>
- <if test="branchOffice != null and branchOffice.id != null and branchOffice.id != ''">
- AND a.branch_office = #{branchOffice.id}
- </if>
- </where>
- </select>
- <select id="findListByUserId" resultType="WorkStaffBasicInfo">
- SELECT
- a.*
- FROM work_staff_basic_info a
- <where>
- a.del_flag = #{DEL_FLAG_NORMAL}
- <if test="achiveId != null and achiveId != ''">
- AND a.user_id = #{userId}
- </if>
- <if test="branchOffice != null and branchOffice.id != null and branchOffice.id != ''">
- AND a.branch_office = #{branchOffice.id}
- </if>
- </where>
- </select>
- <update id="updateStatus">
- update work_staff_basic_info set
- status = #{status}
- where user_id = #{id}
- </update>
- </mapper>
|