Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
product_library_api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyi.chen
product_library_api
Commits
c6337aa0
Commit
c6337aa0
authored
Sep 30, 2024
by
cwy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加统计功能
parent
96c3ef1e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
6 deletions
+100
-6
app/api/controller/EnterpriseAllocation.php
+82
-1
app/api/controller/ProductAllocation.php
+13
-3
app/api/controller/Test.php
+4
-2
app/api/route/api.php
+1
-0
No files found.
app/api/controller/EnterpriseAllocation.php
View file @
c6337aa0
...
@@ -28,12 +28,16 @@ class EnterpriseAllocation extends AuthBase
...
@@ -28,12 +28,16 @@ class EnterpriseAllocation extends AuthBase
// 数据接收
// 数据接收
$page
=
input
(
"param.page"
,
0
,
"intval"
);
$page
=
input
(
"param.page"
,
0
,
"intval"
);
$limit
=
input
(
"param.limit"
,
10
,
"intval"
);
$limit
=
input
(
"param.limit"
,
10
,
"intval"
);
$user_id
=
input
(
"user_id"
);
$department_id
=
input
(
"department_id"
);
$department_id
=
input
(
"department_id"
);
$EnterpriseAllocationModel
=
new
EnterpriseAllocationModel
();
$EnterpriseAllocationModel
=
new
EnterpriseAllocationModel
();
$where
=
[];
$where
=
[];
if
(
$department_id
){
if
(
$department_id
){
$where
[]
=
[
'department_id'
,
'='
,
$department_id
];
$where
[]
=
[
'department_id'
,
'='
,
$department_id
];
}
}
if
(
$user_id
){
$where
[]
=
[
'user_id'
,
'='
,
$user_id
];
}
$result
=
$EnterpriseAllocationModel
->
with
([
$result
=
$EnterpriseAllocationModel
->
with
([
'enterpriseInfo'
=>
function
(
$query
){
'enterpriseInfo'
=>
function
(
$query
){
// $query->where('assignable',1);
// $query->where('assignable',1);
...
@@ -166,7 +170,8 @@ class EnterpriseAllocation extends AuthBase
...
@@ -166,7 +170,8 @@ class EnterpriseAllocation extends AuthBase
$allocation
=
[
$allocation
=
[
'user_id'
=>
$val
[
'id'
],
'user_id'
=>
$val
[
'id'
],
'enterprise_id'
=>
$value
,
'enterprise_id'
=>
$value
,
'distribute_time'
=>
date
(
'Y-m-d H:i:s'
)
'distribute_time'
=>
date
(
'Y-m-d H:i:s'
),
'department_id'
=>
$val
[
'department_id'
],
];
];
$tt
=
Db
::
name
(
'enterprise_allocation'
)
$tt
=
Db
::
name
(
'enterprise_allocation'
)
->
where
(
'user_id'
,
$val
[
'id'
])
->
where
(
'user_id'
,
$val
[
'id'
])
...
@@ -201,4 +206,79 @@ class EnterpriseAllocation extends AuthBase
...
@@ -201,4 +206,79 @@ class EnterpriseAllocation extends AuthBase
}
}
}
}
}
}
public
function
collectStatistics
()
{
try
{
$department_id
=
input
(
"department_id"
);
$userList
=
Db
::
name
(
'admin'
)
->
where
(
'department_id'
,
$department_id
)
->
select
();
$userInfo
=
[];
if
(
empty
(
$userList
)){
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.success"
),[]);
}
$userList
=
$userList
->
toArray
();
$list
=
[];
foreach
(
$userList
as
$value
){
array_push
(
$userInfo
,
$value
[
'id'
]);
$arr
=
[
'user_id'
=>
$value
[
'id'
],
'user_name'
=>
$value
[
'name'
],
'enterprise_quantity'
=>
0
,
// 企业数量
'enterprise_status'
=>
''
,
//完成状态
'product_quantity'
=>
0
,
//产品数量
'unfinished_product'
=>
0
,
//未完成产品数量
'completed_product'
=>
0
,
//已完成产品数量
];
array_push
(
$list
,
$arr
);
}
//总数
$total
=
[
'enterprise_quantity'
=>
0
,
// 总企业数量
'product_quantity'
=>
0
,
// 总产品数量
'completed_product'
=>
0
,
// 总产品完成数量
'unfinished_product'
=>
0
,
// 总产品未完成数量
];
// 企业统计
$enterprise_allocation
=
Db
::
name
(
'enterprise_allocation'
)
->
where
(
'user_id'
,
'in'
,
$userInfo
)
->
select
();
foreach
(
$enterprise_allocation
as
$value
){
$key
=
array_search
(
$value
[
'user_id'
],
$userInfo
);
// 返回 'banana' 的下标,即 2
if
(
$value
[
'department_id'
]
==
$department_id
){
$list
[
$key
][
'enterprise_quantity'
]
+=
1
;
$total
[
'enterprise_quantity'
]
+=
1
;
}
}
//产品统计
$product_allocation
=
Db
::
name
(
'product_allocation'
)
->
select
();
foreach
(
$product_allocation
as
$value
){
$key
=
array_search
(
$value
[
'user_id'
],
$userInfo
);
// 返回 'banana' 的下标,即 2
$list
[
$key
][
'product_quantity'
]
+=
1
;
$total
[
'product_quantity'
]
+=
1
;
if
(
$value
[
'status'
]
==
1
){
$list
[
$key
][
'completed_product'
]
+=
1
;
$total
[
'completed_product'
]
+=
1
;
}
else
{
$list
[
$key
][
'unfinished_product'
]
+=
1
;
$total
[
'unfinished_product'
]
+=
1
;
}
}
// 是否完成
foreach
(
$list
as
$key
=>
$value
){
if
(
$value
[
'product_quantity'
]
==
$value
[
'completed_product'
]){
$list
[
$key
][
'enterprise_status'
]
=
'已完成'
;
}
else
{
$list
[
$key
][
'enterprise_status'
]
=
'未完成'
;
}
}
$result
=
[
'data'
=>
$list
,
'total'
=>
$total
];
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.success"
),
$result
);
}
catch
(
\Exception
$e
){
exception
(
$e
,
self
::
$name
.
'.list'
);
}
}
}
}
\ No newline at end of file
app/api/controller/ProductAllocation.php
View file @
c6337aa0
...
@@ -38,10 +38,18 @@ class ProductAllocation extends AuthBase
...
@@ -38,10 +38,18 @@ class ProductAllocation extends AuthBase
$inspect_status
=
input
(
"inspect_status"
);
$inspect_status
=
input
(
"inspect_status"
);
$product_id
=
input
(
"product_id"
);
$product_id
=
input
(
"product_id"
);
$product_name
=
input
(
"product_name"
);
$product_name
=
input
(
"product_name"
);
$ProductAllocationModel
=
new
ProductAllocationModel
();
$user_id
=
input
(
"user_id"
);
$enterprise_id
=
input
(
"enterprise_id"
);
$where
=
[];
$where
=
[];
if
(
$this
->
userId
!=
1
){
if
(
empty
(
$user_id
)){
$where
[]
=
[
't1.user_id'
,
'='
,
$this
->
userId
];
if
(
$this
->
userId
!=
1
){
$where
[]
=
[
't1.user_id'
,
'='
,
$this
->
userId
];
}
}
else
{
$where
[]
=
[
't1.user_id'
,
'='
,
$user_id
];
}
if
(
$enterprise_id
){
$where
[]
=
[
't1.enterprise_id'
,
'='
,
$enterprise_id
];
}
}
if
(
$product_id
){
if
(
$product_id
){
$where
[]
=
[
't2.product_id'
,
'='
,
$product_id
];
$where
[]
=
[
't2.product_id'
,
'='
,
$product_id
];
...
@@ -56,9 +64,11 @@ class ProductAllocation extends AuthBase
...
@@ -56,9 +64,11 @@ class ProductAllocation extends AuthBase
->
alias
(
't1'
)
->
alias
(
't1'
)
->
join
(
'product t2'
,
't1.product_id=t2.id'
)
->
join
(
'product t2'
,
't1.product_id=t2.id'
)
->
join
(
'admin t3'
,
't1.user_id=t3.id'
)
->
join
(
'admin t3'
,
't1.user_id=t3.id'
)
->
join
(
'enterprise_info t4'
,
't1.enterprise_id=t4.id'
)
->
field
(
't1.status as product_allocation_status,t1.id as allocation_id,t1.*'
)
->
field
(
't1.status as product_allocation_status,t1.id as allocation_id,t1.*'
)
->
field
(
't2.status as product_status,t2.*'
)
->
field
(
't2.status as product_status,t2.*'
)
->
field
(
't3.status as admin_status,t3.*'
)
->
field
(
't3.status as admin_status,t3.*'
)
->
field
(
't4.enterprise_name as enterprise_name'
)
->
where
(
$where
)
->
where
(
$where
)
->
paginate
([
->
paginate
([
'list_rows'
=>
$limit
,
'list_rows'
=>
$limit
,
...
...
app/api/controller/Test.php
View file @
c6337aa0
...
@@ -275,8 +275,9 @@ class Test
...
@@ -275,8 +275,9 @@ class Test
$row
++
;
$row
++
;
}
}
$name
=
'
./
product_'
.
date
(
'Y-m-d H:i:s'
)
.
'.csv'
;
$name
=
'product_'
.
date
(
'Y-m-d H:i:s'
)
.
'.csv'
;
$writer
->
save
(
$name
);
$writer
->
save
(
$name
);
$url
=
'http://gcspider.raisound.com:81/product_library_api/public/'
.
$name
;
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.success"
),
$url
);
}
}
}
}
\ No newline at end of file
app/api/route/api.php
View file @
c6337aa0
...
@@ -103,6 +103,7 @@ Route::rule("task/add","Task/add");
...
@@ -103,6 +103,7 @@ Route::rule("task/add","Task/add");
Route
::
rule
(
"enterpriseAllocation/list"
,
"EnterpriseAllocation/list"
);
Route
::
rule
(
"enterpriseAllocation/list"
,
"EnterpriseAllocation/list"
);
Route
::
rule
(
"enterpriseAllocation/userEnterpriseList"
,
"EnterpriseAllocation/userEnterpriseList"
);
Route
::
rule
(
"enterpriseAllocation/userEnterpriseList"
,
"EnterpriseAllocation/userEnterpriseList"
);
Route
::
rule
(
"enterpriseAllocation/collectStatistics"
,
"EnterpriseAllocation/collectStatistics"
);
//Route::rule("enterpriseAllocation/equalDistributionEnterprise","EnterpriseAllocation/equalDistributionEnterprise");
//Route::rule("enterpriseAllocation/equalDistributionEnterprise","EnterpriseAllocation/equalDistributionEnterprise");
Route
::
rule
(
"service/product"
,
"Service/product"
);
Route
::
rule
(
"service/product"
,
"Service/product"
);
...
...
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