|
@@ -417,6 +417,11 @@ class ApiController extends Controller
|
|
$schedule = Schedule::where(['docter_id' => $docterId, 'schedule_type' => $sType,'organization_id'=>$orgId])->where('schedule_date', '>=', date('Y-m-d', time()))
|
|
$schedule = Schedule::where(['docter_id' => $docterId, 'schedule_type' => $sType,'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($sType == 1){
|
|
|
|
+ $schedule = Schedule::where(['docter_id' => $docterId, 'schedule_type' => $sType,'organization_id'=>0])->where('schedule_date', '>=', date('Y-m-d', time()))
|
|
|
|
+ ->distinct('schedule_date')->pluck('schedule_date', 'id')->toArray();
|
|
|
|
+ }
|
|
|
|
+
|
|
$allData = [];
|
|
$allData = [];
|
|
for ($tType = 1; $tType <= 3; $tType++) {
|
|
for ($tType = 1; $tType <= 3; $tType++) {
|
|
foreach ($schedule as $id => $date) {
|
|
foreach ($schedule as $id => $date) {
|
|
@@ -709,14 +714,8 @@ class ApiController extends Controller
|
|
//2.创建新时间段
|
|
//2.创建新时间段
|
|
self::makeTimePeriod($docter_id, $org_id, $sType, $c_r[$tType], $count, $serviceTime);
|
|
self::makeTimePeriod($docter_id, $org_id, $sType, $c_r[$tType], $count, $serviceTime);
|
|
|
|
|
|
- //检测时间段
|
|
|
|
-// $timeCount = TimePeriod::where(['org_id' => $org_id, 'docter_id' => $docter_id])->count();
|
|
|
|
-// if($timeCount == 0) return apiReturn(603,'请设置时间段');
|
|
|
|
-
|
|
|
|
$time_periods = TimePeriod::where(['org_id' => $org_id, 'docter_id' => $docter_id, 'type' => $sType])->whereBetween('end_time_period', $times[$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();
|
|
- $schedule = Schedule::where(['docter_id' => $docter_id, 'schedule_type' => $sType])->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();
|
|
|
|
|
|
+
|
|
|
|
|
|
if ($sType == 1) {
|
|
if ($sType == 1) {
|
|
$week_schedule = WeekSchedule::where(['docter_id' => $docter_id, 'type' => $tType, 'schedule_type' => $sType]);
|
|
$week_schedule = WeekSchedule::where(['docter_id' => $docter_id, 'type' => $tType, 'schedule_type' => $sType]);
|
|
@@ -727,7 +726,7 @@ class ApiController extends Controller
|
|
|
|
|
|
if ($week != 0) {
|
|
if ($week != 0) {
|
|
//3.以周模板添加2个月的数据
|
|
//3.以周模板添加2个月的数据
|
|
- self::makeSchedule($sType, $docter_id, $org_id, $tType, $schedule, $time_periods);
|
|
|
|
|
|
+ self::makeSchedule($sType, $docter_id, $org_id, $tType, $time_periods);
|
|
//TODO 删除周排班,插入新周排班
|
|
//TODO 删除周排班,插入新周排班
|
|
self::changeWeekSchedule($docter_id, $org_id, $sType, $tType, $time_periods);
|
|
self::changeWeekSchedule($docter_id, $org_id, $sType, $tType, $time_periods);
|
|
}
|
|
}
|
|
@@ -865,7 +864,7 @@ class ApiController extends Controller
|
|
}
|
|
}
|
|
|
|
|
|
//以周模板进行排班
|
|
//以周模板进行排班
|
|
- public static function makeSchedule($sType, $docterId, $orgId, $tType, $schedule, $timePeriods)
|
|
|
|
|
|
+ public static function makeSchedule($sType, $docterId, $orgId, $tType, $timePeriods)
|
|
{
|
|
{
|
|
|
|
|
|
// if(empty($schedule) || count($schedule) < 58){
|
|
// if(empty($schedule) || count($schedule) < 58){
|
|
@@ -880,6 +879,7 @@ class ApiController extends Controller
|
|
|
|
|
|
for ($i = 1; $i < 60; $i++) {
|
|
for ($i = 1; $i < 60; $i++) {
|
|
$todayTimer = $start + (($i - 1) * 86400);
|
|
$todayTimer = $start + (($i - 1) * 86400);
|
|
|
|
+ $numDate = date('Ymd',$todayTimer);
|
|
$date = date('Y-m-d', $todayTimer);
|
|
$date = date('Y-m-d', $todayTimer);
|
|
$week = intval(date('N', strtotime($date)));
|
|
$week = intval(date('N', strtotime($date)));
|
|
|
|
|
|
@@ -889,7 +889,12 @@ class ApiController extends Controller
|
|
$mesure->delete();
|
|
$mesure->delete();
|
|
foreach ($timePeriods as $idt) {
|
|
foreach ($timePeriods as $idt) {
|
|
if (!empty($mesureIds)) {
|
|
if (!empty($mesureIds)) {
|
|
- $scheduleId = Schedule::where(['docter_id' => $docterId, 'schedule_type' => $sType,'organization_id'=>$orgId])->where('schedule_date', $date)->value('id');
|
|
|
|
|
|
+ if($sType == 1) {
|
|
|
|
+ $scheduleId = Schedule::where(['docter_id' => $docterId, 'schedule_type' => $sType,'organization_id'=>0])->where('schedule_day', $numDate)->value('id');
|
|
|
|
+ } else {
|
|
|
|
+ $scheduleId = Schedule::where(['docter_id' => $docterId, 'schedule_type' => $sType,'organization_id'=>$orgId])->where('schedule_day', $numDate)->value('id');
|
|
|
|
+ }
|
|
|
|
+ dump($scheduleId);
|
|
if (empty($scheduleId)) {
|
|
if (empty($scheduleId)) {
|
|
$numDate = date('Ymd', $todayTimer);
|
|
$numDate = date('Ymd', $todayTimer);
|
|
$scheduleData['docter_id'] = $docterId;
|
|
$scheduleData['docter_id'] = $docterId;
|
|
@@ -914,13 +919,17 @@ class ApiController extends Controller
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-// 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, 'schedule_type' => $sType])->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)) {
|
|
|
|
|
|
foreach ($timePeriods as $idt) {
|
|
foreach ($timePeriods as $idt) {
|
|
- $scheduleId = Schedule::where(['docter_id' => $docterId, 'schedule_type' => $sType,'organization_id' => $orgId])->where('schedule_date', $date)->value('id');
|
|
|
|
- if ($scheduleId == 0) {
|
|
|
|
|
|
+ if($sType == 1) {
|
|
|
|
+ $scheduleId = Schedule::where(['docter_id' => $docterId, 'schedule_type' => $sType,'organization_id'=>0])->where('schedule_day', $numDate)->value('id');
|
|
|
|
+ } else {
|
|
|
|
+ $scheduleId = Schedule::where(['docter_id' => $docterId, 'schedule_type' => $sType,'organization_id'=>$orgId])->where('schedule_day', $numDate)->value('id');
|
|
|
|
+ }
|
|
|
|
+ if (empty($scheduleId)) {
|
|
$numDate = date('Ymd', $todayTimer);
|
|
$numDate = date('Ymd', $todayTimer);
|
|
$scheduleData['docter_id'] = $docterId;
|
|
$scheduleData['docter_id'] = $docterId;
|
|
$scheduleData['schedule_date'] = $date;
|
|
$scheduleData['schedule_date'] = $date;
|