后台获取员工接口优化

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 ls.id staffId,if(lso.employee_no='', lso.staff_no,lso.employee_no) staff_no,ls.name,lso.position,
case lso.staff_status when 0 then '在职' else '离职' end staff_status,
if(ls.id in (select staff_id from lz_departments_staff_relate where is_delete=0 and is_leader=1
<if test="departmentId != null and departmentId != ''">
and department_id=#{departmentId}
</if>
),1,0) department_leader
from lz_staff ls,lz_staff_occupation lso
where lso.staff_id=ls.id and ls.is_delete=0 and lso.is_delete=0
and lso.staff_status=#{staffStatus}
<if test="name != null and name != ''">
and ls.name like concat('%',#{name},'%')
</if>
order by department_leader desc
select staffinfo.id as staff_id,
if(occ.employee_no='', occ.staff_no,occ.employee_no) staff_no,
staffinfo.name as name,
occ.position as position,
case occ.staff_status when 0 then '在职' else '离职' end staff_status,
staffinfo.is_leader as department_leader
from
(
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 != ''">
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}
</select>
<select id="getStaffInfoCount" resultType="java.lang.Integer">
select count(ls.id) count
from lz_staff ls,lz_staff_occupation lso
where lso.staff_id=ls.id and ls.is_delete=0
and lso.staff_status=#{staffStatus}
select count(staffinfo.id)
from
(
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 != ''">
and ls.name like concat('%',#{name},'%')
and staff.name like concat('%',#{name},'%')
</if>
and (ls.id in (
select dsr.staff_id from lz_departments_staff_relate dsr where dsr.is_delete=0
<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>
))
) 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
</select>
<select id="getBaseInfo" resultType="com.lz.modules.app.dto.StaffBaseInfoDto">