Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
workbiu-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gxx
workbiu-admin
Commits
b5329efd
Commit
b5329efd
authored
Nov 13, 2017
by
gxx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户平均创建参数与:团队、项目、任务、日程完成 文件部分没有参数未写
parent
fd1aeda1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
1 deletion
+85
-1
StatisticsServiceContract.php
app/Contracts/StatisticsServiceContract.php
+1
-0
StatisticsController.php
app/Http/Controllers/StatisticsController.php
+7
-0
StatisticsService.php
app/Services/StatisticsService.php
+76
-1
web.php
routes/web.php
+1
-0
No files found.
app/Contracts/StatisticsServiceContract.php
View file @
b5329efd
...
...
@@ -18,6 +18,7 @@ interface StatisticsServiceContract
public
function
OutflowUser
();
public
function
ReturnVisit
();
public
function
UserRetention
();
public
function
AverageUserOperation
();
}
\ No newline at end of file
app/Http/Controllers/StatisticsController.php
View file @
b5329efd
...
...
@@ -79,4 +79,11 @@ class StatisticsController extends Controller
return
$data
;
}
public
function
AverageUserOperation
()
{
$data
=
$this
->
mStatistics
->
AverageUserOperation
();
dd
(
$data
);
}
}
app/Services/StatisticsService.php
View file @
b5329efd
...
...
@@ -10,8 +10,12 @@ namespace App\Services;
use
App\Contracts\StatisticsServiceContract
;
use
App\Models\Group
;
use
App\Models\Project
;
use
App\Models\Schedule
;
use
App\Models\Task
;
use
App\Models\User
;
use
App\Models\UserGroup
;
use
App\Models\UserInfo
;
use
Carbon\Carbon
;
...
...
@@ -208,10 +212,81 @@ class StatisticsService implements StatisticsServiceContract
// 用户平均创建参与
public
function
AverageUserOperation
()
{
$users
=
User
::
all
();
$creatorGroupCount
=
0
;
$participateGroupCount
=
0
;
foreach
(
$users
as
$user
){
// 查询团队
$creatorGroup
=
Group
::
where
(
'creator_id'
,
$user
[
'id'
])
->
get
();
$participateGroup
=
UserGroup
::
where
(
'user_id'
,
$user
[
'id'
])
->
get
();
if
(
!
$creatorGroup
->
isEmpty
()){
$creatorGroupCount
+=
count
(
$creatorGroup
);
}
if
(
!
$participateGroup
->
isEmpty
()){
$participateGroupCount
+=
count
(
$participateGroup
);
}
}
$creatorProjectCount
=
0
;
$participateProjectCount
=
0
;
foreach
(
$users
as
$user
){
// 查询项目
$creatorProject
=
Project
::
where
(
'creator_id'
,
$user
[
'id'
])
->
get
();
//$participateGroup = UserGroup::where('user_id',$user['id'])->get();
if
(
!
$creatorProject
->
isEmpty
()){
$creatorProjectCount
+=
count
(
$creatorProject
);
}
foreach
(
$creatorProject
as
$project
){
if
(
count
(
json_decode
(
$project
[
'partners'
]))
>
0
){
$participateProjectCount
+=
count
(
json_decode
(
$project
[
'partners'
]));
}
}
}
$creatorTaskCount
=
0
;
foreach
(
$users
as
$user
){
// 查询任务
$creatorTask
=
Task
::
where
(
'creator_id'
,
$user
[
'id'
])
->
get
();
//$participateTask = Task::where('owner_id',$user['id'])->get();
if
(
!
$creatorTask
->
isEmpty
()){
$creatorTaskCount
+=
count
(
$creatorTask
);
}
}
$creatorScheduleCount
=
0
;
foreach
(
$users
as
$user
){
// 查询日程
$creatorSchedule
=
Schedule
::
where
(
'creator_id'
,
$user
[
'id'
])
->
get
();
if
(
!
$creatorSchedule
->
isEmpty
()){
$creatorScheduleCount
+=
count
(
$creatorSchedule
);
}
}
// 平均团队
$averageGroup
=
ceil
(
round
((
$creatorGroupCount
+
$participateGroupCount
)
/
count
(
$users
)
*
100
,
2
))
.
'%'
;
// 平均项目
$averageProject
=
ceil
(
round
((
$creatorProjectCount
+
$participateProjectCount
)
/
count
(
$users
)
*
100
,
2
))
.
'%'
;
// 平均任务
$averageTask
=
ceil
(
round
(
$creatorTaskCount
/
count
(
$users
)
*
100
,
2
))
.
'%'
;
// 平均日程
$averageSchedule
=
ceil
(
round
(
$creatorTaskCount
/
count
(
$users
)
*
100
,
2
))
.
'%'
;
$data
=
[
'团队'
=>
$averageGroup
,
'项目'
=>
$averageProject
,
'任务'
=>
$averageTask
,
'日程'
=>
$averageSchedule
];
return
$data
;
// dd($averageGroup,$averageProject,$averageTask,$averageSchedule);
}
...
...
routes/web.php
View file @
b5329efd
...
...
@@ -86,6 +86,7 @@ Route::group(['prefix'=> 'statistics'],function (){
Route
::
get
(
'outflow_user'
,
'StatisticsController@OutflowUser'
)
->
name
(
'statistics.OutflowUser'
);
Route
::
get
(
'return_visit'
,
'StatisticsController@ReturnVisit'
)
->
name
(
'statistics.ReturnVisit'
);
Route
::
get
(
'user_retention'
,
'StatisticsController@UserRetention'
)
->
name
(
'statistics.UserRetention'
);
Route
::
get
(
'average_user_operation'
,
'StatisticsController@AverageUserOperation'
)
->
name
(
'statistics.AverageUserOperation'
);
});
...
...
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