<?php

namespace App\Http\Controllers\API\H5;

use App\Http\Controllers\Controller;
use DateTime;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class NMRController extends Controller
{
    //获取核磁号 本月每日剩余号源数量
  public function GetMonthPlanCount()
  {
    $hospital_id =request('hospital_id');
    $month=request('month');
    $list=[
      [
        'date'=>'2024-9-29',
        'count'=>20,
      ],
      [
        'date'=>'2024-9-30',
        'count'=>10,
      ],

    ];
    return \Yz::Return(true,"查询完成",['list'=>$list]);
  }

  //核磁当日号源
  public function GetDayPlanList()
  {
    $hospital_id =request('hospital');
    $date=request('date');
// 获取前后各三天的日期
    $dateTime = new DateTime($date);
    $days7=[];
    for ($i = -3; $i <= 3; $i++) {
      $dateTimeClone = clone $dateTime; // 克隆对象以避免修改原对象
      $dateTimeClone->modify("$i days"); // 修改日期
      $days7[] = $dateTimeClone->format('Y-m-d'); // 按照需要的格式添加到结果数组
    }
    $list=[
      [
        'id'=>1,
        'status'=>1,
        'time'=>'10:15'
      ],
      [
        'id'=>1,
        'status'=>1,
        'time'=>'10:45'
      ]
    ];
    $weeklist=[[
      'date'=>'2024-09-28',
      'count'=>20,
    ]

    ];
    $week7=[];
    $k=0;
    foreach ($days7 as $date) {
      $xingqi=\App\Lib\Tools::GetWeekName($date);
      $week7[]=[
        'date'=>$date,
        'count'=>0,
        'xingqi'=>$xingqi
      ];
      foreach ($weeklist as $plan) {
        if($plan['date'] == $date){
          $week7[$k]=[
            'date'=>$date,
            'xingqi'=>$xingqi,
            'count'=>$plan['count']
          ];
          break;
        }
      }
      $k++;
    }
    return \Yz::Return(true,"查询完成",['list'=>$list,'weeklist'=>$week7]);
  }
}
