1:用户管理页面优化 2:角色管理页面优化 3:分配角色权限优化

This commit is contained in:
2025-10-13 16:35:40 +08:00
parent 96da469bef
commit f6b02a9bd9
11 changed files with 405 additions and 355 deletions
@@ -2,6 +2,7 @@ package com.central.device.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.central.common.datascope.annotation.IgnoreTenantScope;
import com.central.common.model.PageResult;
import com.central.common.service.impl.SuperServiceImpl;
import com.central.device.mapper.LineFileMapper;
@@ -36,6 +37,7 @@ public class LineFileServiceImpl extends SuperServiceImpl<LineFileMapper, LineFi
}
@Override
@IgnoreTenantScope
public LineFile findLineFileByWaylineId(String waylineId) {
return baseMapper.selectOne(new QueryWrapper<LineFile>()
.eq("wayline_id",waylineId));
@@ -233,4 +233,38 @@ public class DashboardController {
return Result.failed("获取订单列表失败:" + e.getMessage());
}
}
@Operation(summary = "获取订单时间序列(创建/完成/退款)")
@GetMapping("/statistics/series")
public Result<List<com.central.order.model.vo.TrendDataVO>> getOrderSeries(
@Parameter(description = "租户ID") @RequestParam(required = false) String tenantId,
@Parameter(description = "是否包含子租户") @RequestParam(required = false) Boolean includeChildren,
@Parameter(description = "统计类型(date/week/month/year)") @RequestParam(required = false) String statType,
@Parameter(description = "景区ID") @RequestParam(required = false) Long tourismId,
@Parameter(description = "二维码ID") @RequestParam(required = false) String qrcodeId,
@Parameter(description = "设备编号") @RequestParam(required = false) String deviceSn,
@Parameter(description = "开始时间") @RequestParam(required = false) String startTime,
@Parameter(description = "结束时间") @RequestParam(required = false) String endTime,
@Parameter(description = "是否包含测试二维码") @RequestParam(required = false, defaultValue = "false") Boolean includeTestQrcodes)
{
try {
Map<String, Object> params = new HashMap<>();
params.put("tenantId", tenantId);
params.put("includeChildren", includeChildren);
params.put("tourismId", tourismId);
params.put("qrcodeId", qrcodeId);
params.put("deviceSn", deviceSn);
params.put("startTime", startTime);
params.put("endTime", endTime);
params.put("includeTestQrcodes", includeTestQrcodes);
// 传递 rangeType 以让后端选择 seriesType
params.put("rangeType", statType);
params.put("statType", statType);
List<com.central.order.model.vo.TrendDataVO> series = dashboardService.getOrderTimeSeries(params);
return Result.succeed(series, "获取订单时间序列成功");
} catch (Exception e) {
log.error("获取订单时间序列失败", e);
return Result.failed("获取订单时间序列失败: " + e.getMessage());
}
}
}
@@ -1,6 +1,7 @@
package com.central.order.mapper;
import com.central.order.model.vo.*;
import com.central.order.model.vo.TrendDataVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@@ -215,6 +216,135 @@ public interface DashboardMapper {
})
Long getTodayPaidOrders(@Param("p") Map<String, Object> params);
// ======================= 新增:折线图三类时间序列(创建/完成/退款) =======================
@Select({
"<script>",
"SELECT",
" <choose>",
" <when test='p.seriesType == \"hour\"'> DATE_FORMAT(o.create_time, '%H:00') </when>",
" <when test='p.seriesType == \"month\"'> DATE_FORMAT(o.create_time, '%Y-%m') </when>",
" <otherwise> DATE_FORMAT(o.create_time, '%Y-%m-%d') </otherwise>",
" </choose> AS date,",
" '订单创建' AS type,",
" 'created' AS typeCode,",
" COUNT(1) AS value",
"FROM orders o",
"JOIN qrcodes q ON o.code_id = q.code_id",
"WHERE 1=1",
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
" AND q.is_test = 0",
"</if>",
"<if test='p.tourismId != null'>",
" AND o.tourism_id = #{p.tourismId}",
"</if>",
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
" AND o.code_id = #{p.qrcodeId}",
"</if>",
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
" AND o.device_sn = #{p.deviceSn}",
"</if>",
"<if test='p.startTime != null and p.startTime != \"\"'>",
" AND o.create_time &gt;= #{p.startTime}",
"</if>",
"<if test='p.endTime != null and p.endTime != \"\"'>",
" AND o.create_time &lt;= #{p.endTime}",
"</if>",
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
" AND o.tourism_id IN",
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
"</if>",
"GROUP BY date",
"ORDER BY date ASC",
"</script>"
})
List<TrendDataVO> getOrderSeriesCreated(@Param("p") Map<String, Object> params);
@Select({
"<script>",
"SELECT",
" <choose>",
" <when test='p.seriesType == \"hour\"'> DATE_FORMAT(o.create_time, '%H:00') </when>",
" <when test='p.seriesType == \"month\"'> DATE_FORMAT(o.create_time, '%Y-%m') </when>",
" <otherwise> DATE_FORMAT(o.create_time, '%Y-%m-%d') </otherwise>",
" </choose> AS date,",
" '完成' AS type,",
" 'completed' AS typeCode,",
" COUNT(1) AS value",
"FROM orders o",
"JOIN qrcodes q ON o.code_id = q.code_id",
"WHERE 1=1",
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
" AND q.is_test = 0",
"</if>",
"AND o.order_status = 3",
"<if test='p.tourismId != null'>",
" AND o.tourism_id = #{p.tourismId}",
"</if>",
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
" AND o.code_id = #{p.qrcodeId}",
"</if>",
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
" AND o.device_sn = #{p.deviceSn}",
"</if>",
"<if test='p.startTime != null and p.startTime != \"\"'>",
" AND o.create_time &gt;= #{p.startTime}",
"</if>",
"<if test='p.endTime != null and p.endTime != \"\"'>",
" AND o.create_time &lt;= #{p.endTime}",
"</if>",
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
" AND o.tourism_id IN",
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
"</if>",
"GROUP BY date",
"ORDER BY date ASC",
"</script>"
})
List<TrendDataVO> getOrderSeriesCompleted(@Param("p") Map<String, Object> params);
@Select({
"<script>",
"SELECT",
" <choose>",
" <when test='p.seriesType == \"hour\"'> DATE_FORMAT(o.create_time, '%H:00') </when>",
" <when test='p.seriesType == \"month\"'> DATE_FORMAT(o.create_time, '%Y-%m') </when>",
" <otherwise> DATE_FORMAT(o.create_time, '%Y-%m-%d') </otherwise>",
" </choose> AS date,",
" '退款' AS type,",
" 'refunded' AS typeCode,",
" COUNT(1) AS value",
"FROM orders o",
"JOIN qrcodes q ON o.code_id = q.code_id",
"WHERE 1=1",
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
" AND q.is_test = 0",
"</if>",
"AND o.order_status = 8",
"<if test='p.tourismId != null'>",
" AND o.tourism_id = #{p.tourismId}",
"</if>",
"<if test='p.qrcodeId != null and p.qrcodeId != \"\"'>",
" AND o.code_id = #{p.qrcodeId}",
"</if>",
"<if test='p.deviceSn != null and p.deviceSn != \"\"'>",
" AND o.device_sn = #{p.deviceSn}",
"</if>",
"<if test='p.startTime != null and p.startTime != \"\"'>",
" AND o.create_time &gt;= #{p.startTime}",
"</if>",
"<if test='p.endTime != null and p.endTime != \"\"'>",
" AND o.create_time &lt;= #{p.endTime}",
"</if>",
"<if test='p.tourismIds != null and p.tourismIds.size > 0'>",
" AND o.tourism_id IN",
" <foreach collection='p.tourismIds' item='tid' open='(' separator=',' close=')'>#{tid}</foreach>",
"</if>",
"GROUP BY date",
"ORDER BY date ASC",
"</script>"
})
List<TrendDataVO> getOrderSeriesRefunded(@Param("p") Map<String, Object> params);
// 对账相关统计
@Select({
"<script>",
@@ -17,4 +17,12 @@ public interface IDashboardService {
* 获取首页订单列表
*/
PageResult<Order> getDashboardOrders(Map<String, Object> params);
/**
* 订单时间序列(创建/完成/退款),按指定粒度聚合:
* - date(天):分小时
* - week/月:按天
* - year:按月
*/
List<com.central.order.model.vo.TrendDataVO> getOrderTimeSeries(Map<String, Object> params);
}
@@ -132,6 +132,56 @@ public class DashboardServiceImpl implements IDashboardService {
return result;
}
@Override
public List<TrendDataVO> getOrderTimeSeries(Map<String, Object> params) {
try {
// 解析租户并派生景区集合
String tenantId = params != null && params.get("tenantId") != null ? String.valueOf(params.get("tenantId")) : null;
List<String> tenantIds = tenantResolverService.resolveTenantIds(tenantId, true);
if (tenantIds == null || tenantIds.isEmpty()) {
log.warn("无法获取租户列表,tenantId: {}", tenantId);
return java.util.Collections.emptyList();
}
List<Long> tourismIds = resolveTourismIdsByTenants(tenantIds);
if (tourismIds == null || tourismIds.isEmpty()) {
tourismIds = new java.util.ArrayList<>();
tourismIds.add(-1L);
}
params.put("tourismIds", tourismIds);
// 维度映射:date->hour,week/month->day,year->month
String rt = params != null && params.get("rangeType") != null ? String.valueOf(params.get("rangeType")) : null;
String statType = params != null && params.get("statType") != null ? String.valueOf(params.get("statType")) : null;
String seriesType;
String t = (rt != null && !rt.isEmpty()) ? rt : (statType != null ? statType : "day");
if ("date".equalsIgnoreCase(t)) {
seriesType = "hour";
} else if ("year".equalsIgnoreCase(t)) {
seriesType = "month";
} else {
seriesType = "day";
}
params.put("seriesType", seriesType);
// 查询三个序列
List<TrendDataVO> created = dashboardMapper.getOrderSeriesCreated(params);
List<TrendDataVO> completed = dashboardMapper.getOrderSeriesCompleted(params);
List<TrendDataVO> refunded = dashboardMapper.getOrderSeriesRefunded(params);
// 合并
List<TrendDataVO> all = new java.util.ArrayList<>();
if (created != null) all.addAll(created);
if (completed != null) all.addAll(completed);
if (refunded != null) all.addAll(refunded);
// 保序(按日期字符串升序)
all.sort((a, b) -> String.valueOf(a.getDate()).compareTo(String.valueOf(b.getDate())));
return all;
} catch (Exception e) {
log.error("获取订单时间序列失败", e);
return java.util.Collections.emptyList();
}
}
/**
* 获取订单统计
*/
@@ -311,4 +361,3 @@ public class DashboardServiceImpl implements IDashboardService {
return tourismMapper.findTourismIdsByTenantId(tenantId) ;
}
}