首页统计金额数据权限问题
parent
3db2358f07
commit
25787cbabe
|
|
@ -17,7 +17,13 @@ public interface DashboardMapper {
|
|||
UserWelcomeDTO selectUserWelcome(@Param("userId") Long userId);
|
||||
|
||||
@DataScope(tableAlias = "o", ownerColumn = "owner_user_id")
|
||||
List<DashboardStatDTO> selectOpportunityStats(@Param("userId") Long userId);
|
||||
DashboardStatDTO selectMonthlyOpportunityStat(@Param("userId") Long userId);
|
||||
|
||||
@DataScope(tableAlias = "o", ownerColumn = "owner_user_id")
|
||||
DashboardStatDTO selectPushedOmsProjectsStat(@Param("userId") Long userId);
|
||||
|
||||
@DataScope(tableAlias = "o", ownerColumn = "owner_user_id")
|
||||
DashboardStatDTO selectMonthlyWonOpportunityStat(@Param("userId") Long userId);
|
||||
|
||||
@DataScope(tableAlias = "c", ownerColumn = "owner_user_id")
|
||||
DashboardStatDTO selectMonthlyChannelStat(@Param("userId") Long userId);
|
||||
|
|
|
|||
|
|
@ -49,11 +49,12 @@ public class DashboardServiceImpl implements DashboardService {
|
|||
throw new BusinessException("未找到当前用户对应数据");
|
||||
}
|
||||
|
||||
List<DashboardStatDTO> stats = new ArrayList<>(dashboardMapper.selectOpportunityStats(userId));
|
||||
List<DashboardStatDTO> stats = new ArrayList<>();
|
||||
addStatIfPresent(stats, dashboardMapper.selectMonthlyOpportunityStat(userId));
|
||||
addStatIfPresent(stats, dashboardMapper.selectPushedOmsProjectsStat(userId));
|
||||
addStatIfPresent(stats, dashboardMapper.selectMonthlyWonOpportunityStat(userId));
|
||||
DashboardStatDTO monthlyChannelStat = dashboardMapper.selectMonthlyChannelStat(userId);
|
||||
if (monthlyChannelStat != null) {
|
||||
stats.add(monthlyChannelStat);
|
||||
}
|
||||
addStatIfPresent(stats, monthlyChannelStat);
|
||||
Set<String> permissionCodes = loadPermissionCodes(userId);
|
||||
boolean todoCardVisible = permissionCodes.contains(DASHBOARD_TODO_CARD_VIEW_PERMISSION);
|
||||
boolean activityCardVisible = permissionCodes.contains(DASHBOARD_ACTIVITY_CARD_VIEW_PERMISSION);
|
||||
|
|
@ -124,6 +125,12 @@ public class DashboardServiceImpl implements DashboardService {
|
|||
return activities;
|
||||
}
|
||||
|
||||
private void addStatIfPresent(List<DashboardStatDTO> stats, DashboardStatDTO stat) {
|
||||
if (stat != null) {
|
||||
stats.add(stat);
|
||||
}
|
||||
}
|
||||
|
||||
private void enrichActivityTimeText(List<DashboardActivityDTO> activities) {
|
||||
if (activities == null || activities.isEmpty()) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -43,23 +43,23 @@
|
|||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectOpportunityStats" resultType="com.unis.crm.dto.dashboard.DashboardStatDTO">
|
||||
<select id="selectMonthlyOpportunityStat" resultType="com.unis.crm.dto.dashboard.DashboardStatDTO">
|
||||
select '本月新增商机' as name,
|
||||
coalesce(round(sum(o.amount) / 10000.0, 2), 0)::numeric as value,
|
||||
'monthlyOpportunities' as metricKey
|
||||
from crm_opportunity o
|
||||
where date_trunc('month', o.created_at) = date_trunc('month', now())
|
||||
</select>
|
||||
|
||||
union all
|
||||
|
||||
<select id="selectPushedOmsProjectsStat" resultType="com.unis.crm.dto.dashboard.DashboardStatDTO">
|
||||
select '已推送OMS项目' as name,
|
||||
coalesce(round(sum(o.amount) / 10000.0, 2), 0)::numeric as value,
|
||||
'pushedOmsProjects' as metricKey
|
||||
from crm_opportunity o
|
||||
where coalesce(o.pushed_to_oms, false) = true
|
||||
</select>
|
||||
|
||||
union all
|
||||
|
||||
<select id="selectMonthlyWonOpportunityStat" resultType="com.unis.crm.dto.dashboard.DashboardStatDTO">
|
||||
select '本月已签单商机金额' as name,
|
||||
coalesce(round(sum(o.amount) / 10000.0, 2), 0)::numeric as value,
|
||||
'monthlyWonOpportunities' as metricKey
|
||||
|
|
|
|||
Loading…
Reference in New Issue