post('id_number'); $id = $request->post('id'); if (!$id_number) return \Yz::echoError('请输入身份证'); $queue = []; $fzc = new fzc(); $res = $fzc->fz('change', [ 'id_number' => $id_number, 'id' => $id, ]); if ($res['code'] == 200) { $queue_info = $res['data']['queue']; if (!!$queue_info) { $queue = [[ 'id' => $queue_info['id'], 'name' => $queue_info['name'], 'clinic' => $queue_info['clinic_name'], 'item' => $queue_info['item_name'], ]]; } } return \Yz::Return(true, '操作完成', [ 'queue' => $queue ]); } public function check_in(Request $request) { $id_number = $request->get('id_number'); if (!$id_number) { $id_number = ''; } $queue = []; if (!!$id_number) { $fzc = new fzc(); $res = $fzc->fz('search', [ 'id_number' => $id_number ]); if ($res['code'] == 200) { $queue_info = $res['data']['queue']; if (!!$queue_info) { $queue = [[ 'id' => $queue_info['id'], 'name' => $queue_info['name'], 'clinic' => $queue_info['clinic_name'], 'item' => $queue_info['item_name'], ]]; } } } return view('fenzhen', [ 'id_number' => $id_number, 'queue' => $queue ]); } public function export(){ $fzc = new fzc(); $date=request('date'); $res = $fzc->fz('export', [ 'date' => $date ]); $table_list=$res['data']['table1']; $clinic_list=$res['data']['table2']; $table_list3=$res['data']['table3']; // dd(json_encode($table_list3,JSON_UNESCAPED_UNICODE)); $template_path = Storage::path('public/excel/check_time.xlsx'); $spreadsheet = IOFactory::load($template_path); $worksheet = $spreadsheet->getActiveSheet(); $styleArray = [ 'borders' => [ 'allBorders' => [ 'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, 'color' => ['argb' => 'FF000000'], ], ], ]; $row = 3; $col = [ 'A' => 'date', 'B' => 'name', 'C' => 'number', 'D' => 'phone', 'E' => 'group_name', 'F' => 'clinic', 'G' => 'doctor', 'H' => 'queue', 'I' => 'calling', 'J' => 'done', 'K' => 'clinic_check_time', 'L' => 'true_check_time', 'M' => 'timeout_check_time', 'N' => 'clinic_wait_time', 'O' => 'true_wait_time', 'P' => 'timeout_wait_time', 'Q' => 'clinic_all_time', 'R' => 'true_all_time', 'S' => 'timeout_all_time', ]; foreach ($table_list as $table_item) { foreach ($col as $index => $key) { $worksheet->setCellValueExplicit($index . $row, $table_item[$key], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); } $row++; } $worksheet->getStyle('A3:S' . ($row - 1))->applyFromArray($styleArray); $row = 3; $col = [ 'U' => 'group_name', 'V' => 'clinic', 'W' => 'doctor', 'X' => 'check', 'Y' => 'check_out', 'Z' => 'wait', 'AA' => 'wait_out', ]; foreach ($clinic_list as $clinic_item) { foreach ($col as $index => $key) { $worksheet->setCellValueExplicit($index . $row, $clinic_item[$key], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); } $row++; } $worksheet->getStyle('U3:AA' . ($row - 1))->applyFromArray($styleArray); $row = 3; $col = [ 'AC' => 'date', 'AD' => 'name', 'AE' => 'number', 'AF' => 'phone', 'AG' => 'combo', 'AH' => 'clinic_time', 'AI' => 'used_time', 'AJ' => 'timeout', ]; //汇总信息 $usercount=count($table_list3); $biaozhun_timecount=0; $shiji_timecount=0; $chaoshi_timecount=0; $weichaoshi_count=0; foreach ($table_list3 as $table_list3_i) { $biaozhun_timecount+=$table_list3_i['clinic_time']; $shiji_timecount+=$table_list3_i['used_time']; $chaoshi_timecount+=$table_list3_i['timeout']; if($table_list3_i['timeout']<=0){ $weichaoshi_count++; } $peis = new PEISApiController(); $data = [ '电话号码' => "", '证件号码' => "", '体检号' => $table_list3_i['uuid'], '包含内部信息' => true ]; $reports = $peis::Post('体检报告查询', 1, $data); if(isset($reports['data'][0]['套餐名称'])){ $table_list3_i['combo']=$reports['data'][0]['套餐名称']; }else{ $table_list3_i['combo']=''; } foreach ($col as $index => $key) { $worksheet->setCellValueExplicit($index . $row, $table_list3_i[$key], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); } $row++; } $worksheet->setCellValueExplicit('AC' . $row, '汇总', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); $worksheet->setCellValueExplicit('AD' . $row, '客户总数', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); $worksheet->setCellValueExplicit('AE' . $row, $usercount, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); $worksheet->setCellValueExplicit('AG' . $row, '总用时:', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); $worksheet->setCellValueExplicit('AH' . $row, $biaozhun_timecount, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); $worksheet->setCellValueExplicit('AI' . $row, $shiji_timecount, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); $worksheet->setCellValueExplicit('AJ' . $row, $chaoshi_timecount, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); $worksheet->setCellValueExplicit('AD' . ($row+1), '未超时总数', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); $worksheet->setCellValueExplicit('AE' . ($row+1), $weichaoshi_count, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); $worksheet->setCellValueExplicit('AD' . ($row+2), "体检准时率", \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); $worksheet->setCellValueExplicit('AE' . ($row+2),$weichaoshi_count/$usercount , \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING); $worksheet->getStyle('AC3:AJ' . ($row +2))->applyFromArray($styleArray); $file_name = Str::orderedUuid(); $dir_path = "public/excel/" . date('Ym') . '/' . $file_name; Storage::makeDirectory($dir_path); $name_date = date('n.j', strtotime($date . ' 00:00:00')); $excel_path = $dir_path . "/体检报表-时间监控$name_date.xlsx"; $writer = new Xlsx($spreadsheet); $writer->save(Storage::path($excel_path)); $url = Storage::url($excel_path); return \Yz::Return(true,"获取成功",['url' => env('APP_URL').$url]); } }