AnalysisController.java
4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package com.glsx.usedcar.web.rest;
import com.glsx.usedcar.module.account.domain.AccountStat;
import com.glsx.usedcar.module.account.entity.Account;
import com.glsx.usedcar.module.analysis.domain.*;
import com.glsx.usedcar.module.analysis.service.AnalysisService;
import com.glsx.usedcar.module.auction.service.BreachService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@RestController
@RequestMapping("/rest/analysis")
public class AnalysisController {
@Resource
private AnalysisService analysisService;
@Resource
private BreachService breachService;
/**
* 获取仪表盘统计数据
*
* @return
*/
@GetMapping("getDashboardStat")
public DashboardStat getDashboardStat() {
DashboardStat vehicleStat = analysisService.getDashboardStat();
return vehicleStat;
}
@GetMapping("getTotalFinanceStat")
public FinanceStat getTotalFinanceStat() {
FinanceStat vehicleStat = analysisService.getTotalFinanceStat();
return vehicleStat;
}
@GetMapping("getFinanceStatDaily")
public FinanceStat getFinanceStatDaily(@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date) {
FinanceStat vehicleStat = analysisService.getFinanceStatDaily(date);
return vehicleStat;
}
@GetMapping("getFinanceStatMonthly")
public FinanceStat getFinanceStatMonthly(@RequestParam int year, @RequestParam int month) {
FinanceStat vehicleStat = analysisService.getFinanceStatMonthly(year, month);
return vehicleStat;
}
@GetMapping("getOrderStatYearly")
public Map<String, Object> getOrderStatYearly(@RequestParam int year) {
Map<String, Object> statMap = new HashMap<>();
statMap.put("gmvs", analysisService.getGMVSumYearly(year));
statMap.put("profits", analysisService.getProfitSumYearly(year));
statMap.put("costs", analysisService.getCostSumYearly(year));
return statMap;
}
@GetMapping("getOrderStatMonthly")
public Map<String, Object> getOrderStatMonthly(@RequestParam int year, @RequestParam int month) {
Map<String, Object> statMap = new HashMap<>();
statMap.put("gmvs", analysisService.getGMVSumMonthly(year, month));
statMap.put("profits", analysisService.getProfitSumMonthly(year, month));
statMap.put("costs", analysisService.getCostSumMonthly(year, month));
return statMap;
}
@GetMapping("getOrderStatDaily")
public Map<String, Object> getOrderStatDaily(@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date) {
Map<String, Object> statMap = new HashMap<>();
statMap.put("gmvs", analysisService.getGMVSumDaily(date));
statMap.put("profits", analysisService.getProfitSumDaily(date));
statMap.put("costs", analysisService.getCostSumDaily(date));
return statMap;
}
@GetMapping("getOrderProfitRadio")
public ProfitRadio getOrderProfitRadio() {
ProfitRadioProjection orderProfitRadio = analysisService.getOrderProfitRadio();
return new ProfitRadio(orderProfitRadio.getAuctionProfit(), orderProfitRadio.getCommissionProfit(), breachService.getDepositDeductSum());
}
@GetMapping("getProvinceCountRate")
public List<ProvinceRate> getProvinceCountRate() {
LocalDate today = LocalDate.now();
return analysisService.getProvinceCountRate(today.atStartOfDay(), today.atTime(23, 59, 59));
}
@GetMapping("getAccountStatByAccount")
public AccountStat getAccountStatByAccount(@RequestParam int accountId) {
return analysisService.getAccountStatByAccount(new Account(accountId));
}
@GetMapping("getTimePeriodsToday")
public List<TimePeriod> getTimePeriodsToday() {
return analysisService.getTimePeriodsToday();
}
}