后台获取员工接口优化

This commit is contained in:
wulin 2020-11-26 18:04:23 +08:00
parent 5edf34ff25
commit 90fd42b7f6

View File

@ -248,43 +248,43 @@
<select id="getStaffInfos" resultType="com.lz.modules.app.dto.StaffDto"> <select id="getStaffInfos" resultType="com.lz.modules.app.dto.StaffDto">
select ls.id staffId,if(lso.employee_no='', lso.staff_no,lso.employee_no) staff_no,ls.name,lso.position, select staffinfo.id as staff_id,
case lso.staff_status when 0 then '在职' else '离职' end staff_status, if(occ.employee_no='', occ.staff_no,occ.employee_no) staff_no,
if(ls.id in (select staff_id from lz_departments_staff_relate where is_delete=0 and is_leader=1 staffinfo.name as name,
<if test="departmentId != null and departmentId != ''"> occ.position as position,
and department_id=#{departmentId} case occ.staff_status when 0 then '在职' else '离职' end staff_status,
</if> staffinfo.is_leader as department_leader
),1,0) department_leader from
from lz_staff ls,lz_staff_occupation lso (
where lso.staff_id=ls.id and ls.is_delete=0 and lso.is_delete=0 select staff.id as id, staff.name as name, relate.is_leader as is_leader
and lso.staff_status=#{staffStatus} from lz_staff staff join lz_departments_staff_relate relate on staff.id=relate.staff_id
<if test="name != null and name != ''"> where staff.is_delete=0 and relate.is_delete=0
and ls.name like concat('%',#{name},'%') <if test="departmentId != null and departmentId != ''">
</if> and relate.department_id=#{departmentId}
order by department_leader desc </if>
<if test="name != null and name != ''">
and staff.name like concat('%',#{name},'%')
</if>
) as staffinfo join lz_staff_occupation as occ on occ.staff_id = staffinfo.id
where occ.is_delete=0 and occ.staff_status=#{staffStatus} order by department_leader desc
limit #{startIndex}, #{pageLimit} limit #{startIndex}, #{pageLimit}
</select> </select>
<select id="getStaffInfoCount" resultType="java.lang.Integer"> <select id="getStaffInfoCount" resultType="java.lang.Integer">
select count(ls.id) count select count(staffinfo.id)
from lz_staff ls,lz_staff_occupation lso from
where lso.staff_id=ls.id and ls.is_delete=0 (
and lso.staff_status=#{staffStatus} select staff.id as id, staff.name as name, relate.is_leader as is_leader
from lz_staff staff join lz_departments_staff_relate relate on staff.id=relate.staff_id
where staff.is_delete=0 and relate.is_delete=0
<if test="departmentId != null and departmentId != ''">
and relate.department_id=#{departmentId}
</if>
<if test="name != null and name != ''"> <if test="name != null and name != ''">
and ls.name like concat('%',#{name},'%') and staff.name like concat('%',#{name},'%')
</if> </if>
and (ls.id in ( ) as staffinfo join lz_staff_occupation as occ on occ.staff_id = staffinfo.id
select dsr.staff_id from lz_departments_staff_relate dsr where dsr.is_delete=0 where occ.is_delete=0 and occ.staff_status=#{staffStatus} order by department_leader desc
<if test="departmentId != null and departmentId != ''">
and dsr.department_id=#{departmentId}
</if>
)
or ls.employee_id in (
select sr.leader_employee_id from lz_departments sr where sr.is_delete=0
<if test="departmentId != null and departmentId != ''">
and sr.department_id=#{departmentId}
</if>
))
</select> </select>
<select id="getBaseInfo" resultType="com.lz.modules.app.dto.StaffBaseInfoDto"> <select id="getBaseInfo" resultType="com.lz.modules.app.dto.StaffBaseInfoDto">