cqpCow 2 years ago
parent
commit
02a7298efa

+ 19 - 0
app/Model/DispatchEmpSub.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ *
+ * Class Unit
+ * @package App\Models
+ */
+class DispatchEmpSub extends Model
+{
+    protected $table = "dispatch_emp_sub"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+
+}

+ 146 - 54
app/Service/DispatchService.php

@@ -3,6 +3,7 @@
 namespace App\Service;
 
 use App\Model\Dispatch;
+use App\Model\DispatchEmpSub;
 use App\Model\DispatchSub;
 use App\Model\Employee;
 use App\Model\EmployeeTeamPermission;
@@ -51,7 +52,7 @@ class DispatchService extends Service
             DB::beginTransaction();
 
             //主表
-            Dispatch::insert(['dispatch_no' => $dispatch_no,'process_id' => $data['process_id'],'equipment_id' => $data['equipment_id'], 'team_id' => $data['team_id'],'dispatch_time_start' => $data['dispatch_time'][0],'dispatch_time_end' => $data['dispatch_time'][1], 'crt_time' => time()]);
+            Dispatch::insert(['dispatch_no' => $dispatch_no,'crt_time' => time()]);
 
             //生产数据的源数据
             $result = $msg;
@@ -61,18 +62,25 @@ class DispatchService extends Service
             $process_model = new OrdersProductProcess(['channel' => $time_tmp]);
 
             $time = time();
+            $equipment_id = is_array($data['equipment_id']) ? $data['equipment_id'] : [$data['equipment_id']];
+            $equipment_id = array_filter($equipment_id);
+            $team_id = is_array($data['team_id']) ? $data['team_id'] : [$data['team_id']];
+            $team_id = array_filter($team_id);
+
+            $insert_emp_sub = [];
             foreach ($result as $key => $value){
                 $quantity_tmp = $data['quantity'][$key];
                 $result[$key]['dispatch_no'] = $dispatch_no;
                 $result[$key]['process_id'] = $data['process_id'];
-                $result[$key]['equipment_id'] = $data['equipment_id'];
-                $result[$key]['team_id'] = $data['team_id'];
                 $result[$key]['dispatch_time_start'] = $data['dispatch_time'][0];
                 $result[$key]['dispatch_time_end'] = $data['dispatch_time'][1];
                 $result[$key]['dispatch_quantity'] = $quantity_tmp;
                 $result[$key]['crt_time'] = $time;
                 $result[$key]['crt_id'] = $user['id'];
 
+                $tmp = $this->makeData($equipment_id,$team_id,$data['employee_id'],$result[$key]);
+                $insert_emp_sub = array_merge_recursive($insert_emp_sub,$tmp);
+
                 $process_model->where('order_product_id',$value['order_product_id'])
                     ->where('process_id',$data['process_id'])
                     ->where('dispatch_no','')
@@ -85,6 +93,8 @@ class DispatchService extends Service
 
             DispatchSub::insert($result);
 
+            if(! empty($insert_emp_sub)) DispatchEmpSub::insert($insert_emp_sub);
+
             //反写已派工数量
             $this->writeDispatchQuantity(array_column($result,'order_product_id'));
 
@@ -97,6 +107,80 @@ class DispatchService extends Service
         return [true,'保存成功!'];
     }
 
