| | |
| | | <if test="status != null and status != ''"> |
| | | AND status = #{status} |
| | | </if> |
| | | <if test="serviceOrderClass != null and serviceOrderClass != ''"> |
| | | AND service_order_class = #{serviceOrderClass} |
| | | </if> |
| | | <if test="dispatchOrderClass != null and dispatchOrderClass != ''"> |
| | | AND dispatch_order_class = #{dispatchOrderClass} |
| | | </if> |
| | | <!-- 数据范围过滤 --> |
| | | ${params.dataScope} |
| | | order by d.parent_id, d.order_num |
| | |
| | | limit 1 |
| | | </select> |
| | | |
| | | <!-- 获取指定部门ID的分公司ID(parent_id=100的部门) --> |
| | | <select id="selectBranchCompanyIdByDeptId" parameterType="Long" resultType="Long"> |
| | | select case |
| | | -- 如果传入的就是分公司(parent_id=100),直接返回 |
| | | when exists(select 1 from sys_dept where dept_id = #{deptId} and parent_id = 100 and del_flag = '0') |
| | | then #{deptId} |
| | | else ( |
| | | -- 否则从 ancestors 中查找分公司ID |
| | | select d.dept_id |
| | | from sys_dept d |
| | | where d.parent_id = 100 |
| | | and d.del_flag = '0' |
| | | and FIND_IN_SET(d.dept_id, ( |
| | | select ancestors from sys_dept where dept_id = #{deptId} and del_flag = '0' |
| | | )) |
| | | limit 1 |
| | | ) |
| | | end |
| | | </select> |
| | | |
| | | </mapper> |