@ -3,11 +3,16 @@
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class FenzhenController extends Controller
{
public static $url = 'https://lkt3.work.cjy.net.cn';
public static $log = null;
public function abandon()
{
// 这里放 弃检逻辑
@ -29,112 +34,194 @@ class FenzhenController extends Controller
$info = DB::table('orders')->where(['id' => $id])->whereIn('status', [2, 4])->first();
if (!$info) return \Yz::echoError1("查询就诊人订单失败");
$end_time = date('H:i', strtotime($info->appointment_date . ' ' . $info->appointment_time) + (60 * 60 * 0.54));
return \Yz::Return(true, "获取成功", [
'info' => [
'name' => $info->name,
'sex' => $info->sex,
'combo_name' => $info->title,
'check_date' => $info->appointment_date,
'start_time' => $info->appointment_time,
'end_time' => $end_time,
'qrcode' => '',
'code' => $info->appointment_number, // 体检条码
],
'list' => [[
'time' => '08:25',
'name' => '体检登记',
'status' => 4,
'desc' => '已完成',
'tip' => '体检登记 2024-08-09 08:25:30',
'more' => 0
], [
'time' => '08:30',
'name' => '体格检查',
'status' => 4,
'desc' => '已完成',
'tip' => '体格检查 2024-08-09 08:30:33',
'more' => 0
], [
'time' => '08:50',
'name' => '超声科',
'status' => 2,
'desc' => '第5位, 预计等待 11 分钟',
'tip' => '腹部彩超',
'more' => 0
], [
'time' => '09:20',
'name' => '心电图',
'status' => 1,
'desc' => '预计 09:20 进入队列',
'tip' => '剩余5项正在排队中, ',
'more' => 1
], [
'time' => $end_time,
'name' => '体检结束',
'status' => -1,
'desc' => '用餐时间 ' . $end_time,
'tip' => '',
'more' => 0
$res = self::fz('time', [
'exam_id' => $info->tj_number ?? '??????????',
'start_time' => date('H:i', strtotime($info->appointment_date . ' ' . $info->appointment_time)),
'clinics' => [[
"name" => "外科诊室",
"count" => 3
], [
'time' => '',
'name' => '出具报告',
'status' => -1,
'desc' => '预计 9月23日 出具体检报告',
'tip' => '',
'more' => 0
], [
'time' => '',
'name' => '报告解读',
'status' => -1,
'desc' => '预计 9月24日 可以预约报告解读',
'tip' => '',
'more' => 0
]],
"name" => "内科诊室",
"count" => 3
]]
]);
if (!!$res) {
$time_line = $res['data']['time_line'];
$check_report_status = -1;
if (!!$res['data']['report']) {
$report_time = date('m月d日', strtotime($res['data']['report'] . ' 00:00:00') + (60 * 60 * 24 * 5));
$report_status = false;
// 这里补充 获取 出具报告 时间的逻辑
if (!$report_status) {
$time_line[] = [
'time' => '',
'name' => '出具报告',
'status' => -1,
'desc' => "预计 $report_time 出具体检报告",
'tip' => '',
'more' => 0
];
} else {
$time_line[] = [
'time' => '',
'name' => '出具报告',
'status' => -1,
'desc' => "已出具体检报告 $report_status",
'tip' => '',
'more' => 0
];
}
$check_report_status = 0;
// $check_report_status = '2024年10月11日';
// 这里补充 获取 报告解读 时间的逻辑
if ($check_report_status == 0) {
$check_report_time = date('m月d日', strtotime($res['data']['report'] . ' 00:00:00') + (60 * 60 * 24 * 6));
$time_line[] = [
'time' => '',
'name' => '报告解读',
'status' => -1,
'desc' => "预计 $check_report_time 可以预约报告解读",
'tip' => '',
'more' => 0
];
} else {
$show_date = explode('年', $check_report_status)[1];
$time_line[] = [
'time' => '',
'name' => '报告解读',
'status' => -1,
'desc' => "已预约 $show_date 报告解读",
'tip' => '',
'more' => 0
];
}
}
return \Yz::Return(true, "获取成功", [
'info' => [
'name' => $info->name,
'sex' => $info->sex,
'combo_name' => $info->title,
'check_date' => $info->appointment_date,
'start_time' => $res['data']['start_time'] . ':00',
'end_time' => $res['data']['end_time'],
'qrcode' => '',
'code' => $info->appointment_number,
],
'list' => $time_line,
'report' => $check_report_status,
]);
} else {
return \Yz::Return(true, "获取成功", [
'info' => [
'name' => $info->name,
'sex' => $info->sex,
'combo_name' => $info->title,
'check_date' => $info->appointment_date,
'start_time' => $info->appointment_time,
'end_time' => $end_time,
'qrcode' => '',
'code' => $info->appointment_number,
],
'list' => [],
'report' => -1,
]);
}
}
public function info()
{
$id = request('id');
$clinic = request('clinic');
$info = DB::table('orders')->where(['id' => $id])->whereIn('status', [2, 4])->first();
if (!$info) return \Yz::echoError1("查询就诊人订单失败");
return \Yz::Return(true, "获取成功", [
'info' => [
'name' => $info->name,
'sex' => $info->sex,
'combo_name' => $info->title,
'check_date' => $info->appointment_date,
'start_time' => $info->appointment_time,
'end_time' => '10:25',
'qrcode' => '',
'code' => $info->appointment_number, // 体检条码
],
'list' => [[
'id' => '1',
'time' => '2024.09.11 08:25',
'name' => '超声科-颈部血管彩超',
'status' => 4,
], [
'id' => '1',
'time' => '2024.09.11 08:25',
'name' => '内科-内科问诊',
'status' => 4,
], [
'id' => '1',
'time' => '2024.09.11 08:25',
'name' => '内科-内科问诊',
'status' => 1,
], [
'id' => '1',
'time' => '2024.09.11 08:25',
'name' => '内科-内科问诊',
'status' => 1,
], [
'id' => '1',
'time' => '2024.09.11 08:25',
'name' => '内科-内科问诊',
'status' => 1,
]],
$res = self::fz('info', [
'exam_id' => $info->tj_number ?? '??????????',
'clinic' => $clinic,
]);
if (!!$res) {
if ($res['code'] == 200) {
return \Yz::Return(true, "获取成功", [
'info' => [
'name' => $info->name,
'sex' => $info->sex,
'combo_name' => $info->title,
'check_date' => $info->appointment_date,
'start_time' => $info->appointment_time,
'end_time' => '10:25',
'qrcode' => '',
'code' => $info->appointment_number,
],
'list' => $res['data']['list'],
]);
} else {
return \Yz::Return(false, $res['message']);
}
} else {
return \Yz::Return(false, "获取失败");
}
}
public function post($url, $data)
{
$data_string = json_encode($data, JSON_UNESCAPED_UNICODE);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data_string),
'Authorization: Bearer BD30333C-CBD4-4BA3-A27C-76727FF4D8B1'
]);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
$r = curl_exec($curl);
curl_close($curl);
return $r;
}
public function fz($type, $content)
{
$date = date('Y-m-d');
self::CheckTableName(date('Y-m-d'));
self::$log->date = $date;
self::$log->type = $type;
self::$log->content = json_encode($content, JSON_UNESCAPED_UNICODE);
self::$log->callback = '{}';
self::$log->save();
$url_map = [
'time' => '/api/Open/TiJian/get',
'info' => '/api/Open/TiJian/info',
];
$url = self::$url;
$res = self::post("$url{$url_map[$type]}", $content);
// /api/Open/TiJian/get
self::$log->callback = $res;
self::$log->save();
if (json_decode($res)) {
return json_decode($res, true);
} else {
return false;
}
}
public static function CheckTableName($date)
{
$table_name = 'zz_fenzhen_log_' . date('ym', strtotime($date));
$table_count = DB::select('select count(1) as c from information_schema.TABLES where table_schema = ? and table_name = ?', [env('DB_DATABASE'), $table_name])[0];
if ($table_count->c === 0) {
Schema::create($table_name, function (Blueprint $table) {
$table->id();
$table->date('date')->index();
$table->string('type', 20)->index();
$table->longText('content');
$table->longText('callback');
$table->timestamps();
});
}
self::$log = new \App\Models\FenzhenLog;
self::$log->setTable($table_name);
return $table_name;
}
}