按日期返回debug+区级计数接口
This commit is contained in:
@@ -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<List<DistrictCountDTO>> getDistrictCount() {
|
||||
try {
|
||||
List<DistrictCountDTO> data = statisticsService.getDistrictCount();
|
||||
return ApiResponse.success(data);
|
||||
} catch (Exception e) {
|
||||
return ApiResponse.error("查询小班计数失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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<PlotStatsDTO> selectPlotStatsByDistrict();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 按照区统计信息(内业外业样地数量)
|
||||
* @return 统计结果 DTO
|
||||
*/
|
||||
List<DistrictCountDTO> loadDistrictCount();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有小班的ID和边界信息
|
||||
* * @param schema 动态传入的数据库模式名
|
||||
* @return 包含ID和GeoJSON的列表
|
||||
*/
|
||||
List<PlotBoundaryDTO> selectAllPlotBoundaries(@Param("schema") String schema);
|
||||
// List<PlotBoundaryDTO> selectAllPlotBoundaries(@Param("schema") String schema);
|
||||
// /**
|
||||
// * 查询单个图斑详情
|
||||
// * @param schema schema 名
|
||||
|
||||
@@ -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<PlotStatsDTO> getAllDistrictStats() {
|
||||
//
|
||||
// // 1️⃣ 查询 unit_info 全部数据
|
||||
// List<UnitInfo> allTasks = unitInfoMapper.findAll();
|
||||
//
|
||||
// // 2️⃣ 按 district 分组
|
||||
// Map<String, List<UnitInfo>> grouped =
|
||||
// allTasks.stream().collect(Collectors.groupingBy(UnitInfo::getDistrict));
|
||||
//
|
||||
// Map<String, PlotStatsDTO> result = new LinkedHashMap<>();
|
||||
//
|
||||
// // 3️⃣ 遍历每个区,累加统计
|
||||
// for (Map.Entry<String, List<UnitInfo>> entry : grouped.entrySet()) {
|
||||
//
|
||||
// String district = entry.getKey();
|
||||
// List<UnitInfo> 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<PlotStatsDTO> list = taskCommonMapper.selectPlotStatsByDistrict();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有区的计数信息
|
||||
*/
|
||||
public List<DistrictCountDTO> getDistrictCount() {
|
||||
// 直接从数据库一次性查出“按区聚合后的统计数据”
|
||||
List<DistrictCountDTO> list = taskCommonMapper.loadDistrictCount();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 按街道统计(传入区名称)
|
||||
|
||||
@@ -7,17 +7,18 @@
|
||||
<select id="finishedPlot" resultType="com.whu.edu.LyStatistic.MapLyStatistic.Dto.DatePlotDTO">
|
||||
SELECT
|
||||
r.region AS district,
|
||||
COUNT(*) AS plotcount, -- 小班数量
|
||||
COUNT(ts."ID") AS sampleplotcount -- 样地数量
|
||||
COUNT(m."ID") AS plotcount, -- 小班数量
|
||||
COUNT(ts."ID") AS sampleplotcount -- 样地数量
|
||||
FROM merged.roottable1_merged m
|
||||
JOIN region r
|
||||
ON substring(m."CUN", 1, 6) = r.regionid::text
|
||||
LEFT JOIN merged.t1sub1_merged ts
|
||||
ON ts."parentID" = m."ID" -- 连接样地表
|
||||
ON ts."parentID" = m."ID"
|
||||
AND ts."database_name" = m."database_name"
|
||||
WHERE (m.reviewer != '-1' OR m.collector != '-1')
|
||||
AND DATE(m.update_time) = #{date}
|
||||
AND Date(m.update_time) = #{date}
|
||||
GROUP BY r.region
|
||||
ORDER BY r.region
|
||||
ORDER BY r.region;
|
||||
</select>
|
||||
|
||||
<select id="finishedSamplePlot" resultType="string">
|
||||
|
||||
@@ -105,4 +105,13 @@
|
||||
FROM "${schema}".roottable1
|
||||
</select>
|
||||
|
||||
|
||||
<select id="loadDistrictCount" resultType="com.whu.edu.LyStatistic.MapLyStatistic.Dto.DistrictCountDTO">
|
||||
SELECT
|
||||
"NAME",
|
||||
"NY",
|
||||
"WY",
|
||||
"YD"
|
||||
FROM xian_stats
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user