cqp 1 ay önce
ebeveyn
işleme
83449d433e

+ 28 - 2
app/Exports/ProjectDepreciationSheetExport.php

@@ -79,7 +79,7 @@ class ProjectDepreciationSheetExport implements WithEvents, WithTitle
                     $dataRowsCount = count($items);
                     foreach ($items as $index => $item) {
                         $sheet->setCellValue("A{$currentRow}", $index + 1);
-                        $sheet->setCellValue("B{$currentRow}", $item['name'] ?? '');
+                        $sheet->setCellValue("B{$currentRow}", $item['device_name'] ?? '');
                         $sheet->setCellValue("C{$currentRow}", $item['total_hours'] ?? 0);
                         $sheet->setCellValue("D{$currentRow}", $item['project_hours'] ?? 0);
                         $sheet->setCellValue("E{$currentRow}", ($item['ratio'] ?? 0) . '%');
@@ -103,7 +103,33 @@ class ProjectDepreciationSheetExport implements WithEvents, WithTitle
                     // 5. 合计行
                     $sheet->setCellValue("A{$currentRow}", "合计");
                     $sheet->mergeCells("A{$currentRow}:B{$currentRow}");
-                    // 这里可以填充合计逻辑...
+
+                    $total = 0;
+                    $totalProjectHours = 0;
+                    $totalOriginalValue = 0;
+                    $totalDepreciation = 0;
+                    $totalConfirmedDepreciation = 0;
+                    $totalAdjustAmount = 0;
+
+                    foreach ($items as $item) {
+                        $total += ($item['total_hours'] ?? 0);
+                        $totalProjectHours += ($item['project_hours'] ?? 0);
+                        $totalOriginalValue += ($item['original_value'] ?? 0);
+                        $totalDepreciation += ($item['depreciation'] ?? 0);
+                        $totalConfirmedDepreciation += ($item['confirmed_depreciation'] ?? 0);
+                        $totalAdjustAmount += ($item['adjust_amount'] ?? 0);
+                    }
+
+                    $sheet->setCellValue("C{$currentRow}", $total);
+                    $sheet->setCellValue("D{$currentRow}", $totalProjectHours);
+                    $sheet->setCellValue("F{$currentRow}", $totalOriginalValue);
+                    $sheet->setCellValue("G{$currentRow}", $totalDepreciation);
+                    $sheet->setCellValue("H{$currentRow}", $totalConfirmedDepreciation);
+                    $sheet->setCellValue("J{$currentRow}", $totalAdjustAmount);
+
+                    // 设置合计行样式:加粗
+                    $sheet->getStyle("A{$currentRow}:J{$currentRow}")->getFont()->setBold(true);
+
                     $currentRow++;
 
                     // 6. 备注

+ 3 - 3
app/Service/ExportFileService.php

@@ -578,10 +578,10 @@ class ExportFileService extends Service
         $finalExportData = [];
 
         foreach ($groupedData as $itemCode => $itemRecords) {
-            $projectName = $itemRecords->first()['item_title'] ?? '';
+            $firstRecord = $itemRecords->first();
+            $projectName = $firstRecord['item_title'];
 
-            // 2. 获取年份(从 order_month 字段提取,如 "2026-01" 取前4位)
-            $firstMonth = $firstRecord['month'] ?? date('Y-m');
+            $firstMonth = $firstRecord['month'];
             $year = substr($firstMonth, 0, 4);
 
             // 3. 构造新的 Key:年-项目 (例如: 2026-53code)