|
|
@@ -9,6 +9,7 @@ use App\Model\Device;
|
|
|
use App\Model\Employee;
|
|
|
use App\Model\EmployeeRole;
|
|
|
use App\Model\Item;
|
|
|
+use App\Model\ItemDetails;
|
|
|
use App\Model\RevenueCost;
|
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
|
|
|
|
@@ -266,6 +267,9 @@ class ExportFileService extends Service
|
|
|
|
|
|
$item_total = Item::where('del_time', 0)->where('is_use', 1)->select('code', 'id','start_time','end_time')->get()->toArray();
|
|
|
|
|
|
+ $time_array = ItemDetails::where('del_time',0)
|
|
|
+ ->pluck('total_hours', 'device_id')
|
|
|
+ ->all();
|
|
|
// 生成起止时间行
|
|
|
$timeRow = $this->getItemTimeRow($column, $item_total);
|
|
|
|
|
|
@@ -274,7 +278,7 @@ class ExportFileService extends Service
|
|
|
|
|
|
$month = date("Y.m", $timeRange[0]);
|
|
|
// --- 1. 处理全月汇总 Sheet ---
|
|
|
- $summaryData = $service->statisticsDeviceFillExportData($rawData, $timeRange, $device, $item_total,true);
|
|
|
+ $summaryData = $service->statisticsDeviceFillExportData($rawData, $timeRange, $device, $item_total,true,$time_array);
|
|
|
// 格式化数据:只取 header 中定义的列,并按顺序排列
|
|
|
$finalExportData[$month . '合计'] = $this->formatSheetData($header, $column, $summaryData);
|
|
|
|
|
|
@@ -288,7 +292,7 @@ class ExportFileService extends Service
|
|
|
foreach ($dataByDay as $date => $dayRows) {
|
|
|
$dayTimestamp = strtotime($date);
|
|
|
// 这里调用你的填充逻辑
|
|
|
- $dayResult = $service->statisticsDeviceFillExportData($dayRows, [$dayTimestamp], $device, $item_total);
|
|
|
+ $dayResult = $service->statisticsDeviceFillExportData($dayRows, [$dayTimestamp], $device, $item_total,false, $time_array);
|
|
|
// 格式化并存入结果集
|
|
|
$finalExportData[date('Y.m.d',$dayTimestamp)] = $this->formatSheetData($header, $column, $dayResult);
|
|
|
}
|