浏览代码

公管人员同步

任敬轩 2 周之前
父节点
当前提交
b6be4fad48
共有 1 个文件被更改,包括 48 次插入3 次删除
  1. 48 3
      app/Http/Controllers/TestsController.php

+ 48 - 3
app/Http/Controllers/TestsController.php

@@ -57,10 +57,55 @@ class TestsController {
 
     //公管公司人员信息同步
     public function gggsRyxx(){
+        // DB::connection('mysql_fwe10')->table('uf_gggs_rygl')->where('id','!=','123')->delete();
+
         $people_list = DB::connection('mysql_fwe10')
-            ->table('eteams.employee')
-            ->get();
-        dd($people_list);
+            ->table('eteams.employee as employee')
+            ->select('employee.username','employee.job_num','employee.mobile','employee.telephone')
+            ->leftJoin('eteams.department as department','employee.department','=','department.id')
+            ->where('department.parent','100001980000000044')
+            ->whereNotNull('employee.username')
+            ->where('employee.username', '!=', '')
+            ->whereNotNull('employee.job_num')
+            ->where('employee.job_num', '!=', '')
+            ->whereRaw('employee.job_num REGEXP ?', ['^[0-9]+$'])
+            ->get()->toArray();
+        // dd($people_list);
+
+        if(count($people_list) > 0){
+            for($i=0;$i<count($people_list);$i++){
+                $id = mt_rand(pow(10, 18), pow(10, 18) + 999999999);
+
+                if($people_list[$i]->mobile != null && $people_list[$i]->mobile != ''){
+                    $dh = explode(';',$people_list[0]->mobile)[0];
+                }elseif($people_list[$i]->telephone != null && $people_list[$i]->telephone != ''){
+                    $dh = explode(';',$people_list[0]->telephone)[0];
+                }else{
+                    $dh = '';
+                }
+
+                $insert = [
+                    'ID' => $id,
+                    'FORM_DATA_ID' => $id,
+                    'DATA_INDEX' => 0.0,
+                    'CREATE_TIME' => date('Y-m-d H:i:s'),
+                    'TENANT_KEY' => 't1zz9w8165',
+                    'IS_DELETE' => 0,
+                    'DELETE_TYPE' => 0,
+                    'FT_STATUS' => 0,
+
+                    'xm' => $people_list[$i]->username,
+                    'gh' => $people_list[$i]->job_num,
+                    'dh' => $dh,
+                    'job_num' => $people_list[$i]->job_num,
+                ];
+                // dd($insert);
+                DB::connection('mysql_fwe10')->table('uf_gggs_rygl')->insert($insert);
+                // Log::info('111111'.$i);
+            }
+        }
+
+        dd('success');
     }
 
     //区域列表接口测试