From dc29f2f4f03cb93367b759c38c7e98c358e1f90e Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 29 一月 2026 16:01:20 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/ProjectCategoryCalculator.java        |    2 
 ruoyi-system/src/main/java/com/ruoyi/system/model/AccidentBrief.java                      |    7 +--
 ruoyi-system/src/main/java/com/ruoyi/system/query/HiddenDangerListQuery.java              |    2 
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ClientServiceImpl.java           |   46 ++++++++++++----------
 ruoyi-system/src/main/java/com/ruoyi/system/vo/HiddenDangerListVo.java                    |    3 +
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DashboardStatisticsController.java |    8 ++++
 ruoyi-system/src/main/java/com/ruoyi/system/query/StoryListQuery.java                     |    6 +++
 ruoyi-system/src/main/resources/mapper/system/ProjectMapper.xml                           |    2 
 8 files changed, 48 insertions(+), 28 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DashboardStatisticsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DashboardStatisticsController.java
index 05489a3..5ad5ee3 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DashboardStatisticsController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DashboardStatisticsController.java
@@ -114,9 +114,17 @@
         List<AccidentClassification> list = accidentClassificationService.list(new LambdaQueryWrapper<AccidentClassification>().eq(AccidentClassification::getDeleted, false));
         LambdaQueryWrapper<AccidentBrief> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(AccidentBrief::getState,1);
+        wrapper.eq(AccidentBrief::getDeleted,false);
         if(query.getCity()!=null && !query.getCity().isEmpty()){
             wrapper.eq(AccidentBrief::getCity, query.getCity());
         }
+        if(query.getProvince()!=null && !query.getProvince().isEmpty()){
+            wrapper.eq(AccidentBrief::getProvince, query.getProvince());
+        }
+        if(query.getArea()!=null && !query.getArea().isEmpty()){
+            wrapper.eq(AccidentBrief::getArea, query.getArea());
+        }
+
         if(query.getClassifyId()!=null){
             wrapper.eq(AccidentBrief::getClassifyId, query.getClassifyId());
         }
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/model/AccidentBrief.java b/ruoyi-system/src/main/java/com/ruoyi/system/model/AccidentBrief.java
index c99a8b2..d7cb60b 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/model/AccidentBrief.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/model/AccidentBrief.java
@@ -1,11 +1,9 @@
 package com.ruoyi.system.model;
 
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.*;
+
 import java.time.LocalDate;
-import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
-import com.baomidou.mybatisplus.annotation.TableField;
 import java.io.Serializable;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -80,6 +78,7 @@
 
     @ApiModelProperty(value = "false正常true删除")
     @TableField("deleted")
+    @TableLogic
     private Boolean deleted;
 
     @TableField("create_time")
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/query/HiddenDangerListQuery.java b/ruoyi-system/src/main/java/com/ruoyi/system/query/HiddenDangerListQuery.java
index 3111e8c..1011fff 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/query/HiddenDangerListQuery.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/query/HiddenDangerListQuery.java
@@ -17,7 +17,7 @@
     @ApiModelProperty("隐患类型 1=安全 2=设备")
     private Integer type;
 
-    @ApiModelProperty("整改情况 1已整改 0未整改")
+    @ApiModelProperty("整改情况 0未整改  1部分整改  2已整改")
     private Integer reformed;
 
     @ApiModelProperty("开始时间")
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/query/StoryListQuery.java b/ruoyi-system/src/main/java/com/ruoyi/system/query/StoryListQuery.java
index 321c8a7..254decb 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/query/StoryListQuery.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/query/StoryListQuery.java
@@ -11,6 +11,12 @@
     @ApiModelProperty("城市")
     private String city;
 
+    @ApiModelProperty("省")
+    private String province;
+
+    @ApiModelProperty("区")
+    private String area;
+
     @ApiModelProperty("类型id")
     private Integer classifyId;
 
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ProjectCategoryCalculator.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ProjectCategoryCalculator.java
index 0a9d2b5..52d76bc 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ProjectCategoryCalculator.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ProjectCategoryCalculator.java
@@ -558,7 +558,7 @@
                             break;
                         }
                     }
