|
@@ -587,7 +587,7 @@ class FinishedOrderService extends Service
|
|
|
if(! $status) return [false, $msg];
|
|
|
}
|
|
|
|
|
|
- return [true, [array_merge($get_order_number, $get_order_number1), $return_dispatch]];
|
|
|
+ return [true, array_merge($get_order_number, $get_order_number1)];
|
|
|
}catch (\Throwable $exception){
|
|
|
return[false, $exception->getMessage() . $exception->getLine()];
|
|
|
}
|
|
@@ -1486,4 +1486,89 @@ class FinishedOrderService extends Service
|
|
|
|
|
|
return [true, ''];
|
|
|
}
|
|
|
+
|
|
|
+ public function finishedOrderList($data){
|
|
|
+ $model = ReportWorkingDetail::from("report_working_detail as a")
|
|
|
+ ->leftJoin("dispatch_sub as b",'a.data_id','b.id')
|
|
|
+ ->leftjoin("report_working as c",'a.report_working_id', 'c.id')
|
|
|
+ ->where("a.del_time", 0)
|
|
|
+ ->where('b.del_time', 0)
|
|
|
+ ->select('a.quantity as finished_num','b.id','b.order_no','b.table_header_mark','b.product_no','b.product_title','b.product_size','b.product_unit','b.dispatch_quantity','b.technology_material','b.technology_name','b.wood_name','b.process_mark','b.table_body_mark','b.dispatch_no','b.crt_id','b.process_id','b.dispatch_time_start','b.dispatch_time_end','a.crt_time','b.customer_name','b.order_product_id','b.out_order_no','b.team_id','b.device_id','b.wg_status','b.status','b.type','c.order_number')
|
|
|
+ ->orderBy('b.id','desc');
|
|
|
+
|
|
|
+ if(isset($data['type'])) $model->where('b.type', $data['type']);
|
|
|
+ if(isset($data['status'])) $model->where('b.status', $data['status']);
|
|
|
+ if(isset($data['wg_status'])) $model->where('b.wg_status', $data['wg_status']);
|
|
|
+ if(! empty($data['order_no'])) $model->where('b.order_no', 'LIKE', '%'.$data['order_no'].'%');
|
|
|
+ if(! empty($data['dispatch_no'])) $model->where('b.dispatch_no', 'LIKE', '%'.$data['dispatch_no'].'%');
|
|
|
+ if(! empty($data['out_order_no'])) $model->where('b.out_order_no', 'LIKE', '%'.$data['out_order_no'].'%');
|
|
|
+ if(! empty($data['order_number'])) $model->where('c.order_number', 'LIKE', '%'.$data['order_number'].'%');
|
|
|
+ if(! empty($data['production_no'])) {
|
|
|
+ $id = OrdersProduct::where('del_time', 0)
|
|
|
+ ->where('b.production_no', 'LIKE', '%'.$data['production_no'].'%')
|
|
|
+ ->select('id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $model->whereIn('order_product_id', array_column($id,'id'));
|
|
|
+ }
|
|
|
+ if(! empty($data['process_id'])) $model->where('b.process_id',$data['process_id']);
|
|
|
+ if(! empty($data['technology_material'])) $model->where('b.technology_material', 'LIKE', '%'.$data['technology_material'].'%');
|
|
|
+ if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) $model->whereBetween('a.crt_time',[$data['crt_time'][0],$data['crt_time'][1]]);
|
|
|
+ if(! empty($data['dispatch_time'][0]) && ! empty($data['dispatch_time'][1])){
|
|
|
+ $model->where('b.dispatch_time_start','>=',$data['dispatch_time'][0]);
|
|
|
+ $model->where('b.dispatch_time_end','<=',$data['dispatch_time'][1]);
|
|
|
+ }
|
|
|
+ if(! empty($data['id'])) $model->where('b.id',$data['id']);
|
|
|
+ if(! empty($data['team_id'])) $model->where('b.team_id',$data['team_id']);
|
|
|
+ if(! empty($data['device_id'])) $model->where('b.device_id',$data['device_id']);
|
|
|
+ if(! empty($data['equipment_id'])) $model->where('b.device_id',$data['equipment_id']);
|
|
|
+ if(! empty($data['employee_id'])) {
|
|
|
+ $team = EmployeeTeamPermission::where('employee_id',$data['employee_id'])
|
|
|
+ ->select('team_id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $model->whereIn('b.team_id',array_unique(array_column($team,'team_id')));
|
|
|
+ }
|
|
|
+
|
|
|
+ $list = $this->limit($model,'',$data);
|
|
|
+ $list = $this->fillDispatchOrderListData($list);
|
|
|
+
|
|
|
+ return [true,$list];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function fillDispatchOrderListData($data){
|
|
|
+ if(empty($data['data'])) return $data;
|
|
|
+
|
|
|
+ $team_map = Team::whereIn('id',array_unique(array_column($data['data'],'team_id')))
|
|
|
+ ->pluck('title','id')
|
|
|
+ ->toArray();
|
|
|
+ $equipment_map = Equipment::whereIn('id',array_unique(array_column($data['data'],'device_id')))
|
|
|
+ ->pluck('title','id')
|
|
|
+ ->toArray();
|
|
|
+ $process_map = Process::whereIn('id',array_column($data['data'],'process_id'))
|
|
|
+ ->pluck('title','id')
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ $orders = OrdersProduct::whereIn('id', array_column($data['data'],'order_product_id'))
|
|
|
+ ->pluck('production_no','id')
|
|
|
+ ->toArray();
|
|
|
+ foreach ($data['data'] as $key => $value){
|
|
|
+ $data['data'][$key]['wg_status_title'] = DispatchSub::$status_name[$value['wg_status']] ?? "";
|
|
|
+ $data['data'][$key]['status_title'] = DispatchSub::$status_name[$value['status']] ?? "";
|
|
|
+ $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d',$value['crt_time']) : '';
|
|
|
+
|
|
|
+ $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]['process_name'] = $process_map[$value['process_id']] ?? '';
|
|
|
+ $data['data'][$key]['team_name'] = $team_map[$value['team_id']] ?? "";
|
|
|
+ $data['data'][$key]['equipment_name'] = $equipment_map[$value['device_id']] ?? "";
|
|
|
+ $data['data'][$key]['equipment_id'] = $value['device_id'];
|
|
|
+ $data['data'][$key]['un_finished_quantity'] = bcsub($value['dispatch_quantity'] , $value['finished_num'],3);
|
|
|
+ $data['data'][$key]['production_no'] = $orders[$value['order_product_id']] ?? '';
|
|
|
+ }
|
|
|
+
|
|
|
+ $total = $this->getTotal($data['data'], 'dispatch_quantity');
|
|
|
+ $data['dispatch_quantity'] = $total;
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
}
|