From 98b6c80ce7ef744462cb496a41884b6dfadadba5 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期三, 21 一月 2026 11:09:29 +0800
Subject: [PATCH] 大屏项目接口

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ProjectInfoServiceImpl.java |   33 ++++++++++++++++++++++++++++++---
 1 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ProjectInfoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ProjectInfoServiceImpl.java
index b613943..e007aba 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ProjectInfoServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ProjectInfoServiceImpl.java
@@ -12,6 +12,8 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.LocalDate;
 import java.time.temporal.TemporalAdjusters;
 import java.util.List;
@@ -45,12 +47,37 @@
         }
 
 
+        LocalDate thisMonth = LocalDate.now().minusMonths(0).with(TemporalAdjusters.firstDayOfMonth());
+        Map<String, List<Record>> map = list.stream().collect(groupingBy(Record::getHierarchyName));
+        List<ProjectHiddenDangerTrendVo> collect = map.entrySet().stream().map(entry -> {
+            ProjectHiddenDangerTrendVo vo = new ProjectHiddenDangerTrendVo();
+            vo.setName(entry.getKey());
+            List<Record> value = entry.getValue();
+            long count = value.stream().filter(record -> record.getCreateTime().isAfter(thisMonth.atStartOfDay())).count();
+            // 根据value集合中的createTime 选出本月的数据
+            vo.setThisMonth((int) count);
+            vo.setLastMonth(value.size()-(int) count);
 
-        return List.of();
+            int num = vo.getThisMonth() - vo.getLastMonth();
+            if (num != 0) {
+                if(vo.getLastMonth()>0){
+                    String rate = BigDecimal.valueOf(num).divide(BigDecimal.valueOf(vo.getLastMonth()), 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).toString();
+                    vo.setRate(rate);
+                }else {
+                    vo.setRate("100.00");
+                }
+            }else {
+                vo.setRate("0.00");
+            }
+            return vo;
+        }).toList();
+
+
+        return collect;
     }
 
     public static void main(String[] args) {
-        LocalDate lastMonth = LocalDate.now().minusMonths(1).with(TemporalAdjusters.firstDayOfMonth());
-        System.out.println(LocalDate.now()+" 23:59:59");
+        LocalDate lastMonth = LocalDate.now().minusMonths(0).with(TemporalAdjusters.firstDayOfMonth());
+        System.out.println(lastMonth+" 23:59:59");
     }
 }

--
Gitblit v1.7.1