cqp 8 months ago
parent
commit
35fc0a4649

+ 364 - 11
app/Http/Controllers/Api/ScreenController.php

@@ -6,13 +6,18 @@ use App\Model\ApplyOrder;
 use App\Model\ApplyOrderDetail;
 use App\Model\ApplyOrderDetail;
 use App\Model\Box;
 use App\Model\Box;
 use App\Model\BoxDetail;
 use App\Model\BoxDetail;
+use App\Model\DispatchEmpSub;
 use App\Model\DispatchSub;
 use App\Model\DispatchSub;
+use App\Model\EmployeeTeamPermission;
+use App\Model\Equipment;
+use App\Model\OrdersProduct;
 use App\Model\OrdersProductProcess;
 use App\Model\OrdersProductProcess;
 use App\Model\Process;
 use App\Model\Process;
 use App\Model\SaleOrdersProduct;
 use App\Model\SaleOrdersProduct;
 use App\Model\SalesFrom;
 use App\Model\SalesFrom;
 use App\Model\ScrappCount;
 use App\Model\ScrappCount;
 use App\Model\SystemL;
 use App\Model\SystemL;
+use App\Model\Team;
 use App\Service\FyySqlServerService;
 use App\Service\FyySqlServerService;
 use App\Service\ReportFormsService;
 use App\Service\ReportFormsService;
 use Carbon\Carbon;
 use Carbon\Carbon;
@@ -282,7 +287,7 @@ class ScreenController extends BaseController
 
 
     //产量趋势图
     //产量趋势图
     public function output_value_efficiency(Request $request){
     public function output_value_efficiency(Request $request){
-        $time = strtotime(date("Y-06-01 00:00:00"));
+        $time = strtotime(date("2024-06-01 00:00:00"));
 
 
         $return = [];
         $return = [];
         $data = ApplyOrderDetail::where('del_time',0)
         $data = ApplyOrderDetail::where('del_time',0)
@@ -291,10 +296,18 @@ class ScreenController extends BaseController
             ->select('quantity','crt_time','data_id')
             ->select('quantity','crt_time','data_id')
             ->get()->toArray();
             ->get()->toArray();
         $dispatch = DispatchSub::whereIn('id',array_column($data,'data_id'))
         $dispatch = DispatchSub::whereIn('id',array_column($data,'data_id'))
-            ->pluck("production_quantity",'id')
+            ->pluck('sale_orders_product_id','id')
             ->toArray();
             ->toArray();
+        $sale_order_map = [];
+        $sale_order = SaleOrdersProduct::whereIn('id', array_unique(array_values($dispatch)))
+            ->select('order_quantity','id','crt_time')
+            ->get()
+            ->toArray();
+        foreach ($sale_order as $value){
+            $sale_order_map[$value['id']] = $value;
+        }
 
 
-        $plan = [];
+        $plan = $plan_2 = [];
         foreach ($data as $value) {
         foreach ($data as $value) {
             $date = date("Y-m-d", $value['crt_time']);
             $date = date("Y-m-d", $value['crt_time']);
             if (isset($return[$date])) {
             if (isset($return[$date])) {
@@ -304,14 +317,20 @@ class ScreenController extends BaseController
                 $return[$date] = $value['quantity'];
                 $return[$date] = $value['quantity'];
             }
             }
 
 
-            $n = $dispatch[$value['data_id']] ?? 0;
-            if (isset($plan[$date])) {
-                $quantity = bcadd($plan[$date], $n, 3);
-                $plan[$date] = $quantity;
-            } else {
-                $plan[$date] = $n;
+            $sale_id = $dispatch[$value['data_id']] ?? 0;
+            $n = $sale_order_map[$sale_id] ?? [];
+            if(! empty($n)){
+                $date_2 = date("Y-m-d", $n['crt_time']);
+                if(isset($plan_2[$date_2]) && in_array($sale_id, $plan_2[$date_2])) continue;
+                if (isset($plan[$date_2])) {
+                    $quantity = bcadd($plan[$date_2], $n['order_quantity'], 3);
+                    $plan[$date_2] = $quantity;
+                } else {
+                    $plan[$date_2] = $n['order_quantity'];
+                }
+                $plan_2[$date_2][] = $sale_id;
             }
             }
-        }
+        }unset($plan_2);
 
 
         ksort($return);
         ksort($return);
 
 
@@ -320,7 +339,7 @@ class ScreenController extends BaseController
             $tmp = [
             $tmp = [
                 'time' => $key,
                 'time' => $key,
                 'output' => $value,
                 'output' => $value,
-                'plan' => $plan[$key] ?? 0,
+                'plan' => $plan[$key] ?? $value,
             ];
             ];
             $result[] = $tmp;
             $result[] = $tmp;
         }
         }
