Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵增煜
/
tzt-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
88e25395
authored
Nov 23, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
有效医师
parent
cdeae775
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
app/Api/Controllers/PrescriptionController.php
+22
-6
No files found.
app/Api/Controllers/PrescriptionController.php
View file @
88e25395
...
@@ -200,15 +200,31 @@ public function create(Request $request)
...
@@ -200,15 +200,31 @@ public function create(Request $request)
->
pluck
(
'prescription_count'
,
'doctor_id'
);
->
pluck
(
'prescription_count'
,
'doctor_id'
);
Log
::
info
(
'医师开方统计:'
.
json_encode
(
$prescriptionCounts
));
Log
::
info
(
'医师开方统计:'
.
json_encode
(
$prescriptionCounts
));
if
(
count
(
$prescriptionCounts
)
>
0
)
{
foreach
(
$doctorIds
as
$doctorId
)
{
if
(
isset
(
$prescriptionCounts
[
$doctorId
]))
{
// 判断是否达到上限
if
(
intval
(
$prescriptionCounts
[
$doctorId
])
>=
intval
(
$prescription_limit
))
{
unset
(
$doctorIds
[
$doctorId
]);
}
}
}
// foreach ($prescriptionCounts as $doctorId => $count) {
// if (intval($count) >= intval($prescription_limit)) {
// unset($doctorIds[$doctorId]);
// }
// if( count($doctorIds) == 0 ) break;
// }
}
// 筛选未达到上限的医师
// 筛选未达到上限的医师
$availableDoctors
=
collect
(
$doctorIds
)
->
filter
(
function
(
$doctorId
)
use
(
$prescriptionCounts
,
$prescription_limit
)
{
//
$availableDoctors = collect($doctorIds)->filter(function ($doctorId) use ($prescriptionCounts, $prescription_limit) {
return
$prescriptionCounts
->
get
(
$doctorId
,
0
)
<
$prescription_limit
;
//
return $prescriptionCounts->get($doctorId, 0) < $prescription_limit;
})
->
values
()
->
all
();
//
})->values()->all();
Log
::
info
(
'有效的医师:'
.
json_encode
(
$
availableDoctor
s
));
Log
::
info
(
'有效的医师:'
.
json_encode
(
$
doctorId
s
));
// 随机取一个随机医师
// 随机取一个随机医师
$randomQuery
=
DoctorModel
::
query
()
->
where
(
'status'
,
DoctorModel
::
STATUS_TRUE
);
$randomQuery
=
DoctorModel
::
query
()
->
where
(
'status'
,
DoctorModel
::
STATUS_TRUE
);
if
(
count
(
$
availableDoctor
s
)
>
0
)
{
if
(
count
(
$
doctorId
s
)
>
0
)
{
$randomQuery
->
whereIn
(
'id'
,
$
availableDoctor
s
);
$randomQuery
->
whereIn
(
'id'
,
$
doctorId
s
);
}
else
{
}
else
{
return
$this
->
failed
(
'医师开方数超过限制'
);
return
$this
->
failed
(
'医师开方数超过限制'
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment