From e755e9d98e2a284e19d548aad9540129dfd950ec Mon Sep 17 00:00:00 2001 From: wuleyan <1175424873@qq.com> Date: Fri, 28 Nov 2025 18:33:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B7=E5=9C=B0+=E6=A0=B7=E6=9C=A8=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/StatisticsController.java | 49 +++++++++++++-- .../MapLyStatistic/Dto/T1sub1DTO.java | 56 +++++++++++++++++ .../MapLyStatistic/Dto/T1sub2DTO.java | 25 ++++++++ .../MapLyStatistic/Mapper/AttrMapper.java | 20 ++++++ .../MapLyStatistic/Mapper/PlotMapper.java | 15 ----- .../MapLyStatistic/Service/AttrService.java | 62 +++++++++++++++++++ .../MapLyStatistic/Service/PlotService.java | 33 ---------- .../Service/StatisticsService.java | 52 ++++++++-------- .../MapLyStatistic/{Plot.xml => Attr.xml} | 18 +++++- 9 files changed, 248 insertions(+), 82 deletions(-) create mode 100644 src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/T1sub1DTO.java create mode 100644 src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/T1sub2DTO.java create mode 100644 src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Mapper/AttrMapper.java delete mode 100644 src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Mapper/PlotMapper.java create mode 100644 src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/AttrService.java delete mode 100644 src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/PlotService.java rename src/main/resources/mapper/MapLyStatistic/{Plot.xml => Attr.xml} (56%) 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 07c2437..d09735d 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 @@ -2,7 +2,7 @@ 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.PlotService; +import com.whu.edu.LyStatistic.MapLyStatistic.Service.AttrService; import com.whu.edu.LyStatistic.MapLyStatistic.Service.DateService; import com.whu.edu.LyStatistic.Util.ApiResponse; import org.springframework.beans.factory.annotation.Autowired; @@ -24,17 +24,48 @@ public class StatisticsController { @Autowired private StatisticsService statisticsService; @Autowired - private PlotService plotService; + private AttrService attrService; @Autowired private DateService dateService; /** * 小班属性 * 入参:内业小班号NYXBH+乡XIANG + * 出参:小班的所有属性+媒体数据 */ @GetMapping("/plot/attr") public ApiResponse getPlotAttr(@RequestParam String nyxbh, @RequestParam String xiang) { try { - PlotAttrDTO data = plotService.getPlotAttributes(nyxbh, xiang); + PlotAttrDTO data = attrService.getPlotAttributes(nyxbh, xiang); + return ApiResponse.success(data); + } catch (Exception e) { + return ApiResponse.error("查询小班属性失败:" + e.getMessage()); + } + } + + /** + * t1sub1样地属性 + * 入参:database_name+ID + * 出参:t1sub1内所有值、t1sub1_media中的媒体数据 + */ + @GetMapping("/t1sub1") + public ApiResponse getT1sub1(@RequestParam String database, @RequestParam String id) { + try { + T1sub1DTO data = attrService.getT1sub1(database, id); + return ApiResponse.success(data); + } catch (Exception e) { + return ApiResponse.error("查询小班属性失败:" + e.getMessage()); + } + } + + /** + * t1sub2样木属性 + * 入参:database_name+ID + * 出参:t1sub2内所有值 + */ + @GetMapping("/t1sub2") + public ApiResponse getT1sub2(@RequestParam String database, @RequestParam String id) { + try { + T1sub2DTO data = attrService.getT1sub2(database, id); return ApiResponse.success(data); } catch (Exception e) { return ApiResponse.error("查询小班属性失败:" + e.getMessage()); @@ -42,9 +73,13 @@ public class StatisticsController { } + /** - * 小班属性 - * 入参:内业小班号NYXBH+乡XIANG + * 按日期返回已完成的小班数和样地数 + * 入参:date yyyy-MM-dd + * 出参:"district": "区名", + * "plotcount": 小班数, + * "sampleplotcount": 样地数 */ @GetMapping("/date") public ApiResponse> getPlotAttr( @@ -78,6 +113,7 @@ public class StatisticsController { /** * 小班计数 * 入参:rootid,databasename + * 出参:样木数等 */ @GetMapping("/plot/count") public ApiResponse getPlotCount(@RequestParam String rootId, @RequestParam String databaseName) { @@ -92,6 +128,9 @@ public class StatisticsController { /** * 区级统计 + * 出参:"completionStatus": 完成状态 + * "plotArea"小班面积 + * "plotCount"小班数量 */ @GetMapping("/district") public ApiResponse getDistrictStats() { diff --git a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/T1sub1DTO.java b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/T1sub1DTO.java new file mode 100644 index 0000000..10870f9 --- /dev/null +++ b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/T1sub1DTO.java @@ -0,0 +1,56 @@ +package com.whu.edu.LyStatistic.MapLyStatistic.Dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class T1sub1DTO { + private String databaseName; + private String id; + private String bz; + private String mgqxj; + + // 对应 MGQZS + private String mgqzs; + + // 对应 PJ_XJ + private String pjXj; + + // 对应 TYPE + private String type; + + // 对应 YDZXJ + private String ydzxj; + + // 对应 ZS + private String zs; + + // 对应 angle + private String angle; + + // 对应 area + private String area; + + // 对应 length + private String length; + + // 对应 parentID (建议转为 parentId) + private String parentId; + + // 对应 shape + private String shape; + + // 对应 version + private String version; + + // 对应 width + private String width; + private List mediaPathList; + // 这里需要生成getter和setter方法 + // 可以使用IDE自动生成或Lombok注解 +} diff --git a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/T1sub2DTO.java b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/T1sub2DTO.java new file mode 100644 index 0000000..260e354 --- /dev/null +++ b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/T1sub2DTO.java @@ -0,0 +1,25 @@ +package com.whu.edu.LyStatistic.MapLyStatistic.Dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class T1sub2DTO { + private String databaseName; + private String grandparentid; + private String cjl; + private String id; + private String sz; + private String type; + private String type2; + private String xj; + private String ymh; + private String parentId; + private String photo; + private String version; +} diff --git a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Mapper/AttrMapper.java b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Mapper/AttrMapper.java new file mode 100644 index 0000000..9772b75 --- /dev/null +++ b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Mapper/AttrMapper.java @@ -0,0 +1,20 @@ +package com.whu.edu.LyStatistic.MapLyStatistic.Mapper; +import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotAttrDTO; +import com.whu.edu.LyStatistic.MapLyStatistic.Dto.T1sub1DTO; +import com.whu.edu.LyStatistic.MapLyStatistic.Dto.T1sub2DTO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +@Mapper +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 findMediaPaths(@Param("id") String id, + @Param("databaseName") String databaseName, + @Param("table") String table); +} diff --git a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Mapper/PlotMapper.java b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Mapper/PlotMapper.java deleted file mode 100644 index cd4bff5..0000000 --- a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Mapper/PlotMapper.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.whu.edu.LyStatistic.MapLyStatistic.Mapper; -import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotAttrDTO; -import com.whu.edu.LyStatistic.MapLyStatistic.Dto.UnitInfo; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -@Mapper -public interface PlotMapper { - - PlotAttrDTO findPlotAttributes(@Param("nyxbh") String nyxbh,@Param("xiang") String xiang); - List findMediaPaths(@Param("id") String id, - @Param("databaseName") String databaseName); -} diff --git a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/AttrService.java b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/AttrService.java new file mode 100644 index 0000000..a81d2b2 --- /dev/null +++ b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/AttrService.java @@ -0,0 +1,62 @@ +package com.whu.edu.LyStatistic.MapLyStatistic.Service; + +import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotAttrDTO; +import com.whu.edu.LyStatistic.MapLyStatistic.Dto.T1sub1DTO; +import com.whu.edu.LyStatistic.MapLyStatistic.Dto.T1sub2DTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.whu.edu.LyStatistic.MapLyStatistic.Mapper.AttrMapper; + +import java.util.List; +@Service +public class AttrService { + @Autowired + private AttrMapper attrMapper; // 查询 unit_info 表 + /** + * 查询小班属性 + * 条件:NYXBH + XIANG + */ + public PlotAttrDTO getPlotAttributes(String nyxbh, String xiang){ + // ① 通过 NYXBH + XIANG + PlotAttrDTO schema = attrMapper.findPlotAttributes(nyxbh, xiang); + if (schema == null) { + throw new RuntimeException("未找到对应的小班所在任务 schema"); + } + + // 第二次查 media_path 列表 + List mediaPaths = attrMapper.findMediaPaths(schema.getId(), schema.getDatabaseName(),"merged.roottable1_media_merged"); + + // 设置到 DTO 中 + schema.setMediaPathList(mediaPaths); + + return schema; + } + /** + * t1sub1样地属性 + * 入参:database_name+ID + * 出参:t1sub1内所有值、t1sub1_media中的媒体数据 + */ + public T1sub1DTO getT1sub1(String database, String id){ + T1sub1DTO schema = attrMapper.findT1sub1(database, id); + if (schema == null) { + throw new RuntimeException("未找到对应的样地所在任务 schema"); + } + + // 第二次查 media_path 列表 + List mediaPaths = attrMapper.findMediaPaths(schema.getId(), schema.getDatabaseName(),"merged.t1sub1_media_merged"); + + // 设置到 DTO 中 + schema.setMediaPathList(mediaPaths); + + return schema; + } + + + public T1sub2DTO getT1sub2(String database, String id){ + T1sub2DTO schema = attrMapper.findT1sub2(database, id); + if (schema == null) { + throw new RuntimeException("未找到对应的样木所在任务 schema"); + } + return schema; + } +} diff --git a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/PlotService.java b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/PlotService.java deleted file mode 100644 index 882a897..0000000 --- a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/PlotService.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.whu.edu.LyStatistic.MapLyStatistic.Service; - -import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotAttrDTO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.whu.edu.LyStatistic.MapLyStatistic.Mapper.PlotMapper; -import java.util.List; -@Service -public class PlotService { - @Autowired - private PlotMapper plotMapper; // 查询 unit_info 表 - /** - * 查询小班属性 - * 条件:NYXBH + XIANG - */ - public PlotAttrDTO getPlotAttributes(String nyxbh, String xiang){ - // ① 通过 NYXBH + XIANG - PlotAttrDTO schema = plotMapper.findPlotAttributes(nyxbh, xiang); - if (schema == null) { - throw new RuntimeException("未找到对应的小班所在任务 schema"); - } - - // 第二次查 media_path 列表 - List mediaPaths = plotMapper.findMediaPaths(schema.getId(), schema.getDatabaseName()); - - // 设置到 DTO 中 - schema.setMediaPathList(mediaPaths); - - return 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 6285686..a93a09b 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 @@ -145,30 +145,30 @@ public class StatisticsService { // // return totalBoundaries; // } - - - // ✅ 防止 null 值累加 - private int safeInt(Integer value) { - return (value != null) ? value : 0; - } - - private double safeDouble(Double value) { - return (value != null) ? value : 0.0; - } - - - /** - * 合并两个 PlotStatsDTO - */ - private void merge(PlotStatsDTO total, PlotStatsDTO add) { - if (add == null) return; - - total.setPlotCount(total.getPlotCount() + add.getPlotCount()); - total.setTotalArea(total.getTotalArea() + add.getTotalArea()); - -// total.setUnPassedCount(total.getUnPassedCount() + add.getUnPassedCount()); -// total.setAssignedCount(total.getAssignedCount() + add.getAssignedCount()); - total.setCollectedCount(total.getCollectedCount() + add.getCollectedCount()); - total.setPublishedUncollectedCount(total.getPublishedUncollectedCount() + add.getPublishedUncollectedCount()); - } +// +// +// // ✅ 防止 null 值累加 +// private int safeInt(Integer value) { +// return (value != null) ? value : 0; +// } +// +// private double safeDouble(Double value) { +// return (value != null) ? value : 0.0; +// } +// +// +// /** +// * 合并两个 PlotStatsDTO +// */ +// private void merge(PlotStatsDTO total, PlotStatsDTO add) { +// if (add == null) return; +// +// total.setPlotCount(total.getPlotCount() + add.getPlotCount()); +// total.setTotalArea(total.getTotalArea() + add.getTotalArea()); +// +//// total.setUnPassedCount(total.getUnPassedCount() + add.getUnPassedCount()); +//// total.setAssignedCount(total.getAssignedCount() + add.getAssignedCount()); +// total.setCollectedCount(total.getCollectedCount() + add.getCollectedCount()); +// total.setPublishedUncollectedCount(total.getPublishedUncollectedCount() + add.getPublishedUncollectedCount()); +// } } diff --git a/src/main/resources/mapper/MapLyStatistic/Plot.xml b/src/main/resources/mapper/MapLyStatistic/Attr.xml similarity index 56% rename from src/main/resources/mapper/MapLyStatistic/Plot.xml rename to src/main/resources/mapper/MapLyStatistic/Attr.xml index 4419881..6460ee0 100644 --- a/src/main/resources/mapper/MapLyStatistic/Plot.xml +++ b/src/main/resources/mapper/MapLyStatistic/Attr.xml @@ -3,7 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + + + - +