Bläddra i källkod

版本大修改

cqp 2 månader sedan
förälder
incheckning
494f543e40

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

@@ -7,6 +7,32 @@ use Illuminate\Http\Request;
 
 class ApplyOrderController extends BaseController
 {
+    public function reportList(Request $request)
+    {
+        $service = new ApplyOrderService();
+        $user = $request->get('auth');
+        list($status,$data) = $service->reportList($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function reportRemainUpdate(Request $request)
+    {
+        $service = new ApplyOrderService();
+        $user = $request->get('auth');
+        list($status,$data) = $service->reportRemainUpdate($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
     public function orderSearchList(Request $request)
     {
         $service = new ApplyOrderService();

+ 18 - 0
app/Model/ReportMessage.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+class ReportMessage extends Model
+{
+    protected $table = "report_message"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+
+    const type_one = 1;
+    public static $type_name = [
+        self::type_one => '质检提醒',
+    ];
+}

+ 84 - 6
app/Service/ApplyOrderService.php

@@ -14,6 +14,7 @@ use App\Model\Equipment;
 use App\Model\InOutRecord;
 use App\Model\OrdersProduct;
 use App\Model\Process;
+use App\Model\ReportMessage;
 use App\Model\ReportWorking;
 use App\Model\ReportWorkingDetail;
 use App\Model\SaleOrdersProduct;
@@ -799,8 +800,25 @@ class ApplyOrderService extends Service
                 $team_man[$v['team_id']][] = $v['employee_id'];
             }
 
+            $process = Process::where('del_time',0)
+                ->where('is_need_remain',1)
+                ->select('id')
+                ->get()->toArray();
+            $process_id = array_column($process,'id');
+
             $detail_insert = [];
             foreach ($data['order_data'] as $v){
+
+                if(in_array($v['process_id'], $process_id)){
+                    ReportMessage::insert([
+                        'order_id' => $v['id'],
+                        'quantity' => $v['quantity'] ?? 0,
+                        'opt_case' => ReportMessage::type_one,
+                        'crt_time' => $time,
+                        'user_id' => $user['id'],
+                    ]);
+                }
+
                 $t = $team_man[$v['team_id']] ?? [];
                 if(! empty($t)){
                     foreach ($t as $t_v){
@@ -1986,7 +2004,7 @@ class ApplyOrderService extends Service
             if (!empty($first)) {
                 $first = $first->toArray();
                 $box_detail = new BoxDetail(['channel' => $first['top_order_no']]);
-                $result = $box_detail->where('order_no', $first['order_no'])->selct('top_id as id')->get()->toArray();
+                $result = $box_detail->where('order_no', $first['order_no'])->select('top_id as id')->get()->toArray();
             }
         } elseif ($data['type'] == 7) {
             $result = ScrappCount::where('del_time', 0)
@@ -2032,7 +2050,7 @@ class ApplyOrderService extends Service
             if (!empty($first)) {
                 foreach ($first as $value) {
                     $box_detail = new BoxDetail(['channel' => $value['top_order_no']]);
-                    $t = $box_detail->where('order_no', $first['order_no'])->selct('top_id as id')->get()->toArray();
+                    $t = $box_detail->where('order_no', $value['order_no'])->select('top_id as id')->get()->toArray();
                     $result = array_merge($result, $t);
                 }
             }
@@ -2049,7 +2067,7 @@ class ApplyOrderService extends Service
             if (!empty($first)) {
                 foreach ($first as $value) {
                     $box_detail = new BoxDetail(['channel' => $value['top_order_no']]);
-                    $t = $box_detail->where('order_no', $first['order_no'])->selct('top_id as id')->get()->toArray();
+                    $t = $box_detail->where('order_no', $value['order_no'])->select('top_id as id')->get()->toArray();
                     $result = array_merge($result, $t);
                 }
             }
@@ -2116,7 +2134,7 @@ class ApplyOrderService extends Service
 
             foreach ($sale as $value){
                 $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
-                $box_detail_order = $box_detail->where('top_id',$data['data_id'])->selct('order_no')->get()->toArray();
+                $box_detail_order = $box_detail->where('top_id',$data['data_id'])->select('order_no')->get()->toArray();
                 $tmp = Box::where('del_time',0)
                     ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
                     ->select("id","order_no")
@@ -2167,7 +2185,7 @@ class ApplyOrderService extends Service
             $ids = [];
             foreach ($sale as $value){
                 $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
-                $box_detail_order = $box_detail->where('top_id',$data['data_id'])->selct('order_no')->get()->toArray();
+                $box_detail_order = $box_detail->where('top_id',$data['data_id'])->select('order_no')->get()->toArray();
                 $tmp = Box::where('del_time',0)
                     ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
                     ->select("id")
@@ -2189,7 +2207,7 @@ class ApplyOrderService extends Service
             $ids = [];
             foreach ($sale as $value){
                 $box_detail = new BoxDetail(['channel'=> $value['order_no']]);
-                $box_detail_order = $box_detail->where('top_id',$data['data_id'])->selct('order_no')->get()->toArray();
+                $box_detail_order = $box_detail->where('top_id',$data['data_id'])->select('order_no')->get()->toArray();
                 $tmp = Box::where('del_time',0)
                     ->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
                     ->select("id")
@@ -2225,4 +2243,64 @@ class ApplyOrderService extends Service
 
         return [true, $result];
     }
+
+    public function reportList($data){
+        $model = ReportMessage::where('del_time',0)
+            ->select('id','order_id','opt_case','quantity','crt_time','user_id','is_use')
+            ->orderBy('id','desc');
+
+        $list = $this->limit($model,'',$data);
+        $list = $this->fillRData($list);
+
+        $count = ReportMessage::where('del_time',0)
+            ->where('is_use',0)
+            ->count();
+
+        return [true, ['list'=> $list, 'count' => $count]];
+    }
+
+    public function fillRData($data){
+        if(empty($data['data'])) return $data;
+
+        $dispatch = DispatchSub::whereIn('id',array_unique(array_column($data['data'],'order_id')))
+            ->select('id','dispatch_no','process_id')
+            ->get()->toArray();
+        $process = Process::where('del_time',0)
+            ->whereIn('id',array_unique(array_column($dispatch,'process_id')))
+            ->pluck('title','id')
+            ->toArray();
+        $map = [];
+        foreach ($dispatch as $value){
+            $map[$value['id']] = $value;
+        }
+        $emp_map = Employee::whereIn('id',array_unique(array_column($data['data'],'user_id')))
+            ->pluck("emp_name",'id')
+            ->toArray();
+        foreach ($data['data'] as $key => $value){
+            $time = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
+            $data['data'][$key]['crt_time'] = $time;
+            $t = $map[$value['order_id']] ?? [];
+            $e = $emp_map[$value['user_id']] ?? "";
+            $p = $process[$t['process_id']] ?? "";
+            $data['data'][$key]['message'] = "派工单:" . $t['dispatch_no'] . "于" . $time . "由($e)完成工序($p)报工,请及时处理";
+        }
+
+        return $data;
+    }
+
+    public function reportRemainUpdate($data){
+        if(empty($data['id'])) return [false, 'ID不能为空'];
+        if(empty($data['type'])) return [false, 'type不能为空'];
+        $type = $data['type'];
+
+        if($type == 1){
+            ReportMessage::where('id', $data['id'])
+                ->update(['is_use' => 1]);
+        }else{
+            ReportMessage::where('id', $data['id'])
+                ->update(['del_time' => time()]);
+        }
+
+        return [true, ''];
+    }
 }

+ 18 - 0
app/Service/Box/BoxService.php

@@ -12,6 +12,8 @@ use App\Model\EmployeeTeamPermission;
 use App\Model\Header_ext;
 use App\Model\OrdersProduct;
 use App\Model\OrdersProductProcess;
+use App\Model\Process;
+use App\Model\ReportMessage;
 use App\Model\ReportWorking;
 use App\Model\ReportWorkingDetail;
 use App\Model\SaleOrdersProduct;
@@ -631,6 +633,11 @@ class BoxService extends Service
             $is_first = false;
         }
 
+        $process = Process::where('del_time',0)
+            ->where('is_need_remain',1)
+            ->select('id')
+            ->get()->toArray();
+        $process_id = array_column($process,'id');
         try {
             DB::beginTransaction();
 
@@ -673,6 +680,17 @@ class BoxService extends Service
                 ]);
 
                 $return[$v['id']] = $id;
+
+                if(in_array($v['process_id'], $process_id)){
+                    ReportMessage::insert([
+                        'order_id' => $v['id'],
+                        'quantity' => $v['quantity'] ?? 0,
+                        'opt_case' => ReportMessage::type_one,
+                        'crt_time' => $time,
+                        'user_id' => $user['id'],
+                        'is_use' => 1
+                    ]);
+                }
             }
 
             DB::commit();

+ 2 - 0
app/Service/ProcessService.php

@@ -103,6 +103,7 @@ class ProcessService extends Service
         $model->wages = $data['wages'] ?? '';
         $model->team_id = $data['team_id'] ?? 0;
         $model->device_id = $data['device_id'] ?? 0;
+        $model->is_need_remain = $data['is_need_remain'] ?? 0;
         $model->save();
 
         return [true,'保存成功!'];
@@ -124,6 +125,7 @@ class ProcessService extends Service
         $model->wages = $data['wages'] ?? '';
         $model->team_id = $data['team_id'] ?? 0;
         $model->device_id = $data['device_id'] ?? 0;
+        $model->is_need_remain = $data['is_need_remain'] ?? 0;
         $model->save();
 
         return [true,'保存成功!'];

+ 2 - 0
routes/api.php

@@ -285,6 +285,8 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('applyOrderAdd', 'Api\ApplyOrderController@materialAdd');
     $route->any('applyOrderDel', 'Api\ApplyOrderController@materialDel');
     $route->any('applyOrderReportList', 'Api\ApplyOrderController@applyOrderReportList');
+    $route->any('reportRemainList', 'Api\ApplyOrderController@reportList');
+    $route->any('reportRemainUpdate', 'Api\ApplyOrderController@reportRemainUpdate');
 
     //仓库
     $route->any('storeHouseList', 'Api\FyyOrderController@getStorehouseDataFromSqlServer');