Просмотр исходного кода

产品年度投入产出率统计优化

unknown 5 месяцев назад
Родитель
Сommit
60855b79a7
1 измененных файлов с 13 добавлено и 15 удалено
  1. 13 15
      application/api/controller/Achievementatestatistics.php

+ 13 - 15
application/api/controller/Achievementatestatistics.php

@@ -807,7 +807,6 @@ class  Achievementatestatistics extends Api
             ->where('YEAR(Sys_rq)', $rq)
             ->where($where)
             ->select();
-
         if (empty($qualityData)) {
             $this->success('未查询到数据', []);
         }
@@ -964,20 +963,20 @@ class  Achievementatestatistics extends Api
 
         // 3. 按月份分组累计数据
         $monthlyData = [];
-        $monthNames = [
-            1 => '1月', 2 => '2月', 3 => '3月', 4 => '4月',
-            5 => '5月', 6 => '6月', 7 => '7月', 8 => '8月',
-            9 => '9月', 10 => '10月', 11 => '11月', 12 => '12月'
-        ];
+//        $monthNames = [
+//            1 => '1月', 2 => '2月', 3 => '3月', 4 => '4月',
+//            5 => '5月', 6 => '6月', 7 => '7月', 8 => '8月',
+//            9 => '9月', 10 => '10月', 11 => '11月', 12 => '12月'
+//        ];
 
         foreach ($uniqueByGongdan as $gdbh => $data) {
             $sysRq = $data['入仓日期'];
             $month = date('n', strtotime($sysRq)); // 1-12 的月份数字
 
             // 初始化月份数据
-            if (!isset($monthlyData[$month])) {
-                $monthlyData[$month] = [
-                    '月份' => $monthNames[$month],
+            if (!isset($monthlyData[$data['工单编号']])) {
+                $monthlyData[$data['工单编号']] = [
+                    '月份' => $month,
                     '订单数量' => 0,
                     '实际投料' => 0,
                     '入仓数量' => 0,
@@ -990,14 +989,13 @@ class  Achievementatestatistics extends Api
                 ];
             }
 
-            $monthlyData[$month]['订单数量'] += round($data['订单数量'] * 10000);
-            $monthlyData[$month]['实际投料'] += round($data['实际投料'] * 10000);
-            $monthlyData[$month]['入仓数量'] += round($data['入仓数量']);
+            $monthlyData[$data['工单编号']]['订单数量'] += round($data['订单数量'] * 10000);
+            $monthlyData[$data['工单编号']]['实际投料'] += round($data['实际投料'] * 10000);
+            $monthlyData[$data['工单编号']]['入仓数量'] += round($data['入仓数量']);
 
             // 记录工单编号
-            $monthlyData[$month]['工单编号'][] = $data['工单编号'];
+            $monthlyData[$data['工单编号']]['工单编号'] = $data['工单编号'];
         }
-
         // 4. 计算每个月的实际合格率并整理结果
         $detailList = [];
         foreach ($monthlyData as $month => $monthData) {
@@ -1023,7 +1021,7 @@ class  Achievementatestatistics extends Api
                 '产品代号' => $monthData['产品代号'],
                 '产品名称' => $monthData['产品名称'],
                 '销售订单号' => $monthData['销售订单号'],
-                '工单编号' => implode(', ', $monthData['工单编号'])
+                '工单编号' => $monthData['工单编号']
             ];
         }