@@ -742,4 +761,338 @@ class ScreenController extends BaseController
 
 
         return $this->json_return(200,'',$return);
         return $this->json_return(200,'',$return);
     }
     }
+
+    public function deviceProduction(Request $request)
+    {
+        $now = time();
+
+        //当天的开始与结束时间戳
+        $timestamp_today_start = strtotime(date("Y-m-d 00:00:00",time()));
+        $timestamp_today_end = strtotime(date("Y-m-d 23:59:59",time()));
+
+        $latestTimes = SystemL::select('device_no', DB::raw('MAX(time) as max_time'))
+            ->whereIn('data_point_name', [SystemL::run, SystemL::work, SystemL::stop, SystemL::standBy])
+            ->where('time', '>=', $timestamp_today_start * 1000)
+            ->where('time', '<=', $timestamp_today_end * 1000)
+            ->groupBy('device_no')
+            ->get()->toArray();
+        $map = array_column($latestTimes,null,'device_no');
+
+        //数据模型
+        $models = [];
+        $is_all_close = 1;
+        $e_map = Equipment::where('del_time',0)->pluck('id','code');
+        foreach (SystemL::$device as $k => $v){
+            $is_close = 1;
+            if(isset($map[$v])){
+                $max_time = intval($map[$v]['max_time']) ?? 0;
+                $max_time = intval($max_time / 1000);
+                $max_time += 3800;
+                if($max_time < $now) $is_close = 0;
+
+                if($is_all_close) $is_all_close = 0;
+            }else{
+                $is_close = -1;
+            }
+
+            if($is_close < 0) {
+                $is_close_title = "暂未开机";
+            } elseif($is_close){
+                $is_close_title = "正在工作";
+            }else{
+                $is_close_title = "暂停工作";
+            }
+
+            $id = $e_map[$v] ?? 0;
+            $models[$id] = [
+                "device_id" => $id,
+                "device_name" => $k,
+                "is_close" => $is_close,
+                "is_close_title" => $is_close_title,
+                "current_order"=> [],
+                "last_counting"=> [],
+                "now_counting"=> [],
+                "pending_order"=> [],
+                "average"=> 0,
+            ];
+        }
+
+        //当前订单信息
+        $current_order = [];
+        if(! $is_all_close) $current_order = $this->getCurrentOrder();
+
+        //昨日生产
+        $last_counting = $this->getLastCounting();
+
+        //今日生产
+        $now_counting = $this->getNowCounting();
+
+        //待执行订单
+        $pending_order = $this->getPendingOrder();
+
+        foreach ($models as $e_id => $value){
+            if(isset($current_order[$e_id])) $models[$e_id]['current_order'] = $current_order[$e_id];
+            if(isset($last_counting[$e_id])) $models[$e_id]['last_counting'] = $last_counting[$e_id];
+            if(isset($pending_order[$e_id])) $models[$e_id]['pending_order'] = $pending_order[$e_id];
+            if(isset($now_counting[$e_id])) {
+                $tmp = $now_counting[$e_id] ?? [];
+                $models[$e_id]['now_counting'] = $tmp;
+                $models[$e_id]['average'] = bcdiv($tmp['finished_num'], 8);
+            }
+        }
+
+        $models = array_values($models);
+        usort($models, function($a, $b) {
+            return $b['is_close'] <=>  $a['is_close'];
+        });
+
+        return $this->json_return(200,'', $models);
+    }
+
+    private function getCurrentOrder(){
+        $timestamp_today_start = strtotime(date("Y-m-d 00:00:00",time()));
+        $timestamp_today_end = strtotime(date("Y-m-d 23:59:59",time()));
+        $apply = ApplyOrderDetail::where('del_time',0)
+            ->where('type',ApplyOrder::type_one)
+            ->where('crt_time', '>=', $timestamp_today_start)
+            ->where('crt_time', '<=', $timestamp_today_end)
+            ->orderBy('id', 'desc')
+            ->get()->toArray();
+
+        $dispatch = DispatchSub::where('del_time',0)
+            ->whereIn('id', array_column($apply,'data_id'))
+            ->select('dispatch_no','order_product_id','out_order_no')
+            ->get()->toArray();
+        $equipment_map = [];
+        $emp_sub = DispatchEmpSub::where('del_time',0)
+            ->whereIn('dispatch_no',array_column($dispatch,'dispatch_no'))
+            ->select('dispatch_no','equipment_id','team_id')
+            ->get()->toArray();
+        if(! empty($emp_sub)){
+            foreach ($emp_sub as $value){
+                if(isset($equipment_map[$value['dispatch_no']])) continue;
+                $equipment_map[$value['dispatch_no']] = [
+                    'equipment_id' => $value['equipment_id'],
+                    'team_id' => $value['team_id'],
+                ];
+            }
+        }
+        //当前订单
+        $current_order = $team_id = [];
+        foreach ($dispatch as $value){
+            $e_data = $equipment_map[$value['dispatch_no']] ?? [];
+            $e_id = $e_data['equipment_id'] ?? 0;
+            if(! $e_id || isset($current_order[$e_id])) continue;
+
+            $value['team_id'] = $e_data['team_id'];
+            $team_id[] = $value['team_id'];
+            $current_order[$e_id] = $value;
+        }
+
+        $product_no = OrdersProduct::whereIn('id', array_unique(array_column($current_order,'order_product_id')))
+            ->pluck('production_no','id')
+            ->toArray();
+        $team_id = array_unique($team_id);
+        $team_map = Team::whereIn('id', $team_id)
+            ->pluck('title','id')
+            ->toArray();
+        $team_array = EmployeeTeamPermission::from('employee_team_permission as a')
+            ->leftJoin('employee as b','b.id','a.employee_id')
+            ->whereIn('team_id', $team_id)
+            ->select('b.emp_name','a.team_id')
+            ->get()->toArray();
+        foreach ($team_array as $value){
+            if(isset($map[$value['team_id']])){
+                $map[$value['team_id']] .= ',' . $value['emp_name'];
+            }else{
+                $map[$value['team_id']] = $value['emp_name'];
+            }
+        }
+        foreach ($current_order as $key => $value){
+            $current_order[$key]['production_no'] = $product_no[$value['order_product_id']] ?? "";
+            $current_order[$key]['team'] = $team_map[$value['team_id']] ?? "";
+            $current_order[$key]['team_man'] = $map[$value['team_id']] ?? "";
+        }
+
+        return $current_order;
+    }
+
+    private function getLastCounting(){
+        $timestamp_today_start = strtotime(date("Y-m-d 00:00:00",time())) - 86400;
+        $timestamp_today_end = strtotime(date("Y-m-d 23:59:59",time())) - 86400;
+        $apply = ApplyOrderDetail::where('del_time',0)
+            ->where('type',ApplyOrder::type_two)
+            ->where('crt_time', '>=', $timestamp_today_start)
+            ->where('crt_time', '<=', $timestamp_today_end)
+            ->get()->toArray();
+
+        $dispatch = DispatchSub::whereIn('id', array_column($apply,'data_id'))
+            ->get()->toArray();
+
+        $equipment_map = [];
+        $emp_sub = DispatchEmpSub::where('del_time',0)
+            ->whereIn('dispatch_no',array_column($dispatch,'dispatch_no'))
+            ->select('dispatch_no','equipment_id')
+            ->get()->toArray();
+        if(! empty($emp_sub)){
+            foreach ($emp_sub as $value){
+                if(isset($equipment_map[$value['dispatch_no']])) continue;
+                $equipment_map[$value['dispatch_no']] = $value['equipment_id'];
+            }
+        }
+        $order = [];
+        foreach ($dispatch as $value){
+            $e_id = $equipment_map[$value['dispatch_no']] ?? 0;
+            $order[$e_id][] = $value;
+        }
+
+        $return = [];
+        foreach ($order as $e_id => $value){
+            $tmp = [
+                "finished_num" => 0,
+                "hg_num" => 0,
+                "blp_num" => 0,
+                "plan_num" => 0,
+            ];
+
+            //产出数据 合格数量
+            $finished_num = 0;
+            foreach (array_column($value,'finished_num') as $value_v){
+                $finished_num = bcadd($finished_num, $value_v,2);
+            }
+            $tmp['finished_num'] = $tmp['hg_num'] = $finished_num;
+
+            //计划数量
+            $production_quantity = 0;
+            foreach (array_column($value,'production_quantity') as $value_v){
+                $production_quantity = bcadd($production_quantity, $value_v,2);
+            }
+            $tmp['plan_num'] = $production_quantity;
+
+            //不良品数量
+            $blp = ScrappCount::where('del_time',0)
+                ->where('crt_time', '>=', $timestamp_today_start)
+                ->where('crt_time', '<=', $timestamp_today_end)
+                ->where('dispatch_sub_id', array_column($value,'id'))
+                ->select('scrapp_num')
+                ->get()->toArray();
+            $scrapp_num = 0;
+            foreach (array_column($blp,'scrapp_num') as $value_v){
+                $scrapp_num = bcadd($scrapp_num, $value_v,2);
+            }
+            $tmp['blp_num'] = $scrapp_num;
+
+            $return[$e_id] = $tmp;
+        }
+
+        return $return;
+    }
+
+    private function getNowCounting(){
+        //当天的开始与结束时间戳
+        $timestamp_today_start = strtotime(date("Y-m-d 00:00:00",time()));
+        $timestamp_today_end = strtotime(date("Y-m-d 23:59:59",time()));
+        $apply = ApplyOrderDetail::where('del_time',0)
+            ->where('type',ApplyOrder::type_two)
+            ->where('crt_time', '>=', $timestamp_today_start)
+            ->where('crt_time', '<=', $timestamp_today_end)
+            ->get()->toArray();
+
+        $dispatch = DispatchSub::whereIn('id', array_column($apply,'data_id'))
+            ->get()->toArray();
+
+        $equipment_map = [];
+        $emp_sub = DispatchEmpSub::where('del_time',0)
+            ->whereIn('dispatch_no',array_column($dispatch,'dispatch_no'))
+            ->select('dispatch_no','equipment_id')
+            ->get()->toArray();
+        if(! empty($emp_sub)){
+            foreach ($emp_sub as $value){
+                if(isset($equipment_map[$value['dispatch_no']])) continue;
+                $equipment_map[$value['dispatch_no']] = $value['equipment_id'];
+            }
+        }
+        $order = [];
+        foreach ($dispatch as $value){
+            $e_id = $equipment_map[$value['dispatch_no']] ?? 0;
+            $order[$e_id][] = $value;
+        }
+
+        $return = [];
+        foreach ($order as $e_id => $value){
+            $tmp = [
+                "finished_num" => 0,
+                "hg_num" => 0,
+                "blp_num" => 0,
+                "plan_num" => 0,
+            ];
+
+            //产出数据 合格数量
+            $finished_num = 0;
+            foreach (array_column($value,'finished_num') as $value_v){
+                $finished_num = bcadd($finished_num, $value_v,2);
+            }
+            $tmp['finished_num'] = $tmp['hg_num'] = $finished_num;
+
+            //计划数量
+            $production_quantity = 0;
+            foreach (array_column($value,'production_quantity') as $value_v){
+                $production_quantity = bcadd($production_quantity, $value_v,2);
+            }
+            $tmp['plan_num'] = $production_quantity;
+
+            //不良品数量
+            $blp = ScrappCount::where('del_time',0)
+                ->where('crt_time', '>=', $timestamp_today_start)
+                ->where('crt_time', '<=', $timestamp_today_end)
+                ->where('dispatch_sub_id', array_column($value,'id'))
+                ->select('scrapp_num')
+                ->get()->toArray();
+            $scrapp_num = 0;
+            foreach (array_column($blp,'scrapp_num') as $value_v){
+                $scrapp_num = bcadd($scrapp_num, $value_v,2);
+            }
+            $tmp['blp_num'] = $scrapp_num;
+
+            $return[$e_id] = $tmp;
+        }
+
+        return $return;
+    }
+
+    private function getPendingOrder(){
+        //当天的开始与结束时间戳
+        $timestamp_today_start = strtotime(date("Y-m-d 00:00:00",time()));
+        $timestamp_today_end = strtotime(date("Y-m-d 23:59:59",time()));
+
+        $dispatch = DispatchSub::where('del_time',0)
+            ->where('crt_time', '>=', $timestamp_today_start)
+            ->where('crt_time', '<=', $timestamp_today_end)
+            ->where('finished_num', 0)
+            ->select('dispatch_no','order_product_id','out_order_no','dispatch_quantity')
+            ->get()->toArray();
+
+        $equipment_map = [];
+        $emp_sub = DispatchEmpSub::where('del_time',0)
+            ->whereIn('dispatch_no',array_column($dispatch,'dispatch_no'))
+            ->select('dispatch_no','equipment_id')
+            ->get()->toArray();
+        if(! empty($emp_sub)){
+            foreach ($emp_sub as $value){
+                if(isset($equipment_map[$value['dispatch_no']])) continue;
+                $equipment_map[$value['dispatch_no']] = $value['equipment_id'];
+            }
+        }
+        $product_no = OrdersProduct::whereIn('id', array_unique(array_column($dispatch,'order_product_id')))
+            ->pluck('production_no','id')
+            ->toArray();
+        $order = [];
+        foreach ($dispatch as $value){
+            $e_id = $equipment_map[$value['dispatch_no']] ?? 0;
+            $value['production_no'] = $product_no[$value['order_product_id']] ?? '';
+            $order[$e_id][] = $value;
+        }
+
+        return $order;
+    }
 }
 }

