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
This commit is contained in:
+34
@@ -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<DashboardStatisticsVO> getStatistics() {
|
||||
try {
|
||||
DashboardStatisticsVO statistics = dashboardService.getDashboardStatistics();
|
||||
return Result.succeed(statistics, "获取首页统计数据成功");
|
||||
} catch (Exception e) {
|
||||
log.error("获取首页统计数据失败", e);
|
||||
return Result.failed("获取统计数据失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
+112
@@ -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({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(order_amount), 0)",
|
||||
"FROM orders",
|
||||
"WHERE is_del = 0",
|
||||
"AND order_status IN ${@com.central.order.constants.OrderStatusConstants@PAID_STATUS}",
|
||||
"</script>"
|
||||
})
|
||||
Long getTotalIncome();
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT COALESCE(SUM(order_amount), 0)",
|
||||
"FROM orders",
|
||||
"WHERE is_del = 0",
|
||||
"AND order_status IN ${@com.central.order.constants.OrderStatusConstants@PAID_STATUS}",
|
||||
"AND DATE(create_time) = CURDATE()",
|
||||
"</script>"
|
||||
})
|
||||
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<TrendDataVO> getOrderTrend();
|
||||
|
||||
@Select({
|
||||
"SELECT",
|
||||
" device_type as type,",
|
||||
" COUNT(*) as value",
|
||||
"FROM devices",
|
||||
"WHERE is_del = 0",
|
||||
"GROUP BY device_type"
|
||||
})
|
||||
List<DistributionDataVO> 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<IncomeDataVO> 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<TourismRankingVO> getTourismRanking();
|
||||
}
|
||||
+19
@@ -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<TrendDataVO> orderTrend;
|
||||
|
||||
@Schema(description = "设备分布")
|
||||
private List<DistributionDataVO> deviceDistribution;
|
||||
|
||||
@Schema(description = "收入构成")
|
||||
private List<IncomeDataVO> incomeData;
|
||||
}
|
||||
+28
@@ -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<TourismRankingVO> tourismRanking;
|
||||
}
|
||||
+19
@@ -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;
|
||||
}
|
||||
+16
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
+19
@@ -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;
|
||||
}
|
||||
+22
@@ -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;
|
||||
}
|
||||
+19
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
+19
@@ -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;
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.central.order.service;
|
||||
|
||||
import com.central.order.model.vo.DashboardStatisticsVO;
|
||||
|
||||
public interface IDashboardService {
|
||||
/**
|
||||
* 获取首页统计数据
|
||||
*/
|
||||
DashboardStatisticsVO getDashboardStatistics();
|
||||
}
|
||||
+173
@@ -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<TourismRankingVO> getTourismRanking() {
|
||||
return dashboardMapper.getTourismRanking();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user