号源计划模板增加节假日区分、号源计划增加按时长计算总量

main
yanzai 1 year ago
parent 7876505a0a
commit 6242bc167e

Binary file not shown.

@ -7,6 +7,7 @@ use App\Services\Admin\YeWu\PlanListService;
use DateTime; use DateTime;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Tools; use Tools;
class PlanListController extends Controller class PlanListController extends Controller
@ -19,6 +20,8 @@ class PlanListController extends Controller
$department_id = $userInfo[0]->department_id; $department_id = $userInfo[0]->department_id;
$dateRange = request('dateRange'); $dateRange = request('dateRange');
$planModelIds = request('ids'); $planModelIds = request('ids');
$HolidayEnable = request('HolidayEnable');
$date_type = request('date_type');
//循环日期和勾选的模板创建明细 //循环日期和勾选的模板创建明细
if (count($dateRange) == 2 && count($planModelIds) > 0) { if (count($dateRange) == 2 && count($planModelIds) > 0) {
$models = DB::table('s_source_roster')->whereIn('id', $planModelIds)->get(); $models = DB::table('s_source_roster')->whereIn('id', $planModelIds)->get();
@ -39,31 +42,47 @@ class PlanListController extends Controller
->where('date', '<=', $end_date->format('Y-m-d')) ->where('date', '<=', $end_date->format('Y-m-d'))
->where('is_del', 0) ->where('is_del', 0)
->get(); ->get();
$msg='</br>当前选中的'; $msg = '</br>当前选中的';
$msglist=''; $msglist = '';
$msgIds=''; $msgIds = '';
if (count($checkList) > 0) { if (count($checkList) > 0) {
foreach ($models as $model ){ foreach ($models as $model) {
foreach ($checkList as $item) { foreach ($checkList as $item) {
$msglist.=$item->date.' '; $msglist .= $item->date . ' ';
$msgIds.=$item->id.' '; $msgIds .= $item->id . ' ';
} }
if($item->roster_id==$model->id){ if ($item->roster_id == $model->id) {
$msg.=" ".$model->weekname.$model->begin_time.'-'.$model->end_time." "; $msg .= " " . $model->weekname . $model->begin_time . '-' . $model->end_time . " ";
} }
} }
return \Yz::Return(false,'已有重复的计划明细,禁止创建!'.$msg.'已存在相同记录,</br>存在于:</br>'.$msglist.'</br>对应记录Id为'.$msgIds.'</br>请先删除后再操作', $checkList); return \Yz::Return(false, '已有重复的计划明细,禁止创建!' . $msg . '已存在相同记录,</br>存在于:</br>' . $msglist . '</br>对应记录Id为' . $msgIds . '</br>请先删除后再操作', $checkList);
} }
//查询勾选的时间范围内所有的节假日
$holiday_list=DB::table('s_holiday')->whereBetween('date',$dateRange)->where(['type'=>2])->pluck('date')->toArray();
// 循环日期并判断星期 // 循环日期并判断星期
$current_date = clone $start_date; $current_date = clone $start_date;
DB::beginTransaction(); DB::beginTransaction();
$success_count=0;//成功创建的数量 $success_count = 0;//成功创建的数量
while ($current_date <= $end_date) { while ($current_date <= $end_date) {
//如果是节假日模板,则判断当前日期是否是节假日,不是则跳过
if ($date_type == 2) {
if (!in_array($current_date->format('Y-m-d'),$holiday_list)){
// 将当前日期增加一天
$current_date->modify('+1 day');
continue;
}
}
//如果选择节假日不可用,并且当前日期是节假日,则跳过
if($HolidayEnable==0 and in_array($current_date->format('Y-m-d'),$holiday_list)){
// 将当前日期增加一天
$current_date->modify('+1 day');
continue;
}
// 获取当前日期的星期几0表示星期日1表示星期一以此类推 // 获取当前日期的星期几0表示星期日1表示星期一以此类推
$weekday = $current_date->format('w'); $weekday = $current_date->format('w');
$weekname = ''; $weekname = '';
@ -91,77 +110,79 @@ class PlanListController extends Controller
break; break;
} }
foreach ($models as $model) { foreach ($models as $model) {
if ($model->weekname == $weekname) { if ($date_type == 1 and $model->date_type==1) {
// 插入明细表 if ($model->weekname <> $weekname) continue;
$data = [ }
'roster_id' => $model->id,
'date' => $current_date, // 插入明细表
'weekname' => $weekname, $data = [
'department_id' => $model->department_id, 'roster_id' => $model->id,
'resources_id' => $model->resources_id, 'date' => $current_date,
'device_id' => $model->device_id, 'weekname' => $weekname,
'period_id' => $model->period_id, 'department_id' => $model->department_id,
'patient_type' => $model->patient_type, 'resources_id' => $model->resources_id,
'begin_time' => $model->begin_time, 'device_id' => $model->device_id,
'end_time' => $model->end_time, 'period_id' => $model->period_id,
'end_reservation_time' => $model->end_reservation_time, 'patient_type' => $model->patient_type,
'time_unit' => $model->time_unit, 'begin_time' => $model->begin_time,
'status' => 1, 'end_time' => $model->end_time,
'adduser' => $userid, 'end_reservation_time' => $model->end_reservation_time,
'is_del' => 0, 'time_unit' => $model->time_unit,
]; 'status' => 1,
'adduser' => $userid,
'is_del' => 0,
];
$plan_id = DB::table('s_source_roster_detail')->insertGetId($data);
if($plan_id){
$success_count++; $plan_id = DB::table('s_source_roster_detail')->insertGetId($data);
} if ($plan_id) {
// 插入数量表 $success_count++;
$model_count_info = DB::table('s_source_roster_count')->where(['roster_id' => $model->id])->get(); }
if (count($model_count_info) > 0) { // 插入数量表
foreach ($model_count_info as $info) { $model_count_info = DB::table('s_source_roster_count')->where(['roster_id' => $model->id])->get();
$i_c = DB::table('s_source_roster_detail_count')->insert([ if (count($model_count_info) > 0) {
'roster_detail_id' => $plan_id, foreach ($model_count_info as $info) {
'appointment_type_id' => $info->appointment_type_id, $i_c = DB::table('s_source_roster_detail_count')->insert([
'count' => $info->count, 'roster_detail_id' => $plan_id,
'max_total' => $info->max_total, 'appointment_type_id' => $info->appointment_type_id,
]); 'count' => $info->count,
if (!$i_c) { 'max_total' => $info->max_total,
DB::rollBack(); ]);
return \Yz::echoError1('渠道数量创建失败'); if (!$i_c) {
} DB::rollBack();
return \Yz::echoError1('渠道数量创建失败');
} }
} else {
DB::rollBack();
return \Yz::echoError1('模板数量信息异常,请重新选择!异常模板Id:' . $model->id);
} }
if(isset($model->device_id)){ } else {
$device_ids =explode(",", $model->device_id); DB::rollBack();
foreach ($device_ids as $dv_key=>$dv_value){ return \Yz::echoError1('模板数量信息异常,请重新选择!异常模板Id:' . $model->id);
$i_dev = DB::table('s_source_roster_detail_device')->insert([ }
'roster_detail_id' => $plan_id, if (isset($model->device_id)) {
'device_id' => $dv_value, $device_ids = explode(",", $model->device_id);
]); foreach ($device_ids as $dv_key => $dv_value) {
if (!$i_dev) { $i_dev = DB::table('s_source_roster_detail_device')->insert([
DB::rollBack(); 'roster_detail_id' => $plan_id,
return \Yz::echoError1('设备关联创建失败'); 'device_id' => $dv_value,
} ]);
if (!$i_dev) {
DB::rollBack();
return \Yz::echoError1('设备关联创建失败');
} }
}else{
DB::rollBack();
return \Yz::echoError1('模板未关联设备,请重新选择!异常模板Id:' . $model->id);
} }
} else {
DB::rollBack();
return \Yz::echoError1('模板未关联设备,请重新选择!异常模板Id:' . $model->id);
} }
} }
// 将当前日期增加一天 // 将当前日期增加一天
$current_date->modify('+1 day'); $current_date->modify('+1 day');
} }
DB::commit(); DB::commit();
return \Yz::Return(true, '执行完成,范围:'.$dateRange[0].'-'.$dateRange[1].',共计生成计划 '.$success_count.' 条', ['dateRange'=>$dateRange,'success_count'=>$success_count]); return \Yz::Return(true, '执行完成,范围:' . $dateRange[0] . '-' . $dateRange[1] . ',共计生成计划 ' . $success_count . ' 条', ['dateRange' => $dateRange, 'success_count' => $success_count]);
} }
} }
@ -242,7 +263,7 @@ class PlanListController extends Controller
} }
} }
return \Yz::Return(true, '获取成功', ['list' => $list,'count' => $count]); return \Yz::Return(true, '获取成功', ['list' => $list, 'count' => $count]);
} }
public function GetDetail() public function GetDetail()
@ -320,12 +341,13 @@ class PlanListController extends Controller
$appointment_type = request('appointment_type'); //预约类型 $appointment_type = request('appointment_type'); //预约类型
$appointment_date = request('date'); //预约日期 $appointment_date = request('date'); //预约日期
$service = new PlanListService(); $service = new PlanListService();
return $service->GetEnablePlan($regnum,$entrustid,$episodeid,$appointment_type,$appointment_date); return $service->GetEnablePlan($regnum, $entrustid, $episodeid, $appointment_type, $appointment_date);
} }
//获取最近可用的,计划 日期 //获取最近可用的,计划 日期
public function NearestEnablePlanDate() public function NearestEnablePlanDate()
{ {
$dateRange=7; $dateRange = 7;
$regnum = request('regnum'); $regnum = request('regnum');
$entrustids = request('entrustid'); $entrustids = request('entrustid');
$episodeid = request('episodeid'); $episodeid = request('episodeid');
@ -333,31 +355,31 @@ class PlanListController extends Controller
$appointment_date = request('date'); //预约日期 $appointment_date = request('date'); //预约日期
$service = new PlanListService(); $service = new PlanListService();
$date_arr=[]; $date_arr = [];
$startDate = new DateTime(); $startDate = new DateTime();
// 设定结束日期为当前日期加7天 // 设定结束日期为当前日期加7天
$endDate = new DateTime(); $endDate = new DateTime();
$endDate->modify('+'.$dateRange.' day'); $endDate->modify('+' . $dateRange . ' day');
// 循环遍历每一天 // 循环遍历每一天
$currentDate = $startDate; $currentDate = $startDate;
while ($currentDate <= $endDate) { while ($currentDate <= $endDate) {
$nowdate= $currentDate->format('Y-m-d'); $nowdate = $currentDate->format('Y-m-d');
$s=$service->GetEnablePlan($regnum,$entrustids,$episodeid,$appointment_type,$nowdate); $s = $service->GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_type, $nowdate);
if($s['status']){ if ($s['status']) {
$list= $s['data']['plan_list']; $list = $s['data']['plan_list'];
if(count($list)>0){ if (count($list) > 0) {
$date_arr[]= $s['data']['appointment_date']; $date_arr[] = $s['data']['appointment_date'];
} }
} }
if(count($date_arr)>=2){ if (count($date_arr) >= 2) {
break; break;
} }
// 每次循环增加一天 // 每次循环增加一天
$currentDate->modify('+1 day'); $currentDate->modify('+1 day');
} }
return \Yz::Return(true,'查询完成',['list'=>$date_arr]); return \Yz::Return(true, '查询完成', ['list' => $date_arr]);
} }
@ -374,7 +396,7 @@ class PlanListController extends Controller
if (!isset($do_type)) return \Yz::echoError1('参数:操作类型 不能为空'); if (!isset($do_type)) return \Yz::echoError1('参数:操作类型 不能为空');
$service = new PlanListService(); $service = new PlanListService();
return $service->YuYue($planid,$appointment_type,$mainlistid,$do_type); return $service->YuYue($planid, $appointment_type, $mainlistid, $do_type);
} }
public function CancelYuYue(Request $request) public function CancelYuYue(Request $request)
@ -386,10 +408,10 @@ class PlanListController extends Controller
$password = request('password'); $password = request('password');
$userid = $request->get('userid');//中间件产生的参数 $userid = $request->get('userid');//中间件产生的参数
$query = DB::table('users')->where(['id' => $userid])->get(); $query = DB::table('users')->where(['id' => $userid])->get();
if(password_verify($password,$query[0]->pwd)) { if (password_verify($password, $query[0]->pwd)) {
$service = new PlanListService(); $service = new PlanListService();
return $service->CancelYuYue($MainListId,$reg_num); return $service->CancelYuYue($MainListId, $reg_num);
// $mainInfo = DB::table('s_list')->where(['id' => $MainListId])->first(); // $mainInfo = DB::table('s_list')->where(['id' => $MainListId])->first();
// if (!$mainInfo) return \Yz::echoError1('医嘱不存在'); // if (!$mainInfo) return \Yz::echoError1('医嘱不存在');
@ -421,7 +443,7 @@ class PlanListController extends Controller
// return \Yz::echoError1('取消异常'); // return \Yz::echoError1('取消异常');
// } // }
}else{ } else {
return \Yz::echoError1('密码不正确'); return \Yz::echoError1('密码不正确');
} }
} }
@ -430,24 +452,24 @@ class PlanListController extends Controller
public function GetUsedList() public function GetUsedList()
{ {
$planid = request('planid'); $planid = request('planid');
$qudaoid= request('qudaoid'); $qudaoid = request('qudaoid');
$list=DB::table('s_list') $list = DB::table('s_list')
->leftJoin('s_department_resources','s_list.reservation_sources','=','s_department_resources.id') ->leftJoin('s_department_resources', 's_list.reservation_sources', '=', 's_department_resources.id')
->select('s_list.*','s_department_resources.department_resources_name') ->select('s_list.*', 's_department_resources.department_resources_name')
->where(['s_list.roster_id'=>$planid,'s_list.is_del'=>0,'s_list.is_nullify'=>0])->whereIn('s_list.list_status',[1,2,3]); ->where(['s_list.roster_id' => $planid, 's_list.is_del' => 0, 's_list.is_nullify' => 0])->whereIn('s_list.list_status', [1, 2, 3]);
if (!empty($qudaoid)) { if (!empty($qudaoid)) {
$list=$list->where(['s_list.appointment_type_id'=>$qudaoid]); $list = $list->where(['s_list.appointment_type_id' => $qudaoid]);
} }
$list=$list->get(); $list = $list->get();
$qudao=DB::table('s_appointment_type')->get(); $qudao = DB::table('s_appointment_type')->get();
foreach ($list as $key=>$item){ foreach ($list as $key => $item) {
foreach ($qudao as $q){ foreach ($qudao as $q) {
if($q->id==$item->appointment_type_id){ if ($q->id == $item->appointment_type_id) {
$item->qudao_name=$q->name; $item->qudao_name = $q->name;
} }
} }
} }
return \Yz::Return(true,'查询完成',$list); return \Yz::Return(true, '查询完成', $list);
} }
} }

