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
6443f579
authored
Dec 24, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-1224' into develop
parents
3346b0dd
719a982e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
1 deletions
+58
-1
app/Api/Controllers/StatisticsController.php
+56
-0
routes/api.php
+2
-1
No files found.
app/Api/Controllers/StatisticsController.php
0 → 100644
View file @
6443f579
<?php
namespace
App\Api\Controllers
;
use
App\Http\Controllers\BaseApiController
;
use
App\Models\DiagnosiModel
;
use
App\Models\DoctorModel
;
use
App\Models\InquiryModel
;
use
App\Models\PatientModel
;
use
App\Models\PharmacistModel
;
use
App\Models\PharmacyDrugModel
;
use
App\Models\PharmacyModel
;
use
App\Models\PrescriptionLogModel
;
use
App\Models\PrescriptionModel
;
use
App\Models\User
;
use
App\Services\SmsService
;
use
Carbon\Carbon
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Log
;
use
Overtrue\EasySms\EasySms
;
class
StatisticsController
extends
BaseApiController
{
public
function
index
(
Request
$request
)
{
$request
=
$request
->
all
();
// var_dump($request);
if
(
!
isset
(
$request
[
'token'
])
||
$request
[
'token'
]
!=
'imohe123@'
){
echo
'错误请求'
;
exit
();
}
// 搜索前一天的数据 23:59:59
$query_time
=
date
(
'Y-m-d 23:59:59'
,
strtotime
(
"-1 day"
));
if
(
isset
(
$request
[
'date'
])
){
$query_time
=
date
(
'Y-m-d 23:59:59'
,
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
();
$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
.
"
"
;
exit
();
}
}
\ No newline at end of file
routes/api.php
View file @
6443f579
...
...
@@ -23,7 +23,8 @@
Route
::
post
(
'login'
,
'App\Api\Controllers\UserController@login'
);
Route
::
get
(
'test'
,
'App\Api\Controllers\SiteConfigController@test'
);
Route
::
get
(
'qrcode'
,
'App\Api\Controllers\PatientController@getQrCode'
);
// 统计数据
Route
::
get
(
'statistics'
,
'App\Api\Controllers\StatisticsController@index'
);
// 需要验证是否登录的路由组
Route
::
middleware
([
'jwt.auth'
,
'checkrole'
])
->
group
(
function
()
{
...
...
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