You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
2.5 KiB
PHP

<?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-10-18',
'count'=>20,
],
[
'date'=>'2024-10-19',
'count'=>10,
],
];
//获取整月日期
// 获取当月的第一天
$firstDay = date("Y-m-d", strtotime($month . "-01"));
// 获取当月的最后一天
$lastDay = date("Y-m-t", strtotime($month));
$dates = array();
$k=0;
for ($i = $firstDay; $i <= $lastDay; $i = date("Y-m-d", strtotime($i . " +1 day"))) {
$xingqi=\App\Lib\Tools::GetWeekName($i);
$dates[]=[
'date'=>$i,
'xingqi'=>$xingqi,
'count'=>0
];
foreach ($list as $item) {
if($item['date'] == $i){
$dates[$k]=[
'date'=>$i,
'xingqi'=>$xingqi,
'count'=>$item['count']
];
break;
}
}
$k++;
}
return \Yz::Return(true,"查询完成",['list'=>$dates]);
}
//核磁当日号源
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]);
}
}