From ede6b613d721a6fa6977b105bda3c1fed8e0f658 Mon Sep 17 00:00:00 2001 From: wuleyan <1175424873@qq.com> Date: Thu, 27 Nov 2025 17:05:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=8C=BA=E7=BA=A7=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=8C=87=E6=A0=87=E8=AE=A1=E7=AE=97=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/StatisticsController.java | 10 ++++---- .../MapLyStatistic/Dto/DatePlotDTO.java | 15 ++++++++++++ .../MapLyStatistic/Dto/PlotStatsDTO.java | 10 ++++---- .../BaseService/BaseTaskQueryService.java | 4 ++-- .../Service/StatisticsService.java | 6 ++--- .../resources/mapper/MapLyStatistic/Date.xml | 24 +++++++++++++++++++ .../MapLyStatistic/TaskCommonMapper.xml | 15 +++++++++++- 7 files changed, 69 insertions(+), 15 deletions(-) create mode 100644 src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/DatePlotDTO.java create mode 100644 src/main/resources/mapper/MapLyStatistic/Date.xml 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 41d6cad..ccb1e76 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 @@ -66,12 +66,12 @@ public class StatisticsController { // 计算完成状态 String status; - if (safeInt(stats.getApprovedCount()) > 0) { - status = "已完成"; - } else if (safeInt(stats.getCollectedCount()) > 0) { - status = "未完成"; + if (safeInt(stats.getCollectedCount()) > 0) { + status = "已采集"; + } else if (safeInt(stats.getCollectedCount()) == 0 && safeInt(stats.getPublishedUncollectedCount()) > 0) { + status = "已发布未开始"; } else { - status = "未开始"; + status = "未发布"; } completionStatus.put(district, status); 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 new file mode 100644 index 0000000..dda6c94 --- /dev/null +++ b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/DatePlotDTO.java @@ -0,0 +1,15 @@ +package com.whu.edu.LyStatistic.MapLyStatistic.Dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DatePlotDTO { + private String district; + private int plotcount; +} diff --git a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/PlotStatsDTO.java b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/PlotStatsDTO.java index be001aa..fffc6cc 100644 --- a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/PlotStatsDTO.java +++ b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Dto/PlotStatsDTO.java @@ -13,9 +13,11 @@ public class PlotStatsDTO { private Integer plotCount; // 图斑总数量 private Double totalArea; // 图斑总面积(sum XBMJ) - private Integer unPassedCount; // -1 审核未通过 - private Integer assignedCount; // 0 已分配,未审核 - private Integer collectedCount; // 1 已采集,未审核 - private Integer approvedCount; // 2 已审核 +// private Integer unPassedCount; // -1 审核未通过 +// private Integer assignedCount; // 0 已分配,未审核 +// private Integer collectedCount; // 1 已采集,未审核 +// private Integer approvedCount; // 2 已审核 + private Integer collectedCount; // collector/reviewer有一个不是-1:已采集 + private Integer publishedUncollectedCount; // collector/reviewer均为-1:已发布未采集 } diff --git a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/BaseService/BaseTaskQueryService.java b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/BaseService/BaseTaskQueryService.java index 50a1f3e..0d72983 100644 --- a/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/BaseService/BaseTaskQueryService.java +++ b/src/main/java/com/whu/edu/LyStatistic/MapLyStatistic/Service/BaseService/BaseTaskQueryService.java @@ -21,13 +21,13 @@ public class BaseTaskQueryService { PlotStatsDTO stats = taskCommonMapper.selectPlotStats(schema); if (stats == null) { // 防止 mapper 返回 null - return new PlotStatsDTO( "0", 0, 0.0, 0, 0, 0, 0); + return new PlotStatsDTO( "0", 0, 0.0, 0, 0); } return stats; } catch (Exception e) { // 表不存在或 schema 不存在,直接跳过 // 不管是什么异常,都返回默认统计,保证批量统计不被中断 - return new PlotStatsDTO( "0", 00, 0.0, 0, 0, 0, 0); + return new PlotStatsDTO( "0", 00, 0.0, 0, 0); } } 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 7d06ee4..2fcf1e4 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 @@ -188,9 +188,9 @@ public class StatisticsService { 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.setUnPassedCount(total.getUnPassedCount() + add.getUnPassedCount()); +// total.setAssignedCount(total.getAssignedCount() + add.getAssignedCount()); total.setCollectedCount(total.getCollectedCount() + add.getCollectedCount()); - total.setApprovedCount(total.getApprovedCount() + add.getApprovedCount()); + total.setPublishedUncollectedCount(total.getPublishedUncollectedCount() + add.getPublishedUncollectedCount()); } } diff --git a/src/main/resources/mapper/MapLyStatistic/Date.xml b/src/main/resources/mapper/MapLyStatistic/Date.xml new file mode 100644 index 0000000..25f3212 --- /dev/null +++ b/src/main/resources/mapper/MapLyStatistic/Date.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + diff --git a/src/main/resources/mapper/MapLyStatistic/TaskCommonMapper.xml b/src/main/resources/mapper/MapLyStatistic/TaskCommonMapper.xml index 728e2c3..c30983a 100644 --- a/src/main/resources/mapper/MapLyStatistic/TaskCommonMapper.xml +++ b/src/main/resources/mapper/MapLyStatistic/TaskCommonMapper.xml @@ -37,7 +37,20 @@ -- 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, - COALESCE(SUM(CASE WHEN m."status"::int = 1 THEN 1 ELSE 0 END), 0) AS collectedCount, + + -- 新的状态统计逻辑 + -- 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