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
485e3ff4
authored
Jan 07, 2025
by
赵增煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加统计
parent
40beae4c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletions
+24
-1
app/Api/Controllers/StatisticsController.php
+24
-1
No files found.
app/Api/Controllers/StatisticsController.php
View file @
485e3ff4
...
...
@@ -32,21 +32,44 @@ public function index(Request $request)
}
// 搜索前一天的数据 23:59:59
$query_time
=
date
(
'Y-m-d 23:59:59'
,
strtotime
(
"-1 day"
));
$prev_start_time
=
date
(
'Y-m-d 00:00:00'
,
strtotime
(
"-1 day"
));
$prev_end_time
=
date
(
'Y-m-d 23:59:59'
,
strtotime
(
"-1 day"
));
$query_date
=
date
(
'Y-m-d'
,
strtotime
(
"-1 day"
));
if
(
isset
(
$request
[
'date'
])
){
$query_time
=
date
(
'Y-m-d 23:59:59'
,
strtotime
(
$request
[
'date'
]));
$prev_start_time
=
date
(
'Y-m-d 00:00:00'
,
strtotime
(
$request
[
'date'
]));
$prev_end_time
=
date
(
'Y-m-d 23:59:59'
,
strtotime
(
$request
[
'date'
]));
$query_date
=
date
(
'Y-m-d'
,
strtotime
(
$request
[
'date'
]));
}
$pharmacy_count
=
PharmacyModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
$pharmacist_count
=
PharmacistModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
$results
=
DB
::
select
(
'SELECT count(pharmacy_id) FROM prescription WHERE created_at <= :query_time GROUP BY pharmacy_id having count(pharmacy_id) >=100'
,
[
'query_time'
=>
$query_time
]);
$prescription_count
=
count
(
$results
);
$prescription_total
=
PrescriptionModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
$prescription_day_total
=
PrescriptionModel
::
where
(
'created_at'
,
'<='
,
$prev_end_time
)
->
where
(
'created_at'
,
'>='
,
$prev_start_time
)
->
count
();
$res
=
DB
::
select
(
'SELECT COUNT(DISTINCT pharmacy_id) AS pharmacy_count
FROM prescription
WHERE created_at >= :start_of_day
AND created_at < :next_day
AND status = 2'
,
// 只统计审方成功的记录
[
'start_of_day'
=>
$query_date
.
' 00:00:00'
,
'next_day'
=>
$query_date
.
' 23:59:59'
]
);
// var_dump($res[0]->pharmacy_count);exit();
$next_day_count
=
$res
[
0
]
->
pharmacy_count
;
$patient_count
=
PatientModel
::
where
(
'created_at'
,
'<='
,
$query_time
)
->
count
();
echo
"统计数据("
.
$query_time
.
"):<br />
药店数量:"
.
$pharmacy_count
.
"<br />
药师数量:"
.
$pharmacist_count
.
"<br />
开方药店(处方数超过100单):"
.
$prescription_count
.
"<br />
处方总量:"
.
$prescription_total
.
"<br />
问诊人数量:"
.
$patient_count
.
"
问诊人数量:"
.
$patient_count
.
"<br />
"
.
$query_date
.
"开方量:"
.
$prescription_day_total
.
"<br />
"
.
$query_date
.
"开方药店量:"
.
$next_day_count
.
"<br />
"
;
exit
();
}
...
...
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