diff --git a/backend/src/main/resources/mapper/llm/LlmMcpMapper.xml b/backend/src/main/resources/mapper/llm/LlmMcpMapper.xml
index ef96f587..8893e29f 100644
--- a/backend/src/main/resources/mapper/llm/LlmMcpMapper.xml
+++ b/backend/src/main/resources/mapper/llm/LlmMcpMapper.xml
@@ -911,10 +911,10 @@
cross join users_scope u
)
select
- case
- when #{groupBy} = 'owner' then e.user_name
- else to_char(e.report_date, 'YYYY-MM-DD')
- end as "groupName",
+
+ e.user_name
+ to_char(e.report_date, 'YYYY-MM-DD')
+ as "groupName",
count(1)::bigint as "expectedCount",
count(r.id)::bigint as "submittedCount",
(count(1) - count(r.id))::bigint as "missingCount",
@@ -924,7 +924,11 @@
on r.user_id = e.user_id
and r.report_date = e.report_date
and coalesce(r.status, 'submitted') in ('submitted', 'read', 'reviewed')
- group by case when #{groupBy} = 'owner' then e.user_name else to_char(e.report_date, 'YYYY-MM-DD') end
+ group by
+
+ e.user_name
+ to_char(e.report_date, 'YYYY-MM-DD')
+
order by "groupName" asc
limit #{limit}
offset #{offset}
@@ -932,11 +936,11 @@
select
- case
- when #{groupBy} = 'owner' then coalesce(nullif(btrim(u.display_name), ''), nullif(btrim(u.username), ''), c.user_name, '')
- when #{groupBy} = 'status' then coalesce(c.status, 'normal')
- else to_char(c.checkin_date, 'YYYY-MM-DD')
- end as "groupName",
+
+ coalesce(nullif(btrim(u.display_name), ''), nullif(btrim(u.username), ''), c.user_name, '')
+ coalesce(c.status, 'normal')
+ to_char(c.checkin_date, 'YYYY-MM-DD')
+ as "groupName",
count(1)::bigint as "checkinCount",
count(distinct c.user_id)::bigint as "userCount",
count(distinct c.biz_id) filter (where c.biz_id is not null)::bigint as "bizCount"
@@ -945,11 +949,12 @@
where c.checkin_date between #{startDate} and #{endDate}
and c.user_id = #{ownerUserId}
and exists (select 1 from sys_tenant_user tu where tu.user_id = c.user_id and tu.tenant_id = #{tenantId} and coalesce(tu.is_deleted, 0) = 0)
- group by case
- when #{groupBy} = 'owner' then coalesce(nullif(btrim(u.display_name), ''), nullif(btrim(u.username), ''), c.user_name, '')
- when #{groupBy} = 'status' then coalesce(c.status, 'normal')
- else to_char(c.checkin_date, 'YYYY-MM-DD')
- end
+ group by
+
+ coalesce(nullif(btrim(u.display_name), ''), nullif(btrim(u.username), ''), c.user_name, '')
+ coalesce(c.status, 'normal')
+ to_char(c.checkin_date, 'YYYY-MM-DD')
+
order by "checkinCount" desc, "groupName" asc
limit #{limit}
offset #{offset}
@@ -1003,21 +1008,22 @@
select
- case
- when #{groupBy} = 'status' then coalesce(c.status, 'unknown')
- when #{groupBy} = 'source' then coalesce(c.source, 'unknown')
- else coalesce(c.industry, 'unknown')
- end as "groupName",
+
+ coalesce(c.status, 'unknown')
+ coalesce(c.source, 'unknown')
+ coalesce(c.industry, 'unknown')
+ as "groupName",
count(1)::bigint as "customerCount"
from crm_customer c
where c.created_at::date between #{startDate} and #{endDate}
and c.owner_user_id = #{ownerUserId}
and exists (select 1 from sys_tenant_user tu where tu.user_id = c.owner_user_id and tu.tenant_id = #{tenantId} and coalesce(tu.is_deleted, 0) = 0)
- group by case
- when #{groupBy} = 'status' then coalesce(c.status, 'unknown')
- when #{groupBy} = 'source' then coalesce(c.source, 'unknown')
- else coalesce(c.industry, 'unknown')
- end
+ group by
+
+ coalesce(c.status, 'unknown')
+ coalesce(c.source, 'unknown')
+ coalesce(c.industry, 'unknown')
+
order by "customerCount" desc, "groupName" asc
limit #{limit}
offset #{offset}
@@ -1025,7 +1031,10 @@
select
- case when #{groupBy} = 'status' then t.status else t.priority end as "groupName",
+
+ t.status
+ t.priority
+ as "groupName",
count(1)::bigint as "todoCount",
count(case when t.status = 'todo' then 1 end)::bigint as "pendingCount",
count(case when t.status = 'done' then 1 end)::bigint as "doneCount"
@@ -1033,7 +1042,11 @@
where t.created_at::date between #{startDate} and #{endDate}
and t.user_id = #{ownerUserId}
and exists (select 1 from sys_tenant_user tu where tu.user_id = t.user_id and tu.tenant_id = #{tenantId} and coalesce(tu.is_deleted, 0) = 0)
- group by case when #{groupBy} = 'status' then t.status else t.priority end
+ group by
+
+ t.status
+ t.priority
+
order by "todoCount" desc, "groupName" asc
limit #{limit}
offset #{offset}
@@ -1151,7 +1164,7 @@
u.user_id as "userId",
u.username as "username",
coalesce(nullif(btrim(u.display_name), ''), nullif(btrim(u.username), ''), '') as "displayName",
- coalesce(u.mobile, '') as "mobile",
+ coalesce(u.phone, '') as "mobile",
coalesce(u.email, '') as "email",
coalesce(u.status, 1) as "status",
org_info.org_ids as "orgIds",
@@ -1186,7 +1199,7 @@
coalesce(u.username, '') ilike concat('%', #{keyword}, '%')
or coalesce(u.display_name, '') ilike concat('%', #{keyword}, '%')
or coalesce(u.username, '') ilike concat('%', #{keyword}, '%')
- or coalesce(u.mobile, '') ilike concat('%', #{keyword}, '%')
+ or coalesce(u.phone, '') ilike concat('%', #{keyword}, '%')
or coalesce(u.email, '') ilike concat('%', #{keyword}, '%')
or coalesce(org_info.org_names, '') ilike concat('%', #{keyword}, '%')
or coalesce(role_info.role_names, '') ilike concat('%', #{keyword}, '%')