cqp 9 giờ trước cách đây
mục cha
commit
7774f609cd

+ 11 - 0
app/Http/Controllers/Api/ReportFormsController.php

@@ -175,4 +175,15 @@ class ReportFormsController extends BaseController
             return $this->json_return(201,$data);
         }
     }
+
+    public function xsReport(Request $request){
+        $service = new ReportFormsService();
+        list($status,$data) = $service->xsReport($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
 }

+ 26 - 0
app/Http/Controllers/Api/ScrappController.php

@@ -110,4 +110,30 @@ class ScrappController extends BaseController
             return $this->json_return(201,$data);
         }
     }
+
+    public function zjList(Request $request)
+    {
+        $service = new ScrappService();
+        $user = $request->get('auth');
+        list($status,$data) = $service->zjdaList($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function zjPlanList(Request $request)
+    {
+        $service = new ScrappService();
+        $user = $request->get('auth');
+        list($status,$data) = $service->zjPlanList($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
 }

+ 14 - 0
app/Model/Zj.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Zj extends Model
+{
+    protected $table = "zj"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+}
+

+ 14 - 0
app/Model/ZjPlan.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+class ZjPlan extends Model
+{
+    protected $table = "zj_plan"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+}
+

+ 18 - 2
app/Service/ApplyOrderService.php

@@ -2662,8 +2662,9 @@ class ApplyOrderService extends Service
         $result = [];
         $type = $data['type'];
         $for_type = $data['for_type'];
+        $process_id = $data['process_id'] ?? 0;
         if ($data['type'] == 1) {
-            $result = $this->typeOne($for_type, $id);
+            $result = $this->typeOne($for_type, $id, $process_id);
         } elseif ($type == 2) {
             $result = $this->typeTwo($for_type, $id);
         } elseif ($type == 3) {
@@ -2695,7 +2696,7 @@ class ApplyOrderService extends Service
         return $result;
     }
 
-    private function typeOne($for_type, $id){
+    private function typeOne($for_type, $id, $process_id){
         $result = [];
         if($for_type == 2){
             $result = OrdersProduct::where('del_time',0)
@@ -2705,11 +2706,17 @@ class ApplyOrderService extends Service
         }elseif ($for_type == 3){
             $result = DispatchSub::where('del_time',0)
                 ->where('sale_orders_product_id', $id)
+                ->when(! empty($process_id), function ($query) use ($process_id){
+                    return $query->where('process_id', $process_id);
+                })
                 ->select('id', 'dispatch_no as order_no')
                 ->get()->toArray();
         }elseif ($for_type == 4){
             $dispatch = DispatchSub::where('del_time',0)
                 ->where('sale_orders_product_id', $id)
+                ->when(! empty($process_id), function ($query) use ($process_id){
+                    return $query->where('process_id', $process_id);
+                })
                 ->select('id')
                 ->get()->toArray();
             $detail = ReportWorkingDetail::whereIn('data_id', array_column($dispatch,'id'))
@@ -2722,6 +2729,9 @@ class ApplyOrderService extends Service
                 ->get()->toArray();
         }elseif ($for_type == 5){
             $result = DispatchSub::where('del_time',0)
+                ->when(! empty($process_id), function ($query) use ($process_id){
+                    return $query->where('process_id', $process_id);
+                })
                 ->where('sale_orders_product_id', $id)
                 ->where('finished_num','>',0)
                 ->select('id', 'dispatch_no as order_no')
@@ -2744,12 +2754,18 @@ class ApplyOrderService extends Service
                 ->pluck('id')
                 ->toArray();
             $result = ScrappCount::where('del_time',0)
+                ->when(! empty($process_id), function ($query) use ($process_id){
+                    return $query->where('process_id', $process_id);
+                })
                 ->where('sale_orders_product_id', $id)
                 ->whereIn('process_id', $process)
                 ->select('id', 'order_number as order_no')
                 ->get()->toArray();
         }elseif ($for_type == 8){
             $result = ScrappCount::where('del_time',0)
+                ->when(! empty($process_id), function ($query) use ($process_id){
+                    return $query->where('process_id', $process_id);
+                })
                 ->where('sale_orders_product_id', $id)
                 ->where('scrapp_num','>', 0)
                 ->select('id', 'order_number as order_no')

+ 1 - 0
app/Service/DispatchService.php

@@ -454,6 +454,7 @@ class DispatchService extends Service
             $tmp = $result_map[$value['id']] ?? [];
             unset($tmp['process_id']);unset($tmp['production_no']);
             $tmp['process_id'] = $value['process_id'];
+            $tmp['zj_plan_id'] = $value['zj_plan_id'] ?? 0;
             $tmp['team_id'] = $value['team_id'];
             $tmp['device_id'] = $value['device_id'];
             $tmp['dispatch_time_start'] = $value['dispatch_time'][0];

+ 64 - 0
app/Service/ReportFormsService.php

@@ -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;
+    }
 }

+ 38 - 0
app/Service/ScrappService.php

@@ -12,6 +12,8 @@ use App\Model\SaleOrdersProduct;
 use App\Model\Scrapp;
 use App\Model\ScrappCount;
 use App\Model\Team;
+use App\Model\Zj;
+use App\Model\ZjPlan;
 
 /**
  * 报废原因
@@ -59,6 +61,42 @@ class ScrappService extends Service
         return [200,$list];
     }
 
+    public function zjdaList($data){
+        $model = Zj::where('del_time',0)
+            ->select('*');
+
+        if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
+
+        $list = $this->limit($model,'',$data);
+
+        return [200,$list];
+    }
+
+    public function zjPlanList($data){
+        $model = ZjPlan::where('del_time',0)
+            ->select('*');
+
+        if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
+
+        $list = $this->limit($model,'',$data);
+
+        $map = Zj::where('del_time',0)->pluck('title','id')->toArray();
+
+        foreach ($list['data'] as $key => $value){
+            $zj_plan_title = "";
+            $tmp = explode(',', $value['zj_id']);
+            foreach ($tmp as $v){
+                $t = $map[$v];
+                if(empty($t)) continue;
+                $zj_plan_title .= $t . ",";
+            }
+
+            $list['data'][$key]['zj_plan_title'] = rtrim($zj_plan_title,',');
+        }
+
+        return [200,$list];
+    }
+
     public function scrappRule($data,$is_add = true){
         if($this->isEmpty($data,'data')) return [false,'数据不能为空!'];
 

+ 7 - 0
routes/api.php

@@ -131,6 +131,11 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('scrappBadList', 'Api\ScrappController@scrappBadList');
     $route->any('scrappBadDetail', 'Api\ScrappController@blpDetail');
 
+    //质检项目档案
+    $route->any('zjList', 'Api\ScrappController@zjList');
+    $route->any('zjPlanList', 'Api\ScrappController@zjPlanList');
+
+
     //销售订单----------------------
     $route->any('salesOrderList', 'Api\FyyOrderController@salesOrderList');
     $route->any('fyyAdd', 'Api\FyyOrderController@add');
@@ -308,4 +313,6 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('getReportRate', 'Api\ApplyOrderController@getReportRate');
 
     $route->any('systemDataList','Api\ScreenController@systemDataList');
+    //销售汇总报表
+    $route->any('xsReport','Api\ReportFormsController@xsReport');
 });