Ver código fonte

一些错误修复

Zhouzhendong 4 anos atrás
pai
commit
9c338c5e90

+ 9 - 0
app/Exceptions/Handler.php

@@ -2,11 +2,13 @@
 
 namespace App\Exceptions;
 
+use App\Log;
 use App\Services\LogService;
 use Exception;
 use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Validation\ValidationException;
+use Symfony\Component\ErrorHandler\Error\FatalError;
 use Throwable;
 
 class Handler extends ExceptionHandler
@@ -47,6 +49,13 @@ class Handler extends ExceptionHandler
     {
         $errMsg='';
         try{
+            if (substr($exception->getFile(),-(strlen("FatalError.php")))==='FatalError.php'){
+                \Illuminate\Support\Facades\Log::emergency("FPM内存耗尽",["user"=>Auth::id(),"param"=>$request->all()]);
+                return response()->view('exception.default',[
+                    'code'=> "500",
+                    'message'=>"网站负载过大,联系管理员处理",
+                ]);
+            }
             $type = $exception->type ?? 'error';
             $errMsg=(function()use($request,$exception){
                 return $errMsg=

+ 14 - 5
app/Http/Controllers/ProcessController.php

@@ -28,6 +28,7 @@ use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Gate;
+use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Validator;
 use Illuminate\View\View;
 use Oursdreams\Export\Export;
@@ -298,6 +299,10 @@ class ProcessController extends Controller
         //同步二次加工单统计
         $processDailiesStatistic=$processDailies->where('output','>',0);
         $processStatistic=ProcessStatistic::find($processDaily->process_id);    //如非录入渠道建单不生成统计单,报错
+        if(!$processStatistic){
+            Log::warning("二次加工统单不存在",["user"=>Auth::id(),"param"=>$processDaily->process_id]);
+            return ["processDailies"=>$processDailies];
+        }
         $processStatistic->top_capacity=$processDailiesStatistic->max('output');
         $processStatistic->bottom_capacity=$processDailiesStatistic->min('output');
         $processStatistic->average_capacity=$processDailiesStatistic->avg('output');
@@ -343,7 +348,7 @@ class ProcessController extends Controller
         $userLabor=UserLabor::find($user_id);
         $processDaily=processDaily::find($daily_id);
         if ($userLabor->isOccupiedAt($processDaily->date,$ended_at)){
-            ['status'=>"warning",'data'=>'该临时工此时间段已存在工作记录!'];
+            return ['status'=>"warning",'data'=>'该临时工此时间段已存在工作记录!'];
         };
         $processDailyParticipant=new ProcessDailyParticipant([
             'process_daily_id'=>$daily_id,
@@ -381,10 +386,14 @@ class ProcessController extends Controller
             $process->update();
             $result['process']=$processDaily->process_id;
             $processStatistic=ProcessStatistic::find($processDaily->process_id);
-            //$processStatistic->started_at=date('Y-m-d H:i:s');
-            $processStatistic->started_at=$processDaily->date.' '.$started_at;
-            $processStatistic->update();
-            app('LogService')->log(__METHOD__,"二次加工单加工中".__FUNCTION__,json_encode($process)." || ".json_encode($processStatistic),Auth::user()['id']);
+            if (!$processStatistic){
+                Log::warning("二次加工统单不存在2",["user"=>Auth::id(),"param"=>$processDaily->process_id]);
+            }else {
+                //$processStatistic->started_at=date('Y-m-d H:i:s');
+                $processStatistic->started_at=$processDaily->date.' '.$started_at;
+                $processStatistic->update();
+                app('LogService')->log(__METHOD__,"二次加工单加工中".__FUNCTION__,json_encode($process)." || ".json_encode($processStatistic),Auth::user()['id']);
+            }
         }
         $result['status']="success";
         $result['data']=$processDailyParticipant;

+ 23 - 2
app/Http/Controllers/TestController.php

@@ -98,6 +98,7 @@ use Laravel\Horizon\Events\JobFailed;
 use Monolog\Handler\IFTTTHandler;
 use phpDocumentor\Reflection\Types\Resource_;
 use PhpOffice\PhpSpreadsheet\Calculation\Web\Service;
+use Symfony\Component\ErrorHandler\Error\FatalError;
 
 class TestController extends Controller
 {
@@ -112,12 +113,32 @@ class TestController extends Controller
 
     public function method(Request $request, $method)
     {
-        return call_user_func([$this, $method], $request);
+        try {
+            return call_user_func([$this, $method], $request);
+        }catch (\BadMethodCallException $e){
+            dd("方法不存在");
+        }
+    }
+    public function test1()
+    {
+        try {
+            $b = DB::connection("oracle")->select("SELECT * FROM DOC_ORDER_HEADER");
+            dump(count($b));
+        }catch (\Exception $e){
+            dd($e);
+        }catch (\Error $e1){
+            dd($e1);
+        }
+        dd(round(memory_get_peak_usage() / 1024 / 1024, 2));
     }
-
 
     public function test()
     {
+        $b = [];
+        for ($i=0;$i<100000;$i++){
+            $b[] = $i;
+        }
+        dd(round(memory_get_peak_usage() / 1024 / 1024, 2));
         $area = OwnerAreaReport::query()->find(398);
         if (!$area->ownerStoragePriceModel)dd("error");
         //信息提取模板

+ 1 - 0
app/Jobs/HandlePastBill.php

@@ -34,6 +34,7 @@ class HandlePastBill implements ShouldQueue
      */
     public function handle(OwnerPriceOperationService $service)
     {
+        ini_set('max_execution_time', 2500);
         list($rule,$owner,$discountIndex,$pivot) = $this->arr;
         $service->handlePastBill($rule,$owner,$discountIndex,$pivot);
     }

+ 10 - 1
resources/views/layouts/notification.blade.php

@@ -137,6 +137,7 @@
             mounted(){
                 if(this.infos.length===15)this.bindListen();
                 $(document.body).append($('<audio id="audio" src="" autoplay></audio>'));
+                if (Notification.permission!=='granted')Notification.requestPermission();
                 this.initBroadcast();
             },
             methods: {
@@ -157,9 +158,17 @@
                         .notification((notification) => {
                             this.count++;
                             this.infos.unshift(notification);
-                            if (notification.mark==0)this.playAudio(notification.mark);
+                            if (notification.mark==0)this._handleWorkOrder(notification);
                         });
                 },
+                _handleWorkOrder(notification){
+                    this.playAudio(notification.mark);
+                    if(window.Notification ) {
+                        Notification.requestPermission(function(status) {
+                            new Notification('通知面板', { body: '有新工单' });
+                        });
+                    }
+                },
                 playAudio(mark){
                     if (!audioPlay)return;
                     let audio = document.getElementById('audio');