+    public function makeData($equipment_id, $team_id,$employee_id,$message){
+        $arr = [];
+        if(! empty($equipment_id)){
+            foreach ($equipment_id as $v_e){
+                if(! empty($team_id)){
+                    foreach ($team_id as $t){
+                        if(! empty($employee_id)){
+                            foreach ($employee_id as $e){
+                                $arr[] = [
+                                    'equipment_id' => $v_e,
+                                    'team_id' => $t,
+                                    'employee_id' => $e,
+                                    'order_product_id' => $message['order_product_id'],
+                                    'dispatch_no' => $message['dispatch_no'],
+                                ];
+                            }
+                        }else{
+                            $arr[] = [
+                                'equipment_id' => $v_e,
+                                'team_id' => $t,
+                                'order_product_id' => $message['order_product_id'],
+                                'dispatch_no' => $message['dispatch_no'],
+                            ];
+                        }
+                    }
+                }elseif(! empty($employee_id)){
+                    foreach ($employee_id as $e){
+                        $arr[] = [
+                            'equipment_id' => $v_e,
+                            'employee_id' => $e,
+                            'order_product_id' => $message['order_product_id'],
+                            'dispatch_no' => $message['dispatch_no'],
+                        ];
+                    }
+                }else{
+                    $arr[] = [
+                        'equipment_id' => $v_e,
+                        'order_product_id' => $message['order_product_id'],
+                        'dispatch_no' => $message['dispatch_no'],
+                    ];
+                }
+            }
+        }elseif (! empty($team_id)){
+            foreach ($team_id as $t){
+                if(! empty($employee_id)){
+                    foreach ($employee_id as $e){
+                        $arr[] = [
+                            'team_id' => $t,
+                            'employee_id' => $e,
+                            'order_product_id' => $message['order_product_id'],
+                            'dispatch_no' => $message['dispatch_no'],
+                        ];
+                    }
+                }else{
+                    $arr[] = [
+                        'team_id' => $t,
+                        'order_product_id' => $message['order_product_id'],
+                        'dispatch_no' => $message['dispatch_no'],
+                    ];
+                }
+            }
+        }elseif(! empty($employee_id)){
+            foreach ($employee_id as $e){
+                $arr[] = [
+                    'employee_id' => $e,
+                    'order_product_id' => $message['order_product_id'],
+                    'dispatch_no' => $message['dispatch_no'],
+                ];
+            }
+        }
+
+        return $arr;
+    }
+
     public function del($data){
         if($this->isEmpty($data,'id')) return [false,'ID不能为空!'];
 
@@ -186,8 +270,6 @@ class DispatchService extends Service
         if(empty($data['dispatch_time'][0]) || empty($data['dispatch_time'][1])) return [false,'计划生产时间不能为空!'];
         if(empty($data['out_order_no_time'][0]) || empty($data['out_order_no_time'][1])) return [false,'制单时间不能为空!'];
         if($this->isEmpty($data,'process_id')) return [false,'工序不能为空!'];
-        if($this->isEmpty($data,'equipment_id')) return [false,'设备不能为空!'];
-        if($this->isEmpty($data,'team_id')) return [false,'班组不能为空!'];
 
         $result = OrdersProduct::whereIn('id',$data['id'])
             ->select('id as order_product_id','sale_orders_product_id','order_no','table_header_mark','product_no','product_title','product_size','product_unit','production_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','sale_orders_product_id','out_order_no_time')
@@ -247,28 +329,43 @@ class DispatchService extends Service
 
     public function dispatchOrderList($data){
         $model = DispatchSub::where('del_time',0)
-            ->select('id','order_no','table_header_mark','product_no','product_title','product_size','product_unit','dispatch_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','production_quantity','dispatch_no','status','crt_id','process_id','equipment_id','team_id','dispatch_time_start','dispatch_time_end','crt_time')
+            ->select('id','order_no','table_header_mark','product_no','product_title','product_size','product_unit','dispatch_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','production_quantity','dispatch_no','status','crt_id','process_id','dispatch_time_start','dispatch_time_end','crt_time','finished_num','waste_num')
             ->orderBy('id','desc');
 
+        if(isset($data['finished_num'])) $model->where('finished_num', '>',0);
+
         if(! empty($data['order_no'])) $model->where('order_no', 'LIKE', '%'.$data['order_no'].'%');
         if(! empty($data['dispatch_no'])) $model->where('dispatch_no', 'LIKE', '%'.$data['dispatch_no'].'%');
         if(! empty($data['process_id'])) $model->where('process_id',$data['process_id']);
-        if(! empty($data['team_id'])) $model->where('team_id',$data['team_id']);
-        if(! empty($data['equipment_id'])) $model->where('equipment_id',$data['equipment_id'].'%');
         if(! empty($data['technology_material'])) $model->where('technology_material', 'LIKE', '%'.$data['technology_material'].'%');
         if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) $model->whereBetween('crt_time',[$data['crt_time'][0],$data['crt_time'][1]]);
         if(! empty($data['dispatch_time'][0]) && ! empty($data['dispatch_time'][1])){
             $model->where('dispatch_time_start','<=',$data['dispatch_time'][0]);
             $model->where('dispatch_time_end','>=',$data['dispatch_time'][1]);
         }
+        if(! empty($data['team_id'])) {
+            $res = DispatchEmpSub::where('del_time',0)
+                ->where('team_id',$data['team_id'])
+                ->distinct()
+                ->select('dispatch_no')
+                ->get()->toArray();
+            $model->whereIn('dispatch_no',array_column($res,'dispatch_no'));
+        }
+        if(! empty($data['equipment_id'])) {
+            $res = DispatchEmpSub::where('del_time',0)
+                ->where('equipment_id',$data['equipment_id'])
+                ->distinct()
+                ->select('dispatch_no')
+                ->get()->toArray();
+            $model->whereIn('dispatch_no',array_column($res,'dispatch_no'));
+        }
         if(! empty($data['employee_id'])) {
-            $team_id = Employee::from('employee as a')
-                ->leftJoin('employee_team_permission as b','b.employee_id','a.id')
-                ->where('a.id', $data['employee_id'])
-                ->select('b.team_id')
+            $res = DispatchEmpSub::where('del_time',0)
+                ->where('employee_id',$data['employee_id'])
+                ->distinct()
+                ->select('dispatch_no')
                 ->get()->toArray();
-            $team_id = array_column($team_id,'team_id');
-            $model->where('team_id',$team_id ?? []);
+            $model->whereIn('dispatch_no',array_column($res,'dispatch_no'));
         }
 
         $list = $this->limit($model,'',$data);
@@ -280,34 +377,40 @@ class DispatchService extends Service
     public function fillDispatchOrderListData($data){
         if(empty($data['data'])) return $data;
 
-        $team = EmployeeTeamPermission::from('employee_team_permission as a')
-            ->leftJoin('employee as b','b.id','a.employee_id')
-            ->whereIn('a.team_id',array_column($data['data'],'team_id'))
-            ->select('b.emp_name','a.team_id')
-            ->get()
-            ->toArray();
-        $team_map = [];
-        if(! empty($team)){
-            foreach ($team as $value){
-                if(isset($team_map[$value['team_id']])){
-                    $team_map[$value['team_id']] .= ','. $value['emp_name'];
-                }else{
-                    $team_map[$value['team_id']] = $value['emp_name'];
-                }
+        $emp_sub = DispatchEmpSub::where('del_time',0)
+            ->whereIn('dispatch_no',array_column($data['data'],'dispatch_no'))
+            ->select('dispatch_no','equipment_id','team_id','employee_id')
+            ->get()->toArray();
+        if(! empty($emp_sub)){
+            $team_map = Team::whereIn('id',array_unique(array_column($emp_sub,'team_id')))
+                ->pluck('title','id')
+                ->toArray();
+            $equipment_map = Equipment::whereIn('id',array_unique(array_column($emp_sub,'equipment_id')))
+                ->pluck('title','id')
+                ->toArray();
+            $emp_map = Employee::whereIn('id',array_unique(array_column($emp_sub,'employee_id')))
+                ->pluck('emp_name','id')
+                ->toArray();
+
+            $equipment_map1 = $team_map1 = $employee_map1 = $employee_map2 = $equipment_map2 = $team_map2 =  [];
+            foreach ($emp_sub as $value){
+                $equipment_name = $equipment_map[$value['equipment_id']] ?? '';
+                $team_name = $team_map[$value['team_id']] ?? '';
+                $employee_name = $emp_map[$value['employee_id']] ?? '';
+
+                $equipment_map1[$value['dispatch_no']][] = $equipment_name;
+                $equipment_map2[$value['dispatch_no']][] = $value['equipment_id'];
+                $team_map1[$value['dispatch_no']][] = $team_name;
+                $team_map2[$value['dispatch_no']][] = $value['team_id'];
+                $employee_map1[$value['dispatch_no']][] = $employee_name;
+                $employee_map2[$value['dispatch_no']][] = $value['employee_id'];
             }
         }
 
         $process_map = Process::whereIn('id',array_column($data['data'],'process_id'))
             ->pluck('title','id')
             ->toArray();
-        $team_maps = Team::whereIn('id',array_column($data['data'],'team_id'))
-            ->pluck('title','id')
-            ->toArray();
-        $equipment_map = Equipment::whereIn('id',array_column($data['data'],'equipment_id'))
-            ->pluck('title','id')
-            ->toArray();
 
-        $finished_map = $this->getFinishedQuantity(array_column($data['data'],'id'));
         date_default_timezone_set("PRC");
         foreach ($data['data'] as $key => $value){
             $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d',$value['crt_time']) : '';
@@ -315,18 +418,21 @@ class DispatchService extends Service
             $time1 = $value['dispatch_time_start'] ? date('Y-m-d',$value['dispatch_time_start']) : '';
             $time2 = $value['dispatch_time_end'] ? date('Y-m-d',$value['dispatch_time_end']) : '';
             $data['data'][$key]['dispatch_time'] = $time1 . ' ' . $time2;
-            $data['data'][$key]['team_man'] = $team_map[$value['team_id']] ?? '';
             $data['data'][$key]['process_name'] = $process_map[$value['process_id']] ?? '';
-            $data['data'][$key]['team_name'] = $team_maps[$value['team_id']] ?? '';
-            $data['data'][$key]['equipment_name'] = $equipment_map[$value['equipment_id']] ?? '';
-            $data['data'][$key]['un_finished_quantity'] = $value['dispatch_quantity'] - ($finished_map[$value['id']] ?? 0);
+            $data['data'][$key]['team_man'] = implode(',',array_unique($employee_map1[$value['dispatch_no']]));
+            $data['data'][$key]['team_man_id'] = array_unique($employee_map2[$value['dispatch_no']]);
+            $data['data'][$key]['team_name'] = implode(',',array_unique($team_map1[$value['dispatch_no']]));
+            $data['data'][$key]['team_id'] = implode(',',array_unique($team_map2[$value['dispatch_no']]));
+            $data['data'][$key]['equipment_name'] = implode(',',array_unique($equipment_map1[$value['dispatch_no']]));
+            $data['data'][$key]['equipment_id'] = implode(',',array_unique($equipment_map2[$value['dispatch_no']]));
+            $data['data'][$key]['un_finished_quantity'] = $value['dispatch_quantity'] - $value['finished_num'];
         }
         $data['dispatch_quantity'] = array_sum(array_column($data['data'], 'dispatch_quantity'));
 
         return $data;
     }
 
-    //反写写工数量
+    //反写写工数量
     public function writeDispatchQuantity($order_product_id){
         if(empty($order_product_id)) return;
 
@@ -345,18 +451,4 @@ class DispatchService extends Service
             ]);
         }
     }
