|
@@ -13,6 +13,7 @@ use App\Models\DocterSetting;
|
|
use App\Models\Order;
|
|
use App\Models\Order;
|
|
use App\Models\Organization;
|
|
use App\Models\Organization;
|
|
use App\Models\OrganizationSettings;
|
|
use App\Models\OrganizationSettings;
|
|
|
|
+use App\Models\Payment;
|
|
use App\Models\Schedule;
|
|
use App\Models\Schedule;
|
|
use App\Models\SchedulePeriod;
|
|
use App\Models\SchedulePeriod;
|
|
use App\Models\SelfSchedule;
|
|
use App\Models\SelfSchedule;
|
|
@@ -25,6 +26,7 @@ use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Log;
|
|
use mysql_xdevapi\Exception;
|
|
use mysql_xdevapi\Exception;
|
|
use phpDocumentor\Reflection\DocBlock\Description;
|
|
use phpDocumentor\Reflection\DocBlock\Description;
|
|
|
|
+use PhpParser\Comment\Doc;
|
|
|
|
|
|
class ScheDuleController extends Controller
|
|
class ScheDuleController extends Controller
|
|
{
|
|
{
|
|
@@ -619,9 +621,13 @@ class ScheDuleController extends Controller
|
|
return apiReturn(604,'参数错误');
|
|
return apiReturn(604,'参数错误');
|
|
}
|
|
}
|
|
|
|
|
|
- $setting = DocterSetting::where(['docter_id'=>$docter_id])->first()->toArray();
|
|
|
|
|
|
+ $setting = DocterSetting::where(['docter_id'=>$docter_id])->first();
|
|
if($type != 1){
|
|
if($type != 1){
|
|
- $setting = OrganizationSettings::where(['org_id'=>$org_id])->first()->toArray();
|
|
|
|
|
|
+ $setting = OrganizationSettings::where(['org_id'=>$org_id])->first();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(empty($setting)){
|
|
|
|
+
|
|
}
|
|
}
|
|
$self_config = object_array(json_decode($setting['service_time']));
|
|
$self_config = object_array(json_decode($setting['service_time']));
|
|
//改变时间段
|
|
//改变时间段
|
|
@@ -656,21 +662,22 @@ class ScheDuleController extends Controller
|
|
|
|
|
|
//添加时间段
|
|
//添加时间段
|
|
|
|
|
|
- $amCount = $configData['amNum'];
|
|
|
|
- $pmCount = $configData['pmNum'];
|
|
|
|
- $evCount = $configData['nightNum'];
|
|
|
|
|
|
+ $countArr = [
|
|
|
|
+ 1=>$configData['amNum'],
|
|
|
|
+ 2=>$configData['pmNum'],
|
|
|
|
+ 3=>$configData['nightNum'],
|
|
|
|
+ ];
|
|
|
|
|
|
$c_r = [
|
|
$c_r = [
|
|
1=>['count'=>$configData['amNum'],'start_time'=>$configData['amStartTime'],'end_time'=>$configData['amEndTime']],
|
|
1=>['count'=>$configData['amNum'],'start_time'=>$configData['amStartTime'],'end_time'=>$configData['amEndTime']],
|
|
2=>['count'=>$configData['pmNum'],'start_time'=>$configData['pmStartTime'],'end_time'=>$configData['pmEndTime']],
|
|
2=>['count'=>$configData['pmNum'],'start_time'=>$configData['pmStartTime'],'end_time'=>$configData['pmEndTime']],
|
|
3=>['count'=>$configData['nightNum'],'start_time'=>$configData['nightStartTime'],'end_time'=>$configData['nightEndTime']]
|
|
3=>['count'=>$configData['nightNum'],'start_time'=>$configData['nightStartTime'],'end_time'=>$configData['nightEndTime']]
|
|
];
|
|
];
|
|
- $changeTimer = [1];
|
|
|
|
|
|
+ $changeTimer = [1,2,3];
|
|
//todo 零时关闭排班功能,后续需要解除
|
|
//todo 零时关闭排班功能,后续需要解除
|
|
if($changeSeviceTime || !empty($changeTimer)){
|
|
if($changeSeviceTime || !empty($changeTimer)){
|
|
|
|
|
|
- foreach ($changeTimer as $tType)
|
|
|
|
- if(in_array($tType,$changeTimer)) {
|
|
|
|
|
|
+ foreach ($changeTimer as $tType){
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|
|
try {
|
|
try {
|
|
//1.删除旧时间段,并删除排班数据
|
|
//1.删除旧时间段,并删除排班数据
|
|
@@ -678,7 +685,7 @@ class ScheDuleController extends Controller
|
|
|
|
|
|
//todo 暂时未删除周排班
|
|
//todo 暂时未删除周排班
|
|
self::delteScheduleInfo($id,$type);
|
|
self::delteScheduleInfo($id,$type);
|
|
- $count = intval($amCount / $serviceNum);
|
|
|
|
|
|
+ $count = intval($countArr[$tType] / $serviceNum);
|
|
//2.创建新时间段
|
|
//2.创建新时间段
|
|
self::makeTimePeriod($type,$docter_id,$org_id,$tType,$c_r[$tType],$count,$serviceTime);
|
|
self::makeTimePeriod($type,$docter_id,$org_id,$tType,$c_r[$tType],$count,$serviceTime);
|
|
if($type == 1){
|
|
if($type == 1){
|
|
@@ -706,19 +713,15 @@ class ScheDuleController extends Controller
|
|
->GroupBy('week')
|
|
->GroupBy('week')
|
|
->toArray();
|
|
->toArray();
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
if (empty($week_schedule)) {
|
|
if (empty($week_schedule)) {
|
|
- Schedule::where(['docter_id' => $docter_id])->delete();
|
|
|
|
- SelfSchedule::where(['docter_id' => $docter_id])->delete();
|
|
|
|
|
|
+// Schedule::where(['docter_id' => $docter_id])->delete();
|
|
|
|
+// SelfSchedule::where(['docter_id' => $docter_id])->delete();
|
|
} else {
|
|
} else {
|
|
-
|
|
|
|
//3.以周模板添加2个月的数据
|
|
//3.以周模板添加2个月的数据
|
|
self::makeSchedule($docter_id,$org_id,$type,$schedule,$week_schedule,$time_periods);
|
|
self::makeSchedule($docter_id,$org_id,$type,$schedule,$week_schedule,$time_periods);
|
|
|
|
|
|
//4.回复自己设置的排班
|
|
//4.回复自己设置的排班
|
|
self::makeSelfScheeule($docter_id,$org_id,$type,$time_periods,$self_schedule);
|
|
self::makeSelfScheeule($docter_id,$org_id,$type,$time_periods,$self_schedule);
|
|
-
|
|
|
|
}
|
|
}
|
|
DB::commit();
|
|
DB::commit();
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
@@ -726,6 +729,7 @@ class ScheDuleController extends Controller
|
|
DB::rollBack();
|
|
DB::rollBack();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
// {"1":{"amStartTime":"08:00","amEndTime":"12:00","amPerson":3},"2":{"pmStartTime":"14:00","pmEndTime":"18:00","pmPerson":5},"3":{"nightStartTime":"18:00","nightEndTime":"23:00","nightPerson":4}}
|
|
// {"1":{"amStartTime":"08:00","amEndTime":"12:00","amPerson":3},"2":{"pmStartTime":"14:00","pmEndTime":"18:00","pmPerson":5},"3":{"nightStartTime":"18:00","nightEndTime":"23:00","nightPerson":4}}
|
|
@@ -773,9 +777,30 @@ class ScheDuleController extends Controller
|
|
$org_id = intval(request('org_id'));
|
|
$org_id = intval(request('org_id'));
|
|
$type = intval(request('type'));
|
|
$type = intval(request('type'));
|
|
|
|
|
|
- $setting = DocterSetting::where(['docter_id'=>$docter_id])->first()->toArray();
|
|
|
|
|
|
+ $setting = DocterSetting::where(['docter_id'=>$docter_id])->first();
|
|
if($type == 1){
|
|
if($type == 1){
|
|
- $setting = OrganizationSettings::where(['org_id'=>$org_id])->first()->toArray();
|
|
|
|
|
|
+ $setting = OrganizationSettings::where(['org_id'=>$org_id])->first();
|
|
|
|
+ }
|
|
|
|
+ $docterConfig = SystemConfig::get('docter_config');
|
|
|
|
+ if(!empty($setting)){
|
|
|
|
+ $setting = $setting->toArray();
|
|
|
|
+ } else {
|
|
|
|
+ $configData = [
|
|
|
|
+ 'amStartTime'=>$docterConfig['morning_start'],
|
|
|
|
+ 'amEndTime'=>$docterConfig['morning_end'],
|
|
|
|
+ 'amNum'=>0,
|
|
|
|
+ 'pmStartTime'=>$docterConfig['afternoon_start'],
|
|
|
|
+ 'pmEndTime'=>$docterConfig['afternoon_start'],
|
|
|
|
+ 'pmNum'=>0,
|
|
|
|
+ 'nightStartTime'=>$docterConfig['evening_start'],
|
|
|
|
+ 'nightEndTime'=>$docterConfig['evening_end'],
|
|
|
|
+ 'nightNum'=>0,
|
|
|
|
+ 'serviceNum'=>1,
|
|
|
|
+ 'showDayNumber'=>7,
|
|
|
|
+ 'status'=>false,
|
|
|
|
+ 'timeSpan'=>30,
|
|
|
|
+ ];
|
|
|
|
+ return apiReturn(200,'ok',$configData);
|
|
}
|
|
}
|
|
$config = object_array(json_decode($setting['service_time']));
|
|
$config = object_array(json_decode($setting['service_time']));
|
|
|
|
|
|
@@ -796,30 +821,13 @@ class ScheDuleController extends Controller
|
|
'timeSpan'=>$setting['service_times'],
|
|
'timeSpan'=>$setting['service_times'],
|
|
];
|
|
];
|
|
|
|
|
|
-
|
|
|
|
-// configData: {
|
|
|
|
-// amEndTime: "11:30", //上午结束时间 string
|
|
|
|
-// amNum: 20, //上午号源 Num
|
|
|
|
-// amStartTime: "09:00", //上午开始时间 string
|
|
|
|
-// nightEndTime: "19:30", //晚上结束时间 string
|
|
|
|
-// nightNum: 8, //晚上号源 num
|
|
|
|
-// nightStartTime: "18:30", //晚上开始时间 staring
|
|
|
|
-// pmEndTime: "16:00", //下午结束时间 string
|
|
|
|
-// pmNum: 20, //下午号源 num
|
|
|
|
-// pmStartTime: "13:30", //下午开始时间 string
|
|
|
|
-// serviceNum: 2, //同时服务人数 Num
|
|
|
|
-// showDayNumber: 7, //可预约服务天数 Num
|
|
|
|
-// status: false, // 是否开启 true false
|
|
|
|
-// timeSpan: "15", // 就诊时长 string
|
|
|
|
-// },
|
|
|
|
-
|
|
|
|
return apiReturn(200,'ok',$configData);
|
|
return apiReturn(200,'ok',$configData);
|
|
|
|
|
|
}
|
|
}
|
|
//获取用户信息
|
|
//获取用户信息
|
|
public function getScheduleInfo()
|
|
public function getScheduleInfo()
|
|
{
|
|
{
|
|
- $id = request('id');
|
|
|
|
|
|
+ $id = intval(request('id'));
|
|
$isDocter = CdmsUsers::where('docter_id',$id)->first();
|
|
$isDocter = CdmsUsers::where('docter_id',$id)->first();
|
|
$isOrg = CdmsUsers::where('org_id',$id)->first();
|
|
$isOrg = CdmsUsers::where('org_id',$id)->first();
|
|
$org_id = null;
|
|
$org_id = null;
|
|
@@ -844,13 +852,13 @@ class ScheDuleController extends Controller
|
|
$lists =[];
|
|
$lists =[];
|
|
if($role == 1){
|
|
if($role == 1){
|
|
$ids = DocterOrganization::where(['organization_id'=>$org_id])->pluck('docter_id')->toArray();
|
|
$ids = DocterOrganization::where(['organization_id'=>$org_id])->pluck('docter_id')->toArray();
|
|
- $list = Docter::whereIn('id',$ids)->get(['id','name']);
|
|
|
|
|
|
+ $list = Docter::whereIn('id',$ids)->distinct('id')->get(['id','name']);
|
|
foreach ($list as $val){
|
|
foreach ($list as $val){
|
|
$lists[] = ['value'=>$val->id,'label'=>$val->name];
|
|
$lists[] = ['value'=>$val->id,'label'=>$val->name];
|
|
}
|
|
}
|
|
$name = Organization::where('id',$org_id)->value('name');
|
|
$name = Organization::where('id',$org_id)->value('name');
|
|
} else if($role == 2){
|
|
} else if($role == 2){
|
|
- $ids = DocterOrganization::where(['docter_id'=>intval($id)])->distinct('organization_id')->pluck('organization_id')->toArray();
|
|
|
|
|
|
+ $ids = DocterOrganization::where(['docter_id'=>$id])->distinct('docter_id')->pluck('organization_id')->toArray();
|
|
$list = Organization::whereIn('id',$ids)->get(['id','name']);
|
|
$list = Organization::whereIn('id',$ids)->get(['id','name']);
|
|
foreach ($list as $val){
|
|
foreach ($list as $val){
|
|
$lists[] = ['value'=>$val->id,'label'=>$val->name];
|
|
$lists[] = ['value'=>$val->id,'label'=>$val->name];
|
|
@@ -905,11 +913,103 @@ class ScheDuleController extends Controller
|
|
public function get_month_schedule()
|
|
public function get_month_schedule()
|
|
{
|
|
{
|
|
$date = request('date');
|
|
$date = request('date');
|
|
|
|
+ $org_id = intval(request('org_id'));
|
|
|
|
+ $docter_id = intval(request('docter_id'));
|
|
|
|
+ $type = intval(request('type'));
|
|
|
|
+ $role = intval(request('role'));
|
|
$start_time = strtotime($date);
|
|
$start_time = strtotime($date);
|
|
- //$start_time = strtotime(date('Y-m',time()));
|
|
|
|
$month_day = date("t",$start_time);
|
|
$month_day = date("t",$start_time);
|
|
|
|
+ $end_time = ($start_time + $month_day * 86400);
|
|
|
|
+ $start_date = date('Y-m-d',$start_time);
|
|
|
|
+ $end_date = date('Y-m-d',$end_time);
|
|
$types = [1=>1,2=>2,3=>3];
|
|
$types = [1=>1,2=>2,3=>3];
|
|
|
|
|
|
|
|
+
|
|
|
|
+// if($type == 1){
|
|
|
|
+// $schedule_data = Schedule::where(['docter_id'=>$docter_id,'organization_id'=>0])
|
|
|
|
+// ->whereBetween('schedule_date',[$start_date,$end_date])->pluck('schedule_date','id')->toArray();
|
|
|
|
+// $settingConfig = DocterSetting::where(['docter_id'=>$docter_id])->first();
|
|
|
|
+// $serviceConfig = object_array(json_decode($settingConfig['service_time']));
|
|
|
|
+// } else {
|
|
|
|
+// $schedule_data = Schedule::where(['docter_id'=>0,'organization_id'=>$org_id])->
|
|
|
|
+// whereBetween('schedule_date',[$start_date,$end_date])->pluck('schedule_date','id')->toArray();
|
|
|
|
+// $settingConfig = OrganizationSettings::where(['org_id'=>$org_id])->first();
|
|
|
|
+// $serviceConfig = object_array(json_decode($settingConfig['service_time']));
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if(!empty($settingConfig)){
|
|
|
|
+// $baseData = [
|
|
|
|
+// ['status'=>false,'type'=>1,'start'=>$serviceConfig[1]['amStartTime'],'end'=>$serviceConfig[1]['amEndTime']],
|
|
|
|
+// ['status'=>false,'type'=>2,'start'=>$serviceConfig[2]['pmStartTime'],'end'=>$serviceConfig[2]['pmEndTime']],
|
|
|
|
+// ['status'=>false,'type'=>3,'start'=>$serviceConfig[3]['nightStartTime'],'end'=>$serviceConfig[3]['nightEndTime']],
|
|
|
|
+// ];
|
|
|
|
+//
|
|
|
|
+// } else{
|
|
|
|
+// $serviceConfig = '';
|
|
|
|
+// $baseData = [
|
|
|
|
+// ['status'=>false,'type'=>1,'start'=>$serviceConfig[1]['amStartTime'],'end'=>$serviceConfig[1]['amEndTime']],
|
|
|
|
+// ['status'=>false,'type'=>2,'start'=>$serviceConfig[2]['pmStartTime'],'end'=>$serviceConfig[2]['pmEndTime']],
|
|
|
|
+// ['status'=>false,'type'=>3,'start'=>$serviceConfig[3]['nightStartTime'],'end'=>$serviceConfig[3]['nightEndTime']],
|
|
|
|
+// ];
|
|
|
|
+//
|
|
|
|
+// self::baseMonthSchedule($month_day,$baseData);
|
|
|
|
+// return [];
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// for($i=1;$i<$month_day; $i++){
|
|
|
|
+// //$startKey = date('d',time());
|
|
|
|
+// $week = date('N',$start_time + ($i-1) * 86400);
|
|
|
|
+// $scheduleDate = date('Y-m-d',$start_time + ($i-1) * 86400);
|
|
|
|
+//
|
|
|
|
+// if(empty($schedule_data)){
|
|
|
|
+// $scheduleList[$i] = [
|
|
|
|
+// 'schedulelingList'=>$baseData,
|
|
|
|
+// 'date'=>$scheduleDate,
|
|
|
|
+// 'week'=>$week,
|
|
|
|
+// 'day'=>$scheduleDate
|
|
|
|
+// ];
|
|
|
|
+// } else {
|
|
|
|
+// if($type == 1){
|
|
|
|
+// $today = SchedulePeriod::where(['docter_id'=>$docter_id,'schedule_date'=>$scheduleDate])->where('organization_id','!=',0)->distinct('organization_id')
|
|
|
|
+// ->distinct('type')->get(['organization_id','type'])->GroupBy('type')->toArray();
|
|
|
|
+//
|
|
|
|
+// if(empty($today)){
|
|
|
|
+// $scheduleList[$i] = [
|
|
|
|
+// 'schedulelingList'=>$baseData,
|
|
|
|
+// 'date'=>$scheduleDate,
|
|
|
|
+// 'week'=>$week,
|
|
|
|
+// 'day'=>$scheduleDate
|
|
|
|
+// ];
|
|
|
|
+// } else {
|
|
|
|
+// foreach ($today as $type => $orginfo){
|
|
|
|
+// $orgids = array_column($orginfo,'organization_id');
|
|
|
|
+// $idSum = array_sum($orgids);
|
|
|
|
+// if($org_id == $idSum) $baseData[$type]['status'] = true;
|
|
|
|
+// if($org_id != $idSum) $baseData[$type]['status'] = 'other';
|
|
|
|
+// }
|
|
|
|
+// $scheduleList[] = [
|
|
|
|
+// 'schedulelingList'=>$baseData,
|
|
|
|
+// 'date'=>$scheduleDate,
|
|
|
|
+// 'week'=>$week,
|
|
|
|
+// 'day'=>$scheduleDate
|
|
|
|
+// ];
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//// if(empty( $schedule_data[$scheduleDate])) continue;
|
|
|
|
+//// $schedule_id = $schedule_data[$schedule_data];
|
|
|
|
+// if($type == 1){
|
|
|
|
+// $today = SchedulePeriod::where(['docter_id'=>$docter_id,'schedule_date'=>$scheduleDate])->get(['organization_id','type'])->GroupBy('type');
|
|
|
|
+//
|
|
|
|
+// dd($today);
|
|
|
|
+// }
|
|
|
|
+//// date'=>($i+1),'day'=>$now_date,'schedulelingList'=>$arr,'week'=>$week
|
|
|
|
+//// dd($scheduleList);
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+//
|
|
$status = [1=>true,2=>'other',3=>false];
|
|
$status = [1=>true,2=>'other',3=>false];
|
|
|
|
|
|
for($i=0;$i<$month_day;$i++){
|
|
for($i=0;$i<$month_day;$i++){
|
|
@@ -962,15 +1062,15 @@ class ScheDuleController extends Controller
|
|
{
|
|
{
|
|
|
|
|
|
//todo 上线取消默认值
|
|
//todo 上线取消默认值
|
|
- $schdule_data = request('schedule_data',1);
|
|
|
|
- $docter_id = intval(request('docter_id',1));
|
|
|
|
- $schedule_type = request('schedule_type',1);
|
|
|
|
- $org_id = intval(request('org_id',1));
|
|
|
|
|
|
+ $schdule_data = request('schedule_data');
|
|
|
|
+ $docter_id = intval(request('docter_id'));
|
|
|
|
+ $schedule_type = request('type');
|
|
|
|
+ $org_id = intval(request('org_id'));
|
|
$date = request('date');
|
|
$date = request('date');
|
|
//判断排班类型
|
|
//判断排班类型
|
|
$schedule_type == 1?$type=2:$type=1;
|
|
$schedule_type == 1?$type=2:$type=1;
|
|
|
|
|
|
- if(empty($schdule_data) || empty($docter_id) || !isset($org_id)){
|
|
|
|
|
|
+ if(empty($schdule_data) || empty($docter_id) || !isset($org_id) || empty($type)){
|
|
return apiReturn(601,'缺少必要参数');
|
|
return apiReturn(601,'缺少必要参数');
|
|
}
|
|
}
|
|
//获取医生排班配置
|
|
//获取医生排班配置
|
|
@@ -978,7 +1078,7 @@ class ScheDuleController extends Controller
|
|
//默认为门诊排班医生配置
|
|
//默认为门诊排班医生配置
|
|
$setting = DocterSetting::where(['docter_id'=>$docter_id])->first();
|
|
$setting = DocterSetting::where(['docter_id'=>$docter_id])->first();
|
|
//获取社区排班设置
|
|
//获取社区排班设置
|
|
-// if($type == 1) $setting = DocterSetting::where(['org_id'=>$org_id])->first();
|
|
|
|
|
|
+ if($type == 1) $setting = OrganizationSettings::where(['org_id'=>$org_id])->first();
|
|
|
|
|
|
$schdule_data = [
|
|
$schdule_data = [
|
|
['status'=>true,'type'=>1,'start'=>"09:00",'end'=>'11:30','date'=>15,'week'=>1],
|
|
['status'=>true,'type'=>1,'start'=>"09:00",'end'=>'11:30','date'=>15,'week'=>1],
|
|
@@ -1159,12 +1259,15 @@ class ScheDuleController extends Controller
|
|
if(empty($docter_id) || empty($org_id) || empty($type) || empty($data)){
|
|
if(empty($docter_id) || empty($org_id) || empty($type) || empty($data)){
|
|
return apiReturn(601,'缺少必要参数');
|
|
return apiReturn(601,'缺少必要参数');
|
|
}
|
|
}
|
|
|
|
+ $docter_setting = [];
|
|
if($type == 1){
|
|
if($type == 1){
|
|
$docter_setting = DocterSetting::where(['docter_id'=>$docter_id])->first();
|
|
$docter_setting = DocterSetting::where(['docter_id'=>$docter_id])->first();
|
|
} else {
|
|
} else {
|
|
$docter_setting = OrganizationSettings::where(['org_id'=>$org_id])->first();
|
|
$docter_setting = OrganizationSettings::where(['org_id'=>$org_id])->first();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
$time = [];
|
|
$time = [];
|
|
if(!empty($docter_setting)){
|
|
if(!empty($docter_setting)){
|
|
$time_period = object_array(json_decode($docter_setting->service_time));
|
|
$time_period = object_array(json_decode($docter_setting->service_time));
|
|
@@ -1173,18 +1276,74 @@ class ScheDuleController extends Controller
|
|
$times[] = TimePeriod::where(['docter_id'=>$docter_id])->whereBetween('end_time_period',[intval($time_period[3]['nightStartTime']),intval($time_period[3]['nightEndTime'])])->pluck('id')->toArray();
|
|
$times[] = TimePeriod::where(['docter_id'=>$docter_id])->whereBetween('end_time_period',[intval($time_period[3]['nightStartTime']),intval($time_period[3]['nightEndTime'])])->pluck('id')->toArray();
|
|
}
|
|
}
|
|
|
|
|
|
- $week_data = [
|
|
|
|
- 'schedule_type'=>$type,
|
|
|
|
- 'organization_id'=>$org_id,
|
|
|
|
- 'docter_id'=>$docter_id
|
|
|
|
- ];
|
|
|
|
|
|
+ //沒有配置就新建
|
|
|
|
+ if(empty($docter_setting) || $times){
|
|
|
|
+ $docter_config = SystemConfig::get('docter_config');
|
|
|
|
+ $amCount = intval(((strtotime($docter_config['morning_end'])) - (strtotime($docter_config['morning_start']))) / ($docter_config['service_time']*60));
|
|
|
|
+ $pmCount = intval(((strtotime($docter_config['afternoon_end'])) - (strtotime($docter_config['afternoon_start']))) / ($docter_config['service_time']*60));
|
|
|
|
+ $evCount = intval(((strtotime($docter_config['evening_end'])) - (strtotime($docter_config['evening_start']))) / ($docter_config['service_time']*60));
|
|
|
|
+ $c_r = [
|
|
|
|
+ 1=>['count'=>$amCount,'start_time'=>$docter_config['morning_start'],'end_time'=>$docter_config['morning_end']],
|
|
|
|
+ 2=>['count'=>$pmCount,'start_time'=>$docter_config['afternoon_start'],'end_time'=>$docter_config['afternoon_end']],
|
|
|
|
+ 3=>['count'=>$evCount,'start_time'=>$docter_config['evening_start'],'end_time'=>$docter_config['evening_end']]
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ if($type == 1){
|
|
|
|
+ $setingData = [
|
|
|
|
+ 'docter_id'=>$docter_id,
|
|
|
|
+ 'type'=>$type,
|
|
|
|
+ 'status'=>false,
|
|
|
|
+ 'show_days'=>7,
|
|
|
|
+ 'service_time'=>json_encode($c_r),
|
|
|
|
+ 'service_times'=>30,
|
|
|
|
+ ];
|
|
|
|
+ $isHave = DocterSetting::where($setingData)->count();
|
|
|
|
+ if(!$isHave) {
|
|
|
|
+ $setingData [ 'created_at']=Carbon::now();
|
|
|
|
+ $setingData [ 'updated_at']=Carbon::now();
|
|
|
|
+ DocterSetting::insert($setingData);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ $setingData = [
|
|
|
|
+ 'org_id'=>$docter_id,
|
|
|
|
+ 'type'=>$type,
|
|
|
|
+ 'status'=>false,
|
|
|
|
+ 'show_days'=>7,
|
|
|
|
+ 'service_time'=>json_encode($c_r),
|
|
|
|
+ 'service_times'=>30,
|
|
|
|
+ ];
|
|
|
|
+ $isHave = OrganizationSettings::where($setingData)->count();
|
|
|
|
+ if(!$isHave) {
|
|
|
|
+ $setingData [ 'created_at']=Carbon::now();
|
|
|
|
+ $setingData [ 'update_at']=Carbon::now();
|
|
|
|
+ OrganizationSettings::insert($data);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ foreach ($c_r as $key => $val){
|
|
|
|
+ self::makeTimePeriod($type,$docter_id,$org_id,$key,$val,$val['count'],$docter_config['service_time']);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if($type == 1){
|
|
|
|
+ $week_data = [
|
|
|
|
+ 'organization_id'=>$org_id,
|
|
|
|
+ 'docter_id'=>$docter_id
|
|
|
|
+ ];
|
|
|
|
+ } else {
|
|
|
|
+ $week_data = [
|
|
|
|
+ 'organization_id'=>$org_id,
|
|
|
|
+ 'docter_id'=>0
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ $week_data ['schedule_type']=$type;
|
|
|
|
|
|
$k = 0;
|
|
$k = 0;
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|
|
$data[0] = array_values(object_array(json_decode($data[0])));
|
|
$data[0] = array_values(object_array(json_decode($data[0])));
|
|
$data[1] = array_values(object_array(json_decode($data[1])));
|
|
$data[1] = array_values(object_array(json_decode($data[1])));
|
|
$data[2] = array_values(object_array(json_decode($data[2])));
|
|
$data[2] = array_values(object_array(json_decode($data[2])));
|
|
-
|
|
|
|
try {
|
|
try {
|
|
for($i=0;$i<=2;$i++){
|
|
for($i=0;$i<=2;$i++){
|
|
$schedule_data = $data[$i];
|
|
$schedule_data = $data[$i];
|
|
@@ -1196,14 +1355,23 @@ class ScheDuleController extends Controller
|
|
// echo '时间列类型'.($i+1).'----'.$key.'星期数'.'<br>';
|
|
// echo '时间列类型'.($i+1).'----'.$key.'星期数'.'<br>';
|
|
foreach ($times[$i] as $id){
|
|
foreach ($times[$i] as $id){
|
|
$week_data['time_period_id'] = $id;
|
|
$week_data['time_period_id'] = $id;
|
|
- $is_have = WeekSchedule::where(['docter_id'=>$docter_id,'schedule_type'=>$type,'type'=>$i+1,'week'=>$key])->where('time_period_id',$id)->value('id');
|
|
|
|
|
|
+ if($type == 1){
|
|
|
|
+ $is_have = WeekSchedule::where(['docter_id'=>$docter_id,'schedule_type'=>$type,'type'=>$i+1,'week'=>$key])->where('time_period_id',$id)->value('id');
|
|
|
|
+ } else {
|
|
|
|
+ $is_have = WeekSchedule::where(['docter_id'=>0,'schedule_type'=>$type,'type'=>$i+1,'week'=>$key])->where('time_period_id',$id)->value('id');
|
|
|
|
+ }
|
|
if($is_have) continue;
|
|
if($is_have) continue;
|
|
$k++;
|
|
$k++;
|
|
WeekSchedule::insert($week_data);
|
|
WeekSchedule::insert($week_data);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- $is_have = WeekSchedule::where(['docter_id' => $docter_id, 'organization_id' => $org_id, 'schedule_type' => $type,'type'=>$i+1,'week'=>$key])->whereIn('time_period_id', $times[$i])->value('id');
|
|
|
|
- if($is_have) WeekSchedule::where(['docter_id' => $docter_id, 'organization_id' => $org_id, 'schedule_type' => $type,'type'=>$i+1,'week'=>$key])->whereIn('time_period_id', $times[$i])->delete();
|
|
|
|
|
|
+ if($type == 1){
|
|
|
|
+ $is_have = WeekSchedule::where(['docter_id' => $docter_id, 'organization_id' => $org_id, 'schedule_type' => $type,'type'=>$i+1,'week'=>$key])->whereIn('time_period_id', $times[$i])->value('id');
|
|
|
|
+ if($is_have) WeekSchedule::where(['docter_id' => $docter_id, 'organization_id' => $org_id, 'schedule_type' => $type,'type'=>$i+1,'week'=>$key])->whereIn('time_period_id', $times[$i])->delete();
|
|
|
|
+ } else {
|
|
|
|
+ $is_have = WeekSchedule::where(['docter_id' => 0, 'organization_id' => $org_id, 'schedule_type' => $type,'type'=>$i+1,'week'=>$key])->whereIn('time_period_id', $times[$i])->value('id');
|
|
|
|
+ if($is_have) WeekSchedule::where(['docter_id' => 0, 'organization_id' => $org_id, 'schedule_type' => $type,'type'=>$i+1,'week'=>$key])->whereIn('time_period_id', $times[$i])->delete();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1341,11 +1509,11 @@ class ScheDuleController extends Controller
|
|
*/
|
|
*/
|
|
public static function delteScheduleInfo($id,$type){
|
|
public static function delteScheduleInfo($id,$type){
|
|
if($type == 1){
|
|
if($type == 1){
|
|
- TimePeriod::where(['docter_id'=>$id])->where('org_id','=',0)->delete();
|
|
|
|
- SchedulePeriod::where(['docter_id'=>$id])->where('organization_id','!=',0)->delete();
|
|
|
|
|
|
+ TimePeriod::where(['docter_id'=>$id,'type'=>$type])->where('org_id','=',0)->delete();
|
|
|
|
+ SchedulePeriod::where(['docter_id'=>$id,'type'=>$type])->where('organization_id','=',0)->delete();
|
|
} else {
|
|
} else {
|
|
- TimePeriod::where(['org_id'=>$id])->where('docter_id','=',0)->delete();
|
|
|
|
- SchedulePeriod::where(['organization_id'=>$id])->where('docter_id','!=',null)->delete();
|
|
|
|
|
|
+ TimePeriod::where(['org_id'=>$id,'type'=>$type])->where('docter_id','=',0)->delete();
|
|
|
|
+ SchedulePeriod::where(['organization_id'=>$id,'type'=>$type])->where('docter_id','=',0)->delete();
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -1364,8 +1532,10 @@ class ScheDuleController extends Controller
|
|
];
|
|
];
|
|
if($scheduleType == 1){
|
|
if($scheduleType == 1){
|
|
$timePreiod['org_id'] = 0;
|
|
$timePreiod['org_id'] = 0;
|
|
|
|
+ $timePreiod['docter_id'] = $docterId;
|
|
} else {
|
|
} else {
|
|
$timePreiod['docter_id'] = 0;
|
|
$timePreiod['docter_id'] = 0;
|
|
|
|
+ $timePreiod['org_id'] = $orgId;
|
|
}
|
|
}
|
|
$isHave = TimePeriod::where($timePreiod)->count();
|
|
$isHave = TimePeriod::where($timePreiod)->count();
|
|
if($isHave) continue;
|
|
if($isHave) continue;
|
|
@@ -1374,139 +1544,99 @@ class ScheDuleController extends Controller
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- public function oldorg(){
|
|
|
|
- if(in_array(2,$is_new)){
|
|
|
|
-
|
|
|
|
- DB::beginTransaction();
|
|
|
|
- try {
|
|
|
|
- $time_periods = TimePeriod::where(['org_id' => $org_id, 'docter_id' => $docter_id, 'type' => 2])->pluck('id')->toArray();
|
|
|
|
- $week_schedule = WeekSchedule::where(['docter_id' => $docter_id, 'type' => 2])->distinct('type')->orderBy('week')->pluck('week')->toArray();
|
|
|
|
- $self_schedule = SelfSchedule::where(['docter_id' => $docter_id, 'schedule_type' => $type, 'type' => 2])->distinct('type')
|
|
|
|
- ->orderBy('schedule_date')->get(['schedule_date', 'type', 'week'])->toArray();
|
|
|
|
- SchedulePeriod::where(['docter_id' => $docter_id])->where('schedule_date', '>', date('Y-m-d', time()))->delete();
|
|
|
|
- if (empty($week_schedule)) {
|
|
|
|
- Schedule::where(['docter_id' => $docter_id])->delete();
|
|
|
|
- SelfSchedule::where(['docter_id' => $docter_id])->delete();
|
|
|
|
|
|
+
|
|
|
|
+ //以周模板进行排班
|
|
|
|
+ public static function makeSchedule ($docterId,$orgId,$type,$schedule,$weekSchedule,$timePeriods){
|
|
|
|
+
|
|
|
|
+ if(empty($schedule) || count($schedule) < 58){
|
|
|
|
+ $start = strtotime(date('Y-m-1',time()));
|
|
|
|
+ $today = date('j',time());
|
|
|
|
+ $allDay = date('t',time());
|
|
|
|
+
|
|
|
|
+ //门诊排班
|
|
|
|
+ if($type == 1){
|
|
|
|
+ $scheduleData['docter_id']=$docterId;
|
|
|
|
+ $scheduleData['organization_id']= 0;
|
|
} else {
|
|
} else {
|
|
- $schedule = Schedule::where(['docter_id'=>$docter_id,'organization_id'=>$org_id])
|
|
|
|
- ->where('schedule_date','>',date('Y-m-d',time()))->pluck('schedule_date','id')->toArray();
|
|
|
|
- $schedule = Schedule::where(['docter_id' => $docter_id, 'organization_id' => $org_id])->pluck('schedule_date', 'id')->toArray();
|
|
|
|
- foreach ($schedule as $id => $date) {
|
|
|
|
- $week = intval(date('N', strtotime($date)));
|
|
|
|
- foreach ($week_schedule as $w) {
|
|
|
|
- if ($week == $w) {
|
|
|
|
- foreach ($time_periods as $idt) {
|
|
|
|
- $s_t = [
|
|
|
|
- 'organization_id' => $org_id,
|
|
|
|
- 'docter_id' => $docter_id,
|
|
|
|
- 'type' => $type,
|
|
|
|
- 'schedule_date' => $date,
|
|
|
|
- 'schedule_id' => $id,
|
|
|
|
- 'time_period_id' => $idt
|
|
|
|
- ];
|
|
|
|
- $schedule_is_have = SchedulePeriod::where($s_t)->count();
|
|
|
|
- if ($schedule_is_have) continue;
|
|
|
|
- $s_t['created_at'] = Carbon::now();
|
|
|
|
- $s_t['updated_at'] = Carbon::now();
|
|
|
|
- SchedulePeriod::insert($s_t);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- SelfSchedule::where(['type'=>2,'docter_id'=>$docter_id,'organization_id'=>$org_id])->whereIn('time_period_id',$time_periods)->delete();
|
|
|
|
- foreach ($self_schedule as $val) {
|
|
|
|
- $self_data = $val;
|
|
|
|
- $self_data['organization_id'] = $org_id;
|
|
|
|
- $self_data['docter_id'] = $docter_id;
|
|
|
|
- foreach ($time_periods as $idt) {
|
|
|
|
- $self_data['time_period_id'] = $idt;
|
|
|
|
- $is_self_have = SelfSchedule::where($self_data)->count();
|
|
|
|
- if ($is_self_have) continue;
|
|
|
|
- $self_data['created_at'] = Carbon::now();
|
|
|
|
- $self_data['updated_at'] = Carbon::now();
|
|
|
|
- SelfSchedule::insert($self_data);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ $scheduleData['docter_id']=0;
|
|
|
|
+ $scheduleData['organization_id']= $orgId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //第一个月
|
|
|
|
+ for ($i=$today;$i<=$allDay;$i++){
|
|
|
|
+ $todayTimer = $start + (($i - 1) *86400);
|
|
|
|
+ $week = date('N',$todayTimer);
|
|
|
|
+
|
|
|
|
+ $date = date('Y-m-d',$todayTimer);
|
|
|
|
+ $numDate = date('Ymd',$todayTimer);
|
|
|
|
+ $scheduleData['schedule_date'] = $date;
|
|
|
|
+ $scheduleData['schedule_day'] = $numDate;
|
|
|
|
+
|
|
|
|
+ $scheduleIsHave = Schedule::where($scheduleData)->count();
|
|
|
|
+ if ($scheduleIsHave) continue;
|
|
|
|
+ Schedule::insertGetId($scheduleData);
|
|
|
|
+ }
|
|
|
|
+ $nextStart = strtotime(date('Y-m-1',strtotime('next month')));
|
|
|
|
+ $nextAllDay = date('t',strtotime('nex month'));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //第二个月
|
|
|
|
+ for($j=1;$j<=$nextAllDay;$j++){
|
|
|
|
+ $todayTimer = $nextStart + (($j-1)*86400);
|
|
|
|
+ $week = date('N',$todayTimer);
|
|
|
|
+ $date = date('Y-m-d',$todayTimer);
|
|
|
|
+ $numDate = date('Ymd',$todayTimer);
|
|
|
|
+ $scheduleData['schedule_date'] = $date;
|
|
|
|
+ $scheduleData['schedule_day'] = $numDate;
|
|
|
|
+ $scheduleIsHave = Schedule::where($scheduleData)->count();
|
|
|
|
+ if ($scheduleIsHave) continue;
|
|
|
|
+ Schedule::insertGetId($scheduleData);
|
|
|
|
+ }
|
|
|
|
+ $schedule = Schedule::where(['docter_id'=>$docterId,'organization_id'=>0])->where('schedule_date','>',date('Y-m-d',time()))
|
|
|
|
+ ->distinct('schedule_date')->pluck('schedule_date','id')->toArray();
|
|
|
|
+ if($type == 2){
|
|
|
|
+ $schedule = Schedule::where(['docter_id'=>0,'organization_id'=>$orgId])->where('schedule_date','>',date('Y-m-d',time()))
|
|
|
|
+ ->distinct('schedule_date')->pluck('schedule_date','id')->toArray();
|
|
}
|
|
}
|
|
- DB::commit();
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
- dd($e->getMessage());
|
|
|
|
- DB::rollBack();
|
|
|
|
- }
|
|
|
|
- for($i=1;$i<=$pmCount;$i++){
|
|
|
|
- $pmdata = [
|
|
|
|
- 'docter_id'=>$docter_id,
|
|
|
|
- 'start_time_period'=> date('H:i',strtotime($configData['pmStartTime']) + ($i-1)*$configData['timeSpan']*60),
|
|
|
|
- 'end_time_period'=> date('H:i',strtotime($configData['pmStartTime']) + $i*$configData['timeSpan']*60),
|
|
|
|
- ];
|
|
|
|
- TimePeriod::insert($pmdata);
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- if(in_array(3,$is_new)){
|
|
|
|
-
|
|
|
|
- DB::beginTransaction();
|
|
|
|
- try {
|
|
|
|
- $time_periods = TimePeriod::where(['org_id' => $org_id, 'docter_id' => $docter_id, 'type' => 3])->pluck('id')->toArray();
|
|
|
|
- $week_schedule = WeekSchedule::where(['docter_id' => $docter_id, 'type' => 3])->distinct('type')->orderBy('week')->pluck('week')->toArray();
|
|
|
|
- $self_schedule = SelfSchedule::where(['docter_id' => $docter_id, 'schedule_type' => $schedule_type, 'type' => 3])->distinct('type')
|
|
|
|
- ->orderBy('schedule_date')->get(['schedule_date', 'type', 'week'])->toArray();
|
|
|
|
- SchedulePeriod::where(['docter_id' => $docter_id])->where('schedule_date', '>', date('Y-m-d', time()))->delete();
|
|
|
|
- if (empty($week_schedule)) {
|
|
|
|
- Schedule::where(['docter_id' => $docter_id])->delete();
|
|
|
|
- SelfSchedule::where(['docter_id' => $docter_id])->delete();
|
|
|
|
- } else {
|
|
|
|
- $schedule = Schedule::where(['docter_id'=>$docter_id,'organization_id'=>$org_id])
|
|
|
|
- ->where('schedule_date','>',date('Y-m-d',time()))->pluck('schedule_date','id')->toArray();
|
|
|
|
-// $schedule = Schedule::where(['docter_id' => $docter_id, 'organization_id' => $org_id])->pluck('schedule_date', 'id')->toArray();
|
|
|
|
- foreach ($schedule as $id => $date) {
|
|
|
|
- $week = intval(date('N', strtotime($date)));
|
|
|
|
- foreach ($week_schedule as $w) {
|
|
|
|
- if ($week == $w) {
|
|
|
|
- foreach ($time_periods as $idt) {
|
|
|
|
- $s_t = [
|
|
|
|
- 'organization_id' => $org_id,
|
|
|
|
- 'docter_id' => $docter_id,
|
|
|
|
- 'type' => $type,
|
|
|
|
- 'schedule_date' => $date,
|
|
|
|
- 'schedule_id' => $id,
|
|
|
|
- 'time_period_id' => $idt
|
|
|
|
- ];
|
|
|
|
- $schedule_is_have = SchedulePeriod::where($s_t)->count();
|
|
|
|
- if ($schedule_is_have) continue;
|
|
|
|
- $s_t['created_at'] = Carbon::now();
|
|
|
|
- $s_t['updated_at'] = Carbon::now();
|
|
|
|
- if ($self_schedule == 1) $s_t['me_sure'] = 1;
|
|
|
|
- SchedulePeriod::insert($s_t);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ foreach ($schedule as $id => $date) {
|
|
|
|
+ $week = intval(date('N', strtotime($date)));
|
|
|
|
+ foreach ($weekSchedule as $w) {
|
|
|
|
+
|
|
|
|
+ //门诊和儿保,计免排班分开
|
|
|
|
+ if($type == 1){
|
|
|
|
+ $realWeek = $w[0]['week'];
|
|
|
|
+ $oId = $w = $w[0]['organization_id'];
|
|
|
|
+ } else {
|
|
|
|
+ $realWeek = $w;
|
|
|
|
+ $oId = $orgId;
|
|
}
|
|
}
|
|
- SelfSchedule::where(['type'=>3,'docter_id'=>$docter_id,'organization_id'=>$org_id])->whereIn('time_period_id',$time_periods)->delete();
|
|
|
|
- foreach ($self_schedule as $val) {
|
|
|
|
- $self_data = $val;
|
|
|
|
- $self_data['organization_id'] = $org_id;
|
|
|
|
- $self_data['docter_id'] = $docter_id;
|
|
|
|
- foreach ($time_periods as $idt) {
|
|
|
|
- $self_data['time_period_id'] = $idt;
|
|
|
|
- $is_self_have = SelfSchedule::where($self_data)->count();
|
|
|
|
- if ($is_self_have) continue;
|
|
|
|
- $self_data['created_at'] = Carbon::now();
|
|
|
|
- $self_data['updated_at'] = Carbon::now();
|
|
|
|
- SelfSchedule::insert($self_data);
|
|
|
|
|
|
+
|
|
|
|
+ if ($week == $realWeek) {
|
|
|
|
+ foreach ($timePeriods as $idt) {
|
|
|
|
+ $s_t = [
|
|
|
|
+ 'organization_id' => $oId,
|
|
|
|
+ 'docter_id' => $docterId,
|
|
|
|
+ 'type' => $type,
|
|
|
|
+ 'schedule_date' => $date,
|
|
|
|
+ 'schedule_id' => $id,
|
|
|
|
+ 'time_period_id' => $idt
|
|
|
|
+ ];
|
|
|
|
+ $scheduleIsHave = SchedulePeriod::where($s_t)->count();
|
|
|
|
+ if ($scheduleIsHave) continue;
|
|
|
|
+ $s_t['created_at'] = Carbon::now();
|
|
|
|
+ $s_t['updated_at'] = Carbon::now();
|
|
|
|
+ SchedulePeriod::insert($s_t);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- DB::commit();
|
|
|
|
- } catch (\Exception $e) {
|
|
|
|
- dd($e->getMessage());
|
|
|
|
- DB::rollBack();
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
- public static function makeSchedule ($docterId,$orgId,$type,$schedule,$weekSchedule,$timePeriods){
|
|
|
|
|
|
+
|
|
|
|
+ public static function makeOrgainzationSchedule ($docterId,$orgId,$type,$schedule,$weekSchedule,$timePeriods){
|
|
//门诊排班
|
|
//门诊排班
|
|
- if($type == 1){
|
|
|
|
if(empty($schedule) || count($schedule) < 58){
|
|
if(empty($schedule) || count($schedule) < 58){
|
|
$start = strtotime(date('Y-m-1',time()));
|
|
$start = strtotime(date('Y-m-1',time()));
|
|
$today = date('j',time());
|
|
$today = date('j',time());
|
|
@@ -1518,16 +1648,16 @@ class ScheDuleController extends Controller
|
|
|
|
|
|
$date = date('Y-m-d',$todayTimer);
|
|
$date = date('Y-m-d',$todayTimer);
|
|
$numDate = date('Ymd',$todayTimer);
|
|
$numDate = date('Ymd',$todayTimer);
|
|
- $scheduleData = [
|
|
|
|
- 'schedule_date'=>$date,
|
|
|
|
- 'schedule_day'=>$numDate,
|
|
|
|
- 'week'=>$week,
|
|
|
|
- 'docter_id'=>$docterId,
|
|
|
|
- 'organization_id'=>0
|
|
|
|
- ];
|
|
|
|
- $scheduleIsHave = Schedule::where($scheduleData)->count();
|
|
|
|
- if ($scheduleIsHave) continue;
|
|
|
|
- Schedule::insertGetId($scheduleData);
|
|
|
|
|
|
+ $scheduleData = [
|
|
|
|
+ 'schedule_date'=>$date,
|
|
|
|
+ 'schedule_day'=>$numDate,
|
|
|
|
+ 'week'=>$week,
|
|
|
|
+ 'docter_id'=>0,
|
|
|
|
+ 'organization_id'=>$orgId
|
|
|
|
+ ];
|
|
|
|
+ $scheduleIsHave = Schedule::where($scheduleData)->count();
|
|
|
|
+ if ($scheduleIsHave) continue;
|
|
|
|
+ Schedule::insertGetId($scheduleData);
|
|
}
|
|
}
|
|
$nextStart = strtotime(date('Y-m-1',strtotime('next month')));
|
|
$nextStart = strtotime(date('Y-m-1',strtotime('next month')));
|
|
$nextAllDay = date('t',strtotime('nex month'));
|
|
$nextAllDay = date('t',strtotime('nex month'));
|
|
@@ -1560,8 +1690,8 @@ class ScheDuleController extends Controller
|
|
if ($week == $w[0]['week']) {
|
|
if ($week == $w[0]['week']) {
|
|
foreach ($timePeriods as $idt) {
|
|
foreach ($timePeriods as $idt) {
|
|
$s_t = [
|
|
$s_t = [
|
|
- 'organization_id' => $w[0]['organization_id'],
|
|
|
|
- 'docter_id' => $docterId,
|
|
|
|
|
|
+ 'organization_id' => $orgId,
|
|
|
|
+ 'docter_id' => 0,
|
|
'type' => $type,
|
|
'type' => $type,
|
|
'schedule_date' => $date,
|
|
'schedule_date' => $date,
|
|
'schedule_id' => $id,
|
|
'schedule_id' => $id,
|
|
@@ -1578,10 +1708,10 @@ class ScheDuleController extends Controller
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //自己排班
|
|
public function makeSelfScheeule($docterId,$orgId,$type,$timesPeriods,$selfSchedule){
|
|
public function makeSelfScheeule($docterId,$orgId,$type,$timesPeriods,$selfSchedule){
|
|
if($type == 1){
|
|
if($type == 1){
|
|
$orgId = 0;
|
|
$orgId = 0;
|
|
@@ -1604,4 +1734,12 @@ class ScheDuleController extends Controller
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ public static function baseMonthSchedule($monthDay, $baseData){
|
|
|
|
+ $start_time = strtotime(date('Y-m-1',time()));
|
|
|
|
+ for($i = 1 ; $i<=$monthDay; $i++){
|
|
|
|
+ $week = date('N',$start_time + ($i-1) * 86400);
|
|
|
|
+ $scheduleDate = date('Y-m-d',$start_time + ($i-1) * 86400);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|