cqp 1 天之前
父節點
當前提交
c668dea571
共有 2 個文件被更改,包括 19 次插入16 次删除
  1. 8 5
      app/Service/ReportFormsService.php
  2. 11 11
      app/Service/ScrappService.php

+ 8 - 5
app/Service/ReportFormsService.php

@@ -443,6 +443,7 @@ class ReportFormsService extends Service
             }
         }unset($orderList);
 
+
         //查询分表数据
         $production_id = array_keys($list);
         $detail = [];
@@ -466,6 +467,7 @@ class ReportFormsService extends Service
 //        }
         $scrapp = ScrappCount::where('del_time',0)
             ->whereIn('order_product_id',$production_id)
+            ->where('scrapp_num','>',0)
             ->select('order_product_id','scrapp_num as bad_goods_num')
             ->get()->toArray();
         foreach ($scrapp as $value){
@@ -479,10 +481,10 @@ class ReportFormsService extends Service
 
         //返回统计数据
         foreach ($list as $key => $value) {
+            $del_num = $detail[$value['id']] ?? 0;
+            if(floatval($del_num) <= 0.0) unset($list[$key]);
             $list[$key]['production_time'] = $value['production_time'] ? date('Y-m-d',$value['production_time']) : '';
             $list[$key]['out_order_no_time'] = $value['out_order_no_time'] ? date('Y-m-d',$value['out_order_no_time']) : '';
-
-            $del_num = $detail[$value['id']] ?? 0;
             $list[$key]['bad_goods_num'] = $del_num;
             $list[$key]['rate'] = $value['production_quantity'] > 0 ? bcdiv($del_num ,$value['production_quantity'], 2) : 0;
         }
@@ -612,6 +614,7 @@ class ReportFormsService extends Service
         $detail = [];
         $scrapp = ScrappCount::where('del_time',0)
             ->whereIn('order_product_id',$production_id)
+            ->where('scrapp_num','>',0)
             ->select('order_product_id','scrapp_num as bad_goods_num')
             ->get()->toArray();
         foreach ($scrapp as $value){
@@ -644,11 +647,11 @@ class ReportFormsService extends Service
         //返回统计数据
 
         foreach ($list as $key => $value) {
-            $list[$key]['production_time'] = $value['production_time'] ? date('Y-m-d',$value['production_time']) : '';
-            $list[$key]['out_order_no_time'] = $value['out_order_no_time'] ? date('Y-m-d',$value['out_order_no_time']) : '';
-
             $del_num = $detail[$value['id']] ?? 0;
+            if(floatval($del_num) <= 0.0) unset($list[$key]);
             $list[$key]['bad_goods_num'] = $del_num;
+            $list[$key]['production_time'] = $value['production_time'] ? date('Y-m-d',$value['production_time']) : '';
+            $list[$key]['out_order_no_time'] = $value['out_order_no_time'] ? date('Y-m-d',$value['out_order_no_time']) : '';
             $list[$key]['rate'] = $value['production_quantity'] > 0 ? bcdiv($del_num ,$value['production_quantity'], 2) : 0;
         }
 

+ 11 - 11
app/Service/ScrappService.php

@@ -211,8 +211,8 @@ class ScrappService extends Service
         $sales_number = SaleOrdersProduct::whereIn('id',array_unique(array_column($data['data'],'sale_orders_product_id')))
             ->pluck('out_order_no','id')
             ->toArray();
-        $dispatch_no = DispatchSub::whereIn('id',array_column($data['data'], 'dispatch_sub_id'))
-            ->pluck('dispatch_no','id')
+        $dispatch_no = ReportWorking::whereIn('id',array_column($data['data'], 'report_id'))
+            ->pluck('order_number','id')
             ->toArray();
         $return = [];
         if(! empty($erg['material'])){
@@ -230,7 +230,7 @@ class ScrappService extends Service
             $data['data'][$key]['equipment_title'] = $equipment_map[$value['equipment_id']] ?? '';
             $data['data'][$key]['process_title'] = $process_map[$value['process_id']] ?? '';
             $data['data'][$key]['sale_order_number'] = $sales_number[$value['sale_orders_product_id']] ?? "";
-            $dispatch_t = $dispatch_no[$value['dispatch_sub_id']] ?? "";
+            $dispatch_t = $dispatch_no[$value['report_id']] ?? "";
             $data['data'][$key]['dispatch_no'] = $dispatch_t;
 //            $data['data'][$key]['crt_time'] = date("Y-m-d",strtotime(substr($dispatch_t,0,8)));
         }
@@ -251,9 +251,9 @@ class ScrappService extends Service
         $order['team_title'] = Team::where('id',$first['team_id'])->value("title");
         $order['finished_title'] = Employee::where('id',$first['finished_id'])->value("emp_name");
         $order['equipment_title'] = Equipment::where('id',$first['equipment_id'])->value("title");
-        $dispatch = DispatchSub::where('id',$first['dispatch_sub_id'])->first();
+        $dispatch = ReportWorking::where('id',$first['report_id'])->first();
         $dispatch = empty($dispatch) ? [] : $dispatch->toArray();
-        $order['dispatch_no'] = $dispatch['dispatch_no'] ?? "";
+        $order['dispatch_no'] = $dispatch['order_number'] ?? "";
         $order['crt_time'] = date("Y-m-d", $first['crt_time']);
 
         $team_man = EmployeeTeamPermission::where('team_id',$first['team_id'])
@@ -327,7 +327,7 @@ class ScrappService extends Service
     public function blpList($data, $user){
         $model = ScrappCount::where('del_time',0)
             ->where('scrapp_num','>',0)
-            ->select('id','dispatch_sub_id','crt_time','team_id','finished_id','equipment_id','order_number','process_id','sale_orders_product_id')
+            ->select('id','dispatch_sub_id','crt_time','team_id','finished_id','equipment_id','order_number','process_id','sale_orders_product_id','report_id')
             ->orderBy('dispatch_sub_id','desc')
             ->groupBy('order_number');
 
@@ -397,8 +397,8 @@ class ScrappService extends Service
         $sales_number = SaleOrdersProduct::whereIn('id',array_unique(array_column($data['data'],'sale_orders_product_id')))
             ->pluck('out_order_no','id')
             ->toArray();
-        $dispatch_no = DispatchSub::whereIn('id',array_column($data['data'], 'dispatch_sub_id'))
-            ->pluck('dispatch_no','id')
+        $dispatch_no = ReportWorking::whereIn('id',array_column($data['data'], 'report_id'))
+            ->pluck('order_number','id')
             ->toArray();
         foreach ($data['data'] as $key => $value){
             $data['data'][$key]['crt_time'] = $value['crt_time'] ? date("Y-m-d", $value['crt_time']) : '';
@@ -408,7 +408,7 @@ class ScrappService extends Service
             $data['data'][$key]['equipment_title'] = $equipment_map[$value['equipment_id']] ?? '';
             $data['data'][$key]['process_title'] = $process_map[$value['process_id']] ?? '';
             $data['data'][$key]['sale_order_number'] = $sales_number[$value['sale_orders_product_id']] ?? "";
-            $dispatch_t = $dispatch_no[$value['dispatch_sub_id']] ?? "";
+            $dispatch_t = $dispatch_no[$value['report_id']] ?? "";
             $data['data'][$key]['dispatch_no'] = $dispatch_t;
 //            $data['data'][$key]['crt_time'] = date("Y-m-d",strtotime(substr($dispatch_t,0,8)));
         }
@@ -429,9 +429,9 @@ class ScrappService extends Service
         $order['team_title'] = Team::where('id',$first['team_id'])->value("title");
         $order['finished_title'] = Employee::where('id',$first['finished_id'])->value("emp_name");
         $order['equipment_title'] = Equipment::where('id',$first['equipment_id'])->value("title");
-        $dispatch = DispatchSub::where('id',$first['dispatch_sub_id'])->first();
+        $dispatch = ReportWorking::where('id',$first['report_id'])->first();
         $dispatch = empty($dispatch) ? [] : $dispatch->toArray();
-        $order['dispatch_no'] = $dispatch['dispatch_no'] ?? "";
+        $order['dispatch_no'] = $dispatch['order_number'] ?? "";
         $order['crt_time'] = date("Y-m-d",$first['crt_time']);
 
         $team_man = EmployeeTeamPermission::where('team_id',$first['team_id'])