-
-    //返回已完工数量
-    public function getFinishedQuantity($dispatch_id = []){
-        if(empty($dispatch_id)) return [];
-
-        $result = FinishedOrderSub::where('del_time',0)
-            ->whereIn("dispatch_id",$dispatch_id)
-            ->select(DB::raw("sum(finished_num) as finished_num"),'dispatch_id')
-            ->groupby('dispatch_id')
-            ->pluck('finished_num','dispatch_id')
-            ->toArray();
-
-        return $result;
-    }
 }

+ 83 - 72
app/Service/FinishedOrderService.php

@@ -14,6 +14,7 @@ use App\Model\OrdersProduct;
 use App\Model\OrdersProductProcess;
 use App\Model\Process;
 use App\Model\SaleOrdersProduct;
+use App\Model\Scrapp;
 use App\Model\Team;
 use Illuminate\Support\Facades\DB;
 
@@ -49,30 +50,54 @@ class FinishedOrderService extends Service
         list($status,$msg) = $this->orderRule($data);
         if(!$status) return [$status,$msg];
 
-        $finished_no = $this->setOrderNO();
         try{
             DB::beginTransaction();
 
-            //主表
-            FinishedOrder::insert(['finished_no' => $finished_no, 'crt_time' => time()]);
+            $waste = [];
+            foreach ($data['waste'] as $key => $value){
+                $waste[$key] = array_sum(array_column($value,'num'));
+            }
 
             //生产数据的源数据
             $result = $msg;
             $time = time();
 
             date_default_timezone_set("PRC");
+
             foreach ($result as $key => $value){
                 $quantity_tmp = $data['quantity'][$key];
+                $finished_id_tmp = $data['finish_id'][$key];
+                $team_tmp = $data['team_id'][$key];
+                $equipment_id_tmp = $data['equipment_id'][$key];
 
-                $team_id_tmp = $data['team_id'][$key] ?? 0;
-                $equipment_id_tmp = $data['equipment_id'][$key] ?? 0;
+                $finished_num = $quantity_tmp + $value['finished_num'];
+                DispatchSub::where('id',$value['id'])
+                    ->update([
+                        'finished_num' => $finished_num,
+                        'waste_num' => $waste[$key]
+                    ]);
 
-                $result[$key]['team_id'] = $team_id_tmp;
-                $result[$key]['equipment_id'] = $equipment_id_tmp;
-                $result[$key]['finished_no'] = $finished_no;
-                $result[$key]['finished_num'] = $quantity_tmp;
-                $result[$key]['crt_time'] = $time;
-                $result[$key]['crt_id'] = $user['id'];
+                $insert_waste = [];
+                if(! empty($data['waste'][$key])){
+                    foreach ($data['waste'][$key] as $v){
+                        for($i = 0 ;$i < $v['num']; $i++){
+                            $insert_waste[] = [
+                                'order_product_id' => $value['order_product_id'],
+                                'order_no' => $value['order_no'],
+                                'product_no' => $value['product_no'],
+                                'product_title' => $value['product_title'],
+                                'process_id' => $value['process_id'],
+                                'crt_time' => $time,
+                                'dispatch_no' => $value['dispatch_no'],
+                                'status' => 4,
+                                'team_id' => $team_tmp,
+                                'finished_id' => $finished_id_tmp,
+                                'equipment_id' => $equipment_id_tmp,
+                                'scrapp_id' => $v['scrapp_id']
+                            ];
+                        }
+                    }
+                }
 
                 $process_model = new OrdersProductProcess(['channel' => date("Ymd",$value['out_order_no_time'])]);
                 $process_model->where('order_product_id',$value['order_product_id'])
@@ -80,29 +105,15 @@ class FinishedOrderService extends Service
                     ->where('dispatch_no',$value['dispatch_no'])
                     ->take($quantity_tmp)
                     ->update([
-                        'finished_no' => $finished_no,
-                        'status' => 2
+                        'finished_time' => $time,
+                        'status' => 2,
+                        'finished_id' => $finished_id_tmp,
+                        'team_id' => $team_tmp,
+                        'equipment_id' => $equipment_id_tmp
                     ]);
-            }
-
-            FinishedOrderSub::insert($result);
 
-            //获取上一次插入订单的所有id
-            $insert = [];
-            $last_insert_id = FinishedOrderSub::where('finished_no',$finished_no)->select('id')->get()->toArray();
-            $last_insert_id = array_column($last_insert_id,'id');
-            foreach ($data['waste'] as $key => $value){
-                foreach ($value as $v){
-                    if(empty($value)) continue;
-
-                    $insert[] = [
-                        'finished_order_id' => $last_insert_id[$key],
-                        'num' => $v['num'],
-                        'scrapp_id' => $v['scrapp_id']
-                    ];
-                }
+                if(! empty($insert_waste)) $process_model->insert($insert_waste);
             }
-            if(!empty($insert)) FinishedOrderScrapp::insert($insert);
 
             $this->writeFinishedQuantity(array_column($result,'sale_orders_product_id'));
 
@@ -122,7 +133,29 @@ class FinishedOrderService extends Service
     }
 
     public function orderDetail($data){
-        return [200,''];
+        if($this->isEmpty($data,'id')) return [false,'ID不能为空!'];
+
+        date_default_timezone_set("PRC");
+
+        $first = DispatchSub::where('id',$data['id'])->first();
+        $process_model = new OrdersProductProcess(['channel' => date("Ymd",$first->out_order_no_time)]);
+
+        $result = $process_model->where('del_time',0)
+            ->where('dispatch_no',$first->dispatch_no)
+            ->where('order_product_id',$first->order_product_id)
+            ->where('status',4)
+            ->select(DB::raw('count(id) as num'),'scrapp_id')
+            ->groupBy('scrapp_id')
+            ->get()->toArray();
+
+        $map = Scrapp::whereIn('id',array_column($result,'scrapp_id'))
+            ->pluck('title','id')
+            ->toArray();
+        foreach ($result as $key => $value){
+            $result[$key]['scrapp_name'] = $map[$value['scrapp_id']] ?? '';
+        }
+
+        return [true,$result];
     }
 
     public function is_same_month($timestamp1,$timestamp2){
@@ -142,6 +175,23 @@ class FinishedOrderService extends Service
         }
     }
 
