From 2b7aaef3c9f8be01f76b6c1a1e8d16daf6a8ce38 Mon Sep 17 00:00:00 2001 From: wuleyan <1175424873@qq.com> Date: Thu, 27 Nov 2025 18:56:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E6=97=A5=E6=9C=9F=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=B7=B2=E5=AE=8C=E6=88=90=E7=9A=84=E5=B0=8F=E7=8F=AD=E6=95=B0?= =?UTF-8?q?=E5=92=8C=E6=A0=B7=E5=9C=B0=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/StatisticsController.java | 22 +++++++++++++- .../MapLyStatistic/Dto/DatePlotDTO.java | 1 + .../MapLyStatistic/Mapper/DateMapper.java | 14 +++++++++ .../MapLyStatistic/Service/DateService.java | 29 +++++++++++++++++++ .../resources/mapper/MapLyStatistic/Date.xml | 21 ++++++++++---- 5 files changed, 80 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Mapper/DateMapper.java create mode 100644 src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/DateService.java 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 ccb1e76..1c357bc 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 @@ -3,17 +3,21 @@ package com.whu.edu.LyStatistic.MapLyStatistic.Controller; import com.whu.edu.LyStatistic.MapLyStatistic.Dto.DistrictStatsDTO; 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.Service.StatisticsService; import com.whu.edu.LyStatistic.MapLyStatistic.Service.PlotService; +import com.whu.edu.LyStatistic.MapLyStatistic.Service.DateService; import com.whu.edu.LyStatistic.Util.ApiResponse; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.format.annotation.DateTimeFormat; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.Date; import java.util.LinkedHashMap; import java.util.Map; import java.util.List; @@ -26,7 +30,8 @@ public class StatisticsController { private StatisticsService statisticsService; @Autowired private PlotService plotService; - + @Autowired + private DateService dateService; /** * 小班属性 * 入参:内业小班号NYXBH+乡XIANG @@ -42,6 +47,21 @@ public class StatisticsController { } + /** + * 小班属性 + * 入参:内业小班号NYXBH+乡XIANG + */ + @GetMapping("/date") + public ApiResponse> getPlotAttr( + @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date date) { + try { + List data = dateService.getPlotAttributes(date); + return ApiResponse.success(data); + } catch (Exception e) { + return ApiResponse.error("查询该日期已完成小班失败:" + e.getMessage()); + } + } + diff --git a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/DatePlotDTO.java b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/DatePlotDTO.java index dda6c94..f69a1e2 100644 --- a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/DatePlotDTO.java +++ b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/DatePlotDTO.java @@ -12,4 +12,5 @@ import java.util.Map; public class DatePlotDTO { private String district; private int plotcount; + private int sampleplotcount; } diff --git a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Mapper/DateMapper.java b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Mapper/DateMapper.java new file mode 100644 index 0000000..56b0032 --- /dev/null +++ b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Mapper/DateMapper.java @@ -0,0 +1,14 @@ +package com.whu.edu.LyStatistic.MapLyStatistic.Mapper; +import com.whu.edu.LyStatistic.MapLyStatistic.Dto.DatePlotDTO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + +@Mapper +public interface DateMapper { + + List finishedPlot(@Param("date") Date date); + +} diff --git a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/DateService.java b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/DateService.java new file mode 100644 index 0000000..836f033 --- /dev/null +++ b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/DateService.java @@ -0,0 +1,29 @@ +package com.whu.edu.LyStatistic.MapLyStatistic.Service; + +import com.whu.edu.LyStatistic.MapLyStatistic.Dto.DatePlotDTO; +import com.whu.edu.LyStatistic.MapLyStatistic.Mapper.DateMapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +@Service +public class DateService { + @Autowired + private DateMapper dateMapper; // 查询 unit_info 表 + /** + * 查询小班属性 + * 条件:NYXBH + XIANG + */ + public List getPlotAttributes(Date date){ + List schema = dateMapper.finishedPlot(date); + if (schema == null) { + throw new RuntimeException("未找到对应时间的小班任务"); + } + return schema; + } + + +} diff --git a/src/main/resources/mapper/MapLyStatistic/Date.xml b/src/main/resources/mapper/MapLyStatistic/Date.xml index 25f3212..09ff582 100644 --- a/src/main/resources/mapper/MapLyStatistic/Date.xml +++ b/src/main/resources/mapper/MapLyStatistic/Date.xml @@ -3,12 +3,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - + SELECT + r.region AS district, + COUNT(*) 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" -- 连接样地表 + WHERE (m.reviewer != '-1' OR m.collector != '-1') + AND DATE(m.update_time) = #{date} + GROUP BY r.region + ORDER BY r.region