Browse Source

超节损运算优化

qiuenguang 1 year ago
parent
commit
93c78acf10
1 changed files with 18 additions and 8 deletions
  1. 18 8
      application/api/controller/OrderSuperLoss.php

+ 18 - 8
application/api/controller/OrderSuperLoss.php

@@ -392,11 +392,21 @@ class OrderSuperLoss extends Api
         $data['warehousing_num'] = $cp_data[0]['cp_sl'];
         $data['warehousing_date'] = substr($cp_data[0]['jjcp_sj'],0,10);
         //查出进入超节损的工序,有上报产量的工序就进入超节损
-        $gxh_sql = "SELECT sczl_gxh FROM 
-                        (SELECT sczl_gxh FROM 设备_产量计酬 WHERE sczl_gdbh = '{$order}' AND sczl_yjno = '{$params['yjno']}' 
-                        UNION SELECT sczl_gxh FROM db_sczl WHERE sczl_gdbh = '{$order}' AND sczl_yjno = '{$params['yjno']}') AS combined_result";
-        $gxh_arr = Db::query($gxh_sql);
+//        $gxh_sql = "SELECT sczl_gxh FROM
+//                        (SELECT sczl_gxh FROM 设备_产量计酬 WHERE sczl_gdbh = '{$order}' AND sczl_yjno = '{$params['yjno']}'
+//                        UNION SELECT sczl_gxh FROM db_sczl WHERE sczl_gdbh = '{$order}' AND sczl_yjno = '{$params['yjno']}') AS combined_result";
+//        $gxh_arr = Db::query($gxh_sql);
+        $gxh_arr = \db('工单_工艺资料')
+            ->where('Gy0_gdbh',$order)
+            ->where('Gy0_yjno',$params['yjno'])
+            ->field('Gy0_gxh as sczl_gxh')
+            ->select();
         $gxh_values = array_column($gxh_arr, 'sczl_gxh');
+        foreach ($gxh_values as $k=>$v){
+            if ((int)$v < 10){
+                $gxh_values[$k] = '0'.$v;
+            }
+        }
         $gy_data =db('工单_工艺资料')
             ->alias('a')
             ->field([
@@ -472,12 +482,12 @@ class OrderSuperLoss extends Api
                         $l++;
                     }
                 }
-                if (!empty($entry[$bhKey])) {
-                    if ($entry[$bhKey] != '000000' && $entry[$slKey] > 0){
+//                if (!empty($entry[$bhKey])) {
+//                    if ($entry[$bhKey] != '000000' && $entry[$slKey] > 0){
                         $quality[$m]= $entry[$slKey];
                         $m++;
-                    }
-                }
+//                    }
+//                }
 
             }
         }