+    public function orderRule($data){
+        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
+        if($this->isEmpty($data,'quantity')) return [false,'请填写完工数量!'];
+        if($this->isEmpty($data,'finish_id') && $this->isEmpty($data,'team_id')) return [false,'人员和班组不能都为空!'];
+
+        $result = DispatchSub::whereIn('id',$data['id'])
+            ->select('id','finished_num','dispatch_quantity','out_order_no_time','process_id','dispatch_no','order_product_id','sale_orders_product_id','order_no','product_no','product_title')
+            ->orderBy('id','desc')
+            ->get()->toArray();
+
+        foreach ($result as $key => $value){
+            if(($data['quantity'][$key] + $value['finished_num']) > $value['dispatch_quantity']) return [false,'完工数量不能大于派工数量'];
+        }
+
+        return [true, $result];
+    }
+
     public function orderList($data){
         $model = FinishedOrderSub::where('del_time',0)
             ->select('id','order_no','table_header_mark','product_no','product_title','product_size','product_unit','dispatch_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','dispatch_quantity','finished_num','status','crt_id','process_id','equipment_id','team_id','dispatch_time_start','dispatch_time_end','dispatch_time','crt_time','dispatch_no')
@@ -174,31 +224,6 @@ class FinishedOrderService extends Service
         return [true,$list];
     }
 
