From 455b965c6435b5359bb5c25f2b6810dbc06f5481 Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期五, 13 二月 2026 17:56:39 +0800
Subject: [PATCH] Merge branch 'dev_New_kthg' of http://114.132.189.42:9002/r/product-inventory-management-after into dev_New_kthg

---
 src/main/java/com/ruoyi/collaborativeApproval/service/impl/NoticeServiceImpl.java |   45 +++++++++++++++++++++++++++++++++------------
 1 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/ruoyi/collaborativeApproval/service/impl/NoticeServiceImpl.java b/src/main/java/com/ruoyi/collaborativeApproval/service/impl/NoticeServiceImpl.java
index 8f2216b..0592318 100644
--- a/src/main/java/com/ruoyi/collaborativeApproval/service/impl/NoticeServiceImpl.java
+++ b/src/main/java/com/ruoyi/collaborativeApproval/service/impl/NoticeServiceImpl.java
@@ -1,6 +1,5 @@
 package com.ruoyi.collaborativeApproval.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -10,10 +9,13 @@
 import com.ruoyi.collaborativeApproval.service.NoticeService;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 @Service
 @Slf4j
@@ -24,22 +26,41 @@
 
     @Override
     public IPage<NoticeDTO> listPage(Page page, NoticeDTO noticeDTO) {
-        return noticeMapper.listPage(page, noticeDTO);
+        IPage<NoticeDTO> noticeDTOIPage = noticeMapper.listPage(page, noticeDTO);
+        noticeDTOIPage.getRecords().forEach(item -> {
+            // 鏍规嵁杩囨湡鏃堕棿鍒ゆ柇statusName
+            if (item.getExpirationDate() == null) {
+                item.setStatusName("鏈煡");
+            }else if(item.getExpirationDate().getTime() < System.currentTimeMillis()){
+                item.setStatusName("宸茶繃鏈�");
+            } else{
+                item.setStatusName("姝e父");
+            }
+        });
+        return noticeDTOIPage;
     }
 
     @Override
     public List<NoticeDTO> selectCount() {
+        List<Notice> noticesList = noticeMapper.selectList(null);
+        Map<String, Notice> uniqueByType = noticesList.stream()
+                .collect(Collectors.toMap(
+                        Notice::getType,
+                        n -> n,
+                        (existing, replacement) -> existing
+                ));
+
+        List<Notice> notices = new ArrayList<>(uniqueByType.values());
+        Map<String, Long> countMap = noticesList.stream().collect(Collectors.groupingBy(Notice::getType, Collectors.counting()));
         List<NoticeDTO> result = new ArrayList<>();
-        NoticeDTO notice = new NoticeDTO();
-        notice.setType(1);
-        notice.setCount(noticeMapper.selectCount(new LambdaQueryWrapper<Notice>().eq(Notice::getType, 1)));
-        result.add(notice);
-
-        NoticeDTO notice1 = new NoticeDTO();
-        notice1.setType(2);
-        notice1.setCount(noticeMapper.selectCount(new LambdaQueryWrapper<Notice>().eq(Notice::getType, 2)));
-        result.add(notice1);
-
+        for (Notice notice : notices) {
+            NoticeDTO notice1 = new NoticeDTO();
+            BeanUtils.copyProperties(notice, notice1);
+            if (countMap.containsKey(notice.getType())) {
+                notice1.setCount(countMap.get(notice.getType()) == null ? 0 : countMap.get(notice.getType()));
+            }
+            result.add(notice1);
+        }
         return result;
     }
 }

--
Gitblit v1.9.3