-                    //短路与开关
+                    //短路或开关
                     // if (!matchesRule) {
                     //     break;
                     // }
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ClientServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ClientServiceImpl.java
index beb7d39..7d0d324 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ClientServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ClientServiceImpl.java
@@ -1,6 +1,7 @@
 package com.ruoyi.system.service.impl;
 
 
+import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
@@ -21,7 +22,6 @@
 import java.time.LocalDate;
 import java.time.YearMonth;
 import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -86,9 +86,10 @@
                 .ne(Project::getType, 2) // 在建工程
                 .and(wrapper -> wrapper
                     .eq(Project::getStatus, 1)  // 在建项目
+                        .between(Project::getCreateTime, monthStart, monthEnd)
                     .or(w -> w
                         .eq(Project::getStatus, 2)  // 已完成项目
-                        .ge(Project::getSuccessTime, monthStart)  // 完成时间 >= 开始日期// 完成时间 <= 结束日期
+                        .between(Project::getSuccessTime, monthStart,monthEnd)  // 完成时间 >= 开始日期// 完成时间 <= 结束日期
                     )
                 );
         if (clientId != null) {
@@ -193,7 +194,7 @@
         calculateMonthlyInspectionForOngoing(vo, projects, projectIds, monthStart, monthEnd);
 
         // 3. 统计大型机械设备数
-        List<MachineryStatisticsVO> machineryStatistics = calculateMachineryStatistics(projectIds);
+        List<MachineryStatisticsVO> machineryStatistics = calculateMachineryStatistics(projectIds, monthStart, monthEnd);
         vo.setMachineryStatistics(machineryStatistics);
 
         // 汇总计算设备总数统计
@@ -229,13 +230,14 @@
         // 查询固定资产项目
         LambdaQueryWrapper<Project> projectWrapper = new LambdaQueryWrapper<>();
         projectWrapper.eq(Project::getDeleted, false)
-                .eq(Project::getType, 2) // 固定资产
+                .eq(Project::getType, 2) // 在建工程
                 .and(wrapper -> wrapper
-                    .eq(Project::getStatus, 1)  // 在建项目
-                    .or(w -> w
-                        .eq(Project::getStatus, 2)  // 已完成项目
-                        .ge(Project::getSuccessTime, monthStart)  // 完成时间 >= 开始日期
-                    )
+                        .eq(Project::getStatus, 1)  // 在建项目
+                        .between(Project::getCreateTime, monthStart, monthEnd)
+                        .or(w -> w
+                                .eq(Project::getStatus, 2)  // 已完成项目
+                                .between(Project::getSuccessTime, monthStart,monthEnd)  // 完成时间 >= 开始日期// 完成时间 <= 结束日期
+                        )
                 );
         if (clientId != null) {
             projectWrapper.eq(Project::getClientId, clientId);
@@ -393,7 +395,7 @@
     /**
      * 统计大型机械设备数(含已检查/未检查)
      */
-    private List<MachineryStatisticsVO> calculateMachineryStatistics(List<Integer> projectIds) {
+    private List<MachineryStatisticsVO> calculateMachineryStatistics(List<Integer> projectIds, Date monthStart, Date monthEnd) {
         if (projectIds.isEmpty()) {
             return new ArrayList<>();
         }
@@ -402,10 +404,10 @@
         LambdaQueryWrapper<DeviceUsage> deviceWrapper = new LambdaQueryWrapper<>();
         deviceWrapper.eq(DeviceUsage::getDeleted, false)
                 .in(DeviceUsage::getProjectId, projectIds);
-        List<DeviceUsage> devices = deviceUsageMapper.selectList(deviceWrapper);
+        List<DeviceUsage> deviceUsages = deviceUsageMapper.selectList(deviceWrapper);
 
         // 批量查询 Device 信息
-        List<Integer> deviceIds = devices.stream()
+        List<Integer> deviceIds = deviceUsages.stream()
                 .map(DeviceUsage::getDeviceId)
                 .filter(Objects::nonNull)
                 .distinct()
@@ -427,7 +429,7 @@
 
         // 按设备类型名称分组统计
         final Map<Integer, Device> finalDeviceMap = deviceMap;
-        Map<String, List<DeviceUsage>> deviceGroupMap = devices.stream()
+        Map<String, List<DeviceUsage>> deviceGroupMap = deviceUsages.stream()
                 .filter(d -> d.getDeviceId() != null)
                 .filter(d -> finalDeviceMap.containsKey(d.getDeviceId()))
                 .collect(Collectors.groupingBy(d -> {
@@ -444,7 +446,7 @@
 
         // 查询设备检查记录
         // 建立 device.id 到 device_usage.id 的映射
-        Map<Integer, List<Integer>> deviceToUsageMap = devices.stream()
+        Map<Integer, List<Integer>> deviceToUsageMap = deviceUsages.stream()
                 .filter(d -> d.getDeviceId() != null)
                 .collect(Collectors.groupingBy(
                         DeviceUsage::getDeviceId,
@@ -457,7 +459,8 @@
             recordWrapper.eq(Record::getRecordType, "error")
                     .isNotNull(Record::getDeviceId)
                     .in(Record::getDeviceId, deviceIds)
-                    .eq(Record::getDeleted, false);
+                    .eq(Record::getDeleted, false)
+                    .between(Record::getCreateTime, monthStart, monthEnd);
             List<Record> records = recordMapper.selectList(recordWrapper);
 
             // 获取已检查的 device.id 集合
@@ -666,11 +669,12 @@
      */
     private Date getStartDate(Date startDate) {
         if (startDate != null) {
-            return startDate;
+            return DateUtil.beginOfDay(startDate);
         }
         // 默认为当前月份第一天
-        YearMonth currentMonth = YearMonth.now();
-        return Date.from(currentMonth.atDay(1).atStartOfDay(ZoneId.systemDefault()).toInstant());
+        Date date = new Date();
+        return DateUtil.beginOfMonth(date);
+
     }
 
     /**
@@ -678,11 +682,11 @@
      */
     private Date getEndDate(Date endDate) {
         if (endDate != null) {
-            return endDate;
+            return DateUtil.endOfDay(endDate);
         }
         // 默认为当前月份最后一天
-        YearMonth currentMonth = YearMonth.now();
-        return Date.from(currentMonth.atEndOfMonth().atTime(23, 59, 59).atZone(ZoneId.systemDefault()).toInstant());
+        Date date = new Date();
+        return DateUtil.endOfMonth(date);
     }
 
     /**
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/vo/HiddenDangerListVo.java b/ruoyi-system/src/main/java/com/ruoyi/system/vo/HiddenDangerListVo.java
index f9999d0..2bcd1cf 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/vo/HiddenDangerListVo.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/vo/HiddenDangerListVo.java
@@ -60,4 +60,7 @@
     @ApiModelProperty("责任人")
     private String responsiblePerson;
 
+    @ApiModelProperty("0未整改  1部分整改  2已整改  3未复查")
+    private Integer state=3;
+
 }
diff --git a/ruoyi-system/src/main/resources/mapper/system/ProjectMapper.xml b/ruoyi-system/src/main/resources/mapper/system/ProjectMapper.xml
index 2d04038..ba59c08 100644
--- a/ruoyi-system/src/main/resources/mapper/system/ProjectMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/ProjectMapper.xml
@@ -43,7 +43,7 @@
             <if test="query.endTime != null and query.endTime != ''">
                 and  #{query.endTime} >=t1.date
             </if>
-
+            GROUP BY t2.id
             order by t1.date desc
 
 

--
Gitblit v1.7.1