cqp 1 өдөр өмнө
parent
commit
8e42988f2b

+ 12 - 0
app/Model/Process.php

@@ -22,5 +22,17 @@ class Process extends Model
         if(empty($name)) return $query->where('del_time', '=', 0);
         else return $query->where($name, '=', 0);
     }
+
+    const type_zero = 0;
+    const type_one = 1;
+    const type_two = 2;
+    const type_three = 3;
+
+    public static $type = [
+        self::type_zero => "无",
+        self::type_one => "全检",
+        self::type_two => "抽检",
+        self::type_three => "过程检验",
+    ];
 }
 

+ 73 - 35
app/Service/ApplyOrderService.php

@@ -4573,24 +4573,35 @@ class ApplyOrderService extends Service
     }
 
     public function reportList($data){
-        $model = ReportMessage::where('del_time',0)
+        $result = ReportMessage::where('del_time',0)
+            ->where('crt_time',">=",strtotime(date('Y-m-01 00:00:00')))
             ->select('id','order_id','opt_case','quantity','crt_time','user_id','is_use','report_working_id')
-            ->orderBy('id','desc');
+            ->orderBy('id','asc')
+            ->get()->toArray();
+        $list = $this->fillRData($result, $data);
 
-        $list = $this->limit($model,'',$data);
-        $list = $this->fillRData($list, $data);
+        $page_index = intval(request('page_index', 1)); // 当前页
+        $page_size  = intval(request('page_size', 40)); // 每页数量
+
+        $total = count($list);
+        $offset = ($page_index - 1) * $page_size;
+        $pagedData = array_slice($list, $offset, $page_size);
+        $result = [
+            'total' => $total,
+            'data' => $pagedData,
+        ];
 
         $count = ReportMessage::where('del_time',0)
             ->where('is_use',0)
             ->count();
 
-        return [true, ['list'=> $list, 'count' => $count]];
+        return [true, ['list'=> $result, 'count' => $count]];
     }
 
     public function fillRData($data, $erg){
-        if(empty($data['data'])) return $data;
+        if(empty($data)) return $data;
 
-        $dispatch = DispatchSub::whereIn('id',array_unique(array_column($data['data'],'order_id')))
+        $dispatch = DispatchSub::whereIn('id',array_unique(array_column($data,'order_id')))
             ->select('id','dispatch_no','process_id')
             ->get()->toArray();
         $process = Process::where('del_time',0)
@@ -4602,54 +4613,81 @@ class ApplyOrderService extends Service
         foreach ($dispatch as $value){
             $map[$value['id']] = $value;
         }
-        $emp_map = Employee::whereIn('id',array_unique(array_column($data['data'],'user_id')))
+        $emp_map = Employee::whereIn('id',array_unique(array_column($data,'user_id')))
             ->pluck("emp_name",'id')
             ->toArray();
-        $order_map = ReportWorking::whereIn('id',array_filter(array_column($data['data'],'report_working_id')))
+        $order_map = ReportWorking::whereIn('id',array_filter(array_column($data,'report_working_id')))
             ->pluck('order_number','id')
             ->toArray();
-        $no_need = isset($erg['not_need']) ? 1 : 0;
-        foreach ($data['data'] as $key => $value){
+
+        $map_2 = [];
+        $map_3 = [];
+        foreach ($data as $key => $value){
             $time = $value['crt_time'] ? date('Y-m-d',$value['crt_time']) : '';
-            $data['data'][$key]['crt_time'] = $time;
+            $data[$key]['crt_time'] = $time;
             $t = $map[$value['order_id']] ?? [];
             $e = $emp_map[$value['user_id']] ?? "";
             $p = $process[$t['process_id']] ?? [];
             $p_t = $p['title'] ?? "";
-            if($p['zj_type'] == 0){
-                $p_t .= ":无需质检";
-            }elseif($p['zj_type'] == 1){
-                $p_t .= ":全检";
-            }else{
-                $p_t .= ":抽检";
+            $type = Process::$type[$p['zj_type']] ?? "";
+            if(! empty($type)){
+                $p_t .= ":" . $type;
             }
-            if(! $no_need){
-                if(empty($value['report_working_id'])){
-                    $str = "派工单:" . $t['dispatch_no'] . "于" . $time . "由($e)完成工序($p_t)报工,数量{$value['quantity']}吨,请及时处理";
-                }else{
-                    $tmp = $order_map[$value['report_working_id']] ?? "";
-                    if(empty($tmp)){
-                        $str = "派工单:" . $t['dispatch_no'] . "于" . $time . "由($e)完成工序($p_t)报工,数量{$value['quantity']}吨,请及时处理";
+
+            if($t['process_id'] == 14){
+                if(isset($map_2[$value['order_id']])){
+                    $tmp = bcadd(0.75, $map_2[$value['order_id']],3);
+                    $map_2[$value['order_id']] = $tmp;
+                    if($tmp == 9){
+                        $title = "中检";
+                    }elseif($tmp >= 12){
+                        $title = "尾检";
+                        unset($map_2[$value['order_id']]);
                     }else{
-                        $str = "派工单:" . $t['dispatch_no'] . "于" . $time . "由($e)完成工序($p_t)报工({$tmp}),数量{$value['quantity']}吨,请及时处理";
+                        unset($data[$key]);
+                        continue;
                     }
+                }else{
+                    $title = "首检";
+                    $map_2[$value['order_id']] = 0.75;
                 }
+
+                $p_t .= $title;
             }else{
-                if(empty($value['report_working_id'])){
-                    $str = "派工单:" . $t['dispatch_no'] . "由($e)完成工序报工,数量{$value['quantity']}吨,请及时处理";
-                }else{
-                    $tmp = $order_map[$value['report_working_id']] ?? "";
-                    if(empty($tmp)){
-                        $str = "派工单:" . $t['dispatch_no'] . "由($e)完成工序报工,数量{$value['quantity']}吨,请及时处理";
+                if(isset($map_3[$value['order_id']])){
+                    $tmp = bcadd(0.75, $map_3[$value['order_id']],3);
+                    $map_3[$value['order_id']] = $tmp;
+                    if($tmp == 9){
+                    }elseif($tmp >= 15){
+                        unset($map_3[$value['order_id']]);
                     }else{
-                        $str = "派工单:" . $t['dispatch_no'] . "由($e)完成工序报工({$tmp}),数量{$value['quantity']}吨,请及时处理";
+                        unset($data[$key]);
+                        continue;
                     }
+                }else{
+                    $map_3[$value['order_id']] = 0.75;
                 }
             }
-            $data['data'][$key]['message'] = $str;
+            if(empty($value['report_working_id'])){
+                $str = "派工单:" . $t['dispatch_no'] . "于" . $time . "由($e)完成工序($p_t)报工,数量{$value['quantity']}吨,请及时处理";
+            }else{
+                $tmp = $order_map[$value['report_working_id']] ?? "";
+                if(empty($tmp)){
+                    $str = "派工单:" . $t['dispatch_no'] . "于" . $time . "由($e)完成工序($p_t)报工,数量{$value['quantity']}吨,请及时处理";
+                }else{
+                    $str = "派工单:" . $t['dispatch_no'] . "于" . $time . "由($e)完成工序($p_t)报工({$tmp}),数量{$value['quantity']}吨,请及时处理";
+                }
+            }
+            $data[$key]['message'] = $str;
+            $data[$key]['process_id'] = $t['process_id'];
         }
 
-        return $data;
+        $data = array_values($data);
+        usort($data, function($a, $b) {
+            return $b['id'] <=>  $a['id'];
+        });
+
+        return array_values($data);
     }
 
     public function reportRemainUpdate($data){

+ 1 - 1
app/Service/LargeScreenService.php

@@ -430,7 +430,7 @@ class LargeScreenService extends Service
         }
         //双周生产计划达成率-----------------------------------------------------
 
-        list($status, $return) = (new ApplyOrderService())->reportList(['page_size' => 3, 'page_index' => 1, 'not_need' => 1]);
+        list($status, $return) = (new ApplyOrderService())->reportList(['page_size' => 3, 'page_index' => 1]);
         $cs = $return['list'] ?? [];
         $cs = $cs['data'] ?? [];
         $cs = array_column($cs, 'message');

+ 11 - 0
app/Service/ProcessService.php

@@ -162,10 +162,21 @@ class ProcessService extends Service
         if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
 
         $list = $this->limit($model,'',$data);
+        $list = $this->fillData($list);
 
         return [200,$list];
     }
 
+    public function fillData($data){
+        if(empty($data['data'])) return $data;
+
+        foreach ($data['data'] as $key => $value){
+            $data['data'][$key]['zj_type_title'] = Process::$type[$value['zj_type']] ?? "";
+        }
+
+        return $data;
+    }
+
     public function processRule($data){
         if($this->isEmpty($data,'title')) return [false,'名称不存在!'];
         if($this->isEmpty($data,'p_id')) return [false,'分类不存在!'];

+ 3 - 2
app/Service/ScrappService.php

@@ -253,6 +253,7 @@ class ScrappService extends Service
         $order['equipment_title'] = Equipment::where('id',$first['equipment_id'])->value("title");
         $dispatch = ReportWorking::where('id',$first['report_id'])->first();
         $dispatch = empty($dispatch) ? [] : $dispatch->toArray();
+        $zj_plan_id = DispatchSub::where('id', $first['dispatch_sub_id'])->value('zj_plan_id');
         $order['dispatch_no'] = $dispatch['order_number'] ?? "";
         $order['crt_time'] = date("Y-m-d", $first['crt_time']);
 
@@ -291,8 +292,8 @@ class ScrappService extends Service
 
         $order['detail'][] = $detail;
         $table1 = $table2 = [];
-        if(! empty($dispatch['zj_plan_id'])){
-            $plan = ZjPlan::where('id',$dispatch['zj_plan_id'])->first();
+        if(! empty($zj_plan_id)){
+            $plan = ZjPlan::where('id',$zj_plan_id)->first();
             if(! empty($plan)){
                 $plan = $plan->toArray();
                 $map = Zj::where('del_time',0)->pluck('title','id')->toArray();