| xqd
@@ -731,43 +731,43 @@ class ApiController extends Controller
|
|
|
}
|
|
|
|
|
|
TimePeriod::where(['org_id' => $org_id, 'type' => $sType, 'docter_id' => $docter_id])->delete();
|
|
|
+ if($serviceTime['status']){
|
|
|
+ for ($i = 1; $i <= 3; $i++) {
|
|
|
+ $tType = $i;
|
|
|
+ DB::beginTransaction();
|
|
|
+ try {
|
|
|
+ //1.删除旧时间段,并删除排班数据
|
|
|
|
|
|
- for ($i = 1; $i <= 3; $i++) {
|
|
|
- $tType = $i;
|
|
|
- DB::beginTransaction();
|
|
|
- try {
|
|
|
- //1.删除旧时间段,并删除排班数据
|
|
|
-
|
|
|
- //todo 暂时未删除周排班
|
|
|
- self::deleteScheduleInfo($docter_id, $sType, $tType, $org_id);
|
|
|
- $count = $countArr[$i];
|
|
|
- //2.创建新时间段
|
|
|
- self::makeTimePeriod($docter_id, $org_id, $sType, $c_r[$tType], $count, $serviceTime);
|
|
|
+ //todo 暂时未删除周排班
|
|
|
+ self::deleteScheduleInfo($docter_id, $sType, $tType, $org_id);
|
|
|
+ $count = $countArr[$i];
|
|
|
+ //2.创建新时间段
|
|
|
+ self::makeTimePeriod($docter_id, $org_id, $sType, $c_r[$tType], $count, $serviceTime);
|
|
|
|
|
|
- $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();
|
|
|
|
|
|
|
|
|
- if ($sType == 1) {
|
|
|
- $week_schedule = WeekSchedule::where(['docter_id' => $docter_id, 'type' => $tType, 'schedule_type' => $sType]);
|
|
|
- } else {
|
|
|
- $week_schedule = WeekSchedule::where(['organization_id' => $org_id, 'type' => $tType, 'schedule_type' => $sType]);
|
|
|
- }
|
|
|
- $week = $week_schedule->count();
|
|
|
+ if ($sType == 1) {
|
|
|
+ $week_schedule = WeekSchedule::where(['docter_id' => $docter_id, 'type' => $tType, 'schedule_type' => $sType]);
|
|
|
+ } else {
|
|
|
+ $week_schedule = WeekSchedule::where(['organization_id' => $org_id, 'type' => $tType, 'schedule_type' => $sType]);
|
|
|
+ }
|
|
|
+ $week = $week_schedule->count();
|
|
|
|
|
|
- if ($week != 0) {
|
|
|
- //3.以周模板添加2个月的数据
|
|
|
- self::makeSchedule($sType, $docter_id, $org_id, $tType, $time_periods);
|
|
|
- //TODO 删除周排班,插入新周排班
|
|
|
- self::changeWeekSchedule($docter_id, $org_id, $sType, $tType, $time_periods);
|
|
|
+ if ($week != 0) {
|
|
|
+ //3.以周模板添加2个月的数据
|
|
|
+ self::makeSchedule($sType, $docter_id, $org_id, $tType, $time_periods);
|
|
|
+ //TODO 删除周排班,插入新周排班
|
|
|
+ self::changeWeekSchedule($docter_id, $org_id, $sType, $tType, $time_periods);
|
|
|
+ }
|
|
|
+ DB::commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ dd($e->getMessage());
|
|
|
+ DB::rollBack();
|
|
|
}
|
|
|
- DB::commit();
|
|
|
- } catch (\Exception $e) {
|
|
|
- dd($e->getMessage());
|
|
|
- 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}}
|
|
|
$config = [
|
|
|
1 => ['amStartTime' => $configData['amStartTime'], "amEndTime" => $configData['amEndTime'], 'amPerson' => $configData['amNum']],
|
| xqd
@@ -870,9 +870,9 @@ class ApiController extends Controller
|
|
|
public static function deleteScheduleInfo($docter_id, $sType, $timeType, $orgId = 0)
|
|
|
{
|
|
|
if ($docter_id != 0) {
|
|
|
- SchedulePeriod::where(['docter_id' => $docter_id, 'type' => $timeType, 'me_sure' => 0])->where('organization_id', '=', $orgId)->delete();
|
|
|
+ SchedulePeriod::where(['docter_id' => $docter_id, 'schedule_type'=>$sType,'type' => $timeType, 'me_sure' => 0])->where('organization_id', '=', $orgId)->delete();
|
|
|
} else {
|
|
|
- SchedulePeriod::where(['organization_id' => $orgId, 'type' => $timeType, 'me_sure' => 0])->where('docter_id', 0)->delete();
|
|
|
+ SchedulePeriod::where(['organization_id' => $orgId, 'schedule_type'=>$sType,'type' => $timeType, 'me_sure' => 0])->where('docter_id', 0)->delete();
|
|
|
}
|
|
|
return true;
|
|
|
}
|