-    public function orderRule($data){
-        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
-        if($this->isEmpty($data,'quantity')) return [false,'请填写完工数量!'];
-        if($this->isEmpty($data,'team_id')) return [false,'班组不能为空!'];
-        if($this->isEmpty($data,'equipment_id')) return [false,'设备不能为空!'];
-
-        $result = DispatchSub::whereIn('id',$data['id'])
-            ->select('order_product_id','dispatch_no','id as dispatch_id','order_no','table_header_mark','product_no','product_title','product_size','product_unit','dispatch_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','process_id','equipment_id','team_id','dispatch_time_start','dispatch_time_end','crt_time as dispatch_time','sale_orders_product_id','out_order_no_time')
-            ->orderBy('id','desc')
-            ->get()->toArray();
-
-        //已完工数据
-        $map = $this->getFinishedQuantity($data['id']);
-
-        foreach ($result as $key => $value){
-            if(isset($map[$value['dispatch_id']])){
-                if($map[$value['dispatch_id']] + $data['quantity'][$key] > $value['dispatch_quantity']) return [false,'完工数量不能大于派工数量'];
-            }else{
-                if($data['quantity'][$key] > $value['dispatch_quantity']) return [false,'完工数量不能大于派工数量'];
-            }
-        }
-
-        return [true, $result];
-    }
-
     public function fillData($data){
         if(empty($data['data'])) return $data;
 
@@ -272,25 +297,11 @@ class FinishedOrderService extends Service
         return $data;
     }
 
