|
|
|
@ -449,6 +449,48 @@ public class WorkbenchServiceImpl implements WorkbenchService { |
|
|
|
List<WorkbenchRevenue> list = workBenchMapper.getRevenue(markets, startDate, endDate); |
|
|
|
return list; |
|
|
|
} |
|
|
|
// 获取精确图表数据 |
|
|
|
@Override |
|
|
|
public WorkbenchCard getExactGraph(Date startDate, Date endDate, List<String> markets) { |
|
|
|
if (markets == null || markets.isEmpty()) { |
|
|
|
return new WorkbenchCard(new ArrayList<>(), new ArrayList<>(), markets, startDate, endDate,0,0,new Date()); |
|
|
|
} |
|
|
|
|
|
|
|
// 单次批量查询 |
|
|
|
List<WorkbenchFullStatistics> statsList = workBenchMapper.getExactByMarketAndDate(markets, startDate, endDate); |
|
|
|
|
|
|
|
// 构建 map: market -> statistics |
|
|
|
Map<String, WorkbenchFullStatistics> statMap = statsList.stream() |
|
|
|
.collect(Collectors.toMap(WorkbenchFullStatistics::getMarket, Function.identity())); |
|
|
|
|
|
|
|
// 构建最终结果 |
|
|
|
List<WorkbenchMarketGraph> marketGraphs = new ArrayList<>(); |
|
|
|
for (String market : markets) { |
|
|
|
WorkbenchFullStatistics stats = statMap.getOrDefault(market, new WorkbenchFullStatistics()); |
|
|
|
|
|
|
|
Map<String, Integer> sums = new HashMap<>(); |
|
|
|
sums.put("recharge", stats.getTotalRecharge() != null ? stats.getTotalRecharge() : 0); |
|
|
|
sums.put("money", stats.getTotalMoney() != null ? stats.getTotalMoney() : 0); |
|
|
|
sums.put("rFree", sums.get("recharge") - sums.get("money")); |
|
|
|
sums.put("cPermanent", stats.getTotalConsumePermanent() != null ? stats.getTotalConsumePermanent() : 0); |
|
|
|
sums.put("cFree", stats.getTotalConsumeFree() != null ? stats.getTotalConsumeFree() : 0); |
|
|
|
sums.put("cTask", stats.getTotalConsumeTask() != null ? stats.getTotalConsumeTask() : 0); |
|
|
|
sums.put("consume", sums.get("cPermanent") + sums.get("cFree") + sums.get("cTask")); |
|
|
|
|
|
|
|
WorkbenchMarketGraph graph = new WorkbenchMarketGraph(); |
|
|
|
graph.setMarket(market); |
|
|
|
graph.setSumRechargePermanent(sums.get("money")); |
|
|
|
graph.setSumRechargeFree(sums.get("rFree")); |
|
|
|
graph.setSumConsumePermanent(sums.get("cPermanent")); |
|
|
|
graph.setSumConsumeFree(sums.get("cFree")); |
|
|
|
graph.setSumConsumeTask(sums.get("cTask")); |
|
|
|
graph.setSumConsume(sums.get("consume")); |
|
|
|
|
|
|
|
marketGraphs.add(graph); |
|
|
|
} |
|
|
|
|
|
|
|
return new WorkbenchCard(new ArrayList<>(), marketGraphs, markets, startDate, endDate,0,0,new Date()); |
|
|
|
} |
|
|
|
|
|
|
|
//获取最近的更新时间 |
|
|
|
private Date findLatestUpdateTime(List<Statistics> statsList) { |
|
|
|
|