diff --git a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Controller/StatisticsController.java b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Controller/StatisticsController.java index 1c357bc..4e11021 100644 --- a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Controller/StatisticsController.java +++ b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Controller/StatisticsController.java @@ -5,7 +5,7 @@ import com.whu.edu.LyStatistic.MapLyStatistic.Dto.StreetStatsDTO; import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotAttrDTO; import com.whu.edu.LyStatistic.MapLyStatistic.Dto.DatePlotDTO; import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotStatsDTO; -import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotBoundaryDTO; +import com.whu.edu.LyStatistic.MapLyStatistic.Dto.DistrictCountDTO; import com.whu.edu.LyStatistic.MapLyStatistic.Service.StatisticsService; import com.whu.edu.LyStatistic.MapLyStatistic.Service.PlotService; import com.whu.edu.LyStatistic.MapLyStatistic.Service.DateService; @@ -63,6 +63,21 @@ public class StatisticsController { } + /** + * 小班属性 + * 入参:内业小班号NYXBH+乡XIANG + */ + @GetMapping("/district/count") + public ApiResponse> getDistrictCount() { + try { + List data = statisticsService.getDistrictCount(); + return ApiResponse.success(data); + } catch (Exception e) { + return ApiResponse.error("查询小班计数失败:" + e.getMessage()); + } + } + + /** diff --git a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/DistrictCountDTO.java b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/DistrictCountDTO.java new file mode 100644 index 0000000..2a024d0 --- /dev/null +++ b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/DistrictCountDTO.java @@ -0,0 +1,15 @@ +package com.whu.edu.LyStatistic.MapLyStatistic.Dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DistrictCountDTO { + private String name; + private String ny; + private String wy; + private String yd; +} diff --git a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Mapper/TaskCommonMapper.java b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Mapper/TaskCommonMapper.java index 00e7518..c8d9824 100644 --- a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Mapper/TaskCommonMapper.java +++ b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Mapper/TaskCommonMapper.java @@ -1,7 +1,7 @@ package com.whu.edu.LyStatistic.MapLyStatistic.Mapper; import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotStatsDTO; -import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotBoundaryDTO; +import com.whu.edu.LyStatistic.MapLyStatistic.Dto.DistrictCountDTO; //import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotDetailDTO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -26,12 +26,23 @@ public interface TaskCommonMapper { * @return 统计结果 DTO */ List selectPlotStatsByDistrict(); + + + + /** + * 按照区统计信息(内业外业样地数量) + * @return 统计结果 DTO + */ + List loadDistrictCount(); + + + /** * 获取所有小班的ID和边界信息 * * @param schema 动态传入的数据库模式名 * @return 包含ID和GeoJSON的列表 */ - List selectAllPlotBoundaries(@Param("schema") String schema); +// List selectAllPlotBoundaries(@Param("schema") String schema); // /** // * 查询单个图斑详情 // * @param schema schema 名 diff --git a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/StatisticsService.java b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/StatisticsService.java index 2fcf1e4..8434fae 100644 --- a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/StatisticsService.java +++ b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/StatisticsService.java @@ -1,24 +1,23 @@ package com.whu.edu.LyStatistic.MapLyStatistic.Service; import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotStatsDTO; -import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotAttrDTO; -import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotBoundaryDTO; -import com.whu.edu.LyStatistic.MapLyStatistic.Dto.UnitInfo; -import com.whu.edu.LyStatistic.MapLyStatistic.Mapper.InfoMapper; +import com.whu.edu.LyStatistic.MapLyStatistic.Dto.DistrictCountDTO; +//import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotBoundaryDTO; +//import com.whu.edu.LyStatistic.MapLyStatistic.Dto.UnitInfo; +//import com.whu.edu.LyStatistic.MapLyStatistic.Mapper.InfoMapper; import com.whu.edu.LyStatistic.MapLyStatistic.Mapper.TaskCommonMapper; -import com.whu.edu.LyStatistic.MapLyStatistic.Service.BaseService.BaseTaskQueryService; +//import com.whu.edu.LyStatistic.MapLyStatistic.Service.BaseService.BaseTaskQueryService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; -import java.util.stream.Collectors; @Service public class StatisticsService { - @Autowired - private InfoMapper unitInfoMapper; // 查询 unit_info 表 - - @Autowired - private BaseTaskQueryService baseQueryService; // 通用任务查询 Service +// @Autowired +// private InfoMapper unitInfoMapper; // 查询 unit_info 表 +// +// @Autowired +// private BaseTaskQueryService baseQueryService; // 通用任务查询 Service @Autowired private TaskCommonMapper taskCommonMapper; @@ -48,49 +47,22 @@ public class StatisticsService { * 返回 Map<区名, PlotStatsDTO> */ public List getAllDistrictStats() { -// -// // 1️⃣ 查询 unit_info 全部数据 -// List allTasks = unitInfoMapper.findAll(); -// -// // 2️⃣ 按 district 分组 -// Map> grouped = -// allTasks.stream().collect(Collectors.groupingBy(UnitInfo::getDistrict)); -// -// Map result = new LinkedHashMap<>(); -// -// // 3️⃣ 遍历每个区,累加统计 -// for (Map.Entry> entry : grouped.entrySet()) { -// -// String district = entry.getKey(); -// List tasks = entry.getValue(); -// -// // 初始化累加对象 -// PlotStatsDTO total = new PlotStatsDTO(0, 0.0, 0, 0, 0, 0); -// -// for (UnitInfo task : tasks) { -// PlotStatsDTO stats = taskCommonMapper.selectPlotStatsByDistrict(); // ✅ 使用安全方法 -// -// if (stats != null) { -// // 累加 -// total.setPlotCount(total.getPlotCount() + safeInt(stats.getPlotCount())); -// total.setTotalArea(total.getTotalArea() + safeDouble(stats.getTotalArea())); -// total.setUnPassedCount(total.getUnPassedCount() + safeInt(stats.getUnPassedCount())); -// total.setAssignedCount(total.getAssignedCount() + safeInt(stats.getAssignedCount())); -// total.setCollectedCount(total.getCollectedCount() + safeInt(stats.getCollectedCount())); -// total.setApprovedCount(total.getApprovedCount() + safeInt(stats.getApprovedCount())); -// } -// } -// -// result.put(district, total); -// } -// -// return result; // 直接从数据库一次性查出“按区聚合后的统计数据” List list = taskCommonMapper.selectPlotStatsByDistrict(); return list; } + /** + * 查询所有区的计数信息 + */ + public List getDistrictCount() { + // 直接从数据库一次性查出“按区聚合后的统计数据” + List list = taskCommonMapper.loadDistrictCount(); + + return list; + } + /** * 按街道统计(传入区名称) diff --git a/src/main/resources/mapper/MapLyStatistic/Date.xml b/src/main/resources/mapper/MapLyStatistic/Date.xml index 09ff582..0fcf5f4 100644 --- a/src/main/resources/mapper/MapLyStatistic/Date.xml +++ b/src/main/resources/mapper/MapLyStatistic/Date.xml @@ -7,17 +7,18 @@ + +