cqp 2 місяців тому
батько
коміт
60f4a57110
1 змінених файлів з 5 додано та 3 видалено
  1. 5 3
      app/Service/DispatchService.php

+ 5 - 3
app/Service/DispatchService.php

@@ -471,7 +471,7 @@ class DispatchService extends Service
         $map = $this->getDispatchQuantity(array_column($data['data'],'id'));
         $emp_map = Employee::whereIn('id',array_column($data['data'],'crt_id'))
             ->pluck('emp_name','id')
-            ->toArray();
+            ->toArray();dd($map);
 
         $tech = Technology::where('id',9)->first();
         $process_id_str = "";
@@ -489,7 +489,8 @@ class DispatchService extends Service
             $last_process = end($tmp);
             $dispatch_quantity = $last_process['dispatch_quantity'] ?? 0;
             $data['data'][$key]['dispatch_quantity'] = $dispatch_quantity;
-            $data['data'][$key]['not_dispatch_quantity'] = bcsub($value['production_quantity'], $dispatch_quantity,3);
+            $not_dispatch_quantity = bcsub($value['production_quantity'], $dispatch_quantity,3);
+            $data['data'][$key]['not_dispatch_quantity'] = $not_dispatch_quantity >= 0 ? $not_dispatch_quantity : 0;
             $data['data'][$key]['out_order_no_time'] = $value['out_order_no_time'] ? date('Y-m-d',$value['out_order_no_time']) : '';
             $data['data'][$key]['out_checker_time'] = $value['out_checker_time'] ? date('Y-m-d',$value['out_checker_time']) : '';
             $data['data'][$key]['production_time'] = $value['production_time'] ? date('Y-m-d',$value['production_time']) : '';
@@ -544,7 +545,8 @@ class DispatchService extends Service
         foreach ($result as $value){
             $key = $value['order_product_id'] . $value['process_id'];
             if(isset($return[$key])){
-                $return[$key] += $value['dispatch_quantity'];
+                $tmp = bcadd($return[$key],$value['dispatch_quantity'],3);
+                $return[$key] = $tmp;
             }else{
                 $return[$key] = $value['dispatch_quantity'];
             }