|
@@ -240,7 +240,7 @@ class ApiController extends Controller
|
|
$org_id = intval(request('org_id'));
|
|
$org_id = intval(request('org_id'));
|
|
$type = intval(request('type'));
|
|
$type = intval(request('type'));
|
|
$role = intval(request('role'));
|
|
$role = intval(request('role'));
|
|
- if(empty($docter_id) || empty($type)){
|
|
|
|
|
|
+ if(empty($role) || empty($type)){
|
|
return apiReturn(604,'缺少必要参数');
|
|
return apiReturn(604,'缺少必要参数');
|
|
}
|
|
}
|
|
|
|
|
|
@@ -312,7 +312,7 @@ class ApiController extends Controller
|
|
$docter_id = 0;
|
|
$docter_id = 0;
|
|
for ($i=1;$i<=7;$i++){
|
|
for ($i=1;$i<=7;$i++){
|
|
for($j=0;$j<=2;$j++){
|
|
for($j=0;$j<=2;$j++){
|
|
- $is_self_have = WeekSchedule::where(['docter_id'=>$docter_id,'schedule_type'=>$type,'organization_id'=>$org_id,'week'=>$i+1])->count();
|
|
|
|
|
|
+ $is_self_have = WeekSchedule::where(['docter_id'=>$docter_id,'schedule_type'=>$type,'type'=>$j+1,'organization_id'=>$org_id,'week'=>$i])->count();
|
|
if($is_self_have){
|
|
if($is_self_have){
|
|
$data[$j][$week_arr[$i]] = true;
|
|
$data[$j][$week_arr[$i]] = true;
|
|
}
|
|
}
|
|
@@ -336,37 +336,38 @@ class ApiController extends Controller
|
|
{
|
|
{
|
|
$docter_id = intval(request('docter_id'));
|
|
$docter_id = intval(request('docter_id'));
|
|
$org_id = intval(request('org_id'));
|
|
$org_id = intval(request('org_id'));
|
|
- $type = intval(request('type')); //排班类型 1门诊 2 儿保 3计免
|
|
|
|
|
|
+ $sType = intval(request('type')); //排班类型 1门诊 2 儿保 3计免
|
|
$data = request('schedulingtime');
|
|
$data = request('schedulingtime');
|
|
- if(empty($docter_id) || empty($org_id) || empty($type) || empty($data)){
|
|
|
|
|
|
+ if(empty($docter_id) || empty($org_id) || empty($sType) || empty($data)){
|
|
return apiReturn(601,'缺少必要参数');
|
|
return apiReturn(601,'缺少必要参数');
|
|
}
|
|
}
|
|
- if($type == 1){
|
|
|
|
|
|
+
|
|
|
|
+ if($sType == 1){
|
|
$docter_setting = DocterSetting::where(['docter_id'=>$docter_id,'org_id'=>$org_id])->first();
|
|
$docter_setting = DocterSetting::where(['docter_id'=>$docter_id,'org_id'=>$org_id])->first();
|
|
} else {
|
|
} else {
|
|
$docter_setting = OrganizationSettings::where(['org_id'=>$org_id])->first();
|
|
$docter_setting = OrganizationSettings::where(['org_id'=>$org_id])->first();
|
|
$docter_id = 0;
|
|
$docter_id = 0;
|
|
}
|
|
}
|
|
$serviceNum = $docter_setting->service_num;
|
|
$serviceNum = $docter_setting->service_num;
|
|
-
|
|
|
|
$times = [];
|
|
$times = [];
|
|
if(!empty($docter_setting)){
|
|
if(!empty($docter_setting)){
|
|
echo $docter_id;
|
|
echo $docter_id;
|
|
$time_period = object_array(json_decode($docter_setting->service_time));
|
|
$time_period = object_array(json_decode($docter_setting->service_time));
|
|
|
|
+ $allCount = TimePeriod::where(['docter_id'=>$docter_id,'org_id'=>$org_id])->count();
|
|
|
|
+ if($allCount == 0) return apiReturn(603,'请设置时间段');
|
|
$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[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[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])->whereBetween('end_time_period',[intval($time_period[3]['nightStartTime']),intval($time_period[3]['nightEndTime'])])->pluck('id')->toArray();
|
|
}
|
|
}
|
|
- echo '時間段'.'<br>';
|
|
|
|
if(count($times) < 3){
|
|
if(count($times) < 3){
|
|
return apiReturn('603','请配置时间段');
|
|
return apiReturn('603','请配置时间段');
|
|
}
|
|
}
|
|
|
|
|
|
- if($type != 1){
|
|
|
|
|
|
+ if($sType != 1){
|
|
$docter_id = 0;
|
|
$docter_id = 0;
|
|
}
|
|
}
|
|
|
|
|
|
- $week_data ['schedule_type'] = $type;
|
|
|
|
|
|
+ $week_data ['schedule_type'] = $sType;
|
|
$week_data ['organization_id'] = $org_id;
|
|
$week_data ['organization_id'] = $org_id;
|
|
$week_data ['docter_id'] = $docter_id;
|
|
$week_data ['docter_id'] = $docter_id;
|
|
|
|
|
|
@@ -388,18 +389,18 @@ class ApiController extends Controller
|
|
// echo '时间列类型'.($i).'----'.$key.'星期数'.'<br>';
|
|
// echo '时间列类型'.($i).'----'.$key.'星期数'.'<br>';
|
|
// foreach ($times[$i-1] as $id){
|
|
// foreach ($times[$i-1] as $id){
|
|
// $new_week_data['time_period_id'] = $id;
|
|
// $new_week_data['time_period_id'] = $id;
|
|
- $is_have = WeekSchedule::where(['docter_id'=>$docter_id,'schedule_type'=>$type,'type'=>$i,'week'=>$key])->value('id');
|
|
|
|
|
|
+ $is_have = WeekSchedule::where(['docter_id'=>$docter_id,'schedule_type'=>$sType,'type'=>$i,'week'=>$key])->value('id');
|
|
if(!$is_have) WeekSchedule::insert($new_week_data);
|
|
if(!$is_have) WeekSchedule::insert($new_week_data);
|
|
// dump($new_week_data);
|
|
// dump($new_week_data);
|
|
$k++;
|
|
$k++;
|
|
// }
|
|
// }
|
|
} else if ($schedule == false) {
|
|
} else if ($schedule == false) {
|
|
- if($type == 1){
|
|
|
|
- $is_have = WeekSchedule::where(['docter_id' => $docter_id, 'organization_id' => $org_id, 'schedule_type' => $type,'type'=>$i,'week'=>$key])->value('id');
|
|
|
|
- if($is_have) WeekSchedule::where(['docter_id' => $docter_id, 'organization_id' => $org_id, 'schedule_type' => $type,'type'=>$i,'week'=>$key])->delete();
|
|
|
|
|
|
+ if($sType == 1){
|
|
|
|
+ $is_have = WeekSchedule::where(['docter_id' => $docter_id, 'organization_id' => $org_id, 'schedule_type' => $sType,'type'=>$i,'week'=>$key])->value('id');
|
|
|
|
+ if($is_have) WeekSchedule::where(['docter_id' => $docter_id, 'organization_id' => $org_id, 'schedule_type' => $sType,'type'=>$i,'week'=>$key])->delete();
|
|
} else {
|
|
} else {
|
|
- $is_have = WeekSchedule::where(['docter_id' => 0, 'organization_id' => $org_id, 'schedule_type' => $type,'type'=>$i,'week'=>$key])->value('id');
|
|
|
|
- if($is_have) WeekSchedule::where(['docter_id' => 0, 'organization_id' => $org_id, 'schedule_type' => $type,'type'=>$i,'week'=>$key])->delete();
|
|
|
|
|
|
+ $is_have = WeekSchedule::where(['docter_id' => 0, 'organization_id' => $org_id, 'schedule_type' => $sType,'type'=>$i,'week'=>$key])->value('id');
|
|
|
|
+ if($is_have) WeekSchedule::where(['docter_id' => 0, 'organization_id' => $org_id, 'schedule_type' => $sType,'type'=>$i,'week'=>$key])->delete();
|
|
}
|
|
}
|
|
$k++;
|
|
$k++;
|
|
}
|
|
}
|
|
@@ -413,13 +414,13 @@ class ApiController extends Controller
|
|
DB::rollBack();
|
|
DB::rollBack();
|
|
return apiReturn(602,$e->getLine().'行'.$e->getMessage());
|
|
return apiReturn(602,$e->getLine().'行'.$e->getMessage());
|
|
}
|
|
}
|
|
- self::setmonthScheduel($docter_id,$org_id,$type,$serviceNum,$times);
|
|
|
|
|
|
+ self::setmonthScheduel($docter_id,$org_id,$sType,$serviceNum,$times);
|
|
|
|
|
|
return apiReturn(200,'ok',$k);
|
|
return apiReturn(200,'ok',$k);
|
|
}
|
|
}
|
|
|
|
|
|
//设置月排班
|
|
//设置月排班
|
|
- public function setmonthScheduel($docterId,$orgId,$scheduleType,$serviceNum,$timePeriods)
|
|
|
|
|
|
+ public function setmonthScheduel($docterId,$orgId,$sType,$serviceNum,$timePeriods)
|
|
{
|
|
{
|
|
|
|
|
|
|
|
|
|
@@ -451,47 +452,34 @@ class ApiController extends Controller
|
|
if (!$scheduleIsHave) Schedule::insert($scheduleData);
|
|
if (!$scheduleIsHave) Schedule::insert($scheduleData);
|
|
}
|
|
}
|
|
|
|
|
|
- echo '医生id '.$docterId.' 机构id '.$orgId . 'times ';
|
|
|
|
|
|
+// echo '医生id '.$docterId.' 机构id '.$orgId . 'times ';
|
|
$schedule = Schedule::where(['docter_id'=>$docterId,'organization_id'=>$orgId])->where('schedule_date','>=',date('Y-m-d',time()))
|
|
$schedule = Schedule::where(['docter_id'=>$docterId,'organization_id'=>$orgId])->where('schedule_date','>=',date('Y-m-d',time()))
|
|
->distinct('schedule_date')->pluck('schedule_date','id')->toArray();
|
|
->distinct('schedule_date')->pluck('schedule_date','id')->toArray();
|
|
if($docterId == 0){
|
|
if($docterId == 0){
|
|
$schedule = Schedule::where(['docter_id'=>0,'organization_id'=>$orgId])->where('schedule_date','>=',date('Y-m-d',time()))
|
|
$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();
|
|
->distinct('schedule_date')->pluck('schedule_date','id')->toArray();
|
|
}
|
|
}
|
|
|
|
+ $allData = [];
|
|
for($tType = 1; $tType<=3 ; $tType++){
|
|
for($tType = 1; $tType<=3 ; $tType++){
|
|
foreach ($schedule as $id => $date) {
|
|
foreach ($schedule as $id => $date) {
|
|
$week = intval(date('N', strtotime($date)));
|
|
$week = intval(date('N', strtotime($date)));
|
|
$real_id = WeekSchedule::where(['docter_id'=>$docterId,'organization_id'=>$orgId,'week'=>$week,'type'=>$tType])->first();
|
|
$real_id = WeekSchedule::where(['docter_id'=>$docterId,'organization_id'=>$orgId,'week'=>$week,'type'=>$tType])->first();
|
|
if (!empty($real_id)) {
|
|
if (!empty($real_id)) {
|
|
foreach ($timePeriods[$tType-1] as $idt) {
|
|
foreach ($timePeriods[$tType-1] as $idt) {
|
|
- dump($timePeriods[$tType-1]);
|
|
|
|
- if($docterId != 0){//门诊
|
|
|
|
- $s_t = [
|
|
|
|
- 'docter_id' => $docterId,
|
|
|
|
- 'organization_id' => $orgId,
|
|
|
|
- 'type' => $tType,
|
|
|
|
- 'schedule_date' => $date,
|
|
|
|
- 'schedule_id' => $id,
|
|
|
|
- 'time_period_id' => $idt
|
|
|
|
- ];
|
|
|
|
- $scheduleIsHave = SchedulePeriod::where($s_t)->count();
|
|
|
|
- $s_t['order_num'] = $serviceNum;
|
|
|
|
-
|
|
|
|
- if (!$scheduleIsHave) SchedulePeriod::insert($s_t);
|
|
|
|
|
|
+// dump($timePeriods[$tType-1]);
|
|
|
|
+ $s_t= [
|
|
|
|
+ 'docter_id' => $docterId,
|
|
|
|
+ 'organization_id' => $orgId,
|
|
|
|
+ 'type' => $tType,
|
|
|
|
+ 'schedule_date' => $date,
|
|
|
|
+ 'schedule_type' => $sType,
|
|
|
|
+ 'schedule_id' => $id,
|
|
|
|
+ 'time_period_id' => $idt
|
|
|
|
+ ];
|
|
|
|
|
|
- } else {
|
|
|
|
- $s_t = [
|
|
|
|
- 'docter_id' =>0,
|
|
|
|
- 'organization_id' => $orgId,
|
|
|
|
- 'type' => $tType,
|
|
|
|
- 'schedule_date' => $date,
|
|
|
|
- 'schedule_id' => $id,
|
|
|
|
- 'time_period_id' => $idt
|
|
|
|
- ];
|
|
|
|
- $scheduleIsHave = SchedulePeriod::where($s_t)->count();
|
|
|
|
- $s_t['order_num'] = $serviceNum;
|
|
|
|
- if (!$scheduleIsHave) SchedulePeriod::insert($s_t);
|
|
|
|
- }
|
|
|
|
|
|
+ $scheduleIsHave = SchedulePeriod::where($s_t)->count();
|
|
|
|
+ $s_t['order_num'] = $serviceNum;
|
|
|
|
+ if (!$scheduleIsHave) $allData[] = $s_t;
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -499,6 +487,7 @@ class ApiController extends Controller
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if($allData) SchedulePeriod::insert($allData);
|
|
return apiReturn('200','ok');
|
|
return apiReturn('200','ok');
|
|
|
|
|
|
}
|
|
}
|
|
@@ -566,13 +555,7 @@ class ApiController extends Controller
|
|
if($type == 1){//门诊
|
|
if($type == 1){//门诊
|
|
$today = SchedulePeriod::where(['docter_id'=>$docter_id,'schedule_date'=>$scheduleDate,'organization_id'=>$org_id])->distinct('organization_id')
|
|
$today = SchedulePeriod::where(['docter_id'=>$docter_id,'schedule_date'=>$scheduleDate,'organization_id'=>$org_id])->distinct('organization_id')
|
|
->distinct('type')->get(['organization_id','type'])->GroupBy('type')->toArray();
|
|
->distinct('type')->get(['organization_id','type'])->GroupBy('type')->toArray();
|
|
-
|
|
|
|
-// //检查排班详情
|
|
|
|
-// self::checkDaySchedule($date,$type,$docter_id,$org_id);
|
|
|
|
-// //检查自己排班
|
|
|
|
-// self::checkSelfDaySchedule($date,$type,$docter_id,$org_id);
|
|
|
|
// echo '周几'.$week.' 日期 '.$scheduleDate.PHP_EOL;
|
|
// echo '周几'.$week.' 日期 '.$scheduleDate.PHP_EOL;
|
|
-
|
|
|
|
if(empty($today)){
|
|
if(empty($today)){
|
|
$scheduleList[$i-1] = [
|
|
$scheduleList[$i-1] = [
|
|
'schedulelingList'=>$baseData,
|
|
'schedulelingList'=>$baseData,
|
|
@@ -592,7 +575,7 @@ class ApiController extends Controller
|
|
//
|
|
//
|
|
}
|
|
}
|
|
//覆盖自定义排班
|
|
//覆盖自定义排班
|
|
- $self = SelfSchedule::where(['docter_id'=>$docter_id,'schedule_date'=>$scheduleDate,'organization_id'=>$org_id])->get(['type'])->GroupBy('type')->toArray();
|
|
|
|
|
|
+ $self = SelfSchedule::where(['docter_id'=>$docter_id,'schedule_date'=>$scheduleDate,'schedule_type'=>$type])->get(['type'])->GroupBy('type')->toArray();
|
|
if(!empty($self)){
|
|
if(!empty($self)){
|
|
foreach($self as $k=>$sf){
|
|
foreach($self as $k=>$sf){
|
|
$newBase[$k-1]['status'] = true;
|
|
$newBase[$k-1]['status'] = true;
|
|
@@ -638,62 +621,6 @@ class ApiController extends Controller
|
|
'day'=>$scheduleDate
|
|
'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];
|
|
|
|
-//
|
|
|
|
-// for($i=0;$i<$month_day;$i++){
|
|
|
|
-// $now_time = $start_time + $i*86400;
|
|
|
|
-// $now_date = date('Y-m-d',$now_time);
|
|
|
|
-// $week = date('N',$now_time);
|
|
|
|
-// $arr = [
|
|
|
|
-// ['status'=>false,'type'=>1,'start'=>"09:00",'end'=>'11:30'],
|
|
|
|
-// ['status'=>true,'type'=>2,'start'=>'13:30','end'=>'16:30'],
|
|
|
|
-// ['status'=>false,'type'=>3,'start'=>'19:30','end'=>'21:00'],
|
|
|
|
-// ];
|
|
|
|
-// if($i%2 == 0){
|
|
|
|
-// $arr = [
|
|
|
|
-// ['status'=>false,'type'=>1,'start'=>"09:00",'end'=>'11:30'],
|
|
|
|
-// ['status'=>true,'type'=>2,'start'=>'13:30','end'=>'16:30'],
|
|
|
|
-// ['status'=>false,'type'=>3,'start'=>'19:30','end'=>'21:00'],
|
|
|
|
-// ];
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// if($i%3 == 0){
|
|
|
|
-// $arr = [
|
|
|
|
-// ['status'=>true,'type'=>1,'start'=>"09:00",'end'=>'11:30'],
|
|
|
|
-// ['status'=>'other','type'=>2,'start'=>'13:30','end'=>'16:30'],
|
|
|
|
-// ['status'=>true,'type'=>3,'start'=>'19:30','end'=>'21:00'],
|
|
|
|
-// ];
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// if($i%4 == 0){
|
|
|
|
-// $arr = [
|
|
|
|
-// ['status'=>'other','type'=>1,'start'=>"09:00",'end'=>'11:30'],
|
|
|
|
-// ['status'=>false,'type'=>2,'start'=>'13:30','end'=>'16:30'],
|
|
|
|
-// ['status'=>false,'type'=>3,'start'=>'19:30','end'=>'21:00'],
|
|
|
|
-// ];
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// if($i == 14){
|
|
|
|
-// $arr = [
|
|
|
|
-// ['status'=>false,'type'=>1,'start'=>"09:00",'end'=>'11:30'],
|
|
|
|
-// ['status'=>false,'type'=>2,'start'=>'13:30','end'=>'16:30'],
|
|
|
|
-// ['status'=>false,'type'=>3,'start'=>'19:30','end'=>'21:00'],
|
|
|
|
-// ];
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// $all_time[] = ['date'=>($i+1),'day'=>$now_date,'schedulelingList'=>$arr,'week'=>$week];
|
|
|
|
}
|
|
}
|
|
return apiReturn(200,'ok',$scheduleList);
|
|
return apiReturn(200,'ok',$scheduleList);
|
|
}
|
|
}
|
|
@@ -704,11 +631,10 @@ class ApiController extends Controller
|
|
{
|
|
{
|
|
$docter_id = intval(request('docter_id'));
|
|
$docter_id = intval(request('docter_id'));
|
|
$org_id = intval(request('org_id'));
|
|
$org_id = intval(request('org_id'));
|
|
- $type = intval(request('type'));
|
|
|
|
|
|
+ $sType = intval(request('type'));
|
|
|
|
|
|
$setting = DocterSetting::where(['docter_id'=>$docter_id,'org_id'=>$org_id])->first();
|
|
$setting = DocterSetting::where(['docter_id'=>$docter_id,'org_id'=>$org_id])->first();
|
|
-// dump($docter_id);
|
|
|
|
- if($type == 2){
|
|
|
|
|
|
+ if($sType == 2){
|
|
$setting = OrganizationSettings::where(['org_id'=>$org_id])->first();
|
|
$setting = OrganizationSettings::where(['org_id'=>$org_id])->first();
|
|
}
|
|
}
|
|
$docterConfig = SystemConfig::get('docter_config');
|
|
$docterConfig = SystemConfig::get('docter_config');
|
|
@@ -759,7 +685,7 @@ class ApiController extends Controller
|
|
{
|
|
{
|
|
$docter_id = intval(request('docter_id'));
|
|
$docter_id = intval(request('docter_id'));
|
|
$configData = request('configData');
|
|
$configData = request('configData');
|
|
- $type = intval(request('type'));//医生类型 1 门诊医生 2 计免 儿保医生
|
|
|
|
|
|
+ $sType = intval(request('type'));//医生类型 1 门诊医生 2 计免 儿保医生
|
|
$org_id = intval(request('org_id'));
|
|
$org_id = intval(request('org_id'));
|
|
$configData = object_array(json_decode($configData));
|
|
$configData = object_array(json_decode($configData));
|
|
if(empty($docter_id) || empty($configData)){
|
|
if(empty($docter_id) || empty($configData)){
|
|
@@ -767,7 +693,7 @@ class ApiController extends Controller
|
|
}
|
|
}
|
|
|
|
|
|
$setting = DocterSetting::where(['docter_id'=>$docter_id,'org_id'=>$org_id])->first();
|
|
$setting = DocterSetting::where(['docter_id'=>$docter_id,'org_id'=>$org_id])->first();
|
|
- if($type != 1){
|
|
|
|
|
|
+ if($sType != 1){
|
|
$setting = OrganizationSettings::where(['org_id'=>$org_id])->first();
|
|
$setting = OrganizationSettings::where(['org_id'=>$org_id])->first();
|
|
$docter_id = 0;
|
|
$docter_id = 0;
|
|
}
|
|
}
|
|
@@ -826,8 +752,8 @@ class ApiController extends Controller
|
|
if(!$changeSeviceTime && empty($changeTimer)){
|
|
if(!$changeSeviceTime && empty($changeTimer)){
|
|
return apiReturn(603,'数据为改变');
|
|
return apiReturn(603,'数据为改变');
|
|
}
|
|
}
|
|
- for ($i=1;$i<=3;$i++){
|
|
|
|
- $tType = $i;
|
|
|
|
|
|
+ for ($i=1;$i<=3;$i++){
|
|
|
|
+ $tType = $i;
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|
|
try {
|
|
try {
|
|
//1.删除旧时间段,并删除排班数据
|
|
//1.删除旧时间段,并删除排班数据
|
|
@@ -838,12 +764,16 @@ class ApiController extends Controller
|
|
//2.创建新时间段
|
|
//2.创建新时间段
|
|
self::makeTimePeriod($docter_id,$org_id,$tType,$c_r[$tType],$count,$serviceTime);
|
|
self::makeTimePeriod($docter_id,$org_id,$tType,$c_r[$tType],$count,$serviceTime);
|
|
|
|
|
|
- if($type == 1){
|
|
|
|
|
|
+ //检测时间段
|
|
|
|
+// $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' => $tType])->pluck('id')->toArray();
|
|
- $self_schedule = SelfSchedule::where(['docter_id' => $docter_id, 'schedule_type' => $type, 'organization_id'=>$org_id,'type' =>$tType])->distinct('type')
|
|
|
|
|
|
+ $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();
|
|
->orderBy('schedule_date')->get(['schedule_date', 'type', 'week'])->toArray();
|
|
$schedule = Schedule::where(['docter_id' => $docter_id, 'organization_id'=>0])->pluck('schedule_date', 'id')->toArray();
|
|
$schedule = Schedule::where(['docter_id' => $docter_id, 'organization_id'=>0])->pluck('schedule_date', 'id')->toArray();
|
|
- $week_schedule = WeekSchedule::where(['docter_id' => $docter_id, 'type' => $tType,'schedule_type'=>$type])
|
|
|
|
|
|
+ $week_schedule = WeekSchedule::where(['docter_id' => $docter_id, 'type' => $tType,'schedule_type'=>$sType])
|
|
->distinct('type')
|
|
->distinct('type')
|
|
->orderBy('week')
|
|
->orderBy('week')
|
|
->get(['week','organization_id'])
|
|
->get(['week','organization_id'])
|
|
@@ -852,9 +782,9 @@ class ApiController extends Controller
|
|
} else {
|
|
} 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' => $tType])->pluck('id')->toArray();
|
|
$schedule = Schedule::where(['docter_id' => 0, 'organization_id'=>$org_id])->pluck('schedule_date', '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' => $type,'organization_id'=>$org_id,'type' =>$tType])->distinct('type')
|
|
|
|
|
|
+ $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();
|
|
->orderBy('schedule_date')->where('schedule_date','>',$Today)->get(['schedule_date', 'type', 'week'])->toArray();
|
|
- $week_schedule = WeekSchedule::where(['organization_id' =>$org_id, 'type' => $tType,'schedule_type'=>$type])
|
|
|
|
|
|
+ $week_schedule = WeekSchedule::where(['organization_id' =>$org_id, 'type' => $tType,'schedule_type'=>$sType])
|
|
->distinct('type')
|
|
->distinct('type')
|
|
->orderBy('week')
|
|
->orderBy('week')
|
|
->pluck('type')
|
|
->pluck('type')
|
|
@@ -863,17 +793,18 @@ class ApiController extends Controller
|
|
}
|
|
}
|
|
|
|
|
|
if (empty($week_schedule)) {
|
|
if (empty($week_schedule)) {
|
|
- // Schedule::where(['docter_id' => $docter_id])->delete();
|
|
|
|
- // SelfSchedule::where(['docter_id' => $docter_id])->delete();
|
|
|
|
|
|
+// return apiReturn(603,'请设置周排班');
|
|
|
|
+ // 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,$tType,$schedule,$time_periods,$serviceNum);
|
|
|
|
|
|
+ self::makeSchedule($sType,$docter_id,$org_id,$tType,$schedule,$time_periods,$serviceNum);
|
|
|
|
|
|
//4.恢复自己设置的排班
|
|
//4.恢复自己设置的排班
|
|
- self::makeSelfScheeule($docter_id,$org_id,$type,$tType,$time_periods,$self_schedule);
|
|
|
|
|
|
+ self::makeSelfScheeule($docter_id,$org_id,$sType,$tType,$time_periods,$self_schedule);
|
|
|
|
|
|
//TODO 删除周排班,插入新周排班
|
|
//TODO 删除周排班,插入新周排班
|
|
- self::changeWeekSchedule($docter_id,$org_id,$type,$tType,$time_periods);
|
|
|
|
|
|
+ self::changeWeekSchedule($docter_id,$org_id,$sType,$tType,$time_periods);
|
|
}
|
|
}
|
|
DB::commit();
|
|
DB::commit();
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
@@ -883,7 +814,7 @@ class ApiController extends Controller
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-// {"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}}
|
|
$config = [
|
|
$config = [
|
|
1=>['amStartTime'=>$configData['amStartTime'],"amEndTime"=>$configData['amEndTime'],'amPerson'=>$configData['amNum']],
|
|
1=>['amStartTime'=>$configData['amStartTime'],"amEndTime"=>$configData['amEndTime'],'amPerson'=>$configData['amNum']],
|
|
2=>["pmStartTime"=>$configData['pmStartTime'],"pmEndTime"=>$configData['pmEndTime'],'pmPerson'=>$configData['pmNum']],
|
|
2=>["pmStartTime"=>$configData['pmStartTime'],"pmEndTime"=>$configData['pmEndTime'],'pmPerson'=>$configData['pmNum']],
|
|
@@ -891,7 +822,7 @@ class ApiController extends Controller
|
|
];
|
|
];
|
|
$setting = [
|
|
$setting = [
|
|
'docter_id'=>$docter_id,
|
|
'docter_id'=>$docter_id,
|
|
- 'type'=>$type,
|
|
|
|
|
|
+ 'type'=>$sType,
|
|
'status'=>$configData['status'],
|
|
'status'=>$configData['status'],
|
|
'show_days'=>$configData['showDayNumber'],
|
|
'show_days'=>$configData['showDayNumber'],
|
|
'service_num'=>$configData['serviceNum'],
|
|
'service_num'=>$configData['serviceNum'],
|
|
@@ -900,9 +831,8 @@ class ApiController extends Controller
|
|
];
|
|
];
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
//更新配置
|
|
//更新配置
|
|
- if($type == 1){
|
|
|
|
|
|
+ if($sType == 1){
|
|
$is_have = DocterSetting::where(['docter_id'=>$docter_id])->value('id');
|
|
$is_have = DocterSetting::where(['docter_id'=>$docter_id])->value('id');
|
|
if($is_have){
|
|
if($is_have){
|
|
DocterSetting::where(['docter_id'=>$docter_id])->update($setting);
|
|
DocterSetting::where(['docter_id'=>$docter_id])->update($setting);
|
|
@@ -911,9 +841,9 @@ class ApiController extends Controller
|
|
DocterSetting::insert($setting);
|
|
DocterSetting::insert($setting);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- unset($setting['docter_id']);
|
|
|
|
- $setting['org_id'] = $org_id;
|
|
|
|
- $is_have = OrganizationSettings::where(['org_id'=>$org_id])->value('id');
|
|
|
|
|
|
+ unset($setting['docter_id']);
|
|
|
|
+ $setting['org_id'] = $org_id;
|
|
|
|
+ $is_have = OrganizationSettings::where(['org_id'=>$org_id])->value('id');
|
|
if($is_have){
|
|
if($is_have){
|
|
OrganizationSettings::where(['org_id'=>$org_id])->update($setting);
|
|
OrganizationSettings::where(['org_id'=>$org_id])->update($setting);
|
|
} else {
|
|
} else {
|
|
@@ -926,16 +856,16 @@ class ApiController extends Controller
|
|
//获取用户信息
|
|
//获取用户信息
|
|
public function getScheduleInfo()
|
|
public function getScheduleInfo()
|
|
{
|
|
{
|
|
- $schedule_type = intval(request('id'));
|
|
|
|
|
|
+ //排班类型 1门诊 2儿保 3计免
|
|
|
|
+ $sType = intval(request('id'));
|
|
$user = Admin::user();
|
|
$user = Admin::user();
|
|
$role = 1;
|
|
$role = 1;
|
|
$docter_id=0;
|
|
$docter_id=0;
|
|
$data['docter_type'] = 1;
|
|
$data['docter_type'] = 1;
|
|
if($user->docter_id&&$user->org_id){
|
|
if($user->docter_id&&$user->org_id){
|
|
$role = 2;
|
|
$role = 2;
|
|
- $docter = Docter::where(['id'=>$user->docter_id])->first();
|
|
|
|
- $data['docter_type'] = $docter->type;
|
|
|
|
- $docter_id = $user->docter_id;
|
|
|
|
|
|
+ $data['docter_type'] = $sType;
|
|
|
|
+ if($sType==1) $docter_id = $user->docter_id;
|
|
}else if(!$user->docter_id&&$user->org_id){
|
|
}else if(!$user->docter_id&&$user->org_id){
|
|
$role = 1;
|
|
$role = 1;
|
|
}else if(!$user->docter_id&&!$user->org_id){
|
|
}else if(!$user->docter_id&&!$user->org_id){
|
|
@@ -971,17 +901,8 @@ class ApiController extends Controller
|
|
$data['name'] = $name;
|
|
$data['name'] = $name;
|
|
$data['org_id'] = $org_id;
|
|
$data['org_id'] = $org_id;
|
|
$data['list'] = $list;
|
|
$data['list'] = $list;
|
|
- $data['docter_type'] = $schedule_type;
|
|
|
|
|
|
+ $data['docter_type'] = $sType;
|
|
|
|
|
|
-//
|
|
|
|
-// if(!empty($docter)){
|
|
|
|
-// if($docter->type == 1){
|
|
|
|
-// $data['list'] = $lists;
|
|
|
|
-// } else {
|
|
|
|
-// $organization = Organization::where(['id'=>$org_id])->first();
|
|
|
|
-// $data['list'] = ['value'=>$organization->id,'label'=>$organization->name];
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
$data['role'] = $role;
|
|
$data['role'] = $role;
|
|
|
|
|
|
return (json_encode(['code'=>200,'msg'=>'ok','data'=>$data]));
|
|
return (json_encode(['code'=>200,'msg'=>'ok','data'=>$data]));
|
|
@@ -1016,15 +937,13 @@ class ApiController extends Controller
|
|
'end_time_period'=> date('H:i',strtotime($timeConfig['start_time']) + $i*$serviceTime*60),
|
|
'end_time_period'=> date('H:i',strtotime($timeConfig['start_time']) + $i*$serviceTime*60),
|
|
];
|
|
];
|
|
$isHave = TimePeriod::where($timePreiod)->count();
|
|
$isHave = TimePeriod::where($timePreiod)->count();
|
|
- if($isHave) continue;
|
|
|
|
- TimePeriod::insert($timePreiod);
|
|
|
|
|
|
+ if(!$isHave) TimePeriod::insert($timePreiod);
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
//以周模板进行排班
|
|
//以周模板进行排班
|
|
- public static function makeSchedule ($docterId,$orgId,$tType,$schedule,$timePeriods,$serviceNum){
|
|
|
|
-
|
|
|
|
|
|
+ public static function makeSchedule ($sType,$docterId,$orgId,$tType,$schedule,$timePeriods,$serviceNum){
|
|
|
|
|
|
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()));
|
|
@@ -1064,11 +983,9 @@ class ApiController extends Controller
|
|
$scheduleIsHave = Schedule::where($scheduleData)->count();
|
|
$scheduleIsHave = Schedule::where($scheduleData)->count();
|
|
$scheduleData['per_time_num'] = $serviceNum;
|
|
$scheduleData['per_time_num'] = $serviceNum;
|
|
if (!$scheduleIsHave) Schedule::insert($scheduleData);
|
|
if (!$scheduleIsHave) Schedule::insert($scheduleData);
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//todo 插入第三个月后的当日号
|
|
//todo 插入第三个月后的当日号
|
|
-
|
|
|
|
$schedule = Schedule::where(['docter_id'=>$docterId,'organization_id'=>$orgId])->where('schedule_date','>=',date('Y-m-d',time()))
|
|
$schedule = Schedule::where(['docter_id'=>$docterId,'organization_id'=>$orgId])->where('schedule_date','>=',date('Y-m-d',time()))
|
|
->distinct('schedule_date')->pluck('schedule_date','id')->toArray();
|
|
->distinct('schedule_date')->pluck('schedule_date','id')->toArray();
|
|
if($docterId == 0){
|
|
if($docterId == 0){
|
|
@@ -1076,54 +993,46 @@ class ApiController extends Controller
|
|
->distinct('schedule_date')->pluck('schedule_date','id')->toArray();
|
|
->distinct('schedule_date')->pluck('schedule_date','id')->toArray();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //
|
|
|
|
+ $allData = [];
|
|
|
|
+
|
|
foreach ($schedule as $id => $date) {
|
|
foreach ($schedule as $id => $date) {
|
|
$week = intval(date('N', strtotime($date)));
|
|
$week = intval(date('N', strtotime($date)));
|
|
// echo '医生id '.$docterId.' 机构id '.$orgId.' 周几 '.$week;
|
|
// echo '医生id '.$docterId.' 机构id '.$orgId.' 周几 '.$week;
|
|
- $real_id = WeekSchedule::where(['docter_id'=>$docterId,'organization_id'=>$orgId,'week'=>$week,'type'=>$tType])->first();
|
|
|
|
|
|
+ $real_id = WeekSchedule::where(['docter_id'=>$docterId,'organization_id'=>$orgId,'week'=>$week,'type'=>$tType,'schedule_type'=>$sType])->first();
|
|
if (!empty($real_id)) {
|
|
if (!empty($real_id)) {
|
|
-// dump($schedule);
|
|
|
|
foreach ($timePeriods as $idt) {
|
|
foreach ($timePeriods as $idt) {
|
|
- if($docterId != 0){//门诊
|
|
|
|
- $s_t = [
|
|
|
|
- 'docter_id' => $docterId,
|
|
|
|
- 'organization_id' => $orgId,
|
|
|
|
- 'type' => $tType,
|
|
|
|
- 'schedule_date' => $date,
|
|
|
|
- 'order_num' => $serviceNum,
|
|
|
|
- 'schedule_id' => $id,
|
|
|
|
- 'time_period_id' => $idt
|
|
|
|
- ];
|
|
|
|
- $scheduleIsHave = SchedulePeriod::where($s_t)->where('docter_id','!=',0)->count();
|
|
|
|
- if ($scheduleIsHave) continue;
|
|
|
|
- } else {
|
|
|
|
- $s_t = [
|
|
|
|
- 'docter_id' => 0,
|
|
|
|
- 'organization_id' => $orgId,
|
|
|
|
- 'type' => $tType,
|
|
|
|
- 'schedule_date' => $date,
|
|
|
|
- 'order_num' => $serviceNum,
|
|
|
|
- 'schedule_id' => $id,
|
|
|
|
- 'time_period_id' => $idt
|
|
|
|
- ];
|
|
|
|
- $scheduleIsHave = SchedulePeriod::where($s_t)->where('docter_id','=',0)->count();
|
|
|
|
- if ($scheduleIsHave) continue;
|
|
|
|
- }
|
|
|
|
- $res = SchedulePeriod::insert($s_t);
|
|
|
|
-
|
|
|
|
|
|
+ $s_t = [
|
|
|
|
+ 'docter_id' => $docterId,
|
|
|
|
+ 'organization_id' => $orgId,
|
|
|
|
+ 'type' => $tType,
|
|
|
|
+ 'schedule_date' => $date,
|
|
|
|
+ 'schedule_type'=>$sType,
|
|
|
|
+ 'schedule_id' => $id,
|
|
|
|
+ 'time_period_id' => $idt
|
|
|
|
+ ];
|
|
|
|
+ $scheduleIsHave = SchedulePeriod::where($s_t)->count();
|
|
|
|
+ $s_t['order_num'] = $serviceNum;
|
|
|
|
+ if ($scheduleIsHave) continue;
|
|
|
|
+ $allData [] = $s_t;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ $res = SchedulePeriod::insert($allData);
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
//自己排班
|
|
//自己排班
|
|
- public static function makeSelfScheeule($docterId,$orgId,$scheduleType,$timeType,$timesPeriods,$selfSchedule){
|
|
|
|
|
|
+ public static function makeSelfScheeule($docterId,$orgId,$sType,$timeType,$timesPeriods,$selfSchedule){
|
|
|
|
|
|
$date = date('Y-m-d',time());
|
|
$date = date('Y-m-d',time());
|
|
// dump($selfSchedule);
|
|
// dump($selfSchedule);
|
|
// dump($timesPeriods);
|
|
// dump($timesPeriods);
|
|
//删除自己排班数据
|
|
//删除自己排班数据
|
|
- SelfSchedule::where(['type'=>$timeType,'docter_id'=>$docterId,'organization_id'=>$orgId,'schedule_type'=>$scheduleType])->where('schedule_date','>',$date)->delete();
|
|
|
|
|
|
+ SelfSchedule::where(['type'=>$timeType,'docter_id'=>$docterId,'organization_id'=>$orgId,'schedule_type'=>$sType])->where('schedule_date','>',$date)->delete();
|
|
|
|
+ $allData = [];
|
|
foreach ($selfSchedule as $val) {
|
|
foreach ($selfSchedule as $val) {
|
|
$self_data = $val;
|
|
$self_data = $val;
|
|
$self_data['organization_id'] = $orgId;
|
|
$self_data['organization_id'] = $orgId;
|
|
@@ -1132,9 +1041,10 @@ class ApiController extends Controller
|
|
$self_data['time_period_id'] = $id;
|
|
$self_data['time_period_id'] = $id;
|
|
$is_self_have = SelfSchedule::where($self_data)->count();
|
|
$is_self_have = SelfSchedule::where($self_data)->count();
|
|
if ($is_self_have) continue;
|
|
if ($is_self_have) continue;
|
|
- SelfSchedule::insert($self_data);
|
|
|
|
|
|
+ $allData[] =$self_data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if(!empty($allData)) SelfSchedule::insert($allData);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1168,6 +1078,11 @@ class ApiController extends Controller
|
|
// ['status'=>false,'type'=>3,'start'=>'19:30','end'=>'21:00','date'=>15,'week'=>1],
|
|
// ['status'=>false,'type'=>3,'start'=>'19:30','end'=>'21:00','date'=>15,'week'=>1],
|
|
// ];
|
|
// ];
|
|
|
|
|
|
|
|
+ if($type != 1){
|
|
|
|
+ $docter_id = 0;
|
|
|
|
+ }
|
|
|
|
+// echo '社区id '.$org_id.' 医生id '.$docter_id;
|
|
|
|
+
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|
|
try {
|
|
try {
|
|
foreach ($schedule['schedulelingList'] as $t=>$v){
|
|
foreach ($schedule['schedulelingList'] as $t=>$v){
|
|
@@ -1177,24 +1092,23 @@ class ApiController extends Controller
|
|
|
|
|
|
if($v['status'] == true){
|
|
if($v['status'] == true){
|
|
$num_date = intval(date('Ymd',strtotime($today)));
|
|
$num_date = intval(date('Ymd',strtotime($today)));
|
|
- $sche_data = ['organization_id'=>$org_id,'schedule_date'=>$today,'schedule_day'=>$num_date];
|
|
|
|
|
|
+ $sche_data = ['docter_id'=>intval($docter_id),'organization_id'=>$org_id,'schedule_date'=>$today,'schedule_day'=>$num_date];
|
|
//判断是否有排班信息
|
|
//判断是否有排班信息
|
|
- $s_id = Schedule::where($sche_data)->value('id');
|
|
|
|
|
|
+ $s_id = Schedule::where($sche_data)->count();
|
|
if(!$s_id){
|
|
if(!$s_id){
|
|
- $s_id = Schedule::insertGetId($sche_data);
|
|
|
|
|
|
+ Schedule::insert($sche_data);
|
|
}
|
|
}
|
|
|
|
|
|
//获取时间段
|
|
//获取时间段
|
|
$timeperiods = TimePeriod::where(['docter_id'=>intval($docter_id),'org_id'=>intval($org_id),'type'=>intval($v['type'])])->pluck('id')->toArray();
|
|
$timeperiods = TimePeriod::where(['docter_id'=>intval($docter_id),'org_id'=>intval($org_id),'type'=>intval($v['type'])])->pluck('id')->toArray();
|
|
- if($type != 1){
|
|
|
|
- $timeperiods = TimePeriod::where(['docter_id'=>intval(0),'org_id'=>$org_id,'type'=>intval($v['type'])])->pluck('id')->toArray();
|
|
|
|
- }
|
|
|
|
|
|
|
|
if(empty($timeperiods)){
|
|
if(empty($timeperiods)){
|
|
return apiReturn(603,'没有时间段');
|
|
return apiReturn(603,'没有时间段');
|
|
// self::setTimeperiod($type,$docter_id,$org_id);
|
|
// self::setTimeperiod($type,$docter_id,$org_id);
|
|
// $timeperiods = self::getTypeTimeperiod($type,$docter_id,$org_id,intval($v['type']));
|
|
// $timeperiods = self::getTypeTimeperiod($type,$docter_id,$org_id,intval($v['type']));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// dump($timeperiods);
|
|
foreach ($timeperiods as $id){
|
|
foreach ($timeperiods as $id){
|
|
$data = [
|
|
$data = [
|
|
'organization_id'=>$org_id,
|
|
'organization_id'=>$org_id,
|
|
@@ -1202,12 +1116,15 @@ class ApiController extends Controller
|
|
'week'=>$week,
|
|
'week'=>$week,
|
|
'type'=>$v['type'],
|
|
'type'=>$v['type'],
|
|
'schedule_date'=>$today,
|
|
'schedule_date'=>$today,
|
|
|
|
+ 'schedule_type'=>$type,
|
|
'docter_id'=>$docter_id,
|
|
'docter_id'=>$docter_id,
|
|
];
|
|
];
|
|
|
|
|
|
|
|
+// dump($data);
|
|
//检查是否已经有数据
|
|
//检查是否已经有数据
|
|
- $self_count = SelfSchedule::where($data)->value('id');
|
|
|
|
|
|
+ $self_count = SelfSchedule::where($data)->count();
|
|
if(!$self_count) SelfSchedule::insert($data);
|
|
if(!$self_count) SelfSchedule::insert($data);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
} else if($v['status'] == false){
|
|
} else if($v['status'] == false){
|
|
@@ -1216,24 +1133,35 @@ class ApiController extends Controller
|
|
'week'=>$week,
|
|
'week'=>$week,
|
|
'type'=>$v['type'],
|
|
'type'=>$v['type'],
|
|
'docter_id'=>$docter_id,
|
|
'docter_id'=>$docter_id,
|
|
|
|
+ 'schedule_type'=>$type,
|
|
'schedule_date'=>$today
|
|
'schedule_date'=>$today
|
|
];
|
|
];
|
|
|
|
+// dump($data);
|
|
//判断是否有自己的排班
|
|
//判断是否有自己的排班
|
|
$self_count = SelfSchedule::where($data)->count();
|
|
$self_count = SelfSchedule::where($data)->count();
|
|
if($self_count) SelfSchedule::where($data)->delete();
|
|
if($self_count) SelfSchedule::where($data)->delete();
|
|
|
|
|
|
|
|
+ unset($data['week']);
|
|
|
|
+ //删除详细排班
|
|
|
|
+ $count_period = SchedulePeriod::where($data)->count();
|
|
|
|
+ if($count_period) SchedulePeriod::where($data)->delete();
|
|
|
|
+
|
|
|
|
+
|
|
// //检查是否是有周排班
|
|
// //检查是否是有周排班
|
|
// $week_schedule = WeekSchedule::where(['week'=>$week,'docter_id'=>$docter_id,'type'=>intval($v['type']),'organization_id'=>$org_id])->count();
|
|
// $week_schedule = WeekSchedule::where(['week'=>$week,'docter_id'=>$docter_id,'type'=>intval($v['type']),'organization_id'=>$org_id])->count();
|
|
// if(!$week_schedule) continue;
|
|
// if(!$week_schedule) continue;
|
|
//
|
|
//
|
|
-// //获取排班id
|
|
|
|
|
|
+// //删除排班日期
|
|
$s_id = Schedule::where(['schedule_date'=>$today,'docter_id'=>$docter_id,'organization_id'=>$org_id])->value('id');
|
|
$s_id = Schedule::where(['schedule_date'=>$today,'docter_id'=>$docter_id,'organization_id'=>$org_id])->value('id');
|
|
- if($s_id) {
|
|
|
|
- Schedule::where(['id'=>$s_id])->delete();
|
|
|
|
- SchedulePeriod::where(['schedule_id'=>$s_id])->delete();
|
|
|
|
|
|
+ unset($data['type']);
|
|
|
|
+ $scount = SelfSchedule::where($data)->count();
|
|
|
|
+ $pcount = SchedulePeriod::where($data)->count();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if($s_id && $scount == 0&& $pcount == 0) {
|
|
|
|
+ Schedule::where(['id'=>$s_id])->delete();
|
|
}
|
|
}
|
|
// //删除排班和详细排班数据
|
|
// //删除排班和详细排班数据
|
|
-
|
|
|
|
// TimePeriod::where(['docter_id'=>$docter_id,'org_id'=>$org_id,'type'=>$t,'schedule_id'=>$s_id])->delete();
|
|
// TimePeriod::where(['docter_id'=>$docter_id,'org_id'=>$org_id,'type'=>$t,'schedule_id'=>$s_id])->delete();
|
|
}
|
|
}
|
|
}
|
|
}
|