feat: 增加任务的区县和镇街信息

This commit is contained in:
moonlight557
2025-10-13 17:24:49 +08:00
parent ec7d0e09df
commit 3a4aa12619
5 changed files with 32 additions and 3 deletions

View File

@@ -11,6 +11,8 @@ import java.util.List;
@NoArgsConstructor
public class TaskStatisticResult {
private String schema;
private String districtName;
private String villageName;
private List<UserStatistic> userStatistics;
private int totalRootCount;
private int totalT1sub1Count;

View File

@@ -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);
}

View File

@@ -42,10 +42,13 @@ public class TaskStatisticService {
.collect(Collectors.toList());
}
String districtName = taskStatisticMapper.getDistrictNameBySchema(schema);
String villageName = taskStatisticMapper.getVillageNameBySchema(schema);
// 2⃣ 查询根表记录(支持时间区间)
List<RootTask> 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);
}

View File

@@ -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

View File

@@ -79,4 +79,18 @@
WHERE "${column}" = #{parentId}
</select>
<!-- 查找schema对应区县名 -->
<select id="getDistrictNameBySchema" resultType="string">
SELECT district
FROM public.unit_info
WHERE schema_code = #{schema}
</select>
<!-- 查找schema对应镇街名 -->
<select id="getVillageNameBySchema" resultType="string">
SELECT village
FROM public.unit_info
WHERE schema_code = #{schema}
</select>
</mapper>