|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Service;
|
|
|
|
|
|
+use App\Model\Box;
|
|
|
use App\Model\DispatchSub;
|
|
|
use App\Model\Employee;
|
|
|
use App\Model\Equipment;
|
|
@@ -9,6 +10,7 @@ use App\Model\OrdersProduct;
|
|
|
use App\Model\OrdersProductProcess;
|
|
|
use App\Model\Process;
|
|
|
use App\Model\ReportWorkingDetail;
|
|
|
+use App\Model\SaleOrdersProduct;
|
|
|
use App\Model\Scrapp;
|
|
|
use App\Model\ScrappCount;
|
|
|
use App\Model\SystemL;
|
|
@@ -1265,4 +1267,66 @@ class ReportFormsService extends Service
|
|
|
|
|
|
return [true, array_values($return)];
|
|
|
}
|
|
|
+
|
|
|
+ public function xsReport($data){
|
|
|
+ $model = SaleOrdersProduct::where('del_time',0)
|
|
|
+ ->select('id','out_order_no','customer_name','product_title','order_quantity','technology_name','production_quantity','box_num','finished_num','box_num as shipment_num')
|
|
|
+ ->orderBy('crt_time','desc');
|
|
|
+
|
|
|
+ if(! empty($data['out_order_no'])) {
|
|
|
+ if(! is_array($data['out_order_no'])) {
|
|
|
+ $model->where('out_order_no', 'LIKE', '%'.$data['out_order_no'].'%');
|
|
|
+ }else{
|
|
|
+ $model->whereIn('out_order_no', $data['out_order_no']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(! empty($data['customer_name'])) $model->where('customer_name', 'LIKE', '%'.$data['customer_name'].'%');
|
|
|
+ if(! empty($data['product_no'])) $model->where('product_no', 'LIKE', '%'.$data['product_no'].'%');
|
|
|
+ if(! empty($data['product_title'])) $model->where('product_title', 'LIKE', '%'.$data['product_title'].'%');
|
|
|
+ if(! empty($data['product_size'])) $model->where('product_size', 'LIKE', '%'.$data['product_size'].'%');
|
|
|
+ if(! empty($data['technology_material'])) $model->where('technology_material', 'LIKE', '%'.$data['technology_material'].'%');
|
|
|
+ if(! empty($data['technology_name'])) $model->where('technology_name', 'LIKE', '%'.$data['technology_name'].'%');
|
|
|
+ if(! empty($data['process_mark'])) $model->where('process_mark', 'LIKE', '%'.$data['process_mark'].'%');
|
|
|
+ if(! empty($data['table_header_mark'])) $model->where('table_header_mark', 'LIKE', '%'.$data['table_header_mark'].'%');
|
|
|
+ if(! empty($data['table_body_mark'])) $model->where('table_body_mark', 'LIKE', '%'.$data['table_body_mark'].'%');
|
|
|
+ if(! empty($data['out_checker_man'])) $model->where('out_checker_man', 'LIKE', '%'.$data['out_checker_man'].'%');
|
|
|
+ if(! empty($data['out_crt_man'])) $model->where('out_crt_man', 'LIKE', '%'.$data['out_crt_man'].'%');
|
|
|
+ if(! empty($data['out_checker_time'][0]) && ! empty($data['out_checker_time'][1])) $model->whereBetween('out_checker_time',[$data['out_checker_time'][0],$data['out_checker_time'][1]]);
|
|
|
+ if(! empty($data['out_order_no_time'][0]) && ! empty($data['out_order_no_time'][1])) $model->whereBetween('out_order_no_time',[$data['out_order_no_time'][0],$data['out_order_no_time'][1]]);
|
|
|
+ if(! empty($data['pre_shipment_time'][0]) && ! empty($data['pre_shipment_time'][1])) $model->whereBetween('pre_shipment_time',[$data['pre_shipment_time'][0],$data['pre_shipment_time'][1]]);
|
|
|
+ if(isset($data['status'])) $model->where('status',$data['status']);
|
|
|
+
|
|
|
+ $list = $this->limit($model,'',$data);
|
|
|
+ $list = $this->fillXsData($list);
|
|
|
+
|
|
|
+ return [true, $list];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function fillXsData($list){
|
|
|
+ if(empty($list['data'])) return $list;
|
|
|
+
|
|
|
+ $sale_orders_product_id = array_column($list['data'],'id');
|
|
|
+ //派工单数据
|
|
|
+ $dispatch_data = DispatchSub::where('del_time',0)
|
|
|
+ ->whereIn('sale_orders_product_id',$sale_orders_product_id)
|
|
|
+ ->select(DB::raw('sum(dispatch_quantity) as dispatch_quantity'),DB::raw('sum(finished_num) as finished_num'),DB::raw('sum(waste_num) as waste_num'),'process_id','sale_orders_product_id')
|
|
|
+ ->groupBy('sale_orders_product_id', 'process_id')
|
|
|
+ ->orderBy('sale_orders_product_id','desc')
|
|
|
+ ->get()->toArray();
|
|
|
+ $dispatch_data_map = [];
|
|
|
+ foreach ($dispatch_data as $value){
|
|
|
+ $dispatch_data_map[$value['sale_orders_product_id']][] = $value;
|
|
|
+ }
|
|
|
+ $process = Process::where('del_time',0)->pluck('title','id')->toArray();
|
|
|
+
|
|
|
+ foreach ($list['data'] as $key => $value){
|
|
|
+ $tmp = $dispatch_data_map[$value['id']] ?? [];
|
|
|
+ foreach ($tmp as $k => $v){
|
|
|
+ $tmp[$k]['process_title'] = $process[$v['process_id']] ?? "";
|
|
|
+ }
|
|
|
+ $list['data'][$key]['mul_data'] = $tmp;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $list;
|
|
|
+ }
|
|
|
}
|