更新
This commit is contained in:
parent
65ad926fb9
commit
55cce053ff
@ -131,13 +131,17 @@
|
||||
COALESCE(proj_stats.waijianCount, 0) AS waijianCount, -- 包含“外检”的订单数量
|
||||
COALESCE(proj_stats.anjianCount, 0) AS anjianCount, -- 包含“安检”的订单数量
|
||||
COALESCE(proj_stats.otherCount, 0) AS otherCount -- 其他订单数量(排除“外检”和“安检”)
|
||||
FROM
|
||||
system_users su
|
||||
LEFT JOIN system_user_role sr ON su.id = sr.user_id
|
||||
LEFT JOIN system_role sr2 ON sr.role_id = sr2.id
|
||||
LEFT JOIN inspection_work_node iwn ON su.id = iwn.deal_user_id
|
||||
LEFT JOIN inspection_info info ON iwn.inspection_info_id = info.id
|
||||
LEFT JOIN order_info orders ON info.inspection_order_id = orders.id
|
||||
FROM system_users su
|
||||
LEFT JOIN system_user_role sr
|
||||
ON su.id = sr.user_id
|
||||
LEFT JOIN system_role sr2
|
||||
ON sr.role_id = sr2.id
|
||||
LEFT JOIN inspection_work_node iwn
|
||||
ON su.id = iwn.deal_user_id
|
||||
LEFT JOIN inspection_info info
|
||||
ON iwn.inspection_info_id = info.id
|
||||
LEFT JOIN order_info orders
|
||||
ON info.inspection_order_id = orders.id
|
||||
LEFT JOIN inspection_project_royalty royalty
|
||||
ON iwn.project_id = royalty.project_id
|
||||
AND orders.goods_id = royalty.goods_id
|
||||
@ -146,38 +150,36 @@
|
||||
iwn.deal_user_id,
|
||||
SUM(CASE WHEN proj.project_name LIKE '%外检%' THEN 1 ELSE 0 END) AS waijianCount,
|
||||
SUM(CASE WHEN proj.project_name LIKE '%安检%' THEN 1 ELSE 0 END) AS anjianCount,
|
||||
SUM(
|
||||
CASE
|
||||
SUM(CASE
|
||||
WHEN proj.project_name NOT LIKE '%外检%'
|
||||
AND proj.project_name NOT LIKE '%安检%'
|
||||
THEN 1 ELSE 0
|
||||
END
|
||||
) AS otherCount -- 统计不包含“外检”和“安检”的订单
|
||||
FROM
|
||||
inspection_work_node iwn
|
||||
LEFT JOIN inspection_project proj ON iwn.project_id = proj.id
|
||||
LEFT JOIN inspection_info info ON iwn.inspection_info_id = info.id
|
||||
END) AS otherCount -- 统计不包含“外检”和“安检”的订单
|
||||
FROM inspection_work_node iwn
|
||||
LEFT JOIN inspection_project proj
|
||||
ON iwn.project_id = proj.id
|
||||
LEFT JOIN inspection_info info
|
||||
ON iwn.inspection_info_id = info.id
|
||||
WHERE
|
||||
iwn.deleted = 0 -- 排除已删除的数据
|
||||
AND iwn.deal_user_id IS NOT NULL -- 排除 deal_user_id 为 NULL 的记录
|
||||
AND iwn.deal_user_id IS NOT NULL -- 排除 deal_user_id 为空的记录
|
||||
AND iwn.status = 2
|
||||
AND info.status = 1
|
||||
GROUP BY
|
||||
iwn.deal_user_id
|
||||
) proj_stats ON su.id = proj_stats.deal_user_id -- 获取“外检”和“安检”的统计
|
||||
GROUP BY iwn.deal_user_id
|
||||
) proj_stats
|
||||
ON su.id = proj_stats.deal_user_id -- 获取“外检”和“安检”的统计
|
||||
WHERE
|
||||
(sr2.service_package_id = 'jiance') -- 角色条件
|
||||
AND (sr2.code != 'jcyh') -- 排除特定角色
|
||||
AND (iwn.deleted = 0 OR iwn.deleted IS NULL) -- 排除已删除的数据
|
||||
AND (iwn.deal_user_id IS NOT NULL) -- 排除 deal_user_id 为 NULL 的记录
|
||||
AND (iwn.status = 2 OR iwn.status IS NULL)
|
||||
sr2.service_package_id = 'jiance' -- 角色条件
|
||||
AND sr2.code != 'jcyh' -- 排除特定角色
|
||||
AND (iwn.deleted = 0 OR iwn.deleted IS NULL) -- 允许 iwn 为空
|
||||
AND (iwn.deal_user_id IS NOT NULL OR iwn.deal_user_id IS NULL) -- 允许没有工单的用户
|
||||
AND (iwn.status = 2 OR iwn.status IS NULL) -- 允许 iwn 为空
|
||||
AND (info.status = 1 OR info.status IS NULL)
|
||||
<if test="id != null and id != ''">
|
||||
AND iwn.project_id = #{id} -- 只在这里加上id过滤
|
||||
</if>
|
||||
GROUP BY
|
||||
su.id -- 根据处理人员ID进行分组
|
||||
ORDER BY
|
||||
orderCount DESC; -- 根据接单数量进行降序排序
|
||||
GROUP BY su.id -- 根据处理人员ID进行分组
|
||||
ORDER BY orderCount DESC; -- 根据接单数量进行降序排序
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user