新增删除登记预约记录接口,完善相关日志

main
岩仔88 1 month ago
parent 4b0f2cfbd2
commit 74676108a1

@ -58,7 +58,7 @@ public function CreateAppointment(){
if($c[0]->status==1){
$up=DB::table('appointment_record')->where(['id'=>$c[0]->id])->update(['status'=>2]);
if($up){
return \Yz::Return(true,'保存成功',[]);
return \Yz::Return(true,'保存成功',['id'=>$c[0]->id]);
}else{
return \Yz::echoError1('保存失败');
}
@ -70,7 +70,7 @@ public function CreateAppointment(){
if($Hmac['status']!=true){
return \Yz::echoError1('HMAC摘要失败');
}
$i=DB::table('appointment_record')->insert([
$i=DB::table('appointment_record')->insertGetId([
'source'=>$source,
'type'=>$info['type'],
'name'=>$info['name'],
@ -91,11 +91,66 @@ public function CreateAppointment(){
]);
if($i){
return \Yz::Return(true,'保存成功',[]);
return \Yz::Return(true,'保存成功',['id'=>$i]);
}else{
return \Yz::echoError1('保存失败');
}
}
//对外接口,删除登记预约记录
public function DelAppintmentInfo()
{
$org_code = request('org_code');
$id_card_num = request('id_card_num');
$id = request('id');
$doctor_name = request('doctor_name');
if(!isset($id_card_num)) return \Yz::echoError1('证件号不能为空');
if(!isset($id)) return \Yz::echoError1('记录id不能为空');
//HSM加密
$HSM_sfz = \App\Lib\HSM::HsmEncrypt($id_card_num);
if($HSM_sfz['status']!=true){
return \Yz::echoError1('调用HSM加密失败');
}
$id_card_num_encrypted = $HSM_sfz['data'];
//根据id查找记录
$record = DB::table('appointment_record')->where('id', $id)->first();
if(!$record) return \Yz::echoError1('未找到对应记录');
//校验证件号匹配
if($record->id_card_num !== $id_card_num_encrypted){
return \Yz::echoError1('证件号与记录不匹配');
}
//校验是否已删除
if($record->is_del == 1){
return \Yz::echoError1('该记录已被删除');
}
//记录删除日志
$deleteLogService = app()->make(\App\Services\DeleteLogService::class);
$deleteLogService->logDeletion(
'appointment_record',
$record->id,
$record->name,
$record->id_card_num,
null,
$doctor_name,
'对外接口删除',
''
);
//软删除
$del = DB::table('appointment_record')->where('id', $record->id)->update(['is_del'=>1]);
if($del){
return \Yz::Return(true,'删除成功',[]);
}else{
return \Yz::echoError1('删除失败');
}
}
public function Del()
{
$id=request('id');

@ -35,8 +35,11 @@ public function CheckRequirements(){
$id_card_num=request('id_card_num');
$name=request('name');
$type=request('type');//体检类型 1,健康证2老年人
$currentOrgName=request('org_name');
$doctor_name=request('doctor_name');
$s=app()->make(AppointmentService::class);
return $s->CheckAppointment($name,$id_card_num,$type);
return $s->CheckAppointment($name,$id_card_num,$type,$currentOrgName,$doctor_name);
}
//获取个人预约记录详情
@ -212,13 +215,18 @@ public function CheckUpCount(Request $request)
return \Yz::Return(true,'查询成功',['list'=>$list,'dateRange'=>[$searchInfo['start'],$searchInfo['end']]]);
}
//删除体检记录
//删除体检记录,用于取消总检
public function DelCheckUpInfo()
{
$id_card_num=request('id_card_num');
$tijian_num=request('tijian_num');
$code=request('code');
$type=request('type');
$doctor_name=request('doctor_name');
if(!isset($id_card_num)) return \Yz::echoError1('证件号不能为空');
if(!isset($tijian_num)) return \Yz::echoError1('体检号不能为空');
if(!isset($code)) return \Yz::echoError1('机构编码不能为空');
$HSM_sfz =\App\Lib\HSM::HsmEncrypt($id_card_num);
if($HSM_sfz['status']!=true){
return \Yz::echoError1('调用HSM加密失败');
@ -228,7 +236,21 @@ public function DelCheckUpInfo()
if(!$org_id) return \Yz::echoError1('机构不存在');
$info=DB::table('examination_records')->where(['tijian_num'=>$tijian_num,'id_card_num'=>$id_card_num,'institution_id'=>$org_id->id])->first();
if(!$info) return \Yz::echoError1('未找到对应记录');
$del=DB::table('examination_records')->where(['id'=>$info->id])->delete();
//记录删除日志
$deleteLogService = app()->make(\App\Services\DeleteLogService::class);
$deleteLogService->logDeletion(
'examination_records',
$info->id,
$info->name,
$info->id_card_num,
null,
$doctor_name,
'接口删除-取消总检',
''
);
$del=DB::table('examination_records')->where(['id'=>$info->id])->update(['is_del'=>1]);
if($del){
return \Yz::Return(true,'删除成功',[]);
}else{

@ -99,13 +99,15 @@ public function GetList(Request $request)
public function Del(Request $request)
{
$group = $request->get('role');//中间件产生的参数
$userid = $request->get('userid');//中间件产生的参数
$group = $request->get('role');
$userid = $request->get('userid');
if ($group != 1) {
return \Yz::echoError1('权限不足');
}
$id = request('id');
$leixing = request('leixing');
$reason = request('reason');
$screenshot = request('screenshot') ?: '';
$tablename = 'appointment_record';
if ($leixing == '预约') {
$tablename = 'appointment_record';
@ -113,6 +115,24 @@ public function Del(Request $request)
if ($leixing == '体检') {
$tablename = 'examination_records';
}
$record = DB::table($tablename)->where('id', $id)->first();
if (!$record) {
return \Yz::echoError1('未找到记录');
}
$operatorName = '';
$user = DB::table('users')->where('id', $userid)->first();
if ($user) $operatorName = $user->cn_name;
$deleteLogService = app()->make(\App\Services\DeleteLogService::class);
$deleteLogService->logDeletion(
$tablename,
$id,
$record->name,
$record->id_card_num,
$userid,
$operatorName,
$reason,
$screenshot
);
$update = DB::table($tablename)->where('id', $id)->update(['is_del' => 1]);
if ($update) {
return \Yz::Return(true, '标记删除完成', ['id' => $id, 'tablename' => $tablename, 'userid' => $userid]);

@ -66,7 +66,7 @@ public function GetAppointmentList($arr){
}
//检测是否有登记预约记录
public function CheckAppointment($name,$id_card_num,$type){
public function CheckAppointment($name,$id_card_num,$type,$currentOrgName='',$doctor_name=''){
if(strlen($id_card_num)>0){
date_default_timezone_set('PRC');
$currentYear = date('Y');
@ -116,6 +116,8 @@ public function CheckAppointment($name,$id_card_num,$type){
$date->modify('+'.$month.' months');
$now = new DateTime();
if ($date > $now) {
$conflictService = app()->make(\App\Services\ConflictService::class);
$conflictService->logConflict($name, $encode_id_card_num, $currentOrgName,$doctor_name, $cha_jkz->org_name, $cha_jkz->created_at, $type, 'CheckAppointment');
return \Yz::Return(false,'该人员已于'.$cha_jkz->created_at.'在'.$cha_jkz->org_name.'登记');
}
}
@ -130,6 +132,9 @@ public function CheckAppointment($name,$id_card_num,$type){
$c=$c->get();
if(count($c)){
$conflictService = app()->make(\App\Services\ConflictService::class);
//dd($name, $encode_id_card_num, $currentOrgName, $c[0]->org_name, $c[0]->insertime, $type, 'CheckAppointment');
$conflictService->logConflict($name, $encode_id_card_num, $currentOrgName,$doctor_name, $c[0]->org_name, $c[0]->insertime, $type, 'CheckAppointment');
$result['status']=false;
$result['msg']='该人员已于'.$c[0]->insertime.'在'.$c[0]->org_name.'登记.';
$result['info']=$c;

@ -0,0 +1,29 @@
<?php
namespace App\Services;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class ConflictService
{
public function logConflict($name, $idCardNum, $currentOrgName,$doctor_name, $lastOrgName, $lastCheckupTime, $type, $source)
{
try {
DB::table('conflict_record')->insert([
'name' => $name,
'id_card_num' => $idCardNum,
'current_org_name' => $currentOrgName,
'doctor_name' => $doctor_name,
'last_org_name' => $lastOrgName,
'last_checkup_time' => $lastCheckupTime,
'type' => $type,
'source' => $source,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]);
} catch (\Exception $e) {
Log::error('冲突记录写入失败: ' . $e->getMessage());
}
}
}

@ -0,0 +1,29 @@
<?php
namespace App\Services;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class DeleteLogService
{
public function logDeletion($tableName, $recordId, $name, $idCardNum, $operatorId, $operatorName, $reason, $screenshot)
{
try {
DB::table('delete_operation_log')->insert([
'table_name' => $tableName,
'record_id' => $recordId,
'name' => $name,
'id_card_num' => $idCardNum,
'operator_id' => $operatorId,
'operator_name' => $operatorName,
'reason' => $reason,
'screenshot' => $screenshot,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]);
} catch (\Exception $e) {
Log::error('删除操作日志写入失败: ' . $e->getMessage());
}
}
}

@ -107,6 +107,7 @@
Route::post('CreateCheckupPdf','App\Http\Controllers\API\Admin\YeWu\HealthCheckupController@CreateCheckupPdf');//对外接口,创建体检记录 姓名、电话、身份证、体检机构编码、体检号、pdfs
Route::get('GetReportUrl','App\Http\Controllers\API\mH5\PersonController@GetReportUrl');//对外接口获取用户体检报告url
Route::post('DelCheckUpInfo','App\Http\Controllers\API\Admin\YeWu\HealthCheckupController@DelCheckUpInfo');//对外接口,删除体检记录
Route::post('DelAppintmentInfo','App\Http\Controllers\API\Admin\YeWu\AppointmentController@DelAppintmentInfo');//对外接口,删除登记预约记录
Route::post('Encrypt','App\Http\Controllers\API\Internal\HsmController@Encrypt');//加密
});

Loading…
Cancel
Save