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