+ 3 - 3
app/Service/ApplyOrderService.php

@@ -660,7 +660,7 @@ class ApplyOrderService extends Service
         //派工单
         //派工单
         $d = DispatchSub::where('del_time',0)
         $d = DispatchSub::where('del_time',0)
             ->whereIn('id', $apply_id)
             ->whereIn('id', $apply_id)
-            ->select('id', 'dispatch_no as order_no', 'product_title','technology_material','wood_name','product_no','process_id','product_unit','price','product_size')
+            ->select('id', 'dispatch_no as order_no', 'product_title','technology_name','wood_name','product_no','process_id','product_unit','price','product_size')
             ->get()->toArray();
             ->get()->toArray();
         $d_tmp = array_column($d,null,'id');
         $d_tmp = array_column($d,null,'id');
 
 
@@ -682,7 +682,7 @@ class ApplyOrderService extends Service
                     'product_title' => $tmp['product_title'] ?? "",
                     'product_title' => $tmp['product_title'] ?? "",
                     'product_size' => $tmp['product_size'] ?? "",
                     'product_size' => $tmp['product_size'] ?? "",
                     'product_unit' => $tmp['product_unit'] ?? "",
                     'product_unit' => $tmp['product_unit'] ?? "",
-                    'technology_material' => $tmp['technology_material'] ?? "",
+                    'technology_name' => $tmp['technology_name'] ?? "",
                     'wood_name' => $tmp['wood_name'] ?? "",
                     'wood_name' => $tmp['wood_name'] ?? "",
                     'order_no' => $tmp['order_no'] ?? "",
                     'order_no' => $tmp['order_no'] ?? "",
                     'process_id' => $tmp['process_id'] ?? 0,
                     'process_id' => $tmp['process_id'] ?? 0,
