Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
data-collect-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
data-collect-api
Commits
7ae05594
Commit
7ae05594
authored
Mar 21, 2024
by
wenyi.chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
綫上0321完整版本
parent
29b53431
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
176 additions
and
22 deletions
+176
-22
app/api/business/NormListBus.php
+7
-1
app/api/business/NormOrdersBus.php
+2
-11
app/api/controller/Norm.php
+112
-9
app/api/controller/NormCollects.php
+22
-0
app/api/controller/NormList.php
+2
-0
app/api/controller/NormOrders.php
+7
-1
app/api/controller/NormReceives.php
+2
-0
app/api/controller/TaskPackage.php
+21
-0
app/api/route/api.php
+1
-0
No files found.
app/api/business/NormListBus.php
View file @
7ae05594
...
...
@@ -49,6 +49,9 @@ class NormListBus extends BaseBus
$hideField
=
[];
// 排序
$order
=
[
"id"
=>
"desc"
];
if
(
!
empty
(
$data
[
'sort'
]))
{
$order
=
[
"sort"
=>
$data
[
'sort'
],
"id"
=>
"desc"
];
}
// 分页
$page
=
$data
[
'page'
];
$limit
=
$data
[
'limit'
];
...
...
@@ -101,7 +104,10 @@ class NormListBus extends BaseBus
// 需要排除显示的字段,默认空全部显示,优先级大
$hideField
=
[];
// 排序
$order
=
[
"id"
=>
"desc"
];
$order
=
[
"id"
=>
"desc"
];
if
(
!
empty
(
$data
[
'sort'
]))
{
$order
=
[
"sort"
=>
$data
[
'sort'
],
"id"
=>
"desc"
];
}
$model
=
new
NormListModel
();
// 查询数据
$res
=
$model
->
listDataSql
(
$where
,
$displayField
,
$hideField
,
$order
);
...
...
app/api/business/NormOrdersBus.php
View file @
7ae05594
...
...
@@ -34,12 +34,6 @@ class NormOrdersBus extends BaseBus
if
(
!
empty
(
$data
[
'user_id'
]))
{
$where
[]
=
[
'user_id'
,
'='
,
$data
[
'user_id'
]];
}
if
(
!
empty
(
$data
[
'task_id'
]))
{
$where
[]
=
[
'task_id'
,
'='
,
$data
[
'task_id'
]];
}
if
(
!
empty
(
$data
[
'name'
]))
{
$where
[]
=
[
'name'
,
'like'
,
"%
{
$data
[
'name'
]
}
%"
];
}
if
(
!
empty
(
$data
[
'status'
]))
{
$where
[]
=
[
'status'
,
'in'
,
"
{
$data
[
'status'
]
}
"
];
}
...
...
@@ -87,11 +81,8 @@ class NormOrdersBus extends BaseBus
if
(
!
empty
(
$data
[
'id'
]))
{
$where
[]
=
[
'id'
,
'='
,
$data
[
'id'
]];
}
if
(
!
empty
(
$data
[
'task_id'
]))
{
$where
[]
=
[
'task_id'
,
'='
,
$data
[
'task_id'
]];
}
if
(
!
empty
(
$data
[
'name'
]))
{
$where
[]
=
[
'name'
,
'like'
,
"%
{
$data
[
'name'
]
}
%"
];
if
(
!
empty
(
$data
[
'user_id'
]))
{
$where
[]
=
[
'user_id'
,
'='
,
$data
[
'user_id'
]];
}
if
(
!
empty
(
$data
[
'status'
]))
{
$where
[]
=
[
'status'
,
'in'
,
"
{
$data
[
'status'
]
}
"
];
...
...
app/api/controller/Norm.php
View file @
7ae05594
...
...
@@ -13,6 +13,7 @@ use app\api\business\CommonBus as CommonBus; // 指标待领取扩展业务
use
think\facade\Db
;
class
Norm
{
public
$num
=
1
;
/**
* 任务列表
* @return \josn|void
...
...
@@ -32,9 +33,9 @@ class Norm
$result
=
$normBus
->
listData
(
$data
);
//获取所有数据
// 指标详情
foreach
(
$result
as
$index
=>
$value
){
$
r
es
=
$normBus
->
getConditionalQuery
([
'id'
=>
$value
[
'id'
]]);
$
normR
es
=
$normBus
->
getConditionalQuery
([
'id'
=>
$value
[
'id'
]]);
// 指标扩展详情
$result
[
$index
][
'addItem'
]
=
$
r
es
;
$result
[
$index
][
'addItem'
]
=
$
normR
es
;
$normExtendBus
=
new
CommonBus
(
'NormExtendBus'
);
$res
=
$normExtendBus
->
getConditionalQueryAll
([
'norm_id'
=>
$value
[
'id'
]]);
$result
[
$index
][
'custom'
]
=
$res
;
...
...
@@ -43,10 +44,10 @@ class Norm
$totalDegree
=
$NormListBus
->
getConditionalQueryAll
([
'norm_id'
=>
$value
[
'id'
]]);
$NormReceivesBus
=
new
CommonBus
(
'NormReceivesBus'
);
// 通过公共业务初始化指标类
$receivedTimes
=
$NormReceivesBus
->
getConditionalQueryAll
([
'norm_id'
=>
$value
[
'id'
]]);
$result
[
$index
][
'receivedQuantity'
]
=
count
(
$receivedTimes
)
.
'/'
.
count
(
$totalDegree
)
;
$result
[
'data'
][
$index
][
'receivedQuantity'
]
=
count
(
$receivedTimes
)
.
'/'
.
count
(
$totalDegree
)
*
$normRes
[
'num'
]
;
$NormCollectsBus
=
new
CommonBus
(
'NormCollectsBus'
);
// 通过公共业务初始化指标类
$collectsTimes
=
$NormCollectsBus
->
getConditionalQueryAll
([
'norm_id'
=>
$value
[
'id'
]]);
$result
[
$index
][
'collectsQuantity'
]
=
count
(
$collectsTimes
)
.
'/'
.
count
(
$totalDegree
)
;
$result
[
'data'
][
$index
][
'collectsQuantity'
]
=
count
(
$collectsTimes
)
.
'/'
.
count
(
$totalDegree
)
*
$normRes
[
'num'
]
;
}
}
else
{
//查询全部数据
...
...
@@ -114,11 +115,12 @@ class Norm
'refer'
=>
$data
[
'refer'
],
'price'
=>
$data
[
'price'
],
'guide'
=>
$data
[
'guide'
],
'num'
=>
2
'num'
=>
$this
->
num
,
];
$normBus
=
new
CommonBus
(
'NormBus'
);
// 通过公共业务初始化指标类
// 检查指标名称是否有重复
$query
=
$normBus
->
getConditionalQuery
([
'task_id'
=>
$data
[
'task_id'
],
'name'
=>
$data
[
'name'
]]);
var_dump
(
$query
);
if
(
$query
){
return
returnResult
(
config
(
"config.code.error"
),
'指标名称已存在!'
);
}
...
...
@@ -184,7 +186,7 @@ class Norm
$normList
[
'price'
]
=
$data
[
'price'
];
$normList
[
'guide'
]
=
$data
[
'guide'
];
$normList
[
'status'
]
=
0
;
$normList
[
'num'
]
=
2
;
$normList
[
'num'
]
=
$this
->
num
;
$normList
[
'sort'
]
=
$data
[
'sort'
];
$normListBus
=
new
CommonBus
(
'NormListBus'
);
// 通过公共业务初始化用户待领取指标类
$normListId
=
$normListBus
->
addData
(
$normList
);
...
...
@@ -275,6 +277,70 @@ class Norm
{
try
{
$queryArr
=
json_decode
(
file_get_contents
(
'php://input'
),
true
);
$displayArea
=
false
;
//判断是否有更新展示端
$userArea
=
false
;
/******************************************展示端修改了内容*********************/
$normBus
=
new
CommonBus
(
'NormBus'
);
$normExtendBus
=
new
CommonBus
(
'NormExtendBus'
);
$norm_id
=
$queryArr
[
'norm_id'
];
$addItem
=
$queryArr
[
'addItem'
];
$res
=
$normBus
->
getConditionalQuery
([
'id'
=>
$norm_id
]);
$new
=
[
'name'
=>
$addItem
[
'name'
],
'level'
=>
$addItem
[
'level'
],
'sort'
=>
$addItem
[
'sort'
],
];
$old
=
[
'name'
=>
$res
[
'name'
],
'level'
=>
$res
[
'level'
],
'sort'
=>
$res
[
'sort'
],
];
// 判断是否有更新的内容
if
(
$new
!=
$old
){
$displayArea
=
true
;
}
$res
=
$normExtendBus
->
getConditionalQueryAll
([
'norm_id'
=>
$norm_id
,
'user_filled'
=>
0
]);
$new
=
[];
foreach
(
$res
as
$index
=>
$vlaue
){
array_push
(
$new
,[
'name'
=>
$vlaue
[
'extend_name'
],
'value'
=>
$vlaue
[
'extend_value'
]]);
}
$old
=
$queryArr
[
'dynamicItem'
];
// 判断是否有更新的内容
if
(
$new
!=
$old
){
$displayArea
=
true
;
}
/******************************************用户端修改了内容*********************/
$normExtendBus
=
new
CommonBus
(
'NormExtendBus'
);
$res
=
$normExtendBus
->
getConditionalQueryAll
([
'norm_id'
=>
$norm_id
,
'user_filled'
=>
1
]);
$new
=
[];
foreach
(
$res
as
$index
=>
$vlaue
){
array_push
(
$new
,[
'name'
=>
$vlaue
[
'extend_name'
],
'radio'
=>
$vlaue
[
'required'
],
'remarks'
=>
$vlaue
[
'extend_remarks'
]]);
}
$old
=
$queryArr
[
'userFilled'
];
if
(
$new
!=
$old
){
$userArea
=
true
;
}
// 执行相关操作
if
(
$displayArea
){
$this
->
editDele
(
$queryArr
);
}
if
(
$userArea
){
$this
->
editSave
(
$queryArr
);
}
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.success"
),[]);
}
catch
(
\Exception
$e
){
exception
(
$e
,
'Norm.edit'
);
}
}
/**
* 修改了展示端的内容,删除相关信息
* @param $queryArr
* @return \josn|void
*/
public
function
editDele
(
$queryArr
)
{
try
{
$data
=
array
();
$normId
=
trim
(
$queryArr
[
'norm_id'
]);
$normBus
=
new
CommonBus
(
'NormBus'
);
// 通过公共业务初始化指标类
...
...
@@ -321,7 +387,7 @@ class Norm
'refer'
=>
$data
[
'refer'
],
'price'
=>
$data
[
'price'
],
'guide'
=>
$data
[
'guide'
],
'num'
=>
2
'num'
=>
$this
->
num
];
$normBus
=
new
CommonBus
(
'NormBus'
);
// 通过公共业务初始化指标类
// 检查指标名称是否有重复
...
...
@@ -391,7 +457,7 @@ class Norm
$normList
[
'price'
]
=
$data
[
'price'
];
$normList
[
'guide'
]
=
$data
[
'guide'
];
$normList
[
'status'
]
=
0
;
$normList
[
'num'
]
=
2
;
$normList
[
'num'
]
=
$this
->
num
;
$normList
[
'sort'
]
=
$data
[
'sort'
];
$normListBus
=
new
CommonBus
(
'NormListBus'
);
// 通过公共业务初始化用户待领取指标类
$normListId
=
$normListBus
->
addData
(
$normList
);
...
...
@@ -422,7 +488,44 @@ class Norm
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.null_data"
),[]);
}
}
catch
(
\Exception
$e
){
exception
(
$e
,
'Norm.add'
);
exception
(
$e
,
'Norm.editDele'
);
}
}
/**
* 修改了用户端的内容,修改领取状态保存信息
* @param $data
* @return void
*/
public
function
editSave
(
$queryArr
)
{
try
{
$normId
=
$queryArr
[
'norm_id'
];
// 指标扩展数据
$normExtendList
=
[];
// 将自定义填写的数据格式化
foreach
(
$queryArr
[
'userFilled'
]
as
$value
){
$arr
=
[
'norm_id'
=>
$normId
,
'extend_name'
=>
$value
[
'name'
],
'extend_value'
=>
''
,
'user_filled'
=>
1
,
'required'
=>
$value
[
'radio'
],
'extend_type'
=>
1
,
'extend_remarks'
=>
$value
[
'remarks'
]];
array_push
(
$normExtendList
,
$arr
);
}
$normExtendBus
=
new
CommonBus
(
'NormExtendBus'
);
$normExtendBus
->
conditionDeletion
([
'norm_id'
=>
$normId
,
'user_filled'
=>
1
]);
$NormCollectsBus
=
new
CommonBus
(
'NormCollectsBus'
);
$NormCollectsBus
->
conditionDeletion
([
'norm_id'
=>
$normId
]);
$NormCollectsExtendBus
=
new
CommonBus
(
'NormCollectsExtendBus'
);
$NormCollectsExtendBus
->
conditionDeletion
([
'norm_id'
=>
$normId
]);
$res
=
$normExtendBus
->
addData
(
$normExtendList
);
$normReceivesBus
=
new
CommonBus
(
'NormReceivesBus'
);
$normReceivesBus
->
updateData
([
'status'
=>
0
],[
'norm_id'
=>
$normId
]);
$PreserveBus
=
new
CommonBus
(
'PreserveBus'
);
$PreserveBus
->
conditionDeletion
([
'norm_id'
=>
$normId
]);
if
(
$res
){
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.success"
),
$res
);
}
else
{
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.null_data"
),[]);
}
}
catch
(
\Exception
$e
){
exception
(
$e
,
'Norm.editSave'
);
}
}
...
...
app/api/controller/NormCollects.php
View file @
7ae05594
...
...
@@ -275,6 +275,7 @@ class NormCollects extends AuthBase
{
try
{
$data
=
[];
$data
[
'norm_id'
]
=
input
(
"param.norm_id"
);
$data
[
'norm_receive_id'
]
=
input
(
"param.norm_receive_id"
,
''
,
"trim"
);
$data
[
'content'
]
=
input
(
"param.content"
,
''
,
"trim"
);
$data
[
'editor'
]
=
input
(
"param.editor"
);
...
...
@@ -294,6 +295,27 @@ class NormCollects extends AuthBase
exception
(
$e
,
'NormCollects.preserve'
);
}
}
/**
* 数据不可采集
* @return void
*/
public
function
notCollectible
()
{
$id
=
input
(
"param.id"
);
$remarks
=
input
(
"param.reason"
);
if
(
empty
(
$id
)
||
empty
(
$remarks
)){
return
returnResult
(
config
(
"config.code.error"
),
'请填写不可采集的原因!'
,
''
);
}
$NormReceivesBus
=
new
\app\api\business\CommonBus
(
'NormReceivesBus'
);
// 通过公共业务初始化指标类
$res
=
$NormReceivesBus
->
updateData
([
'not_collectible_remarks'
=>
$remarks
,
'status'
=>
1
,
'not_collectible'
=>
1
],[
'id'
=>
$id
]);
if
(
$res
){
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.success"
),
$res
);
}
else
{
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.null_data"
),[]);
}
}
/**
* 数据保存
* @return void
...
...
app/api/controller/NormList.php
View file @
7ae05594
...
...
@@ -18,6 +18,8 @@ class NormList extends AuthBase
try
{
$data
=
array
();
// 数据接收
$data
[
'task_id'
]
=
input
(
"param.task_id"
);
$data
[
'sort'
]
=
input
(
"param.sort"
);
$data
[
'page'
]
=
input
(
"param.page"
,
0
,
"intval"
);
$data
[
'limit'
]
=
input
(
"param.limit"
,
0
,
"intval"
);
$data
[
'name'
]
=
input
(
"param.name"
);
...
...
app/api/controller/NormOrders.php
View file @
7ae05594
...
...
@@ -24,6 +24,10 @@ class NormOrders extends AuthBase
$data
[
'limit'
]
=
input
(
"param.limit"
,
0
,
"intval"
);
$data
[
'name'
]
=
input
(
"param.name"
);
$data
[
'user_id'
]
=
input
(
"param.user_id"
);
$data
[
'admin'
]
=
input
(
"param.admin"
)
?
input
(
"param.admin"
)
:
0
;
if
(
$data
[
'admin'
]
==
0
){
$data
[
'user_id'
]
=
$this
->
userId
;
}
$NormOrdersBus
=
new
\app\api\business\NormOrdersBus
;
// 分页数据
if
(
$data
[
'page'
]
==
-
1
){
...
...
@@ -87,7 +91,9 @@ class NormOrders extends AuthBase
if
(
empty
(
$result
)){
$index
++
;
}
array_push
(
$addList
,
$data
);
if
(
$value
[
'not_collectible'
]
!=
1
){
array_push
(
$addList
,
$data
);
}
}
}
// 处理单个用户多条数据合并问题
...
...
app/api/controller/NormReceives.php
View file @
7ae05594
...
...
@@ -24,7 +24,9 @@ class NormReceives extends AuthBase
$data
[
'name'
]
=
input
(
"param.name"
);
$data
[
'task_id'
]
=
input
(
"param.task_id"
);
$data
[
'status'
]
=
input
(
"param.status"
);
$data
[
'user_id'
]
=
input
(
"param.user_id"
);
$data
[
'order'
]
=
input
(
"param.order"
)
?
input
(
"param.order"
)
:
'desc'
;
// $data['user_id'] = $this->userId;
$data
[
'admin'
]
=
input
(
"param.admin"
)
?
input
(
"param.admin"
)
:
0
;
if
(
$data
[
'admin'
]
==
0
){
...
...
app/api/controller/TaskPackage.php
View file @
7ae05594
...
...
@@ -11,6 +11,8 @@
namespace
app\api\controller
;
use
app\api\business\CommonBus
as
CommonBus
;
class
TaskPackage
extends
AuthBase
{
/**
...
...
@@ -32,6 +34,25 @@ class TaskPackage extends AuthBase
}
else
{
//查询全部数据
$result
=
$bus
->
pagingListData
(
$data
);
//获取所有数据带分页
foreach
(
$result
[
'data'
]
as
$index
=>
$value
)
{
// $normBus = new CommonBus('normBus'); // 通过公共业务初始化指标类
// $normRes = $normBus->getConditionalQuery(['task_id'=>$value['id']]);
// // 领取进度
$NormListBus
=
new
CommonBus
(
'NormListBus'
);
// 通过公共业务初始化指标类
$totalDegree
=
$NormListBus
->
getConditionalQueryAll
([
'task_id'
=>
$value
[
'id'
]]);
$NormReceivesBus
=
new
CommonBus
(
'NormReceivesBus'
);
// 通过公共业务初始化指标类
$receivedTimes
=
$NormReceivesBus
->
getConditionalQueryAll
([
'task_id'
=>
$value
[
'id'
]]);
$NormCollectsBus
=
new
CommonBus
(
'NormCollectsBus'
);
// 通过公共业务初始化指标类
$collectsTimes
=
$NormCollectsBus
->
getConditionalQueryAll
([
'task_id'
=>
$value
[
'id'
]]);
if
(
$totalDegree
){
$totalNum
=
count
(
$totalDegree
)
*
$totalDegree
[
0
][
'num'
];
$result
[
'data'
][
$index
][
'receivedQuantity'
]
=
count
(
$receivedTimes
)
.
'/'
.
$totalNum
;
$result
[
'data'
][
$index
][
'collectsQuantity'
]
=
count
(
$collectsTimes
)
.
'/'
.
$totalNum
;
}
else
{
$result
[
'data'
][
$index
][
'receivedQuantity'
]
=
'0/0'
;
$result
[
'data'
][
$index
][
'collectsQuantity'
]
=
'0/0'
;
}
}
}
if
(
$result
){
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.success"
),
$result
);
...
...
app/api/route/api.php
View file @
7ae05594
...
...
@@ -81,6 +81,7 @@ Route::rule("normCollects/preserve","NormCollects/preserve"); // 填写数据保
Route
::
rule
(
"normCollects/getPreserve"
,
"NormCollects/getPreserve"
);
// 数据获取
Route
::
rule
(
"normCollects/detail"
,
"normCollects/detail"
);
// 查看指标填写详情
Route
::
rule
(
"normCollects/modify"
,
"normCollects/modify"
);
// 修改指标填写详情
Route
::
rule
(
"normCollects/notCollectible"
,
"normCollects/notCollectible"
);
// 数据不可采集
/***************************上传 */
Route
::
rule
(
"upload/picture"
,
"upload/picture"
);
...
...
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