diff --git a/src/main/java/com/whu/edu/LyStatistic/statistic/dto/TaskStatisticResult.java b/src/main/java/com/whu/edu/LyStatistic/statistic/dto/TaskStatisticResult.java index 26eb192..19aa09c 100644 --- a/src/main/java/com/whu/edu/LyStatistic/statistic/dto/TaskStatisticResult.java +++ b/src/main/java/com/whu/edu/LyStatistic/statistic/dto/TaskStatisticResult.java @@ -11,6 +11,8 @@ import java.util.List; @NoArgsConstructor public class TaskStatisticResult { private String schema; + private String districtName; + private String villageName; private List userStatistics; private int totalRootCount; private int totalT1sub1Count; diff --git a/src/main/java/com/whu/edu/LyStatistic/statistic/mapper/TaskStatisticMapper.java b/src/main/java/com/whu/edu/LyStatistic/statistic/mapper/TaskStatisticMapper.java index ed717f0..5cfa65f 100644 --- a/src/main/java/com/whu/edu/LyStatistic/statistic/mapper/TaskStatisticMapper.java +++ b/src/main/java/com/whu/edu/LyStatistic/statistic/mapper/TaskStatisticMapper.java @@ -45,4 +45,14 @@ public interface TaskStatisticMapper { @Param("table") String table, @Param("column") String column, @Param("parentId") Long parentId); + + /** + * 查询 schema 对应的区县名 + */ + String getDistrictNameBySchema(@Param("schema") String schema); + + /** + * 查询 schema 对应的镇街名 + */ + String getVillageNameBySchema(@Param("schema") String schema); } diff --git a/src/main/java/com/whu/edu/LyStatistic/statistic/service/TaskStatisticService.java b/src/main/java/com/whu/edu/LyStatistic/statistic/service/TaskStatisticService.java index 0b1668c..4f5de1f 100644 --- a/src/main/java/com/whu/edu/LyStatistic/statistic/service/TaskStatisticService.java +++ b/src/main/java/com/whu/edu/LyStatistic/statistic/service/TaskStatisticService.java @@ -42,10 +42,13 @@ public class TaskStatisticService { .collect(Collectors.toList()); } + String districtName = taskStatisticMapper.getDistrictNameBySchema(schema); + String villageName = taskStatisticMapper.getVillageNameBySchema(schema); + // 2️⃣ 查询根表记录(支持时间区间) List rootTasks = taskStatisticMapper.findRootTasksByTimeRange(schema, startTime, endTime, userIds); if (rootTasks.isEmpty()) { - return new TaskStatisticResult(schema, Collections.emptyList(), 0, 0, 0, 0); + return new TaskStatisticResult(schema, districtName, villageName, Collections.emptyList(), 0, 0, 0, 0); } // 3️⃣ 获取所有根表ID @@ -129,7 +132,7 @@ public class TaskStatisticService { int totalT1sub2Count = t1sub2Map.values().stream().mapToInt(Integer::intValue).sum(); int totalT1sub3Count = t1sub3Map.values().stream().mapToInt(Integer::intValue).sum(); - return new TaskStatisticResult(schema, results, + return new TaskStatisticResult(schema, districtName, villageName, results, totalRootCount, totalT1sub1Count, totalT1sub2Count, totalT1sub3Count); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index d92b157..0bab0c1 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,7 +4,7 @@ server.port=9001 server.address=0.0.0.0 spring.datasource.host=120.48.89.193 spring.datasource.port=5432 -spring.datasource.database=lydc_statistic +spring.datasource.database=tj_lydc spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.url=jdbc:postgresql://${spring.datasource.host}:${spring.datasource.port}/${spring.datasource.database}?useSSL=true&allowMultiQueries=true spring.datasource.username=postgres diff --git a/src/main/resources/mapper/TaskStatisticMapper.xml b/src/main/resources/mapper/TaskStatisticMapper.xml index 3a4a5ff..92ed06f 100644 --- a/src/main/resources/mapper/TaskStatisticMapper.xml +++ b/src/main/resources/mapper/TaskStatisticMapper.xml @@ -79,4 +79,18 @@ WHERE "${column}" = #{parentId} + + + + + +