| xqd
@@ -348,15 +348,12 @@ class ApiController extends Controller
|
|
|
$serviceNum = $docter_setting->service_num;
|
|
|
$time_period = object_array(json_decode($docter_setting->service_time));
|
|
|
$allCount = TimePeriod::where(['docter_id'=>$docter_id,'org_id'=>$org_id])->count();
|
|
|
- dump($allCount);
|
|
|
if($allCount == 0) return apiReturn(603,'请设置时间段');
|
|
|
- echo '查看时间段';
|
|
|
- $times[] = TimePeriod::where(['docter_id'=>$docter_id,'org_id'=>$org_id])->whereBetween('end_time_period',[intval($time_period[1]['amStartTime']),intval($time_period[1]['amEndTime'])])->pluck('id')->toArray();
|
|
|
- $times[] = TimePeriod::where(['docter_id'=>$docter_id,'org_id'=>$org_id])->whereBetween('end_time_period',[intval($time_period[2]['pmStartTime']),intval($time_period[2]['pmEndTime'])])->pluck('id')->toArray();
|
|
|
- $times[] = TimePeriod::where(['docter_id'=>$docter_id,'org_id'=>$org_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,'org_id'=>$org_id,'type'=>$sType])->whereBetween('end_time_period',[intval($time_period[1]['amStartTime']),intval($time_period[1]['amEndTime'])])->pluck('id')->toArray();
|
|
|
+ $times[] = TimePeriod::where(['docter_id'=>$docter_id,'org_id'=>$org_id,'type'=>$sType])->whereBetween('end_time_period',[intval($time_period[2]['pmStartTime']),intval($time_period[2]['pmEndTime'])])->pluck('id')->toArray();
|
|
|
+ $times[] = TimePeriod::where(['docter_id'=>$docter_id,'org_id'=>$org_id,'type'=>$sType])->whereBetween('end_time_period',[intval($time_period[3]['nightStartTime']),intval($time_period[3]['nightEndTime'])])->pluck('id')->toArray();
|
|
|
}
|
|
|
if(count($times) < 3){
|
|
|
- echo '时间段少于三个时间段';
|
|
|
return apiReturn('603','请配置时间段');
|
|
|
}
|
|
|
|
| xqd
@@ -436,9 +433,7 @@ class ApiController extends Controller
|
|
|
$allScheduleData = [];
|
|
|
//插入两个月的数据
|
|
|
for ($i=1;$i<60;$i++){
|
|
|
-
|
|
|
$todayTimer = $start + (($i - 1) *86400);
|
|
|
-
|
|
|
$date = date('Y-m-d',$todayTimer);
|
|
|
$numDate = date('Ymd',$todayTimer);
|
|
|
|
| xqd
@@ -468,7 +463,6 @@ class ApiController extends Controller
|
|
|
$real_id = WeekSchedule::where(['docter_id'=>$docterId,'organization_id'=>$orgId,'week'=>$week,'type'=>$tType])->first();
|
|
|
if (!empty($real_id)) {
|
|
|
foreach ($timePeriods[$tType-1] as $idt) {
|
|
|
-// dump($timePeriods[$tType-1]);
|
|
|
$s_t= [
|
|
|
'docter_id' => $docterId,
|
|
|
'organization_id' => $orgId,
|
| xqd
@@ -739,6 +733,12 @@ class ApiController extends Controller
|
|
|
3=>['count'=>$configData['nightNum'],'start_time'=>$configData['nightStartTime'],'end_time'=>$configData['nightEndTime']]
|
|
|
];
|
|
|
|
|
|
+ $times = [
|
|
|
+ 1=>[$configData['amStartTime'],$configData['amEndTime']],
|
|
|
+ 2=>[$configData['pmStartTime'],$configData['pmEndTime']],
|
|
|
+ 3=>[$configData['nightStartTime'],$configData['nightEndTime']],
|
|
|
+ ];
|
|
|
+
|
|
|
if(!$changeSeviceTime && empty($changeTimer)){
|
|
|
return apiReturn(603,'数据为改变');
|
|
|
}
|
| xqd
@@ -752,14 +752,14 @@ class ApiController extends Controller
|
|
|
self::deleteScheduleInfo($docter_id,$tType,$org_id);
|
|
|
$count = $countArr[$i];
|
|
|
//2.创建新时间段
|
|
|
- self::makeTimePeriod($docter_id,$org_id,$tType,$c_r[$tType],$count,$serviceTime);
|
|
|
+ self::makeTimePeriod($docter_id,$org_id,$sType,$tType,$c_r[$tType],$count,$serviceTime);
|
|
|
|
|
|
//检测时间段
|
|
|
// $timeCount = TimePeriod::where(['org_id' => $org_id, 'docter_id' => $docter_id])->count();
|
|
|
// if($timeCount == 0) return apiReturn(603,'请设置时间段');
|
|
|
|
|
|
if($sType == 1){
|
|
|
- $time_periods = TimePeriod::where(['org_id' => $org_id, 'docter_id' => $docter_id, 'type' => $tType])->pluck('id')->toArray();
|
|
|
+ $time_periods = TimePeriod::where(['org_id' => $org_id, 'docter_id' => $docter_id, 'type' => $sType])->whereBetween('end_time_period',$times[$tType])->pluck('id')->toArray();
|
|
|
$self_schedule = SelfSchedule::where(['docter_id' => $docter_id, 'schedule_type' => $sType, 'organization_id'=>$org_id,'type' =>$tType])->distinct('type')
|
|
|
->orderBy('schedule_date')->get(['schedule_date', 'type', 'week'])->toArray();
|
|
|
$schedule = Schedule::where(['docter_id' => $docter_id, 'organization_id'=>0])->pluck('schedule_date', 'id')->toArray();
|
| xqd
@@ -770,7 +770,7 @@ class ApiController extends Controller
|
|
|
->GroupBy('week')
|
|
|
->toArray();
|
|
|
} else {
|
|
|
- $time_periods = TimePeriod::where(['org_id' => $org_id, 'docter_id' => 0, 'type' => $tType])->pluck('id')->toArray();
|
|
|
+ $time_periods = TimePeriod::where(['org_id' => $org_id, 'docter_id' => 0, 'type' =>$sType])->whereBetween('end_time_period',$times[$tType])->pluck('id')->toArray();
|
|
|
$schedule = Schedule::where(['docter_id' => 0, 'organization_id'=>$org_id])->pluck('schedule_date', 'id')->toArray();
|
|
|
$self_schedule = SelfSchedule::where(['docter_id' => 0, 'schedule_type' => $sType,'organization_id'=>$org_id,'type' =>$tType])->distinct('type')
|
|
|
->orderBy('schedule_date')->where('schedule_date','>',$Today)->get(['schedule_date', 'type', 'week'])->toArray();
|
| xqd
@@ -906,13 +906,13 @@ class ApiController extends Controller
|
|
|
}
|
|
|
|
|
|
//插入时间段
|
|
|
- public static function makeTimePeriod($docterId,$orgId,$timeType,$timeConfig,$timerCount,$serviceTime)
|
|
|
+ public static function makeTimePeriod($docterId,$orgId,$sType,$tType,$timeConfig,$timerCount,$serviceTime)
|
|
|
{
|
|
|
for($i=1;$i<=$timerCount;$i++){
|
|
|
$timePreiod = [
|
|
|
'org_id'=>$orgId,
|
|
|
'docter_id'=>$docterId,
|
|
|
- 'type'=>$timeType,
|
|
|
+ 'type'=>$sType,
|
|
|
'start_time_period'=> date('H:i',strtotime($timeConfig['start_time']) + ($i-1)*$serviceTime*60),
|
|
|
'end_time_period'=> date('H:i',strtotime($timeConfig['start_time']) + $i*$serviceTime*60),
|
|
|
];
|
| xqd
@@ -947,6 +947,7 @@ class ApiController extends Controller
|
|
|
if (!$scheduleIsHave) Schedule::insert($scheduleData);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
$nextStart = strtotime(date('Y-m-1',strtotime('next month')));
|
|
|
$nextAllDay = date('t',strtotime('nex month'));
|
|
|
|
| xqd
@@ -1008,8 +1009,7 @@ class ApiController extends Controller
|
|
|
public static function makeSelfScheeule($docterId,$orgId,$sType,$timeType,$timesPeriods,$selfSchedule){
|
|
|
|
|
|
$date = date('Y-m-d',time());
|
|
|
-// dump($selfSchedule);
|
|
|
-// dump($timesPeriods);
|
|
|
+
|
|
|
//删除自己排班数据
|
|
|
SelfSchedule::where(['type'=>$timeType,'docter_id'=>$docterId,'organization_id'=>$orgId,'schedule_type'=>$sType])->where('schedule_date','>',$date)->delete();
|
|
|
$allData = [];
|
| xqd
@@ -1018,14 +1018,27 @@ class ApiController extends Controller
|
|
|
$self_data['organization_id'] = $orgId;
|
|
|
$self_data['docter_id'] = $docterId;
|
|
|
$self_data['schedule_type'] = $sType;
|
|
|
+ $s_id = Schedule::where(['docter_id'=>$docterId,'organization_id'=>$orgId,'schedule_date'=>$val['schedule_date']])->value('id');
|
|
|
+ $numDay = intval(str_replace('-','',$val['schedule_date']));
|
|
|
+// if(empty($s_id)) {
|
|
|
+// Schedule::insert(['docter_id'=>$docterId,'organization_id'=>$orgId,'schedule_date'=>$val['schedule_date'],'schedule_day'=>$numDay]);
|
|
|
+// }
|
|
|
+ SchedulePeriod::where(['schedule_id'=>$s_id])->whereIn('time_period_id',$timesPeriods)->delete();
|
|
|
+
|
|
|
foreach ($timesPeriods as $id) {
|
|
|
$self_data['time_period_id'] = $id;
|
|
|
$is_self_have = SelfSchedule::where($self_data)->count();
|
|
|
- if ($is_self_have) continue;
|
|
|
+ if($is_self_have) continue;
|
|
|
+ $self_data['schedule_id'] = $s_id;
|
|
|
+ if(empty($s_id)) continue;
|
|
|
+ $is_schedule_period = SchedulePeriod::where($self_data)->count();
|
|
|
+
|
|
|
+ $allScheduleData [] = $self_data;
|
|
|
$allData[] =$self_data;
|
|
|
}
|
|
|
}
|
|
|
if(!empty($allData)) SelfSchedule::insert($allData);
|
|
|
+ if(!empty($allScheduleData)) SchedulePeriod::insert($allScheduleData);
|
|
|
}
|
|
|
|
|
|
|
| xqd
@@ -1076,7 +1089,7 @@ class ApiController extends Controller
|
|
|
//判断是否有排班信息
|
|
|
$s_id = Schedule::where($sche_data)->count();
|
|
|
if(!$s_id){
|
|
|
- Schedule::insert($sche_data);
|
|
|
+ $s_id = Schedule::insertGetId($sche_data);
|
|
|
}
|
|
|
|
|
|
//获取时间段
|
| xqd
@@ -1105,6 +1118,10 @@ class ApiController extends Controller
|
|
|
$self_count = SelfSchedule::where($data)->count();
|
|
|
if(!$self_count) SelfSchedule::insert($data);
|
|
|
|
|
|
+ $data['schedule_id']=$s_id;
|
|
|
+ $is_schedule_period = SchedulePeriod::where($data)->count();
|
|
|
+ if(!$is_schedule_period) SelfSchedule::insert($data);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
} else if($v['status'] == false){
|
| xqd
@@ -1121,6 +1138,7 @@ class ApiController extends Controller
|
|
|
$self_count = SelfSchedule::where($data)->count();
|
|
|
if($self_count) SelfSchedule::where($data)->delete();
|
|
|
|
|
|
+
|
|
|
unset($data['week']);
|
|
|
//删除详细排班
|
|
|
$count_period = SchedulePeriod::where($data)->count();
|