Explorar el Código

访问记录邮件发送

任敬轩 hace 2 años
padre
commit
a2c946ae6b
Se han modificado 1 ficheros con 14 adiciones y 82 borrados
  1. 14 82
      app/Console/Commands/LogEmailSend.php

+ 14 - 82
app/Console/Commands/LogEmailSend.php

@@ -3,7 +3,15 @@
 namespace App\Console\Commands;
 
 use Illuminate\Console\Command;
-use Illuminate\Support\Facades\Mail;
+use Illuminate\Support\Facades\Input;
+use Modules\Camera\Entities\CameraList;
+use Modules\Camera\Enum\CameraEnum;
+use Modules\Camera\Services\CameraServices;
+use Modules\Camera\Http\Controllers\Api\TdwyController;
+use Modules\Mine\Entities\MineList;
+use Modules\Mine\Entities\MineListExt;
+use Modules\Mine\Enum\MineEnum;
+use Modules\Mine\Services\MineServices;
 use Illuminate\Support\Facades\DB;
 
 class LogEmailSend extends Command
@@ -45,89 +53,13 @@ class LogEmailSend extends Command
     //同步区域列表
     public function logSendEmail()
     {
-        $email = DB::table('email')->get();
-        $date = date("Y-m-d",strtotime("yesterday"));
-        foreach($email as $k=>$v){
-            $to = $v->email;
-            $info = $this->info($v);
-            Mail::send('mail-msg',['info'=>$info], function ($message) use ($to,$date) {
-                $message->to($to)->subject($date.'摄像头访问记录');
-            });
-        }
+        $data['mine_id_list'] = '1,2,3';
+        $data['email'] = '123';
+        $data['created_at'] = date('Y-m-d H:i:s');
+        $data['updated_at'] = date('Y-m-d H:i:s');
+        DB::table('email')->insert($data);
     }
 
-    public function info($email){
-        $mine_array = explode(';',$email->mine_id_list);
-        $mine_all = DB::table('mine_list')->where('deleted_at',null)->get();//所有区域
-        $mine_use = [];//权限内矿区下所有区域
-        foreach($mine_all as $k=>$v){
-            if(in_array(explode('|',$v->degree)[0],$mine_array)){
-                $mine_use[] = $v->id;
-            }
-        }
 
-        $log_list = DB::table('log')
-            ->select('log.*','mine_list.title','mine_list.degree','camera_list.camera_name')
-            ->leftJoin('mine_list','mine_list.id','=','log.mine_id')
-            ->leftJoin('camera_list','camera_list.id','=','log.camera_id')
-            ->whereIn('log.mine_id',$mine_use)
-            ->orderBy('camera_list.camera_name', 'desc');
-
-        $mine_export = '';
-        $mine_list = DB::table('mine_list')->whereIn('id',$mine_array)->get();
-        foreach($mine_list as $k=>$v){
-            $mine_export = $mine_export.$v->title.'和';
-        }
-        $mine_export = substr($mine_export,0,strlen($mine_export)-3).date("Y-m-d",strtotime("yesterday")).'访问记录';
-        $start_time = date("Y-m-d H:i:s",strtotime("yesterday"));
-        $end_time = date("Y-m-d H:i:s",strtotime("today"));
-        $log_list = $log_list->whereBetween('log.created_at',[$start_time,$end_time]);
-
-        $log_list = $log_list->get()->toArray();
-
-        if(count($log_list)>0){
-            for($i=0;$i<count($log_list);$i++){
-                $degree = explode('|',$log_list[$i]->degree);
-                $mine = DB::table('mine_list')->where('id',$degree[0])->get();
-                $log_list[$i]->mine_name = $mine[0]->title;
-                if($log_list[$i]->status == 0){
-                    $log_list[$i]->status = '正常';
-                }else{
-                    $log_list[$i]->status = '异常';
-                }
-            }
-        }
-
-        //去掉重复数据改为次数
-        $new_log_list = [];
-        foreach($log_list as $log){
-            $repeat = 0;//不在新数组
-            if(count($new_log_list)>0){
-                for($i=0;$i<count($new_log_list);$i++){
-                    if($log->camera_name==$new_log_list[$i]['camera_name'] && $log->status==$new_log_list[$i]['status']){
-                        $new_log_list[$i]['count']++;
-                        $repeat = 1;//在新数组
-                    }
-                }
-            }
-
-            if($repeat == 0){//不在新数组
-                $size = count($new_log_list);
-                $new_log_list[$size]['mine_name'] = $log->mine_name;
-                $new_log_list[$size]['title'] = $log->title;
-                $new_log_list[$size]['camera_id'] = $log->camera_id;
-                $new_log_list[$size]['camera_name'] = $log->camera_name;
-                $new_log_list[$size]['status'] = $log->status;
-                $new_log_list[$size]['log'] = $log->log;
-                $new_log_list[$size]['created_at'] = $log->created_at;
-                $new_log_list[$size]['count'] = 1;
-            }
-        }
-
-        $data['title'] = $mine_export;
-        $data['content'] = $new_log_list;
-
-        return $data;
-    }
 
 }