From 981699d9d0890dfd86786220882864e37575b637 Mon Sep 17 00:00:00 2001 From: Iamasoldier <1272745473@qq.com> Date: Mon, 14 Apr 2025 14:27:19 +0800 Subject: [PATCH] Please enter the commit message for your changes. Lines starting with '#' will be ignored, and an empty message aborts the commit. On branch develop Your branch is up to date with 'goflyapp/develop'. Changes to be committed: modified: zlt-business/file-center/src/main/resources/bootstrap.yml new file: zlt-business/order-center/src/main/java/com/central/order/controller/DashboardController.java new file: zlt-business/order-center/src/main/java/com/central/order/mapper/DashboardMapper.java new file: zlt-business/order-center/src/main/java/com/central/order/model/vo/ChartStatistics.java new file: zlt-business/order-center/src/main/java/com/central/order/model/vo/DashboardStatisticsVO.java new file: zlt-business/order-center/src/main/java/com/central/order/model/vo/DeviceStatistics.java new file: zlt-business/order-center/src/main/java/com/central/order/model/vo/DistributionDataVO.java new file: zlt-business/order-center/src/main/java/com/central/order/model/vo/IncomeDataVO.java new file: zlt-business/order-center/src/main/java/com/central/order/model/vo/IncomeStatistics.java new file: zlt-business/order-center/src/main/java/com/central/order/model/vo/OrderStatistics.java new file: zlt-business/order-center/src/main/java/com/central/order/model/vo/TourismRankingVO.java new file: zlt-business/order-center/src/main/java/com/central/order/model/vo/TrendDataVO.java new file: zlt-business/order-center/src/main/java/com/central/order/model/vo/WaylineStatistics.java new file: zlt-business/order-center/src/main/java/com/central/order/service/IDashboardService.java new file: zlt-business/order-center/src/main/java/com/central/order/service/impl/DashboardServiceImpl.java modified: zlt-business/user-center/src/main/resources/bootstrap.yml modified: zlt-uaa/src/main/resources/bootstrap.yml modified: zlt-web/react-web/src/main/frontend/config/proxy.ts modified: zlt-web/react-web/src/main/frontend/nginx.conf modified: zlt-web/react-web/src/main/frontend/src/pages/Welcome.less modified: zlt-web/react-web/src/main/frontend/src/pages/Welcome.tsx modified: zlt-web/react-web/src/main/frontend/src/pages/orders/HomeCarousel/index.less modified: zlt-web/react-web/src/main/frontend/src/pages/orders/HomeCarousel/index.tsx modified: zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/components/UpdateForm.tsx modified: zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/index.less modified: zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/index.tsx modified: zlt-web/react-web/src/main/frontend/src/services/orders/api.ts modified: zlt-web/react-web/src/main/frontend/src/services/orders/typings.d.ts modified: zlt-web/react-web/src/main/frontend/src/services/welcome/api.ts modified: zlt-web/react-web/src/main/frontend/src/services/welcome/typings.d.ts --- .../src/main/resources/bootstrap.yml | 8 +- .../order/controller/DashboardController.java | 34 ++ .../central/order/mapper/DashboardMapper.java | 112 +++++ .../order/model/vo/ChartStatistics.java | 19 + .../order/model/vo/DashboardStatisticsVO.java | 28 ++ .../order/model/vo/DeviceStatistics.java | 19 + .../order/model/vo/DistributionDataVO.java | 16 + .../central/order/model/vo/IncomeDataVO.java | 16 + .../order/model/vo/IncomeStatistics.java | 19 + .../order/model/vo/OrderStatistics.java | 22 + .../order/model/vo/TourismRankingVO.java | 19 + .../central/order/model/vo/TrendDataVO.java | 19 + .../order/model/vo/WaylineStatistics.java | 19 + .../order/service/IDashboardService.java | 10 + .../service/impl/DashboardServiceImpl.java | 173 ++++++++ .../src/main/resources/bootstrap.yml | 8 +- zlt-uaa/src/main/resources/bootstrap.yml | 8 +- .../src/main/frontend/config/proxy.ts | 32 +- .../react-web/src/main/frontend/nginx.conf | 12 +- .../src/main/frontend/src/pages/Welcome.less | 174 +++++++- .../src/main/frontend/src/pages/Welcome.tsx | 412 +++++++++--------- .../src/pages/orders/HomeCarousel/index.less | 23 + .../src/pages/orders/HomeCarousel/index.tsx | 16 +- .../orders/Qrcode/components/UpdateForm.tsx | 7 + .../src/pages/orders/Qrcode/index.less | 21 + .../src/pages/orders/Qrcode/index.tsx | 34 +- .../main/frontend/src/services/orders/api.ts | 7 + .../frontend/src/services/orders/typings.d.ts | 45 ++ .../main/frontend/src/services/welcome/api.ts | 7 +- .../src/services/welcome/typings.d.ts | 50 +++ 30 files changed, 1148 insertions(+), 241 deletions(-) create mode 100644 zlt-business/order-center/src/main/java/com/central/order/controller/DashboardController.java create mode 100644 zlt-business/order-center/src/main/java/com/central/order/mapper/DashboardMapper.java create mode 100644 zlt-business/order-center/src/main/java/com/central/order/model/vo/ChartStatistics.java create mode 100644 zlt-business/order-center/src/main/java/com/central/order/model/vo/DashboardStatisticsVO.java create mode 100644 zlt-business/order-center/src/main/java/com/central/order/model/vo/DeviceStatistics.java create mode 100644 zlt-business/order-center/src/main/java/com/central/order/model/vo/DistributionDataVO.java create mode 100644 zlt-business/order-center/src/main/java/com/central/order/model/vo/IncomeDataVO.java create mode 100644 zlt-business/order-center/src/main/java/com/central/order/model/vo/IncomeStatistics.java create mode 100644 zlt-business/order-center/src/main/java/com/central/order/model/vo/OrderStatistics.java create mode 100644 zlt-business/order-center/src/main/java/com/central/order/model/vo/TourismRankingVO.java create mode 100644 zlt-business/order-center/src/main/java/com/central/order/model/vo/TrendDataVO.java create mode 100644 zlt-business/order-center/src/main/java/com/central/order/model/vo/WaylineStatistics.java create mode 100644 zlt-business/order-center/src/main/java/com/central/order/service/IDashboardService.java create mode 100644 zlt-business/order-center/src/main/java/com/central/order/service/impl/DashboardServiceImpl.java diff --git a/zlt-business/file-center/src/main/resources/bootstrap.yml b/zlt-business/file-center/src/main/resources/bootstrap.yml index e15c1688..005bb0d4 100644 --- a/zlt-business/file-center/src/main/resources/bootstrap.yml +++ b/zlt-business/file-center/src/main/resources/bootstrap.yml @@ -4,10 +4,10 @@ server: spring: application: name: file-center -# cloud: -# nacos: -# discovery: -# ip: 119.45.169.13 + cloud: + nacos: + discovery: + ip: 119.45.169.13 servlet: multipart: max-file-size: 20MB diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/DashboardController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/DashboardController.java new file mode 100644 index 00000000..600e4a66 --- /dev/null +++ b/zlt-business/order-center/src/main/java/com/central/order/controller/DashboardController.java @@ -0,0 +1,34 @@ +package com.central.order.controller; + +import com.central.common.model.Result; +import com.central.order.model.vo.DashboardStatisticsVO; +import com.central.order.service.IDashboardService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Slf4j +@RestController +@RequestMapping("/dashboard") +@Tag(name = "首页统计", description = "首页统计数据接口") +@RequiredArgsConstructor +public class DashboardController { + + private final IDashboardService dashboardService; + + @Operation(summary = "获取首页统计数据") + @GetMapping("/statistics") + public Result getStatistics() { + try { + DashboardStatisticsVO statistics = dashboardService.getDashboardStatistics(); + return Result.succeed(statistics, "获取首页统计数据成功"); + } catch (Exception e) { + log.error("获取首页统计数据失败", e); + return Result.failed("获取统计数据失败:" + e.getMessage()); + } + } +} diff --git a/zlt-business/order-center/src/main/java/com/central/order/mapper/DashboardMapper.java b/zlt-business/order-center/src/main/java/com/central/order/mapper/DashboardMapper.java new file mode 100644 index 00000000..a14f1893 --- /dev/null +++ b/zlt-business/order-center/src/main/java/com/central/order/mapper/DashboardMapper.java @@ -0,0 +1,112 @@ +package com.central.order.mapper; + +import com.central.order.model.vo.DistributionDataVO; +import com.central.order.model.vo.IncomeDataVO; +import com.central.order.model.vo.TourismRankingVO; +import com.central.order.model.vo.TrendDataVO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +@Mapper +public interface DashboardMapper { + + @Select("SELECT COUNT(*) FROM orders WHERE is_del = 0") + Long getTotalOrders(); + + @Select("SELECT COUNT(*) FROM orders WHERE is_del = 0 AND DATE(create_time) = CURDATE()") + Long getTodayOrders(); + + @Select("SELECT COUNT(*) FROM orders WHERE is_del = 0 AND DATE(create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY)") + Long getYesterdayOrders(); + + @Select("SELECT COUNT(*) FROM orders WHERE is_del = 0 AND order_status = #{completeStatus}") + Long getCompletedOrders(); + + @Select({ + "" + }) + Long getTotalIncome(); + + @Select({ + "" + }) + Long getTodayIncome(); + + @Select("SELECT COUNT(*) FROM waylines WHERE is_del = 0") + Long getTotalWaylines(); + + @Select("SELECT COUNT(*) FROM waylines WHERE is_del = 0 AND last_use_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)") + Long getActiveWaylines(); + + @Select("SELECT COUNT(*) FROM devices WHERE is_del = 0") + Long getTotalDevices(); + + @Select("SELECT COUNT(*) FROM devices WHERE is_del = 0 AND status = 1") + Long getOnlineDevices(); + + @Select({ + "SELECT", + " DATE_FORMAT(create_time, '%Y-%m-%d') as date,", + " 'orders' as type,", + " COUNT(*) as value", + "FROM orders", + "WHERE is_del = 0", + " AND create_time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)", + "GROUP BY DATE_FORMAT(create_time, '%Y-%m-%d')" + }) + List getOrderTrend(); + + @Select({ + "SELECT", + " device_type as type,", + " COUNT(*) as value", + "FROM devices", + "WHERE is_del = 0", + "GROUP BY device_type" + }) + List getDeviceDistribution(); + + @Select({ + "SELECT", + " 'platform' as type,", + " SUM(platform_amount) as value", + "FROM order_statistics", + "WHERE DATE(create_time) = CURDATE()", + "UNION ALL", + "SELECT", + " 'tourism' as type,", + " SUM(tourism_amount) as value", + "FROM order_statistics", + "WHERE DATE(create_time) = CURDATE()" + }) + List getIncomeData(); + + @Select({ + "SELECT", + " t.id,", + " t.tourism_name as name,", + " COUNT(o.id) as value", + "FROM tourisms t", + "LEFT JOIN orders o ON t.id = o.tourism_id", + "WHERE t.is_del = 0", + " AND o.is_del = 0", + " AND o.create_time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)", + "GROUP BY t.id, t.tourism_name", + "ORDER BY value DESC", + "LIMIT 10" + }) + List getTourismRanking(); +} diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/vo/ChartStatistics.java b/zlt-business/order-center/src/main/java/com/central/order/model/vo/ChartStatistics.java new file mode 100644 index 00000000..ea106819 --- /dev/null +++ b/zlt-business/order-center/src/main/java/com/central/order/model/vo/ChartStatistics.java @@ -0,0 +1,19 @@ +package com.central.order.model.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +@Schema(description = "图表统计数据") +public class ChartStatistics { + @Schema(description = "订单趋势") + private List orderTrend; + + @Schema(description = "设备分布") + private List deviceDistribution; + + @Schema(description = "收入构成") + private List incomeData; +} \ No newline at end of file diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/vo/DashboardStatisticsVO.java b/zlt-business/order-center/src/main/java/com/central/order/model/vo/DashboardStatisticsVO.java new file mode 100644 index 00000000..71196488 --- /dev/null +++ b/zlt-business/order-center/src/main/java/com/central/order/model/vo/DashboardStatisticsVO.java @@ -0,0 +1,28 @@ +package com.central.order.model.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +@Schema(description = "首页统计数据VO") +public class DashboardStatisticsVO { + @Schema(description = "订单统计") + private OrderStatistics orderStats; + + @Schema(description = "收入统计") + private IncomeStatistics incomeStats; + + @Schema(description = "航线统计") + private WaylineStatistics waylineStats; + + @Schema(description = "设备统计") + private DeviceStatistics deviceStats; + + @Schema(description = "图表统计") + private ChartStatistics chartStats; + + @Schema(description = "景区排行") + private List tourismRanking; +} \ No newline at end of file diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/vo/DeviceStatistics.java b/zlt-business/order-center/src/main/java/com/central/order/model/vo/DeviceStatistics.java new file mode 100644 index 00000000..672589e3 --- /dev/null +++ b/zlt-business/order-center/src/main/java/com/central/order/model/vo/DeviceStatistics.java @@ -0,0 +1,19 @@ +package com.central.order.model.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +@Schema(description = "设备统计数据") +public class DeviceStatistics { + @Schema(description = "设备总数") + private Long totalDevices; + + @Schema(description = "在线设备数") + private Long onlineDevices; + + @Schema(description = "设备在线率") + private BigDecimal deviceOnlineRate; +} \ No newline at end of file diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/vo/DistributionDataVO.java b/zlt-business/order-center/src/main/java/com/central/order/model/vo/DistributionDataVO.java new file mode 100644 index 00000000..0a287a0c --- /dev/null +++ b/zlt-business/order-center/src/main/java/com/central/order/model/vo/DistributionDataVO.java @@ -0,0 +1,16 @@ +package com.central.order.model.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +@Schema(description = "分布数据") +public class DistributionDataVO { + @Schema(description = "类型") + private String type; + + @Schema(description = "数值") + private BigDecimal value; +} \ No newline at end of file diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/vo/IncomeDataVO.java b/zlt-business/order-center/src/main/java/com/central/order/model/vo/IncomeDataVO.java new file mode 100644 index 00000000..568842b0 --- /dev/null +++ b/zlt-business/order-center/src/main/java/com/central/order/model/vo/IncomeDataVO.java @@ -0,0 +1,16 @@ +package com.central.order.model.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +@Schema(description = "收入数据") +public class IncomeDataVO { + @Schema(description = "类型") + private String type; + + @Schema(description = "数值") + private BigDecimal value; +} \ No newline at end of file diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/vo/IncomeStatistics.java b/zlt-business/order-center/src/main/java/com/central/order/model/vo/IncomeStatistics.java new file mode 100644 index 00000000..07dbfb4a --- /dev/null +++ b/zlt-business/order-center/src/main/java/com/central/order/model/vo/IncomeStatistics.java @@ -0,0 +1,19 @@ +package com.central.order.model.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +@Schema(description = "收入统计数据") +public class IncomeStatistics { + @Schema(description = "总收入(分)") + private Long totalAmount; + + @Schema(description = "今日收入(分)") + private Long todayAmount; + + @Schema(description = "目标完成率") + private BigDecimal targetCompletion; +} \ No newline at end of file diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/vo/OrderStatistics.java b/zlt-business/order-center/src/main/java/com/central/order/model/vo/OrderStatistics.java new file mode 100644 index 00000000..a91a0098 --- /dev/null +++ b/zlt-business/order-center/src/main/java/com/central/order/model/vo/OrderStatistics.java @@ -0,0 +1,22 @@ +package com.central.order.model.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +@Schema(description = "订单统计数据") +public class OrderStatistics { + @Schema(description = "订单总数") + private Long totalOrders; + + @Schema(description = "今日订单数") + private Long todayOrders; + + @Schema(description = "订单增长率") + private BigDecimal orderGrowth; + + @Schema(description = "订单完成率") + private BigDecimal completionRate; +} \ No newline at end of file diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/vo/TourismRankingVO.java b/zlt-business/order-center/src/main/java/com/central/order/model/vo/TourismRankingVO.java new file mode 100644 index 00000000..7e30a636 --- /dev/null +++ b/zlt-business/order-center/src/main/java/com/central/order/model/vo/TourismRankingVO.java @@ -0,0 +1,19 @@ +package com.central.order.model.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +@Schema(description = "景区排行数据") +public class TourismRankingVO { + @Schema(description = "景区ID") + private String id; + + @Schema(description = "景区名称") + private String name; + + @Schema(description = "数值") + private BigDecimal value; +} \ No newline at end of file diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/vo/TrendDataVO.java b/zlt-business/order-center/src/main/java/com/central/order/model/vo/TrendDataVO.java new file mode 100644 index 00000000..a903059c --- /dev/null +++ b/zlt-business/order-center/src/main/java/com/central/order/model/vo/TrendDataVO.java @@ -0,0 +1,19 @@ +package com.central.order.model.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +@Schema(description = "趋势数据") +public class TrendDataVO { + @Schema(description = "日期") + private String date; + + @Schema(description = "类型") + private String type; + + @Schema(description = "数值") + private BigDecimal value; +} \ No newline at end of file diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/vo/WaylineStatistics.java b/zlt-business/order-center/src/main/java/com/central/order/model/vo/WaylineStatistics.java new file mode 100644 index 00000000..54f89bbe --- /dev/null +++ b/zlt-business/order-center/src/main/java/com/central/order/model/vo/WaylineStatistics.java @@ -0,0 +1,19 @@ +package com.central.order.model.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +@Schema(description = "航线统计数据") +public class WaylineStatistics { + @Schema(description = "航线总数") + private Long totalWaylines; + + @Schema(description = "活跃航线数") + private Long activeWaylines; + + @Schema(description = "航线使用率") + private BigDecimal waylineUsage; +} \ No newline at end of file diff --git a/zlt-business/order-center/src/main/java/com/central/order/service/IDashboardService.java b/zlt-business/order-center/src/main/java/com/central/order/service/IDashboardService.java new file mode 100644 index 00000000..e67974aa --- /dev/null +++ b/zlt-business/order-center/src/main/java/com/central/order/service/IDashboardService.java @@ -0,0 +1,10 @@ +package com.central.order.service; + +import com.central.order.model.vo.DashboardStatisticsVO; + +public interface IDashboardService { + /** + * 获取首页统计数据 + */ + DashboardStatisticsVO getDashboardStatistics(); +} diff --git a/zlt-business/order-center/src/main/java/com/central/order/service/impl/DashboardServiceImpl.java b/zlt-business/order-center/src/main/java/com/central/order/service/impl/DashboardServiceImpl.java new file mode 100644 index 00000000..5a4d5fc6 --- /dev/null +++ b/zlt-business/order-center/src/main/java/com/central/order/service/impl/DashboardServiceImpl.java @@ -0,0 +1,173 @@ +package com.central.order.service.impl; + +import com.central.order.mapper.DashboardMapper; +import com.central.order.model.vo.*; +import com.central.order.service.IDashboardService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.List; + +@Slf4j +@Service +@RequiredArgsConstructor +public class DashboardServiceImpl implements IDashboardService { + + private final DashboardMapper dashboardMapper; + + @Override + public DashboardStatisticsVO getDashboardStatistics() { + DashboardStatisticsVO statistics = new DashboardStatisticsVO(); + + // 1. 获取订单统计 + statistics.setOrderStats(getOrderStatistics()); + + // 2. 获取收入统计 + statistics.setIncomeStats(getIncomeStatistics()); + + // 3. 获取航线统计 + statistics.setWaylineStats(getWaylineStatistics()); + + // 4. 获取设备统计 + statistics.setDeviceStats(getDeviceStatistics()); + + // 5. 获取图表统计 + statistics.setChartStats(getChartStatistics()); + + // 6. 获取景区排行 + statistics.setTourismRanking(getTourismRanking()); + + return statistics; + } + + /** + * 获取订单统计 + */ + private OrderStatistics getOrderStatistics() { + OrderStatistics stats = new OrderStatistics(); + + // 获取订单总数 + stats.setTotalOrders(dashboardMapper.getTotalOrders()); + + // 获取今日订单数 + stats.setTodayOrders(dashboardMapper.getTodayOrders()); + + // 计算订单增长率 + Long yesterdayOrders = dashboardMapper.getYesterdayOrders(); + if (yesterdayOrders > 0) { + BigDecimal growth = new BigDecimal(stats.getTodayOrders() - yesterdayOrders) + .divide(new BigDecimal(yesterdayOrders), 4, RoundingMode.HALF_UP) + .multiply(new BigDecimal(100)); + stats.setOrderGrowth(growth); + } + + // 计算完成率 + Long completedOrders = dashboardMapper.getCompletedOrders(); + if (stats.getTotalOrders() > 0) { + BigDecimal completionRate = new BigDecimal(completedOrders) + .divide(new BigDecimal(stats.getTotalOrders()), 4, RoundingMode.HALF_UP) + .multiply(new BigDecimal(100)); + stats.setCompletionRate(completionRate); + } + + return stats; + } + + /** + * 获取收入统计 + */ + private IncomeStatistics getIncomeStatistics() { + IncomeStatistics stats = new IncomeStatistics(); + + // 获取总收入 + stats.setTotalAmount(dashboardMapper.getTotalIncome()); + + // 获取今日收入 + stats.setTodayAmount(dashboardMapper.getTodayIncome()); + + // 计算目标完成率(假设每日目标10000元) + BigDecimal targetAmount = new BigDecimal(1000000); // 100元 * 100(分) + if (stats.getTodayAmount() > 0) { + BigDecimal completion = new BigDecimal(stats.getTodayAmount()) + .divide(targetAmount, 4, RoundingMode.HALF_UP) + .multiply(new BigDecimal(100)); + stats.setTargetCompletion(completion); + } + + return stats; + } + + /** + * 获取航线统计 + */ + private WaylineStatistics getWaylineStatistics() { + WaylineStatistics stats = new WaylineStatistics(); + + // 获取航线总数 + stats.setTotalWaylines(dashboardMapper.getTotalWaylines()); + + // 获取活跃航线数 + stats.setActiveWaylines(dashboardMapper.getActiveWaylines()); + + // 计算使用率 + if (stats.getTotalWaylines() > 0) { + BigDecimal usage = new BigDecimal(stats.getActiveWaylines()) + .divide(new BigDecimal(stats.getTotalWaylines()), 4, RoundingMode.HALF_UP) + .multiply(new BigDecimal(100)); + stats.setWaylineUsage(usage); + } + + return stats; + } + + /** + * 获取设备统计 + */ + private DeviceStatistics getDeviceStatistics() { + DeviceStatistics stats = new DeviceStatistics(); + + // 获取设备总数 + stats.setTotalDevices(dashboardMapper.getTotalDevices()); + + // 获取在线设备数 + stats.setOnlineDevices(dashboardMapper.getOnlineDevices()); + + // 计算在线率 + if (stats.getTotalDevices() > 0) { + BigDecimal onlineRate = new BigDecimal(stats.getOnlineDevices()) + .divide(new BigDecimal(stats.getTotalDevices()), 4, RoundingMode.HALF_UP) + .multiply(new BigDecimal(100)); + stats.setDeviceOnlineRate(onlineRate); + } + + return stats; + } + + /** + * 获取图表统计 + */ + private ChartStatistics getChartStatistics() { + ChartStatistics stats = new ChartStatistics(); + + // 获取订单趋势(最近7天) + stats.setOrderTrend(dashboardMapper.getOrderTrend()); + + // 获取设备分布 + stats.setDeviceDistribution(dashboardMapper.getDeviceDistribution()); + + // 获取收入构成 + stats.setIncomeData(dashboardMapper.getIncomeData()); + + return stats; + } + + /** + * 获取景区排行 + */ + private List getTourismRanking() { + return dashboardMapper.getTourismRanking(); + } +} diff --git a/zlt-business/user-center/src/main/resources/bootstrap.yml b/zlt-business/user-center/src/main/resources/bootstrap.yml index c2b67a64..a23d0891 100644 --- a/zlt-business/user-center/src/main/resources/bootstrap.yml +++ b/zlt-business/user-center/src/main/resources/bootstrap.yml @@ -4,10 +4,10 @@ server: spring: application: name: user-center -# cloud: -# nacos: -# discovery: -# ip: 124.222.128.40 + cloud: + nacos: + discovery: + ip: 124.222.128.40 # cloud: # nacos: # discovery: diff --git a/zlt-uaa/src/main/resources/bootstrap.yml b/zlt-uaa/src/main/resources/bootstrap.yml index f24da648..aff9b849 100644 --- a/zlt-uaa/src/main/resources/bootstrap.yml +++ b/zlt-uaa/src/main/resources/bootstrap.yml @@ -8,10 +8,10 @@ server: spring: application: name: uaa-server -# cloud: -# nacos: -# discovery: -# ip: 124.222.128.40 + cloud: + nacos: + discovery: + ip: 124.222.128.40 encrypt: key-store: diff --git a/zlt-web/react-web/src/main/frontend/config/proxy.ts b/zlt-web/react-web/src/main/frontend/config/proxy.ts index 0afbb14b..61b5280f 100644 --- a/zlt-web/react-web/src/main/frontend/config/proxy.ts +++ b/zlt-web/react-web/src/main/frontend/config/proxy.ts @@ -9,43 +9,43 @@ export default { dev: { '/api-uaa/': { - // target: 'http://119.45.169.13:9900', - target: 'http://127.0.0.1:9900', + target: 'http://119.45.169.13:9900', + // target: 'http://127.0.0.1:9900', changeOrigin: true, }, '/api-user/': { - target: 'http://127.0.0.1:9900', - // target: 'http://119.45.169.13:9900', + target: 'http://119.45.169.13:9900', + // target: 'http://127.0.0.1:9900', changeOrigin: true, }, '/api-log/': { - target: 'http://127.0.0.1:9900', - // target: 'http://119.45.169.13:9900', + target: 'http://119.45.169.13:9900', + // target: 'http://127.0.0.1:9900', changeOrigin: true, }, '/api-search/': { - target: 'http://127.0.0.1:9900', - // target: 'http://119.45.169.13:9900', + target: 'http://119.45.169.13:9900', + // target: 'http://127.0.0.1:9900', changeOrigin: true, }, '/api-generator/': { - target: 'http://127.0.0.1:9900', - // target: 'http://119.45.169.13:9900', + target: 'http://119.45.169.13:9900', + // target: 'http://127.0.0.1:9900', changeOrigin: true, }, '/api-file/': { - target: 'http://127.0.0.1:9900', - // target: 'http://119.45.169.13:9900', + target: 'http://119.45.169.13:9900', + // target: 'http://127.0.0.1:9900', changeOrigin: true, }, '/api-order/': { - target: 'http://127.0.0.1:9900', - // target: 'http://119.45.169.13:9900', + target: 'http://119.45.169.13:9900', + // target: 'http://127.0.0.1:9900', changeOrigin: true, }, '/api-device/': { - target: 'http://127.0.0.1:9900', - // target: 'http://119.45.169.13:9900', + target: 'http://119.45.169.13:9900', + // target: 'http://127.0.0.1:9900', changeOrigin: true, }, }, diff --git a/zlt-web/react-web/src/main/frontend/nginx.conf b/zlt-web/react-web/src/main/frontend/nginx.conf index 00a22501..89a1d35b 100644 --- a/zlt-web/react-web/src/main/frontend/nginx.conf +++ b/zlt-web/react-web/src/main/frontend/nginx.conf @@ -10,7 +10,7 @@ server { gzip_vary on; gzip_proxied any; - root /usr/share/nginx/html; + root /usr/share/nginx/html/react-web; index index.html; # 支持 history 路由 @@ -19,7 +19,7 @@ server { # 添加必要的跨域和缓存控制头 add_header Access-Control-Allow-Origin *; - add_header Cache-Control no-cache; + add_header Cache-Control "no-cache, no-store, must-revalidate"; # 添加安全相关头 add_header X-Frame-Options SAMEORIGIN; @@ -68,4 +68,12 @@ server { return 204; } } + + # API 代理配置 + location /api-order/ { + proxy_pass http://119.45.169.13:9900/api-order/; # 替换为您的后端API地址 + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } } \ No newline at end of file diff --git a/zlt-web/react-web/src/main/frontend/src/pages/Welcome.less b/zlt-web/react-web/src/main/frontend/src/pages/Welcome.less index a3f41196..9ded211c 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/Welcome.less +++ b/zlt-web/react-web/src/main/frontend/src/pages/Welcome.less @@ -1,10 +1,140 @@ @import (reference) '~antd/es/style/themes/index'; @import '~antd/es/style/themes/default.less'; -.stat { - margin-top: @margin-md; - padding: @padding-md; - background-color: @white; +.container { + :global { + .ant-card { + border-radius: 8px; + box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05); + transition: all 0.3s; + + &:hover { + box-shadow: 0 4px 16px rgba(0, 0, 0, 0.09); + } + } + } +} + +.statCard { + height: 180px; + + .statHeader { + display: flex; + align-items: center; + margin-bottom: 16px; + + span { + margin-left: 8px; + font-size: 16px; + font-weight: 500; + } + } + + .subStats { + margin-top: 16px; + display: flex; + justify-content: space-between; + align-items: flex-end; + + :global { + .ant-statistic { + flex: 1; + } + + .ant-progress { + width: 100px; + margin-left: 16px; + } + } + } +} + +// 图标样式 +.iconOrders { + font-size: 24px; + color: #1890ff; +} + +.iconIncome { + font-size: 24px; + color: #52c41a; +} + +.iconWayline { + font-size: 24px; + color: #722ed1; +} + +.iconDevice { + font-size: 24px; + color: #faad14; +} + +.trend { + font-size: 14px; + margin-left: 8px; + color: #52c41a; +} + +.chartsRow { + margin-top: 16px; +} + +.businessRow { + margin-top: 16px; +} + +.rankList { + .rankItem { + display: flex; + align-items: center; + padding: 12px 0; + border-bottom: 1px solid #f0f0f0; + + &:last-child { + border-bottom: none; + } + + .rankNum { + width: 20px; + height: 20px; + line-height: 20px; + text-align: center; + background: #fafafa; + border-radius: 10px; + margin-right: 16px; + font-size: 12px; + color: #8c8c8c; + + &.topThree { + color: #fff; + &:nth-child(1) { background: #f5222d; } + &:nth-child(2) { background: #fa8c16; } + &:nth-child(3) { background: #faad14; } + } + } + + .rankName { + flex: 1; + color: rgba(0, 0, 0, 0.85); + } + + .rankValue { + color: rgba(0, 0, 0, 0.45); + } + } +} + +// 响应式调整 +@media screen and (max-width: 768px) { + .statCard { + height: auto; + margin-bottom: 16px; + } + + .chartsRow, .businessRow { + margin-top: 8px; + } } .pie { @@ -111,3 +241,39 @@ } } } + +.statisticIcon { + color: #1890ff; + font-size: 20px; +} + +.statisticGroup { + margin-top: 24px; +} + +.chartRow { + margin-top: 24px; + + .ant-card { + height: 100%; + } +} + +.tourismCard { + margin-top: 24px; +} + +// 响应式调整 +@media screen and (max-width: 768px) { + .statisticGroup { + margin-top: 16px; + } + + .chartRow { + margin-top: 16px; + } + + .tourismCard { + margin-top: 16px; + } +} diff --git a/zlt-web/react-web/src/main/frontend/src/pages/Welcome.tsx b/zlt-web/react-web/src/main/frontend/src/pages/Welcome.tsx index 9c5ab549..ad302e3f 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/Welcome.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/Welcome.tsx @@ -1,73 +1,64 @@ -import { PageContainer, StatisticCard } from '@ant-design/pro-components'; -import { Card, Tag, Space, Tabs, Col, Row, Skeleton, Empty } from 'antd'; -import RcResizeObserver from 'rc-resize-observer'; -import React, { useState, useEffect, useMemo } from 'react'; -import { statistic } from '@/services/welcome/api'; -import { Area, Pie } from '@ant-design/plots'; +import { PageContainer } from '@ant-design/pro-components'; +import { Card, Row, Col, Statistic, Progress, Typography } from 'antd'; +import React, { useState, useEffect } from 'react'; +import { dashboard } from '@/services/orders/api'; +import { Area, Column, Pie } from '@ant-design/plots'; import { + ShoppingCartOutlined, + RocketOutlined, + MobileOutlined, UserOutlined, - EyeOutlined, - TeamOutlined, - LineChartOutlined, - BarChartOutlined, + RiseOutlined, + PayCircleOutlined, } from '@ant-design/icons'; import styles from './Welcome.less'; -const { Divider } = StatisticCard; +const { Title } = Typography; + +interface Statistics { + totalOrders: number; + todayOrders: number; + orderGrowth: number; + completionRate: number; + totalAmount: number; + todayAmount: number; + targetCompletion: number; + totalWaylines: number; + activeWaylines: number; + waylineUsage: number; + totalDevices: number; + onlineDevices: number; + deviceOnlineRate: number; + orderTrend: Array<{ + date: string; + type: string; + value: number; + }>; + deviceDistribution: Array<{ + type: string; + value: number; + }>; + incomeData: Array<{ + type: string; + value: number; + }>; + tourismRanking: Array<{ + id: string; + name: string; + value: number; + }>; +} const Welcome: React.FC = () => { - const [responsive, setResponsive] = useState(false); const [loading, setLoading] = useState(true); - const [statistics, setStatistics] = useState({}); - const [weeks, setWeeks] = useState([]); - const [days, setDays] = useState([]); - - const mapWeek = (result: WELCOME.Statistic) => { - const { statWeek_items, statWeek_pv, statWeek_uv } = result; - if (statWeek_items && statWeek_pv && statWeek_uv) { - const weekData = [ - ...statWeek_pv.map((pv, index) => ({ - type: '访问量(PV)', - date: statWeek_items[index], - value: pv, - })), - ...statWeek_uv.map((uv, index) => ({ - type: '独立用户(UV)', - date: statWeek_items[index], - value: uv, - })), - ]; - setWeeks(weekData); - } - }; - - const mapDay = (result: WELCOME.Statistic) => { - const { statDate_items, statDate_pv, statDate_uv } = result; - if (statDate_items && statDate_pv && statDate_uv) { - const dayData = [ - ...statDate_pv.map((pv, index) => ({ - type: '访问量(PV)', - date: statDate_items[index], - value: pv, - })), - ...statDate_uv.map((uv, index) => ({ - type: '独立用户(UV)', - date: statDate_items[index], - value: uv, - })), - ]; - setDays(dayData); - } - }; + const [statistics, setStatistics] = useState({}); const fetchData = async () => { try { setLoading(true); - const result = await statistic(); - if (result) { - setStatistics(result); - mapWeek(result); - mapDay(result); + const result = await dashboard(); + if (result.resp_code === 0) { + setStatistics(result.data); } } catch (error) { console.error('获取统计数据失败:', error); @@ -78,166 +69,191 @@ const Welcome: React.FC = () => { useEffect(() => { fetchData(); - // 每5分钟刷新一次数据 const timer = setInterval(fetchData, 5 * 60 * 1000); return () => clearInterval(timer); }, []); - const areaConfig = useMemo(() => ({ - smooth: true, - height: 260, - animation: true, - legend: { - layout: 'horizontal', - position: 'top', - }, + // 更新数据访问方式 + const orderStats = statistics.orderStats || {}; + const incomeStats = statistics.incomeStats || {}; + const waylineStats = statistics.waylineStats || {}; + const deviceStats = statistics.deviceStats || {}; + const chartStats = statistics.chartStats || {}; + + // 订单趋势配置 + const orderTrendConfig = { + data: chartStats.orderTrend || [], xField: 'date', yField: 'value', seriesField: 'type', - color: ['#1890ff', '#52c41a'], + smooth: true, + animation: true, + legend: { + position: 'top', + }, areaStyle: { fillOpacity: 0.6, }, - tooltip: { - shared: true, - showCrosshairs: true, - }, - }), []); + }; - const pieConfig = useMemo(() => ({ - height: 280, + // 设备分布配置 + const deviceDistConfig = { + data: chartStats.deviceDistribution || [], angleField: 'value', - colorField: 'name', - appendPadding: 10, - radius: 0.75, - animation: true, + colorField: 'type', + radius: 0.8, label: { - type: 'spider', - labelHeight: 28, - content: '{name}\n{percentage}', + type: 'outer', + content: '{name} {percentage}', }, - legend: { - layout: 'horizontal', - position: 'bottom', + }; + + // 收入统计配置 + const incomeConfig = { + data: chartStats.incomeData || [], + xField: 'type', + yField: 'value', + label: { + position: 'middle', + style: { + fill: '#FFFFFF', + opacity: 0.6, + }, }, - interactions: [ - { type: 'element-selected' }, - { type: 'element-active' }, - ], - }), []); + }; return ( - - 简单 - 高效 - 可扩展 - - } - > - setResponsive(offset.width < 596)} - > - - - , - description: 实时, - }} + + {/* 核心指标 */} + + + +
+ + 订单总览 +
+ + {orderStats.orderGrowth || 0}% + + } /> - - , - description: 今日, - }} - /> - - , - description: 今日, - }} - /> - - , - description: 本周, - }} - /> - - , - description: 本月, - }} - /> -
-
+
+ + +
+ + - - - - {weeks.length > 0 ? ( - - ) : ( - - )} - - - {days.length > 0 ? ( - - ) : ( - - )} - - - + + +
+ + 收入统计 +
+ +
+ + +
+
+ - - - - {statistics.browser_datas?.length ? ( - - ) : ( - - )} - - - - - {statistics.operatingSystem_datas?.length ? ( - - ) : ( - - )} - - - -
+ + +
+ + 航线概况 +
+ +
+ + +
+
+ + + + +
+ + 设备状态 +
+ +
+ + +
+
+ + + + {/* 图表展示 */} + + + + + + + + + + + + + + {/* 业务数据 */} + + + + + + + + +
+ {(statistics.tourismRanking || []).map((item: any, index: number) => ( +
+ + {index + 1} + + {item.name} + {item.value} +
+ ))} +
+
+ +
); }; diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/HomeCarousel/index.less b/zlt-web/react-web/src/main/frontend/src/pages/orders/HomeCarousel/index.less index 8d289828..473cc609 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/orders/HomeCarousel/index.less +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/HomeCarousel/index.less @@ -1 +1,24 @@ @import (reference) '~antd/es/style/themes/index'; + +// 添加查询栏样式 +.query-filter { + padding: 24px 24px 0; + background-color: #fff; + border-radius: 2px; + + :global { + .ant-form-item { + margin-bottom: 24px; + } + + .ant-select, + .ant-input { + width: 100%; + } + } +} + +// 调整表格上边距 +.ant-pro-table { + margin-top: 16px; +} diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/HomeCarousel/index.tsx b/zlt-web/react-web/src/main/frontend/src/pages/orders/HomeCarousel/index.tsx index 9fcc91f6..9c0e22ad 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/orders/HomeCarousel/index.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/HomeCarousel/index.tsx @@ -201,24 +201,38 @@ const TableList: React.FC = () => { defaultCollapsed={false} split span={6} - onFinish={setSearchParams} + className="query-filter" + onFinish={async (values) => { + setSearchParams(values); + actionRef.current?.reload(); + }} + style={{ marginBottom: 16 }} > diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/components/UpdateForm.tsx b/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/components/UpdateForm.tsx index d287facd..cd6ef537 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/components/UpdateForm.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/components/UpdateForm.tsx @@ -44,6 +44,13 @@ const UpdateForm: React.FC = (props) => { initialValues={values} > + { dataIndex: 'index', valueType: 'indexBorder', width: 48, + fixed: 'left', }, { title: 'ID', @@ -207,11 +208,18 @@ const TableList: React.FC = () => { title: 'CodeID', dataIndex: 'codeId', width: 120, + ellipsis: true, + }, + { + title: '名称', + dataIndex: 'name', + width: 120, + ellipsis: true, }, { title: '景区名称', dataIndex: 'tourismId', - width: 160, + width: 140, ellipsis: true, render: (_, entity) => { const tourism = tourismOptions.find(item => item.value === entity.tourismId); @@ -221,7 +229,7 @@ const TableList: React.FC = () => { { title: '航线名称', dataIndex: 'waylineId', - width: 160, + width: 140, ellipsis: true, render: (waylineId) => { const wayline = waylineOptions.find(item => item.value === waylineId); @@ -235,7 +243,8 @@ const TableList: React.FC = () => { render: (viewUrl) => viewUrl ? ( ) : '-', @@ -255,19 +264,21 @@ const TableList: React.FC = () => { { title: '状态', dataIndex: 'status', - width: 100, + width: 80, render: (status) => renderStatus(status), }, { title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', - width: 180, + width: 160, + ellipsis: true, }, { title: '操作', key: 'action', width: 120, + fixed: 'right', render: (_, record) => ( { request={qrcode} search={false} params={params} + scroll={{ x: 1500 }} pagination={{ showSizeChanger: true, showQuickJumper: true, + defaultPageSize: 10, }} toolBarRender={() => [ , ]} + style={{ + width: '100%', + overflow: 'auto', + }} /> { onFinish={async (values) => handleTableAction('add', undefined, values)} > + ; + deviceDistribution: Array<{ + type: string; + value: number; + }>; + incomeData: Array<{ + type: string; + value: number; + }>; + }; + tourismRanking: Array<{ + id: string; + name: string; + value: number; + }>; + } } declare namespace API { diff --git a/zlt-web/react-web/src/main/frontend/src/services/welcome/api.ts b/zlt-web/react-web/src/main/frontend/src/services/welcome/api.ts index 42f656a5..b2f6db5e 100644 --- a/zlt-web/react-web/src/main/frontend/src/services/welcome/api.ts +++ b/zlt-web/react-web/src/main/frontend/src/services/welcome/api.ts @@ -1,9 +1,10 @@ // @ts-ignore /* eslint-disable */ -import { request } from 'umi'; +import { request } from '@/utils/request'; -export async function statistic() { - return request('/api-log/requestStat', { +/** 获取首页统计数据 GET /api-order/dashboard */ +export async function getDashboardStatistics() { + return request('/api-order/dashboard', { method: 'GET', }); } diff --git a/zlt-web/react-web/src/main/frontend/src/services/welcome/typings.d.ts b/zlt-web/react-web/src/main/frontend/src/services/welcome/typings.d.ts index dc9980c2..c6393a72 100644 --- a/zlt-web/react-web/src/main/frontend/src/services/welcome/typings.d.ts +++ b/zlt-web/react-web/src/main/frontend/src/services/welcome/typings.d.ts @@ -31,4 +31,54 @@ declare namespace WELCOME { date: Date; value: number; }; + + interface DashboardStatistics { + orderStats: { + totalOrders: number; + todayOrders: number; + orderGrowth: number; + completionRate: number; + }; + incomeStats: { + totalAmount: number; + todayAmount: number; + targetCompletion: number; + }; + waylineStats: { + totalWaylines: number; + activeWaylines: number; + waylineUsage: number; + }; + deviceStats: { + totalDevices: number; + onlineDevices: number; + deviceOnlineRate: number; + }; + chartStats: { + orderTrend: Array<{ + date: string; + type: string; + value: number; + }>; + deviceDistribution: Array<{ + type: string; + value: number; + }>; + incomeData: Array<{ + type: string; + value: number; + }>; + }; + tourismRanking: Array<{ + id: string; + name: string; + value: number; + }>; + } + + interface DashboardResponse { + resp_code: number; + resp_msg: string; + data: DashboardStatistics; + } }