|
|
@@ -3,6 +3,7 @@ package com.zksy.park.service.impl;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.ExcelWriter;
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.zksy.common.core.domain.Result;
|
|
|
@@ -20,6 +21,7 @@ import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author Administrator
|
|
|
@@ -28,10 +30,50 @@ import java.util.List;
|
|
|
*/
|
|
|
@Service
|
|
|
public class WaterUsageDataServiceImpl extends ServiceImpl<WaterUsageDataMapper, WaterUsageData>
|
|
|
- implements WaterUsageDataService {
|
|
|
+ implements WaterUsageDataService {
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> getMonthSummary() {
|
|
|
+ return this.listMaps(new QueryWrapper<WaterUsageData>()
|
|
|
+ .select("statistical_time as statTime",
|
|
|
+ "SUM(water_volume) as totalWater",
|
|
|
+ "SUM(amount) as totalAmount")
|
|
|
+ .groupBy("statistical_time"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> getCustomerSummary() {
|
|
|
+ return this.listMaps(new QueryWrapper<WaterUsageData>()
|
|
|
+ .select("customer_name as customerName",
|
|
|
+ "SUM(water_volume) as totalWater",
|
|
|
+ "SUM(amount) as totalAmount")
|
|
|
+ .groupBy("customer_name"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> getTopNCustomers(int topN) {
|
|
|
+ return this.listMaps(new QueryWrapper<WaterUsageData>()
|
|
|
+ .select("customer_name as customerName",
|
|
|
+ "SUM(water_volume) as totalWater",
|
|
|
+ "SUM(amount) as totalAmount")
|
|
|
+ .groupBy("customer_name")
|
|
|
+ .orderByDesc("SUM(amount)")
|
|
|
+ .last("LIMIT " + topN));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> getCustomerTrend(Long customerCode) {
|
|
|
+ return this.listMaps(new QueryWrapper<WaterUsageData>()
|
|
|
+ .select("statistical_time as statTime",
|
|
|
+ "SUM(water_volume) as totalWater",
|
|
|
+ "SUM(amount) as totalAmount")
|
|
|
+ .eq("customer_code", customerCode)
|
|
|
+ .groupBy("statistical_time")
|
|
|
+ .orderByAsc("statistical_time"));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|