@@ -693,7 +693,7 @@ class ApplyOrderService extends Service
             }
             }
         }
         }
 
 
-        $detail['order_data'] = $return;
+        $detail['order_data'] = array_values($return);
 
 
         return [true, $detail];
         return [true, $detail];
     }
     }

+ 9 - 3
app/Service/Box/BoxHookService.php

@@ -9,6 +9,7 @@ use App\Model\BoxDetail;
 use App\Model\Header_ext;
 use App\Model\Header_ext;
 use App\Model\Orders;
 use App\Model\Orders;
 use App\Model\OrdersProduct;
 use App\Model\OrdersProduct;
+use App\Service\EmployeeService;
 use App\Service\Service;
 use App\Service\Service;
 
 
 /**
 /**
@@ -42,12 +43,12 @@ class BoxHookService extends Service
      * @param $data
      * @param $data
      * @return array
      * @return array
      */
      */
-    public function boxInsert($data){
+    public function boxInsert($data,$user){
         $box = new Box();
         $box = new Box();
         if(!isset($data['order_no'])||empty($data['order_no'])) $data['order_no'] = $this->setOrderNo();
         if(!isset($data['order_no'])||empty($data['order_no'])) $data['order_no'] = $this->setOrderNo();
         if(empty($data['order_no'])) return [false, "包装单号生成失败"];
         if(empty($data['order_no'])) return [false, "包装单号生成失败"];
         if(!isset($data['out_order_no'])) return [false,'out_order_no不存在!'];
         if(!isset($data['out_order_no'])) return [false,'out_order_no不存在!'];
-        list($status,$box) = $this->dealBox($box,$data);
+        list($status,$box) = $this->dealBox($box,$data,$user);
         if(!$status) return [false,$box];
         if(!$status) return [false,$box];
         $box->save();
         $box->save();
         list($status,$msg) =  $this->boxDetailInsert($data);
         list($status,$msg) =  $this->boxDetailInsert($data);
@@ -56,7 +57,11 @@ class BoxHookService extends Service
         return [true,$box];
         return [true,$box];
     }
     }
 
 
