样地+样木查询修正了limit 1并且做不完期末作业
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
package com.whu.edu.LyStatistic.MapLyStatistic.Controller;
|
||||
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.*;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Service.StatisticsService;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Service.StatisticService;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Service.AttrService;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Service.DateService;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Service.CountService;
|
||||
import com.whu.edu.LyStatistic.Util.ApiResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
@@ -22,11 +23,13 @@ import java.util.List;
|
||||
public class StatisticsController {
|
||||
|
||||
@Autowired
|
||||
private StatisticsService statisticsService;
|
||||
private StatisticService statisticService;
|
||||
@Autowired
|
||||
private AttrService attrService;
|
||||
@Autowired
|
||||
private DateService dateService;
|
||||
@Autowired
|
||||
private CountService countService;
|
||||
/**
|
||||
* 小班属性
|
||||
* 入参:内业小班号NYXBH+乡XIANG
|
||||
@@ -48,9 +51,9 @@ public class StatisticsController {
|
||||
* 出参:t1sub1内所有值、t1sub1_media中的媒体数据
|
||||
*/
|
||||
@GetMapping("/t1sub1")
|
||||
public ApiResponse<T1sub1DTO> getT1sub1(@RequestParam String database, @RequestParam String id) {
|
||||
public ApiResponse<List<T1sub1DTO>> getT1sub1(@RequestParam String database, @RequestParam String id) {
|
||||
try {
|
||||
T1sub1DTO data = attrService.getT1sub1(database, id);
|
||||
List<T1sub1DTO> data = attrService.getT1sub1(database, id);
|
||||
return ApiResponse.success(data);
|
||||
} catch (Exception e) {
|
||||
return ApiResponse.error("查询小班属性失败:" + e.getMessage());
|
||||
@@ -63,9 +66,9 @@ public class StatisticsController {
|
||||
* 出参:t1sub2内所有值
|
||||
*/
|
||||
@GetMapping("/t1sub2")
|
||||
public ApiResponse<T1sub2DTO> getT1sub2(@RequestParam String database, @RequestParam String id) {
|
||||
public ApiResponse<List<T1sub2DTO>> getT1sub2(@RequestParam String database, @RequestParam String id) {
|
||||
try {
|
||||
T1sub2DTO data = attrService.getT1sub2(database, id);
|
||||
List<T1sub2DTO> data = attrService.getT1sub2(database, id);
|
||||
return ApiResponse.success(data);
|
||||
} catch (Exception e) {
|
||||
return ApiResponse.error("查询小班属性失败:" + e.getMessage());
|
||||
@@ -103,7 +106,7 @@ public class StatisticsController {
|
||||
@GetMapping("/district/count")
|
||||
public ApiResponse<DistrictCountDTO> getDistrictCount(@RequestParam String district) {
|
||||
try {
|
||||
DistrictCountDTO data = statisticsService.getDistrictCount(district);
|
||||
DistrictCountDTO data = countService.getDistrictCount(district);
|
||||
return ApiResponse.success(data);
|
||||
} catch (Exception e) {
|
||||
return ApiResponse.error("查询区计数失败:" + e.getMessage());
|
||||
@@ -118,7 +121,7 @@ public class StatisticsController {
|
||||
@GetMapping("/plot/count")
|
||||
public ApiResponse<PlotCountDTO> getPlotCount(@RequestParam String rootId, @RequestParam String databaseName) {
|
||||
try {
|
||||
PlotCountDTO data = statisticsService.getPlotCount(rootId,databaseName);
|
||||
PlotCountDTO data = countService.getPlotCount(rootId,databaseName);
|
||||
return ApiResponse.success(data);
|
||||
} catch (Exception e) {
|
||||
return ApiResponse.error("查询小班计数失败:" + e.getMessage());
|
||||
@@ -136,7 +139,7 @@ public class StatisticsController {
|
||||
public ApiResponse<DistrictStatsDTO> getDistrictStats() {
|
||||
try {
|
||||
// 1️⃣ 获取各区统计 List
|
||||
List<PlotStatsDTO> statsList = statisticsService.getAllDistrictStats();
|
||||
List<PlotStatsDTO> statsList = statisticService.getAllDistrictStats();
|
||||
|
||||
// 2️⃣ 构建 DTO 需要的 Map
|
||||
Map<String, String> completionStatus = new LinkedHashMap<>();
|
||||
|
||||
@@ -12,8 +12,8 @@ import java.util.List;
|
||||
public interface AttrMapper {
|
||||
|
||||
PlotAttrDTO findPlotAttributes(@Param("nyxbh") String nyxbh,@Param("xiang") String xiang);
|
||||
T1sub1DTO findT1sub1(@Param("database") String database, @Param("id") String id);
|
||||
T1sub2DTO findT1sub2(@Param("database") String database, @Param("id") String id);
|
||||
List<T1sub1DTO> findT1sub1(@Param("database") String database, @Param("id") String id);
|
||||
List<T1sub2DTO> findT1sub2(@Param("database") String database, @Param("id") String id);
|
||||
List<String> findMediaPaths(@Param("id") String id,
|
||||
@Param("databaseName") String databaseName,
|
||||
@Param("table") String table);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.whu.edu.LyStatistic.MapLyStatistic.Mapper;
|
||||
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.DistrictCountDTO;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotCountDTO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* TaskCommonMapper.xml
|
||||
* 区、小班的计数
|
||||
*/
|
||||
@Mapper
|
||||
public interface CountMapper {
|
||||
|
||||
/**
|
||||
* 按照区统计数量(内业外业样地数量)
|
||||
* @return 统计结果 DTO
|
||||
*/
|
||||
DistrictCountDTO loadDistrictCount(String district);
|
||||
|
||||
/**
|
||||
* 按照小班统计数量(样地数量)
|
||||
* @return 统计结果 DTO
|
||||
*/
|
||||
PlotCountDTO loadPlotCount(String rootId, String databaseName);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.whu.edu.LyStatistic.MapLyStatistic.Mapper;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotStatsDTO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TaskCommonMapper.xml
|
||||
* 通用 Mapper,用于不同 schema 下的 roottable1 表
|
||||
*/
|
||||
@Mapper
|
||||
public interface StatisticMapper {
|
||||
|
||||
|
||||
/**
|
||||
* 按照区统计图斑信息(数量、面积、各状态)
|
||||
* @return 统计结果 DTO
|
||||
*/
|
||||
List<PlotStatsDTO> selectPlotStatsByDistrict();
|
||||
|
||||
|
||||
}
|
||||
@@ -1,12 +1,8 @@
|
||||
package com.whu.edu.LyStatistic.MapLyStatistic.Mapper;
|
||||
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotStatsDTO;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.DistrictCountDTO;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotCountDTO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TaskCommonMapper.xml
|
||||
@@ -21,25 +17,6 @@ public interface TaskCommonMapper {
|
||||
* @return 统计结果 DTO
|
||||
*/
|
||||
PlotStatsDTO selectPlotStats(@Param("schema") String schema);
|
||||
/**
|
||||
* 按照区统计图斑信息(数量、面积、各状态)
|
||||
* @return 统计结果 DTO
|
||||
*/
|
||||
List<PlotStatsDTO> selectPlotStatsByDistrict();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 按照区统计数量(内业外业样地数量)
|
||||
* @return 统计结果 DTO
|
||||
*/
|
||||
DistrictCountDTO loadDistrictCount(String district);
|
||||
|
||||
/**
|
||||
* 按照小班统计信息(内业外业样地数量)
|
||||
* @return 统计结果 DTO
|
||||
*/
|
||||
PlotCountDTO loadPlotCount(String rootId, String databaseName);
|
||||
|
||||
/**
|
||||
* 获取所有小班的ID和边界信息
|
||||
|
||||
@@ -36,24 +36,30 @@ public class AttrService {
|
||||
* 入参:database_name+ID
|
||||
* 出参:t1sub1内所有值、t1sub1_media中的媒体数据
|
||||
*/
|
||||
public T1sub1DTO getT1sub1(String database, String id){
|
||||
T1sub1DTO schema = attrMapper.findT1sub1(database, id);
|
||||
if (schema == null) {
|
||||
public List<T1sub1DTO> getT1sub1(String database, String id){
|
||||
|
||||
// 查询得到 List<T1sub1DTO>
|
||||
List<T1sub1DTO> schema = attrMapper.findT1sub1(database, id);
|
||||
if (schema == null || schema.isEmpty()) {
|
||||
throw new RuntimeException("未找到对应的样地所在任务 schema");
|
||||
}
|
||||
|
||||
// 第二次查 media_path 列表
|
||||
List<String> mediaPaths = attrMapper.findMediaPaths(schema.getId(), schema.getDatabaseName(),"merged.t1sub1_media_merged");
|
||||
|
||||
// 设置到 DTO 中
|
||||
schema.setMediaPathList(mediaPaths);
|
||||
// 为每条 DTO 设置 mediaPathList
|
||||
for (T1sub1DTO dto : schema) {
|
||||
List<String> mediaPaths = attrMapper.findMediaPaths(
|
||||
dto.getId(),
|
||||
dto.getDatabaseName(),
|
||||
"merged.t1sub1_media_merged"
|
||||
);
|
||||
dto.setMediaPathList(mediaPaths);
|
||||
}
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
||||
|
||||
public T1sub2DTO getT1sub2(String database, String id){
|
||||
T1sub2DTO schema = attrMapper.findT1sub2(database, id);
|
||||
public List<T1sub2DTO> getT1sub2(String database, String id){
|
||||
List<T1sub2DTO> schema = attrMapper.findT1sub2(database, id);
|
||||
if (schema == null) {
|
||||
throw new RuntimeException("未找到对应的样木所在任务 schema");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.whu.edu.LyStatistic.MapLyStatistic.Service;
|
||||
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.DistrictCountDTO;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotCountDTO;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Mapper.CountMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class CountService {
|
||||
|
||||
@Autowired
|
||||
private CountMapper countMapper;
|
||||
|
||||
/**
|
||||
* 查询区的计数信息
|
||||
*/
|
||||
public DistrictCountDTO getDistrictCount(String district) {
|
||||
DistrictCountDTO data = countMapper.loadDistrictCount(district);
|
||||
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* 查询小班的计数信息
|
||||
*/
|
||||
public PlotCountDTO getPlotCount(String rootId, String databaseName) {
|
||||
PlotCountDTO data = countMapper.loadPlotCount(rootId,databaseName);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,26 +1,30 @@
|
||||
package com.whu.edu.LyStatistic.MapLyStatistic.Service;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotStatsDTO;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.DistrictCountDTO;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotCountDTO;
|
||||
//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.Mapper.StatisticMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class StatisticsService {
|
||||
public class StatisticService {
|
||||
// @Autowired
|
||||
// private InfoMapper unitInfoMapper; // 查询 unit_info 表
|
||||
//
|
||||
// @Autowired
|
||||
// private BaseTaskQueryService baseQueryService; // 通用任务查询 Service
|
||||
@Autowired
|
||||
private TaskCommonMapper taskCommonMapper;
|
||||
private StatisticMapper statisticMapper;
|
||||
/**
|
||||
* 查询所有区的统计信息
|
||||
* 返回 Map<区名, PlotStatsDTO>
|
||||
*/
|
||||
public List<PlotStatsDTO> getAllDistrictStats() {
|
||||
// 直接从数据库一次性查出“按区聚合后的统计数据”
|
||||
List<PlotStatsDTO> list = statisticMapper.selectPlotStatsByDistrict();
|
||||
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* 查询单个区的统计信息
|
||||
*/
|
||||
@@ -42,34 +46,6 @@ public class StatisticsService {
|
||||
// return total;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 查询所有区的统计信息
|
||||
* 返回 Map<区名, PlotStatsDTO>
|
||||
*/
|
||||
public List<PlotStatsDTO> getAllDistrictStats() {
|
||||
// 直接从数据库一次性查出“按区聚合后的统计数据”
|
||||
List<PlotStatsDTO> list = taskCommonMapper.selectPlotStatsByDistrict();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询区的计数信息
|
||||
*/
|
||||
public DistrictCountDTO getDistrictCount(String district) {
|
||||
DistrictCountDTO data = taskCommonMapper.loadDistrictCount(district);
|
||||
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
* 查询小班的计数信息
|
||||
*/
|
||||
public PlotCountDTO getPlotCount(String rootId, String databaseName) {
|
||||
PlotCountDTO data = taskCommonMapper.loadPlotCount(rootId,databaseName);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按街道统计(传入区名称)
|
||||
* 返回 Map<街道名, PlotStatsDTO>
|
||||
@@ -8,7 +8,7 @@ import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface TaskStatisticMapper {
|
||||
public interface StatisticDataMapper {
|
||||
|
||||
/**
|
||||
* 查询根表任务(支持时间范围 + 人员过滤)
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.whu.edu.LyStatistic.statistic.service;
|
||||
|
||||
import com.whu.edu.LyStatistic.statistic.dto.*;
|
||||
import com.whu.edu.LyStatistic.statistic.mapper.TaskStatisticMapper;
|
||||
import com.whu.edu.LyStatistic.statistic.mapper.StatisticDataMapper;
|
||||
import com.whu.edu.LyStatistic.statistic.mapper.UserStaffMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -18,7 +18,7 @@ public class TaskStatisticService {
|
||||
private UserStaffMapper userStaffMapper;
|
||||
|
||||
@Autowired
|
||||
private TaskStatisticMapper taskStatisticMapper;
|
||||
private StatisticDataMapper statisticDataMapper;
|
||||
|
||||
/**
|
||||
* 按 schema 和时间区间统计任务数据
|
||||
@@ -42,11 +42,11 @@ public class TaskStatisticService {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
String districtName = taskStatisticMapper.getDistrictNameBySchema(schema);
|
||||
String villageName = taskStatisticMapper.getVillageNameBySchema(schema);
|
||||
String districtName = statisticDataMapper.getDistrictNameBySchema(schema);
|
||||
String villageName = statisticDataMapper.getVillageNameBySchema(schema);
|
||||
|
||||
// 2️⃣ 查询根表记录(支持时间区间)
|
||||
List<RootTask> rootTasks = taskStatisticMapper.findRootTasksByTimeRange(schema, startTime, endTime, userIds);
|
||||
List<RootTask> rootTasks = statisticDataMapper.findRootTasksByTimeRange(schema, startTime, endTime, userIds);
|
||||
if (rootTasks.isEmpty()) {
|
||||
return new TaskStatisticResult(schema, districtName, villageName, Collections.emptyList(), 0, 0, 0, 0);
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public class TaskStatisticService {
|
||||
// 🧩 安全封装:防止 schema 无表时报错
|
||||
private Map<Long, Integer> safeCountByParent(String schema, String table, List<Long> rootIds) {
|
||||
try {
|
||||
return taskStatisticMapper.countGroupByParent(schema, table, "parentID", rootIds)
|
||||
return statisticDataMapper.countGroupByParent(schema, table, "parentID", rootIds)
|
||||
.stream()
|
||||
.filter(m -> m.get("parentid") != null)
|
||||
.collect(Collectors.toMap(
|
||||
@@ -153,7 +153,7 @@ public class TaskStatisticService {
|
||||
|
||||
private List<Map<String, Object>> safeFindSubIds(String schema, String table, List<Long> rootIds) {
|
||||
try {
|
||||
return taskStatisticMapper.findSubIdsGroupByParent(schema, table, "parentID", rootIds);
|
||||
return statisticDataMapper.findSubIdsGroupByParent(schema, table, "parentID", rootIds);
|
||||
} catch (Exception e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -161,7 +161,7 @@ public class TaskStatisticService {
|
||||
|
||||
private Integer safeCountByParentId(String schema, String table, Long parentId) {
|
||||
try {
|
||||
return taskStatisticMapper.countByParentId(schema, table, "parentID", parentId);
|
||||
return statisticDataMapper.countByParentId(schema, table, "parentID", parentId);
|
||||
} catch (Exception e) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
SELECT *
|
||||
FROM merged.t1sub1_merged
|
||||
WHERE database_name = #{database} AND "parentID" = #{id}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="findMediaPaths" resultType="string">
|
||||
@@ -30,7 +29,6 @@
|
||||
SELECT *
|
||||
FROM merged.t1sub2_merged
|
||||
WHERE database_name = #{database} AND "parentID" = #{id}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
23
src/main/resources/mapper/MapLyStatistic/Count.xml
Normal file
23
src/main/resources/mapper/MapLyStatistic/Count.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.whu.edu.LyStatistic.MapLyStatistic.Mapper.CountMapper">
|
||||
<!-- 按区返回计数 -->
|
||||
<select id="loadDistrictCount" resultType="com.whu.edu.LyStatistic.MapLyStatistic.Dto.DistrictCountDTO">
|
||||
SELECT
|
||||
"NY",
|
||||
"WY",
|
||||
"YD"
|
||||
FROM xian_stats
|
||||
WHERE "NAME" = #{district}
|
||||
</select>
|
||||
|
||||
<!-- 按小班返回计数 -->
|
||||
<select id="loadPlotCount" resultType="com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotCountDTO">
|
||||
SELECT *
|
||||
FROM root_summary
|
||||
WHERE root_id = #{rootId} AND database_name = #{databaseName}
|
||||
</select>
|
||||
</mapper>
|
||||
66
src/main/resources/mapper/MapLyStatistic/Statistic.xml
Normal file
66
src/main/resources/mapper/MapLyStatistic/Statistic.xml
Normal file
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.whu.edu.LyStatistic.MapLyStatistic.Mapper.StatisticMapper">
|
||||
|
||||
<select id="selectPlotStatsByDistrict"
|
||||
resultType="com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotStatsDTO">
|
||||
|
||||
SELECT
|
||||
r.region AS district,
|
||||
|
||||
-- 统计总行数(plotCount)
|
||||
COUNT(*) AS plotCount,
|
||||
|
||||
-- 面积求和,XBMJ 是 text,需要转 numeric
|
||||
COALESCE(SUM(NULLIF(m."XBMJ", '')::numeric), 0) AS totalArea,
|
||||
|
||||
-- status 也是 text,因此必须先转 integer
|
||||
COALESCE(SUM(CASE WHEN m."status"::int = -1 THEN 1 ELSE 0 END), 0) AS unPassedCount,
|
||||
COALESCE(SUM(CASE WHEN m."status"::int = 0 THEN 1 ELSE 0 END), 0) AS assignedCount,
|
||||
|
||||
-- 新的状态统计逻辑
|
||||
-- collector/reviewer有一个不是-1:已采集
|
||||
COALESCE(SUM(CASE
|
||||
WHEN (m."collector" != '-1' OR m."reviewer" != '-1')
|
||||
THEN 1 ELSE 0
|
||||
END), 0) AS collectedCount,
|
||||
|
||||
-- collector/reviewer均为-1:已发布未采集
|
||||
COALESCE(SUM(CASE
|
||||
WHEN m."collector" = '-1' AND m."reviewer" = '-1'
|
||||
THEN 1 ELSE 0
|
||||
END), 0) AS publishedUncollectedCount,
|
||||
|
||||
COALESCE(SUM(CASE WHEN m."status"::int = 2 THEN 1 ELSE 0 END), 0) AS approvedCount
|
||||
|
||||
FROM merged.roottable1_merged m
|
||||
JOIN region r
|
||||
ON substring(m."CUN", 1, 6) = r.regionid::text
|
||||
|
||||
GROUP BY r.region
|
||||
ORDER BY r.region
|
||||
</select>
|
||||
|
||||
<!--按街道
|
||||
统计图斑信息:
|
||||
- plotCount: 图斑数量
|
||||
- totalArea: 图斑面积汇总 (XBMJ)
|
||||
- 各状态数量 (-1,0,1,2)
|
||||
-->
|
||||
<select id="selectPlotStatsByStreet" resultType="com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotStatsDTO">
|
||||
SELECT
|
||||
COUNT(*) AS plotCount,
|
||||
COALESCE(SUM("XBMJ"), 0) AS totalArea,
|
||||
COALESCE(SUM(CASE WHEN "status" = -1 THEN 1 ELSE 0 END), 0) AS unPassedCount,
|
||||
COALESCE(SUM(CASE WHEN "status" = 0 THEN 1 ELSE 0 END), 0) AS assignedCount,
|
||||
COALESCE(SUM(CASE WHEN "status" = 1 THEN 1 ELSE 0 END), 0) AS collectedCount,
|
||||
COALESCE(SUM(CASE WHEN "status" = 2 THEN 1 ELSE 0 END), 0) AS approvedCount
|
||||
FROM merged.roottable1_merged
|
||||
WHERE village = #{village}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -105,20 +105,5 @@
|
||||
FROM "${schema}".roottable1
|
||||
</select>
|
||||
|
||||
<!-- 按区返回计数 -->
|
||||
<select id="loadDistrictCount" resultType="com.whu.edu.LyStatistic.MapLyStatistic.Dto.DistrictCountDTO">
|
||||
SELECT
|
||||
"NY",
|
||||
"WY",
|
||||
"YD"
|
||||
FROM xian_stats
|
||||
WHERE "NAME" = #{district}
|
||||
</select>
|
||||
|
||||
<!-- 按小班返回计数 -->
|
||||
<select id="loadPlotCount" resultType="com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotCountDTO">
|
||||
SELECT *
|
||||
FROM root_summary
|
||||
WHERE root_id = #{rootId} AND database_name = #{databaseName}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.whu.edu.LyStatistic.statistic.mapper.TaskStatisticMapper">
|
||||
<mapper namespace="com.whu.edu.LyStatistic.statistic.mapper.StatisticDataMapper">
|
||||
|
||||
<!-- 根表记录 -->
|
||||
<select id="findRootTasks" resultType="com.whu.edu.LyStatistic.statistic.dto.RootTask">
|
||||
|
||||
Reference in New Issue
Block a user