@ -15,13 +15,14 @@ class PlanModelController extends Controller
$searchInfo = request('searchInfo'); $searchInfo = request('searchInfo');
$page = request('page'); $page = request('page');
$pageSize = request('pageSize'); $pageSize = request('pageSize');
$searchInfo['date_type']=$searchInfo['date_type']?$searchInfo['date_type']:1;
$department_id = 0; $department_id = 0;
$list = DB::table('s_source_roster') $list = DB::table('s_source_roster')
->leftJoin('s_department_resources', 's_source_roster.resources_id', '=', 's_department_resources.id') ->leftJoin('s_department_resources', 's_source_roster.resources_id', '=', 's_department_resources.id')
// ->leftJoin('s_devices', 's_source_roster.device_id', '=', 's_devices.id') // ->leftJoin('s_devices', 's_source_roster.device_id', '=', 's_devices.id')
->leftJoin('s_period', 's_source_roster.period_id', '=', 's_period.id') ->leftJoin('s_period', 's_source_roster.period_id', '=', 's_period.id')
->select('s_source_roster.*', 's_department_resources.department_resources_name', 's_period.period_name') ->select('s_source_roster.*', 's_department_resources.department_resources_name', 's_period.period_name')
->where(['s_source_roster.is_del' => 0]); ->where(['s_source_roster.is_del' => 0,'s_source_roster.date_type' => $searchInfo['date_type']]);
if ($group == 1) {//如果是管理员 if ($group == 1) {//如果是管理员
if (!empty($searchInfo['department_id'])) { if (!empty($searchInfo['department_id'])) {
$list = $list->where('s_source_roster.department_id', $searchInfo['department_id']); $list = $list->where('s_source_roster.department_id', $searchInfo['department_id']);
@ -95,73 +96,85 @@ class PlanModelController extends Controller
public function Save(Request $request) public function Save(Request $request)
{ {
$userid = $request->get('userid');//中间件产生的参数 $userid = $request->get('userid');//中间件产生的参数
$bitian = array('xingqi', 'max_total', 'qudao_total', 'period_id', 'begin_time', 'end_time', 'end_reservation_time', 'resources_id', 'devices', 'patientType'); $date_type = request('date_type');
$bitian_zh = array('星期', '当日总量', '渠道数量', '时间段', '开始时间', '结束时间', '停止预约时间', '资源', '设备', '患者类型');
$planInfo = request('planInfo'); $planInfo = request('planInfo');
$bitian = array('max_total', 'qudao_total', 'period_id', 'begin_time', 'end_time', 'end_reservation_time', 'resources_id', 'devices', 'patientType');
$bitian_zh = array('当日总量', '渠道数量', '时间段', '开始时间', '结束时间', '停止预约时间', '资源', '设备', '患者类型');
if($date_type==1){//如果是普通类型计划 1普通2节假日
$bitian[]='xingqi';
$bitian_zh[]='星期';
}
foreach ($bitian as $key => $field) { //必填项不能为空 foreach ($bitian as $key => $field) { //必填项不能为空
if (array_key_exists($field, $planInfo) && $planInfo[$field] !== '' && $planInfo[$field] !== null && $planInfo[$field] !== [] && $planInfo[$field] !== 0) { if (array_key_exists($field, $planInfo) && $planInfo[$field] !== '' && $planInfo[$field] !== null && $planInfo[$field] !== [] && $planInfo[$field] !== 0) {
} else { } else {
return \Yz::echoError1($bitian_zh[$key] . ' 不能为空'); return \Yz::echoError1($bitian_zh[$key] . ' 不能为空');
} }
} }
if($planInfo['end_reservation_time']>$planInfo['end_time']) return \Yz::echoError1('停止预约时间不能超过结束时间');
$userInfo = DB::table('users')->where(['id' => $userid])->first(); $userInfo = DB::table('users')->where(['id' => $userid])->first();
if (!isset($userInfo->department_id)) return \Yz::echoError1('该用户未绑定科室'); if (!isset($userInfo->department_id)) return \Yz::echoError1('该用户未绑定科室');
$department_id = $userInfo->department_id; $department_id = $userInfo->department_id;
DB::beginTransaction(); DB::beginTransaction();
foreach ($planInfo['xingqi'] as $key => $value) { $data = [
$data = [ 'department_id' => $department_id,
'department_id' => $department_id, 'weekname' => '',
'weekname' => $value, 'resources_id' => $planInfo['resources_id'],
'resources_id' => $planInfo['resources_id'], 'device_id' => isset($planInfo['devices']) ? implode(',', $planInfo['devices']) : '',
'device_id' => isset($planInfo['devices']) ? implode(',', $planInfo['devices']) : '', 'period_id' => $planInfo['period_id'], //时间段id
'period_id' => $planInfo['period_id'], //时间段id 'patient_type' => isset($planInfo['patientType']) ? implode(',', $planInfo['patientType']) : '',//病人类型
'patient_type' => isset($planInfo['patientType']) ? implode(',', $planInfo['patientType']) : '',//病人类型 'begin_time' => $planInfo['begin_time'],
'begin_time' => $planInfo['begin_time'], 'end_time' => $planInfo['end_time'],
'end_time' => $planInfo['end_time'], 'end_reservation_time' => $planInfo['end_reservation_time'],
'end_reservation_time' => $planInfo['end_reservation_time'], 'time_unit' => $planInfo['time_unit'],
'time_unit' => $planInfo['time_unit'], 'status' => $planInfo['status'],
'status' => $planInfo['status'], 'adduser' => $userid,
'adduser' => $userid, 'date_type' => $date_type,
]; ];
if($planInfo['end_reservation_time']>$planInfo['end_time']) return \Yz::echoError1('停止预约时间不能超过结束时间'); $param=[
'department_id' => $department_id,
//判断记录是否存在 'resources_id' => $planInfo['resources_id'],
$is_ex = DB::table('s_source_roster')->where([ 'is_del' => 0,
'department_id' => $department_id, 'date_type' => $date_type,
'weekname' => $value, ];
'resources_id' => $planInfo['resources_id'], if($date_type==1){
// 'period_id' => $planInfo['period_id'], //时间段id foreach ($planInfo['xingqi'] as $key => $value) {
'is_del' => 0, $data['weekname'] = $value;
]); //判断记录是否存在
if ($planInfo['id'] > 0) { $param['weekname'] = $value;
$is_ex = $is_ex->where('id', '<>', $planInfo['id']); $check=$this->Check($planInfo,$param,$value);
} if(!$check['status']){
$start = $planInfo['begin_time'];
$end = $planInfo['end_time'];
$is_ex = $is_ex->where(function ($query) use ($start, $end) {
// 情况1开始时间在查询区间内
$query->whereBetween('begin_time', [$start, $end])
->orWhereBetween('end_time', [$start, $end]);
// 情况2查询区间的开始时间在数据库记录的开始和结束时间之间
// 注意:对于时间类型的比较,直接使用字符串比较可能不够精确,特别是跨天情况,以下逻辑需根据实际情况调整
$query->orWhere(function ($query) use ($start, $end) {
$query->where('begin_time', '<=', $start)
->where('end_time', '>=', $end);
});
})->get();
// dd($is_ex);
//遍历判断设备是否有重叠,有则返回错误
foreach ($is_ex as $k => $v) {
$db_device_ids = explode(',', $v->device_id);
$overlap = array_intersect($planInfo['devices'], $db_device_ids);
if (count($overlap) > 0) {
DB::rollBack(); DB::rollBack();
return \Yz::echoError1($value . '时段服务组关联重复,计划id为:' . $v->id); return \Yz::echoError1($check['msg']);
}
if ($planInfo['id'] == 0) {//新增
$roster_id = DB::table('s_source_roster')->insertGetId($data);
if ($roster_id) {
foreach ($planInfo['qudao_total'] as $k => $v) {
$i_c = DB::table('s_source_roster_count')->insert([
'roster_id' => $roster_id,
'appointment_type_id' => $v['id'],
'max_total' => $planInfo['max_total'],
'count' => $v['count'],
]);
if (!$i_c) {
DB::rollBack();
return \Yz::echoError1('保存失败');
}
}
} else {
DB::rollBack();
return \Yz::echoError1('保存失败');
}
} }
}
}
}elseif ($date_type==2){
$check=$this->Check($planInfo,$param,"当前选定的");
if(!$check['status']){
DB::rollBack();
return \Yz::echoError1($check['msg']);
}
if ($planInfo['id'] == 0) {//新增 if ($planInfo['id'] == 0) {//新增
$roster_id = DB::table('s_source_roster')->insertGetId($data); $roster_id = DB::table('s_source_roster')->insertGetId($data);
if ($roster_id) { if ($roster_id) {
@ -181,29 +194,62 @@ class PlanModelController extends Controller
DB::rollBack(); DB::rollBack();
return \Yz::echoError1('保存失败'); return \Yz::echoError1('保存失败');
} }
} else {//修改 }
$data['id'] = $planInfo['id'];
$i = DB::table('s_source_roster')->where(['id' => $planInfo['id'], 'is_del' => 0])->update($data); }
if($planInfo['id'] > 0) {//修改
$data['id'] = $planInfo['id'];
foreach ($planInfo['qudao_total'] as $k => $v) { $i = DB::table('s_source_roster')->where(['id' => $planInfo['id'], 'is_del' => 0])->update($data);
$i_c = DB::table('s_source_roster_count')->where(['roster_id' => $planInfo['id'], 'appointment_type_id' => $v['appointment_type_id']])->update([
'max_total' => $planInfo['max_total'],
'count' => $v['count'],
]);
} foreach ($planInfo['qudao_total'] as $k => $v) {
if ($i or $i_c) { $i_c = DB::table('s_source_roster_count')->where(['roster_id' => $planInfo['id'], 'appointment_type_id' => $v['appointment_type_id']])->update([
} else { 'max_total' => $planInfo['max_total'],
DB::rollBack(); 'count' => $v['count'],
return \Yz::echoError1('保存失败'); ]);
}
}
}
if ($i or $i_c) {
} else {
DB::rollBack();
return \Yz::echoError1('保存失败');
}
} }
DB::commit(); DB::commit();
return \Yz::Return(true, '保存成功', []); return \Yz::Return(true, '保存成功', []);
} }
//检测提交的信息是否有效
function Check($planInfo,$param,$shiduan)
{
$is_ex = DB::table('s_source_roster')->where($param);
if ($planInfo['id'] > 0) {
$is_ex = $is_ex->where('id', '<>', $planInfo['id']);
}
$start = $planInfo['begin_time'];
$end = $planInfo['end_time'];
$is_ex = $is_ex->where(function ($query) use ($start, $end) {
// 情况1开始时间在查询区间内
$query->whereBetween('begin_time', [$start, $end])
->orWhereBetween('end_time', [$start, $end]);
// 情况2查询区间的开始时间在数据库记录的开始和结束时间之间
// 注意:对于时间类型的比较,直接使用字符串比较可能不够精确,特别是跨天情况,以下逻辑需根据实际情况调整
$query->orWhere(function ($query) use ($start, $end) {
$query->where('begin_time', '<=', $start)
->where('end_time', '>=', $end);
});
})->get();
//遍历判断设备是否有重叠,有则返回错误
foreach ($is_ex as $k => $v) {
$db_device_ids = explode(',', $v->device_id);
$overlap = array_intersect($planInfo['devices'], $db_device_ids);
if (count($overlap) > 0) {
return ['status'=>false,'msg'=>$shiduan . '时段服务组关联重复,计划id为:' . $v->id];
}
}
return ['status'=>true,'msg'=>''];
}
//获取模板信息详情 //获取模板信息详情
public function GetDetailInfo() public function GetDetailInfo()

@ -57,11 +57,12 @@ class TimePeriodController extends Controller
$searchInfo =request('searchInfo'); $searchInfo =request('searchInfo');
$page =request('page'); $page =request('page');
$pageSize =request('pageSize'); $pageSize =request('pageSize');
$searchInfo['date_type']=$searchInfo['date_type']?$searchInfo['date_type']:1;
$department_id=0; $department_id=0;
$list=DB::table('s_period') $list=DB::table('s_period')
->leftJoin('s_department', 's_period.department_id', '=', 's_department.id') ->leftJoin('s_department', 's_period.department_id', '=', 's_department.id')
->select('s_period.*','s_department.department_name') ->select('s_period.*','s_department.department_name')
->where(['s_period.is_del'=>0]); ->where(['s_period.is_del'=>0,'s_period.date_type'=>$searchInfo['date_type']]);
if($group==1){//如果是管理员 if($group==1){//如果是管理员
if(!empty($searchInfo['department_id'])){ if(!empty($searchInfo['department_id'])){
@ -83,9 +84,14 @@ class TimePeriodController extends Controller
{ {
$userid = $request->get('userid');//中间件产生的参数 $userid = $request->get('userid');//中间件产生的参数
$group = $request->get('role');//中间件产生的参数 $group = $request->get('role');//中间件产生的参数
$date_type =request('date_type');
$userInfo = DB::table('users')->where(['id'=>$userid])->get(); $userInfo = DB::table('users')->where(['id'=>$userid])->get();
$department_id=$userInfo[0]->department_id; $department_id=$userInfo[0]->department_id;
$list=DB::table('s_period'); $list=DB::table('s_period');
if(isset($date_type)){
$list=$list->where('date_type',$date_type);
}
$list=$list->where(['department_id'=>$department_id,'period_status'=>1,'is_del'=>0])->get(); $list=$list->where(['department_id'=>$department_id,'period_status'=>1,'is_del'=>0])->get();
if(count($list)>0){ if(count($list)>0){
return \Yz::Return(true, '操作成功',$list); return \Yz::Return(true, '操作成功',$list);

@ -1,6 +1,6 @@
ENV = 'production' ENV = 'production'
VITE_APP_API = 'http://10.50.120.166/YiJiYuYue/Laravel/public/api/' VITE_APP_API_66 = 'http://10.50.120.166/YiJiYuYue/Laravel/public/api/'
VITE_APP_FILE = 'http://10.50.120.166/YiJiYuYue/Laravel/public/' VITE_APP_FILE_666 = 'http://10.50.120.166/YiJiYuYue/Laravel/public/'
VITE_APP_API_6666 = 'https://yiji.yuluo.online/Laravel/public/api/' VITE_APP_API = 'https://yiji.yuluo.online/Laravel/public/api/'
VITE_APP_FILE_555 = 'https://yiji.yuluo.online/Laravel/public/' VITE_APP_FILE = 'https://yiji.yuluo.online/Laravel/public/'

@ -43,11 +43,18 @@
<el-button type="success" @click="CreatedPlanClick()" style="margin-left: 20px;">生成选中的计划</el-button> <el-button type="success" @click="CreatedPlanClick()" style="margin-left: 20px;">生成选中的计划</el-button>
</el-row> </el-row>
</div> </div>
<el-table :data="tableData" :span-method="arraySpanMethod" border style="width: 100%;" row-key="id" v-loading="loading" <el-row>
@selection-change="handleSelectionChange"> <el-radio-group style="margin-bottom: 8px;" v-model="searchInfo.date_type"
@change="DateTypeChange()">
<el-radio-button :label="1">工作日</el-radio-button>
<el-radio-button :label="2">节假日</el-radio-button>
</el-radio-group>
</el-row>
<el-table :data="tableData" :span-method="arraySpanMethod" border style="width: 100%;" row-key="id"
v-loading="loading" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" /> <el-table-column type="selection" width="55" />
<el-table-column prop="id" label="Id" width="70" /> <el-table-column prop="id" label="Id" width="70" />
<el-table-column prop="weekname" label="星期" width="80" /> <el-table-column prop="weekname" label="星期" width="80" v-if="searchInfo.date_type==1"/>
<el-table-column prop="resources_id" label="" v-if="false" /> <el-table-column prop="resources_id" label="" v-if="false" />
<el-table-column prop="department_resources_name" label="资源" width="150" /> <el-table-column prop="department_resources_name" label="资源" width="150" />
<el-table-column prop="" label="服务组" show-overflow-tooltip width="150"> <el-table-column prop="" label="服务组" show-overflow-tooltip width="150">
@ -92,12 +99,12 @@
:page-sizes="[15, 50, 100, 200]" layout="total,sizes, prev, pager, next" :total="total" :page-sizes="[15, 50, 100, 200]" layout="total,sizes, prev, pager, next" :total="total"
@size-change="PageSizeChange" @current-change="PageCurrentChange" /> @size-change="PageSizeChange" @current-change="PageCurrentChange" />
</div> --> </div> -->
<el-dialog v-model="dialogVisible" title="时间段" width="45%"> <el-dialog v-model="dialogVisible" :title="'时间段('+date_type_name+')'" width="45%">
<el-form ref="PlanInfoForm" :model="PlanInfo" label-width="100px" v-loading="loading" <el-form ref="PlanInfoForm" :model="PlanInfo" label-width="100px" v-loading="loading"
style="padding-right: 40px;"> style="padding-right: 40px;">
<el-form-item label="星期:" prop="xingqi"> <el-form-item label="星期:" prop="xingqi" v-if="searchInfo.date_type==1">
<el-checkbox :disabled="PlanInfo.id==0?false:true" style="margin-right: 8px;" v-model="CheckedAll" @change="CheckedAllFunc" <el-checkbox :disabled="PlanInfo.id==0?false:true" style="margin-right: 8px;" v-model="CheckedAll"
label="全选"><span style="font-weight: 700;color: #409eff;">全选</span> @change="CheckedAllFunc" label="全选"><span style="font-weight: 700;color: #409eff;">全选</span>
</el-checkbox> </el-checkbox>
<el-checkbox-group v-model="PlanInfo.xingqi"> <el-checkbox-group v-model="PlanInfo.xingqi">
<el-checkbox :disabled="PlanInfo.id==0?false:true" v-for="(item, index) in xingqi" :key="index" <el-checkbox :disabled="PlanInfo.id==0?false:true" v-for="(item, index) in xingqi" :key="index"
@ -106,11 +113,20 @@
</el-checkbox-group> </el-checkbox-group>
</el-form-item> </el-form-item>
<el-form-item label="渠道名额:"> <el-form-item label="渠道名额:">
<div style="margin-right: 16px"> <div style="margin-right: 26px">
<div>当日总量</div> <div>
<el-radio-group v-model="CountType" @change="CountTypeChange">
<el-radio label="1">根据总量</el-radio>
<el-radio style="margin-left: -10px;" label="2">根据时长(分钟)</el-radio>
</el-radio-group>
</div>
<div class="qudao_k_input"> <div class="qudao_k_input">
<el-input @input="MaxCountChange" type="number" v-model="PlanInfo.max_total" :min="1" <el-input v-if="CountType==1" style="width: 220px;" @input="MaxCountChange" type="number"
placeholder="0" oninput="value=value.replace(/^0|[^0-9]/g, '')" /> v-model="PlanInfo.max_total" :min="1" placeholder="0"
oninput="value=value.replace(/^0|[^0-9]/g, '')" />
<el-input v-if="CountType==2" style="width: 220px;" @input="TimeLongChange" type="number"
v-model="PlanInfo.time_long" :min="1" placeholder="0"
oninput="value=value.replace(/^0|[^0-9]/g, '')" />
</div> </div>
<div style="font-size: 12px;color: #999">设置渠道比例可自动分配</div> <div style="font-size: 12px;color: #999">设置渠道比例可自动分配</div>
</div> </div>
@ -172,7 +188,8 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="服务组:" v-if="devicesList.length>0"> <el-form-item label="服务组:" v-if="devicesList.length>0">
<div v-if="devicesList.length>1" style="width: 100%;font-size: 12px;color: #999;">()</div> <div v-if="devicesList.length>1" style="width: 100%;font-size: 12px;color: #999;">
此诊室包含多台设备如同时勾选多个被勾选设备将共同占用分配的名额如需为设备单独分配名额请单独勾选(推荐)</div>
<el-checkbox-group v-model="PlanInfo.devices"> <el-checkbox-group v-model="PlanInfo.devices">
<el-checkbox v-for="(item,index) in devicesList" :key="index" <el-checkbox v-for="(item,index) in devicesList" :key="index"
:label="item.id">{{ item.device_name }} :label="item.id">{{ item.device_name }}
@ -208,6 +225,10 @@
<el-date-picker v-model="dateRange" type="daterange" range-separator="To" start-placeholder="" <el-date-picker v-model="dateRange" type="daterange" range-separator="To" start-placeholder=""
end-placeholder="结束时间" value-format="YYYY-MM-DD" /> end-placeholder="结束时间" value-format="YYYY-MM-DD" />
</el-form-item> </el-form-item>
<el-form-item label="节假日生成:">
<el-switch v-model="HolidayEnable" size="large" active-text="" inactive-text=""
:active-value="1" :inactive-value="0" />
</el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
<span class="dialog-footer"> <span class="dialog-footer">
@ -245,7 +266,7 @@
ElMessage, ElMessage,
ElMessageBox ElMessageBox
} from 'element-plus' } from 'element-plus'
let CountType = ref("1"); //
let loading = ref(false) let loading = ref(false)
let tableData = ref([]) let tableData = ref([])
let currentPage = ref(1) // let currentPage = ref(1) //
@ -284,6 +305,8 @@
CreatePlanList({ CreatePlanList({
dateRange: dateRange.value, dateRange: dateRange.value,
ids: ids, ids: ids,
HolidayEnable:HolidayEnable.value,
date_type:searchInfo.value.date_type
}).then(res => { }).then(res => {
if (res.status) { if (res.status) {
CreatePlanDialogVisible.value = false; CreatePlanDialogVisible.value = false;
@ -292,12 +315,12 @@
type: 'success', type: 'success',
}) })
} else { } else {
ElMessageBox.alert(res.msg, '提示', { ElMessageBox.alert(res.msg, '提示', {
// if you want to disable its autofocus // if you want to disable its autofocus
// autofocus: false, // autofocus: false,
confirmButtonText: '确定', confirmButtonText: '确定',
dangerouslyUseHTMLString: true, dangerouslyUseHTMLString: true,
}) })
} }
}) })
} }
@ -308,6 +331,8 @@
xingqi: null, xingqi: null,
status: null, status: null,
}) })
let HolidayEnable=ref(1)
let date_type_name =ref('工作日')
let dialogVisible = ref(false) let dialogVisible = ref(false)
const GetList = () => { const GetList = () => {
PlanModelGetList({ PlanModelGetList({
@ -363,7 +388,7 @@
let PlanInfo = ref(DataDefault()) let PlanInfo = ref(DataDefault())
const Add = (row = null) => { const Add = (row = null) => {
CheckedAll.value=false CheckedAll.value = false
dialogVisible.value = true dialogVisible.value = true
PlanInfo.value = DataDefault() PlanInfo.value = DataDefault()
@ -381,7 +406,11 @@
} }
} }
const DateTypeChange=()=>{
if(searchInfo.value.date_type==1) date_type_name.value='工作日'
if(searchInfo.value.date_type==2) date_type_name.value='节假日'
GetList()
}
const Save = () => { const Save = () => {
// console.log(PlanInfo.value) // console.log(PlanInfo.value)
// //
@ -404,6 +433,7 @@
.then(() => { .then(() => {
loading.value = true loading.value = true
PlanModelSave({ PlanModelSave({
date_type:searchInfo.value.date_type,
planInfo: PlanInfo.value planInfo: PlanInfo.value
}).then(res => { }).then(res => {
loading.value = false loading.value = false
@ -497,7 +527,6 @@
} }
// //
const MaxCountChange = (e) => { const MaxCountChange = (e) => {
console.log(e)
if (e === '' || e == null || e === 0) { if (e === '' || e == null || e === 0) {
PlanInfo.value.max_total = 0 PlanInfo.value.max_total = 0
} }
@ -532,17 +561,18 @@
let index = PlanInfo.value.qudao_total.indexOf(minRatioItem); let index = PlanInfo.value.qudao_total.indexOf(minRatioItem);
console.log("最小且非零项在原数组中的位置:", index); console.log("最小且非零项在原数组中的位置:", index);
console.log(bodongzhi); console.log(bodongzhi);
if(bodongzhi>0){ if (bodongzhi > 0) {
PlanInfo.value.qudao_total[index].count = PlanInfo.value.qudao_total[index].count -bodongzhi PlanInfo.value.qudao_total[index].count = PlanInfo.value.qudao_total[index].count - bodongzhi
} }
if(bodongzhi<0 && index>0){ if (bodongzhi < 0 && index > 0) {
PlanInfo.value.qudao_total[index-1].count = PlanInfo.value.qudao_total[index-1].count -bodongzhi PlanInfo.value.qudao_total[index - 1].count = PlanInfo.value.qudao_total[index - 1].count -
bodongzhi
} }
if(bodongzhi<0 && index==0){ if (bodongzhi < 0 && index == 0) {
PlanInfo.value.qudao_total[index].count = PlanInfo.value.qudao_total[index].count -bodongzhi PlanInfo.value.qudao_total[index].count = PlanInfo.value.qudao_total[index].count - bodongzhi
} }
PlanInfo.value.qudao_total.sort((a, b) => b.ratio - a.ratio); PlanInfo.value.qudao_total.sort((a, b) => b.ratio - a.ratio);
} }
} }
@ -551,7 +581,7 @@
let TimePeriodList = ref([]) let TimePeriodList = ref([])
const GetEnableTimePeriod = () => { const GetEnableTimePeriod = () => {
loading.value = true loading.value = true
TimePeriodGetEnableList().then(res => { TimePeriodGetEnableList({date_type:searchInfo.value.date_type}).then(res => {
loading.value = false loading.value = false
if (res.status) { if (res.status) {
TimePeriodList.value = res.data TimePeriodList.value = res.data
@ -614,7 +644,7 @@
// //
let devicesList = ref([]) let devicesList = ref([])
const resourceChange = () => { const resourceChange = () => {
PlanInfo.value.devices=[]; PlanInfo.value.devices = [];
loading.value = true loading.value = true
ResourceGetBindDeviceList({ ResourceGetBindDeviceList({
resource_id: PlanInfo.value.resources_id resource_id: PlanInfo.value.resources_id
@ -629,89 +659,148 @@
}) })
} }
// //
const setMonthRange=()=>{ const setMonthRange = () => {
GetServiceDateTime().then(res => { GetServiceDateTime().then(res => {
if (res.status) { if (res.status) {
let currentdate=res.data.datetime.substring(0,10) let currentdate = res.data.datetime.substring(0, 10)
var date = new Date(currentdate); var date = new Date(currentdate);
// JavaScript0 // JavaScript0
var currentMonth = date.getMonth(); var currentMonth = date.getMonth();
// 121 // 121
var nextMonthMonth = (currentMonth + 1) % 12; var nextMonthMonth = (currentMonth + 1) % 12;
var nextMonthYear = date.getFullYear() + ((currentMonth + 1) / 12 | 0); // var nextMonthYear = date.getFullYear() + ((currentMonth + 1) / 12 | 0); //
// //
var currentDay = date.getDate(); var currentDay = date.getDate();
// //
var nextMonthSameDay = new Date(nextMonthYear, nextMonthMonth, currentDay); var nextMonthSameDay = new Date(nextMonthYear, nextMonthMonth, currentDay);
// 331431 // 331431
if (nextMonthSameDay.getMonth() !== nextMonthMonth) { if (nextMonthSameDay.getMonth() !== nextMonthMonth) {
// //
nextMonthSameDay = new Date(nextMonthYear, nextMonthMonth, 0); nextMonthSameDay = new Date(nextMonthYear, nextMonthMonth, 0);
} }
// //
let nextMonth= nextMonthSameDay.toISOString().split('T')[0]; // YYYY-MM-DD let nextMonth = nextMonthSameDay.toISOString().split('T')[0]; // YYYY-MM-DD
dateRange.value=[currentdate,nextMonth]; dateRange.value = [currentdate, nextMonth];
} }
}) })
} }
let CheckedAll=ref(false); let CheckedAll = ref(false);
// //
const CheckedAllFunc=(e)=>{ const CheckedAllFunc = (e) => {
if(e){ if (e) {
PlanInfo.value.xingqi=['星期一','星期二','星期三','星期四','星期五','星期六','星期日']; PlanInfo.value.xingqi = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日'];
}else{ } else {
PlanInfo.value.xingqi=[] PlanInfo.value.xingqi = []
} }
} }
// //
let bb_countRowspan=1; let bb_countRowspan = 1;
const arraySpanMethod=({ const arraySpanMethod = ({
row, row,
column, column,
rowIndex, rowIndex,
columnIndex, columnIndex,
})=>{ }) => {
const fields =['weekname'] const fields = ['weekname']
const cellValue =row[column.property] const cellValue = row[column.property]
let countRowspan=1 let countRowspan = 1
if(cellValue && fields.includes(column.property)){ if (cellValue && fields.includes(column.property)) {
const prevRow = tableData.value[rowIndex-1] const prevRow = tableData.value[rowIndex - 1]
let nextRow=tableData.value[rowIndex+1] let nextRow = tableData.value[rowIndex + 1]
if(prevRow&& prevRow[column.property]=== cellValue && prevRow.declareRegion == row.declareRegion){ if (prevRow && prevRow[column.property] === cellValue && prevRow.declareRegion == row.declareRegion) {
bb_countRowspan=countRowspan bb_countRowspan = countRowspan
return {rowspan:0,colspan:0} return {
rowspan: 0,
colspan: 0
}else{ }
while(nextRow && nextRow[column.property]===cellValue && nextRow.declareRegion==row.declareRegion){
nextRow=tableData.value[++countRowspan+rowIndex]
} } else {
if(countRowspan>1){ while (nextRow && nextRow[column.property] === cellValue && nextRow.declareRegion == row
bb_countRowspan=countRowspan .declareRegion) {
return {rowspan:countRowspan,colspan:1} nextRow = tableData.value[++countRowspan + rowIndex]
}
} if (countRowspan > 1) {
} bb_countRowspan = countRowspan
return {
} rowspan: countRowspan,
if (columnIndex === 3) { colspan: 1
if(bb_countRowspan>1){ }
return {rowspan:bb_countRowspan,colspan:1}
}else{ }
return {rowspan:0,colspan:0} }
}
} }
// if (columnIndex === 3) {
// if (bb_countRowspan > 1) {
// return {
// rowspan: bb_countRowspan,
// colspan: 1
// }
// } else {
// return {
// rowspan: 0,
// colspan: 0
// }
// }
// }
}
//
const CountTypeChange = (e) => {
CountType.value = e
MaxCountChange(0)
TimeLongChange(0)
if (e == 2) {
}
}
//
const TimeLongChange=(timelong)=>{
if (CountType.value == 2) { //
if (PlanInfo.value.begin_time == '' || PlanInfo.value.end_time == '') {
ElMessage.error("请先设置时段")
PlanInfo.value.max_total = 0
return false
}
ComPuteCountByTime(timelong)
}
}
//
const ComPuteCountByTime = (timelong) => {
let count=calculateTimeSegments(PlanInfo.value.begin_time,PlanInfo.value.end_time,timelong)
PlanInfo.value.max_total=count
MaxCountChange(count)
}
//
function calculateTimeSegments(startTime, endTime, span) {
//
function timeToMinutes(timeStr) {
const [hours, minutes] = timeStr.split(':').map(Number);
return hours * 60 + minutes;
}
const startMinutes = timeToMinutes(startTime);
const endMinutes = timeToMinutes(endTime);
//
const totalMinutes = endMinutes - startMinutes;
//
const segments = Math.floor(totalMinutes / span);
return segments;
} }
onMounted(() => { onMounted(() => {
searchInfo.value.date_type=1
GetList() GetList()
GetDepartmentEnableList() GetDepartmentEnableList()
getEnableResource() getEnableResource()

@ -13,6 +13,13 @@
<el-button type="primary" @click="Add()" style="margin-left: 10px;">添加</el-button> <el-button type="primary" @click="Add()" style="margin-left: 10px;">添加</el-button>
</el-row> </el-row>
</div> </div>
<el-row>
<el-radio-group style="margin-bottom: 8px;" v-model="searchInfo.date_type"
@change="DateTypeChange()">
<el-radio-button :label="1">工作日</el-radio-button>
<el-radio-button :label="2">节假日</el-radio-button>
</el-radio-group>
</el-row>
<el-table :data="tableData" style="width: 100%;" row-key="id" v-loading="loading"> <el-table :data="tableData" style="width: 100%;" row-key="id" v-loading="loading">
<el-table-column prop="id" label="Id" width="100" /> <el-table-column prop="id" label="Id" width="100" />
<el-table-column prop="department_name" label="科室名称" /> <el-table-column prop="department_name" label="科室名称" />
@ -132,7 +139,7 @@
} }
PeriodInfo.value.period_begin_time=PeriodInfo.value.timeRange[0] PeriodInfo.value.period_begin_time=PeriodInfo.value.timeRange[0]
PeriodInfo.value.period_end_time=PeriodInfo.value.timeRange[1] PeriodInfo.value.period_end_time=PeriodInfo.value.timeRange[1]
PeriodInfo.value.date_type=searchInfo.value.date_type
loading.value = true loading.value = true
TimePeriodSave({PeriodInfo:PeriodInfo.value}).then(res => { TimePeriodSave({PeriodInfo:PeriodInfo.value}).then(res => {
loading.value = false loading.value = false
@ -207,12 +214,14 @@
} }
// //
const changeTimeRange=()=>{ const changeTimeRange=()=>{
PeriodInfo.value.period_deadline=PeriodInfo.value.timeRange[1] PeriodInfo.value.period_deadline=PeriodInfo.value.timeRange[1]
}
//
const DateTypeChange=()=>{
GetList()
} }
onMounted(()=>{ onMounted(()=>{
searchInfo.value.date_type=1
GetList() GetList()
GetDepartmentEnableList() GetDepartmentEnableList()
}) })

Loading…
Cancel
Save