|
|
@@ -507,7 +507,7 @@
|
|
|
|
|
|
|
|
|
<select id="deptCostRank" resultType="java.util.Map">
|
|
|
- select tb5.sub_dept_id as dept_id, concat(tb5.dept_name, '-', tb5.sub_dept_name) as dept_name,
|
|
|
+ select tb5.sub_dept_name as dept_name,
|
|
|
rank() over (order by sum(cost_amount) desc) as rk,
|
|
|
<include refid="costAmount"/>,
|
|
|
sum(dj_cost_amount) as dj_cost_amount,
|
|
|
@@ -531,14 +531,20 @@
|
|
|
left join (select user_id, nick_name, phonenumber, dept_id from tidb.deepthink.sys_user) tb4
|
|
|
on tb1.user_id=tb4.user_id
|
|
|
left join (
|
|
|
- select dp.dept_id, dp.dept_name, ifnull(subdp.dept_id, dp.dept_id) as sub_dept_id, ifnull(subdp.dept_name, dp.dept_name) as sub_dept_name from (select * from tidb.deepthink.sys_dept where parent_id in (300)) dp
|
|
|
- right join tidb.deepthink.sys_dept subdp on dp.dept_id=subdp.parent_id
|
|
|
- where dp.dept_id is not null
|
|
|
- union all
|
|
|
- select dept_id, dept_name, dept_id as sub_dept_id, dept_name as sub_dept_name from tidb.deepthink.sys_dept where parent_id in (300)
|
|
|
+ select sub_dept_id,
|
|
|
+ case when dept_id in (180204,180205) then dept_name else concat(dept_name, '-', sub_dept_name) end as sub_dept_name
|
|
|
+ from (
|
|
|
+ select dp.dept_id, dp.dept_name, ifnull(subdp.dept_id, dp.dept_id) as sub_dept_id, ifnull(subdp.dept_name, dp.dept_name) as sub_dept_name
|
|
|
+ from (select * from tidb.deepthink.sys_dept where parent_id in (300)) dp
|
|
|
+ right join tidb.deepthink.sys_dept subdp on dp.dept_id=subdp.parent_id and subdp.del_flag=0
|
|
|
+ where dp.dept_id is not null
|
|
|
+ union all
|
|
|
+ select dept_id, dept_name, dept_id as sub_dept_id, dept_name as sub_dept_name from tidb.deepthink.sys_dept where parent_id in (300) and del_flag=0
|
|
|
+ )
|
|
|
+ st
|
|
|
) tb5
|
|
|
on tb4.dept_id = tb5.sub_dept_id
|
|
|
- group by tb5.sub_dept_id, tb5.dept_name, tb5.sub_dept_name
|
|
|
+ group by tb5.sub_dept_name
|
|
|
having sum(cost_amount)>1
|
|
|
order by rk asc
|
|
|
limit 10
|