-    public function dealBox($box,$data){
+    public function dealBox($box,$data,$user){
+        //包装审核
+        $em = new EmployeeService();
+        $auto = $em->is_auto($user, "bz_auto");
+
         $box->order_no = $data['order_no'];
         $box->order_no = $data['order_no'];
         $box->out_order_no = $data['out_order_no'];
         $box->out_order_no = $data['out_order_no'];
 //        $box->top_id = $data['top_id'];
 //        $box->top_id = $data['top_id'];
@@ -67,6 +72,7 @@ class BoxHookService extends Service
         $box->ext_4 = isset($data['ext_4']) ? $data['ext_4'] : '';
         $box->ext_4 = isset($data['ext_4']) ? $data['ext_4'] : '';
         $box->ext_5 = isset($data['ext_5']) ? $data['ext_5'] : '';
         $box->ext_5 = isset($data['ext_5']) ? $data['ext_5'] : '';
         $box->top_order_no = $data['top_order_no'];
         $box->top_order_no = $data['top_order_no'];
+        $box->status = $auto;
         $box->shipment_order_no = isset($data['shipment_order_no'])? $data['shipment_order_no'] : '';
         $box->shipment_order_no = isset($data['shipment_order_no'])? $data['shipment_order_no'] : '';
 
 
         return [true,$box];
         return [true,$box];

+ 1 - 1
app/Service/Box/BoxService.php

@@ -197,7 +197,7 @@ class BoxService extends Service
             $insert['order_no'] = $box_no;
             $insert['order_no'] = $box_no;
             $insert['shipment_order_no'] = $transport_no;
             $insert['shipment_order_no'] = $transport_no;
             //生成包装单
             //生成包装单
-            list($status,$msg) = self::$box_hook->boxInsert($insert);
+            list($status,$msg) = self::$box_hook->boxInsert($insert,$user);
             if(! $status) {
             if(! $status) {
                 $this->dellimitingSendRequestBackgNeed($limit_key);
                 $this->dellimitingSendRequestBackgNeed($limit_key);
                 DB::rollBack();
                 DB::rollBack();

+ 1 - 1
app/Service/CommandService.php

@@ -30,7 +30,7 @@ class CommandService extends Service
 //        }
 //        }
     }
     }
 
 
-    public function productionAdd($data,$user,$id){
+    public function productionAdd($data,$user,$id){dd(1);
         $service = new ProductionOrderService();
         $service = new ProductionOrderService();
         list($status,$msg) = $service->orderRule($data);
         list($status,$msg) = $service->orderRule($data);
         //生产数据的源数据
         //生产数据的源数据

+ 4 - 1
app/Service/DispatchService.php

@@ -461,7 +461,6 @@ class DispatchService extends Service
             ->toArray();
             ->toArray();
 
 
         $process_map = $this->getProcess($data['data']);
         $process_map = $this->getProcess($data['data']);
-
         foreach ($data['data'] as $key => $value){
         foreach ($data['data'] as $key => $value){
             $tmp = $process_map[$value['id']] ?? [];
             $tmp = $process_map[$value['id']] ?? [];
             foreach ($tmp as $t => $v) {
             foreach ($tmp as $t => $v) {
@@ -610,6 +609,9 @@ class DispatchService extends Service
             ->pluck('title','id')
             ->pluck('title','id')
             ->toArray();
             ->toArray();
 
 
+        $orders = OrdersProduct::whereIn('id', array_column($data['data'],'order_product_id'))
+            ->pluck('production_no','id')
+            ->toArray();
         foreach ($data['data'] as $key => $value){
         foreach ($data['data'] as $key => $value){
             $data['data'][$key]['wg_status_title'] = DispatchSub::$status_name[$value['wg_status']] ?? "";
             $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]['status_title'] = DispatchSub::$status_name[$value['status']] ?? "";
@@ -623,6 +625,7 @@ class DispatchService extends Service
             $data['data'][$key]['equipment_name'] = $equipment_map[$value['device_id']] ?? "";
             $data['data'][$key]['equipment_name'] = $equipment_map[$value['device_id']] ?? "";
             $data['data'][$key]['equipment_id'] = $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]['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');
         $total = $this->getTotal($data['data'], 'dispatch_quantity');

+ 1 - 1
app/Service/ReportFormsService.php

@@ -1020,7 +1020,7 @@ class ReportFormsService extends Service
 
 
             $string = $value['finished_id'] . $value['process_id'];
             $string = $value['finished_id'] . $value['process_id'];
             if(isset($return[$string])){
             if(isset($return[$string])){
-                $quantity = bcadd($value['quantity'], $return[$string]['quantity'], 0);
+                $quantity = bcadd($value['quantity'], $return[$string]['quantity'], 3);
                 $return[$string]['quantity'] = $quantity;
                 $return[$string]['quantity'] = $quantity;
                 if(! in_array($value['id'], $return[$string]['report_id'])){
                 if(! in_array($value['id'], $return[$string]['report_id'])){
                     $id = array_merge_recursive($return[$string]['report_id'], [$value['id']]);
                     $id = array_merge_recursive($return[$string]['report_id'], [$value['id']]);

+ 1 - 0
routes/api.php

@@ -43,6 +43,7 @@ Route::any('work_order','Api\ScreenController@work_order');
 Route::any('nu_work_order','Api\ScreenController@nu_work_order');
 Route::any('nu_work_order','Api\ScreenController@nu_work_order');
 Route::any('saleOrdersFromAddress','Api\ScreenController@saleOrdersFromAddress');
 Route::any('saleOrdersFromAddress','Api\ScreenController@saleOrdersFromAddress');
 Route::any('production_status','Api\ScreenController@production_status');
 Route::any('production_status','Api\ScreenController@production_status');
+Route::any('deviceProduction','Api\ScreenController@deviceProduction');
 Route::group(['middleware'=> ['checkLogin']],function ($route){
 Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('HeaderSettingsAdd', 'Api\HeaderWordController@add');
     $route->any('HeaderSettingsAdd', 'Api\HeaderWordController@add');
     $route->any('HeaderSettingsDetail', 'Api\HeaderWordController@detail');
     $route->any('HeaderSettingsDetail', 'Api\HeaderWordController@detail');