-    //返回已完工工数量
-    public function getFinishedQuantity($dispatch_id = []){
-        if(empty($dispatch_id)) return [];
-
-        $result = FinishedOrderSub::where('del_time',0)
-            ->whereIn("dispatch_id",$dispatch_id)
-            ->select(DB::raw("sum(dispatch_quantity) as finished_num"),'dispatch_id')
-            ->groupby('dispatch_id')
-            ->pluck('finished_num','dispatch_id')
-            ->toArray();
-
-        return $result;
-    }
-
     //反写写完工数量
     public function writeFinishedQuantity($sale_orders_product_id){
         if(empty($sale_orders_product_id)) return;
 
-        $result = FinishedOrderSub::where('del_time',0)
+        $result = DispatchSub::where('del_time',0)
             ->whereIn('sale_orders_product_id',$sale_orders_product_id)
             ->select(DB::raw("sum(finished_num) as finished_num"),'sale_orders_product_id')
             ->groupby('sale_orders_product_id')

+ 7 - 0
app/Service/FyySqlServerService.php

@@ -206,6 +206,13 @@ class FyySqlServerService extends Service
         //现存量查询结束
 
         foreach ($result as $key => $value){
+            $result[$key]->technology_material = $value->technology_material ?? '';
+            $result[$key]->technology_name = $value->technology_name ?? '';
+            $result[$key]->wood_name = $value->wood_name ?? '';
+            $result[$key]->process_mark = $value->process_mark ?? '';
+            $result[$key]->table_body_mark = $value->table_body_mark ?? '';
+            $result[$key]->table_header_mark = $value->table_header_mark ?? '';
+
             $keys = $value->product_no . $value->technology_name . $value->wood_name;
             $result[$key]->out_order_no_time = $value->out_order_no_time ? strtotime($value->out_order_no_time) : 0;
             $result[$key]->out_checker_time = $value->out_checker_time ? strtotime($value->out_checker_time) : 0;

+ 1 - 0
routes/api.php

@@ -133,6 +133,7 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     //工序完工
     $route->any('finishedOrderAdd', 'Api\FinishedOrderController@add');
     $route->any('finishedOrderEdit', 'Api\FinishedOrderController@edit');
+    $route->any('finishedOrderDetail', 'Api\FinishedOrderController@orderDetail');
     $route->any('finishedOrderDel', 'Api\FinishedOrderController@del');
     $route->any('finishedOrderList', 'Api\FinishedOrderController@orderList');