From 4922e5fb02c3a095791a6f6e65c70883054fa3d9 Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期五, 28 三月 2025 16:45:22 +0800
Subject: [PATCH] bug修改

---
 medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwMicroEquipmentRecordServiceImpl.java |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwMicroEquipmentRecordServiceImpl.java b/medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwMicroEquipmentRecordServiceImpl.java
index ec4b822..dd2aca7 100644
--- a/medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwMicroEquipmentRecordServiceImpl.java
+++ b/medicalWaste-system/src/main/java/com/sinata/system/service/impl/MwMicroEquipmentRecordServiceImpl.java
@@ -256,6 +256,57 @@
             departmentReportItemVO.getData().add(totalCount);
             result.add(departmentReportItemVO);
         }
+
+        // 添加合计行
+        if (!result.isEmpty()) {
+            DepartmentReportItemVO totalRow = new DepartmentReportItemVO();
+            totalRow.setName("合计");
+            totalRow.setData(new ArrayList<>());
+
+            // 计算各类型废物的重量和数量总计
+            for (SysDictData sysDictData : medicalWasteTypeList) {
+                BigDecimal totalTypeWeight = BigDecimal.ZERO;
+                BigDecimal totalTypeCount = BigDecimal.ZERO;
+
+                for (DepartmentReportItemVO item : result) {
+                    // 每种废物类型占用两列(重量和数量)
+                    int index = medicalWasteTypeList.indexOf(sysDictData);
+                    int weightIndex = index * 2;
+                    int countIndex = weightIndex + 1;
+
+                    if (weightIndex < item.getData().size()) {
+                        totalTypeWeight = totalTypeWeight.add(item.getData().get(weightIndex));
+                    }
+                    if (countIndex < item.getData().size()) {
+                        totalTypeCount = totalTypeCount.add(item.getData().get(countIndex));
+                    }
+                }
+
+                totalRow.getData().add(totalTypeWeight);
+                totalRow.getData().add(totalTypeCount);
+            }
+
+            // 计算总的重量和数量
+            BigDecimal finalTotalWeight = BigDecimal.ZERO;
+            BigDecimal finalTotalCount = BigDecimal.ZERO;
+
+            for (DepartmentReportItemVO item : result) {
+                int totalWeightIndex = item.getData().size() - 2;
+                int totalCountIndex = item.getData().size() - 1;
+
+                if (totalWeightIndex >= 0 && totalCountIndex >= 0) {
+                    finalTotalWeight = finalTotalWeight.add(item.getData().get(totalWeightIndex));
+                    finalTotalCount = finalTotalCount.add(item.getData().get(totalCountIndex));
+                }
+            }
+
+            totalRow.getData().add(finalTotalWeight);
+            totalRow.getData().add(finalTotalCount);
+
+            // 将合计行添加到列表开头
+            result.add(0, totalRow);
+        }
+
         vo.setList(result);
         return vo;
     }

--
Gitblit v1.7.1