Browse Source

设备达成率优化

unknown 6 months ago
parent
commit
40e5304a3d
1 changed files with 27 additions and 8 deletions
  1. 27 8
      application/api/controller/Achievementatestatistics.php

+ 27 - 8
application/api/controller/Achievementatestatistics.php

@@ -323,20 +323,37 @@ class  Achievementatestatistics extends Api
                 'a.sczl_异常停机工时 as 异常总工时',
                 'a.sczl_异常工时1 as 异常补时',
                 'a.sczl_设备运行工时 as 运行工时',
-                'c.排单小时定额 as 小时产能'
+                'c.排单小时定额 as 小时产能',
+                'c.平均车速'
             ])
             ->join('设备_基本资料 c', 'a.sczl_jtbh = c.设备编号')
             ->whereIn('a.sczl_jtbh', $devices)
             ->where('a.sczl_rq', 'like', $ym . '%')
             ->select();
-
         // 分组汇总:按 机台编号 + 班组
         $resultList = [];
         foreach ($records as $row) {
             $jtbh = $row['机台编号'];
             $bz = $row['班组'] ?: '未分组';
             $key = $jtbh . '|' . $bz;
-
+            if ($row['运行工时'] >= 8) {
+                $row['运行工时'] = $row['运行工时'] - 1;
+            }elseif ($row['运行工时'] < 8 && $row['运行工时'] > 4) {
+                $row['运行工时'] = $row['运行工时'] - 0.5;
+            }
+            if (strpos($row['机台编号'],'YJY') !== false) {
+                $plate_hours = $row['装板补产工时'] * 1.7;
+                $plate_mounting_hours = $row['装板实际工时'] * 1.5;
+                if ($plate_hours < $plate_mounting_hours) {
+                    $row['装板补产工时'] = $plate_hours;
+                }elseif ($plate_hours > $plate_mounting_hours) {
+                    $row['装板补产工时'] = $plate_mounting_hours;
+                }elseif ($row['装板补产工时'] > $plate_mounting_hours) {
+                    $row['装板补产工时'] = $row['装板补产工时'];
+                }else{
+                    $row['装板补产工时'] = $plate_hours;
+                }
+            }
             if (!isset($resultList[$key])) {
                 $resultList[$key] = [
                     '机台编号' => $jtbh,
@@ -354,7 +371,8 @@ class  Achievementatestatistics extends Api
                     // 新增字段
                     '目标产量' => 0,
                     '负荷产量' => 0,
-                    '小时产能' => $row['小时产能']
+                    '小时产能' => $row['小时产能'],
+                    '平均车速' => $row['平均车速']
                 ];
             }
 
@@ -369,7 +387,6 @@ class  Achievementatestatistics extends Api
             $resultList[$key]['异常补时'] += floatval($row['异常补时']);
             $resultList[$key]['运行工时'] += floatval($row['运行工时']);
         }
-
         // 汇总并计算目标/负荷产量及达成率
         $grouped = []; // [机台编号 => [班组数据...]]
         foreach ($resultList as $item) {
@@ -397,9 +414,9 @@ class  Achievementatestatistics extends Api
             ];
             foreach ($rows as &$row) {
                 // 计算目标 & 负荷产量
-                $有效工时 = max(0, $row['运行工时'] - $row['保养工时'] - $row['装板补产工时'] - $row['异常总工时']);
+                $有效工时 = max(0, $row['运行工时'] - $row['保养工时'] - $row['装板补产工时'] - $row['异常总工时'] - $row['打样补产工时']);
                 $row['目标产量'] = round($有效工时 * $row['小时产能'], 2);
-                $row['负荷产量'] = $row['目标产量'];
+                $row['负荷产量'] = round($有效工时 * $row['平均车速'], 2);
 
                 // 计算达成率 & 利用率
                 $row['目标达成'] = ($row['目标产量'] > 0)
@@ -482,10 +499,12 @@ class  Achievementatestatistics extends Api
                 'SUM(a.sczl_异常工时1) as 异常补时',
                 'SUM(a.sczl_设备运行工时) as 运行工时',
                 'c.排单小时定额 as 小时产能',
-                'c.平均车速'
+                'c.平均车速',
+                'd.工价系数 as 难度系数'
             ])
             ->join('工单_印件资料 b', 'a.sczl_gdbh = b.Yj_Gdbh AND a.sczl_yjno = b.Yj_YjNo', 'LEFT') // 添加印件号关联条件
             ->join('设备_基本资料 c', 'a.sczl_jtbh = c.设备编号')
+            ->join('工单_工艺资料 d', 'a.sczl_gdbh = d.Gy0_gdbh AND a.sczl_yjno = d.Gy0_yjno AND a.sczl_gxh = d.Gy0_gxh', 'LEFT')
             ->where('a.sczl_jtbh', $jtbh)
             ->whereLike('a.sczl_rq', $ym . '%')
             ->group('a.sczl_rq, a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, a.sczl_jtbh ,a.sczl_bzdh') // 确保唯一性分组