cqp před 2 měsíci
rodič
revize
7c41ed6e13

+ 8 - 2
app/Service/DeviceWorkService.php

@@ -1073,6 +1073,7 @@ class DeviceWorkService extends Service
             ->join('rule_set as r', 'r.id', '=', 'rd.main_id')
             ->where('r.month', $monthStart)
             ->where('rd.type', RuleSetDetails::type_two) // 设备类型
+            ->where('rd.top_depart_id', $topDepartId)
             ->where('r.del_time', 0)
             ->where('rd.del_time', 0)
             ->select('rd.*')
@@ -1089,11 +1090,16 @@ class DeviceWorkService extends Service
 
         // 标准班次 & 日历 (逻辑同前)
         $standardWorkRanges = DB::table('work_range_details')
-            ->where('top_depart_id', $topDepartId)->where('del_time', 0)->get();
+            ->where('top_depart_id', $topDepartId)
+            ->where('del_time', 0)
+            ->get();
         $dayMaxAvail = (int)$standardWorkRanges->sum('total_work_min');
 
         $workDays = DB::table('calendar_details')
-            ->where('month', $monthStart)->where('is_work', 1)->where('del_time', 0)
+            ->where('top_depart_id', $topDepartId)
+            ->where('month', $monthStart)
+            ->where('is_work', 1)
+            ->where('del_time', 0)
             ->orderBy('time', 'asc')->get();
 
         if ($workDays->isEmpty()) return ['status' => false, 'msg' => '未配置工作日历'];

+ 16 - 5
app/Service/PersonWorkService.php

@@ -1148,12 +1148,23 @@ class PersonWorkService extends Service
             ->groupBy('data_id');
 
         // 加载员工/标准班次、日历、请假加班数据 (逻辑同前)
-        $empWorkRanges = DB::table('employee_work_range')->whereIn('employee_id', $empIds)->where('top_depart_id', $topDepartId)->get()->groupBy('employee_id');
-        $standardWorkRanges = DB::table('work_range_details')->where('top_depart_id', $topDepartId)->where('del_time', 0)->get();
-        $allDays = DB::table('calendar_details')->where('month', $monthStart)->where('del_time', 0)->orderBy('time', 'asc')->get();
+        $empWorkRanges = DB::table('employee_work_range')
+            ->whereIn('employee_id', $empIds)
+            ->where('top_depart_id', $topDepartId)
+            ->get()->groupBy('employee_id');
+        $standardWorkRanges = DB::table('work_range_details')->where('top_depart_id', $topDepartId)
+            ->where('del_time', 0)->get();
+        $allDays = DB::table('calendar_details')->where('top_depart_id', $topDepartId)
+            ->where('month', $monthStart)
+            ->where('del_time', 0)
+            ->orderBy('time', 'asc')
+            ->get();
         $leaveOverData = DB::table('p_leave_over_order_details as d')->join('p_leave_over_order as m', 'd.main_id', '=', 'm.id')
-            ->whereBetween('m.order_time', [$monthStart, $monthEnd])->where('m.del_time', 0)
-            ->select('d.*', 'm.order_time', 'm.type as main_type')->get()->groupBy(['employee_id', 'order_time']);
+            ->whereBetween('m.order_time', [$monthStart, $monthEnd])
+            ->where('d.top_depart_id', $topDepartId)
+            ->where('m.del_time', 0)
+            ->select('d.*', 'm.order_time', 'm.type as main_type')
+            ->get()->groupBy(['employee_id', 'order_time']);
 
         // --- 2. 阶段一:计算每个人每天在每个项目上应分配的整数分钟数 ---
         $finalAlloc = [];