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
5615cfc3
Commit
5615cfc3
authored
Apr 15, 2024
by
wenyi.chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
导入pdf
parent
eac39d4d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
107 additions
and
70 deletions
+107
-70
app/api/controller/ExcelFile.php
+24
-62
app/api/controller/ExcelFilessssssss.php
+0
-0
app/api/controller/Norm.php
+35
-1
app/api/controller/NormCollects.php
+28
-2
app/api/controller/TaskPackage.php
+9
-4
app/api/controller/Upload.php
+3
-1
app/api/route/api.php
+2
-0
runtime/session/sess_75f1472990e8c7cb747f128032bfb5ca
+2
-0
runtime/session/sess_aed0a9a703105fef024f8acb001acb3b
+2
-0
runtime/session/sess_b2b45fb0b1ecabc88f659ca396a1b9b1
+2
-0
No files found.
app/api/controller/ExcelFile.php
View file @
5615cfc3
...
...
@@ -19,64 +19,9 @@ use think\facade\Env;
use
think\facade\Db
;
class
ExcelFile
extends
BaseController
{
public
function
importFile1
()
{
try
{
$spreadsheet
=
IOFactory
::
load
(
'./import/测试.xls'
);
// $allSheets = $spreadsheet->getAllSheets();
$objWorksheet
=
$spreadsheet
->
getSheet
(
0
);
$drawings
=
$objWorksheet
->
getDrawingCollection
();
$imgList
=
[];
foreach
(
$drawings
as
$index
=>
$drawing
)
{
// 图片类型:JPEG, PNG, GIF
$imageType
=
$drawing
->
getExtension
();
$imageName
=
'image_'
.
$index
.
'.'
.
$imageType
;
$imagePath
=
'images/'
.
$imageName
;
// 保存图片到本地
$drawing
->
getPath
()
?
Filesystem
::
put
(
$imagePath
,
file_get_contents
(
$drawing
->
getPath
()))
:
$drawing
->
save
(
$imagePath
);
array_push
(
$imgList
,
$imagePath
);
// echo "图片已保存到:{$imagePath}\n";
}
dump
(
$imgList
);
// $data = $objWorksheet->toArray();
// $list = [];
// $i=0;
// foreach ($data as $index=>$value){
// if($index>0){
// $arr = [
// 'task_id'=>1,
// 'name'=>$value[1], // 指标名称
// 'level'=>1, // 难度等级
// 'name2'=>$value[4], // 参考信源
// 'name3'=>$value[5], // 单价
// 'name4'=>$value[6], // 参考指南
// 'name5'=>$value[7], // 任务状态
// 'name6'=>$value[8], //优先级高中低(3,2,1)
// 'name7'=>$value[9], //可领取次数
// 'name8'=>$value[10],
// 'name9'=>$value[11],
// 'name10'=>$value[12],
// 'name11'=>$value[13],
// 'name12'=>$value[14],
// 'name13'=>$value[15],
// 'name14'=>$value[16],
// ];
// if(empty($value[10])){
// $arr['name8'] = $imgList[$i];
// $i++;
// }
// array_push($list,$arr);
// }
// }
}
catch
(
\Exception
$e
){
exception
(
$e
,
'ExcelFile.importFile'
);
}
}
/**
* 格式化文件数据
*
导入指标
格式化文件数据
* @param $file //excel文件地址
* @return array|void
*/
...
...
@@ -89,7 +34,8 @@ class ExcelFile extends BaseController
$imgList
=
[];
foreach
(
$drawings
as
$index
=>
$drawing
)
{
// 图片类型:JPEG, PNG, GIF
$imageType
=
$drawing
->
getExtension
();
$imageType
=
'png'
;
// $imageType = $drawing->getExtension();
$imageName
=
'image_'
.
time
()
.
$index
.
'.'
.
$imageType
;
$imagePath
=
'images/'
.
$imageName
;
$savePath
=
config
(
"config.resource_address"
)
.
'public/storage/images/'
.
$imageName
;
...
...
@@ -119,6 +65,8 @@ class ExcelFile extends BaseController
'not_collectible'
=>
''
,
// 是否可以采集
'not_collectible_remarks'
=>
''
,
//原因
'imgPath'
=>
''
,
//图片路径
'fileListPdf'
=>
''
,
//文件路径
'file_name'
=>
''
//文件名称
];
// 指标名称
if
(
empty
(
$value
[
$current
])){
...
...
@@ -129,7 +77,6 @@ class ExcelFile extends BaseController
$arr
[
'name'
]
=
$value
[
$current
];
$current
++
;
}
// 信源类型
if
(
empty
(
$value
[
$current
])){
$error
++
;
...
...
@@ -156,6 +103,12 @@ class ExcelFile extends BaseController
$arr
[
'remark'
]
=
$value
[
$current
];
$current
++
;
// 文件路径
$arr
[
'fileListPdf'
]
=
$value
[
$current
];
$current
++
;
// 文件名称
$arr
[
'file_name'
]
=
$value
[
$current
];
$current
++
;
$adminSign
=
0
;
// 需要读取的列数 3 2
// 展示端数量
if
(
is_numeric
(
$value
[
$current
])){
...
...
@@ -188,7 +141,7 @@ class ExcelFile extends BaseController
$userSign
=
0
;
// 需要读取的列数
// 用户端数量
if
(
is_numeric
(
$value
[
$current
])){
if
(
$value
[
$current
]
>
2
0
){
if
(
$value
[
$current
]
>
5
0
){
$error
++
;
$errorInfo
=
'用户端自定义数值超出范围!'
;
break
;
...
...
@@ -280,7 +233,13 @@ class ExcelFile extends BaseController
$normInfo
[
'price'
]
=
input
(
'price'
);
$normInfo
[
'guide'
]
=
input
(
'guide'
);
$normInfo
[
'sort'
]
=
input
(
'sort'
);
$normInfo
[
'type'
]
=
input
(
'type'
);
$normInfo
[
'type'
]
=
1
;
Db
::
startTrans
();
$info
=
Db
::
name
(
'norm'
)
->
where
(
'name'
,
$normInfo
[
'name'
])
->
find
();
if
(
$info
){
$res
[
'message'
]
=
'子任务名称已存在!'
;
return
returnResult
(
config
(
"config.code.error"
),
$res
[
'message'
]);
}
$norm_id
=
Db
::
name
(
'norm'
)
->
insertGetId
(
$normInfo
);
$file
=
request
()
->
file
(
'file'
);
// 上传到本地服务器
...
...
@@ -305,7 +264,7 @@ class ExcelFile extends BaseController
return
returnResult
(
config
(
"config.code.error"
),
$res
[
'message'
]);
}
// 开启数据库事务
Db
::
startTrans
()
;
$control
=
1
;
$user_id
=
1
;
//用户ID
$normExtendSql
=
[];
// 指标自定义
// 展时端自定义
...
...
@@ -354,6 +313,7 @@ class ExcelFile extends BaseController
'num'
=>
0
,
'sort'
=>
$normInfo
[
'sort'
],
'guide'
=>
$normInfo
[
'guide'
],
'type'
=>
1
,
];
$norm_list_id
=
Db
::
name
(
'norm_list'
)
->
insertGetId
(
$arr
);
...
...
@@ -393,6 +353,8 @@ class ExcelFile extends BaseController
'refer_type'
=>
$value
[
'refer_type'
],
'remark'
=>
$value
[
'remark'
],
'imgPath'
=>
$value
[
'imgPath'
],
'fileListPdf'
=>
$value
[
'fileListPdf'
],
'file_name'
=>
$value
[
'file_name'
],
];
$norm_collects_id
=
Db
::
name
(
'norm_collects'
)
->
insertGetId
(
$arr
);
...
...
@@ -766,7 +728,7 @@ class ExcelFile extends BaseController
try
{
$Ids
=
input
(
'ids'
);
if
(
empty
(
$Ids
)){
return
returnResult
(
config
(
"config.code.
success
"
),
'请选择导出的子任务!'
,[]);
return
returnResult
(
config
(
"config.code.
error
"
),
'请选择导出的子任务!'
,[]);
}
$data
=
[];
foreach
(
$Ids
as
$value
){
...
...
app/api/controller/ExcelFilessssssss.php
0 → 100644
View file @
5615cfc3
This diff is collapsed.
Click to expand it.
app/api/controller/Norm.php
View file @
5615cfc3
...
...
@@ -115,7 +115,6 @@ class Norm
'refer'
=>
$data
[
'refer'
],
'price'
=>
$data
[
'price'
],
'guide'
=>
$data
[
'guide'
],
'type'
=>
1
,
'num'
=>
$this
->
num
,
];
$normBus
=
new
CommonBus
(
'NormBus'
);
// 通过公共业务初始化指标类
...
...
@@ -529,6 +528,41 @@ class Norm
}
/**
* 删除任务
* @return \josn|void
*/
public
function
delete
()
{
try
{
// 数据接收
$normId
=
input
(
"param.norm_id"
,
''
,
"trim"
);
// 业务处理
Db
::
startTrans
();
$control
=
1
;
$bus
=
new
\app\api\business\CommonBus
(
'NormBus'
);
$info
=
$bus
->
deleteData
(
$normId
);
$NormCollectsBus
=
new
\app\api\business\CommonBus
(
'NormCollectsBus'
);
$result
=
$NormCollectsBus
->
conditionDeletion
([
'norm_id'
=>
$normId
]);
$NormCollectsExtendBus
=
new
\app\api\business\CommonBus
(
'NormCollectsExtendBus'
);
$result
=
$NormCollectsExtendBus
->
conditionDeletion
([
'norm_id'
=>
$normId
]);
$NormListBus
=
new
\app\api\business\CommonBus
(
'NormListBus'
);
$result
=
$NormListBus
->
conditionDeletion
([
'norm_id'
=>
$normId
]);
$NormReceivesBus
=
new
\app\api\business\CommonBus
(
'NormReceivesBus'
);
$result
=
$NormReceivesBus
->
conditionDeletion
([
'norm_id'
=>
$normId
]);
// 全部添加完成提交
if
(
$control
==
1
){
Db
::
commit
();
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.success"
),
$info
);
}
else
{
Db
::
rollback
();
return
returnResult
(
config
(
"config.code.success"
),
config
(
"config.describe.null_data"
),[]);
}
}
catch
(
\Exception
$e
){
exception
(
$e
,
'TaskPackage.add'
);
}
}
/**
* 返回最后一条信息
* @return \josn|void
*/
...
...
app/api/controller/NormCollects.php
View file @
5615cfc3
...
...
@@ -30,7 +30,6 @@ class NormCollects extends AuthBase
$data
[
'remark'
]
=
trim
(
$queryArr
[
'addItem'
][
'remark'
]);
$data
[
'imgPath'
]
=
$queryArr
[
'editorImgList'
];
$data
[
'fileListPdf'
]
=
$queryArr
[
'fileListPdf'
];
$data
[
'editorContent'
]
=
$queryArr
[
'editorContent'
];
$data
[
'user_id'
]
=
$this
->
userId
;
if
(
empty
(
$data
[
'norm_list_id'
])
||
empty
(
$data
[
'task_id'
])
||
empty
(
$data
[
'norm_id'
])
||
empty
(
$data
[
'norm_receive_id'
])
||
empty
(
$data
[
'user_id'
])){
errorRecord
(
'NormCollects.add'
,
json_encode
(
$data
),
true
);
...
...
@@ -56,9 +55,17 @@ class NormCollects extends AuthBase
$data
[
'imgPath'
]
=
''
;
}
if
(
$data
[
'fileListPdf'
]){
$data
[
'fileListPdf'
]
=
implode
(
','
,
$data
[
'fileListPdf'
]);
$file_name
=
[];
$fileUrl
=
[];
foreach
(
$data
[
'fileListPdf'
]
as
$value
){
array_push
(
$file_name
,
$value
[
'name'
]);
array_push
(
$fileUrl
,
$value
[
'url'
]);
}
$data
[
'fileListPdf'
]
=
implode
(
','
,
$fileUrl
);
$data
[
'file_name'
]
=
implode
(
','
,
$file_name
);
}
else
{
$data
[
'fileListPdf'
]
=
''
;
$data
[
'file_name'
]
=
''
;
}
$NormCollectsBus
=
new
\app\api\business\CommonBus
(
'NormCollectsBus'
);
// 通过公共业务初始化指标类
$res
=
$NormCollectsBus
->
getConditionalQuery
(
$arr
);
...
...
@@ -195,6 +202,8 @@ class NormCollects extends AuthBase
$data
[
'remark'
]
=
trim
(
$queryArr
[
'addItem'
][
'remark'
]);
$data
[
'imgPath'
]
=
$queryArr
[
'editorImgList'
];
$data
[
'editorContent'
]
=
$queryArr
[
'editorContent'
];
$fileListPdf
=
$queryArr
[
'fileListPdf'
];
$originalUpload
=
$queryArr
[
'originalUpload'
];
$data
[
'user_id'
]
=
$this
->
userId
;
if
(
empty
(
$data
[
'norm_list_id'
])
||
empty
(
$data
[
'task_id'
])
||
empty
(
$data
[
'norm_id'
])
||
empty
(
$data
[
'norm_receive_id'
])
||
empty
(
$data
[
'user_id'
])){
errorRecord
(
'NormCollects.add'
,
json_encode
(
$data
),
true
);
...
...
@@ -219,6 +228,21 @@ class NormCollects extends AuthBase
}
else
{
$data
[
'imgPath'
]
=
''
;
}
// 新文件上传
$data
[
'fileListPdf'
]
=
array_merge
(
$fileListPdf
,
$originalUpload
);
if
(
$data
[
'fileListPdf'
]){
$file_name
=
[];
$fileUrl
=
[];
foreach
(
$data
[
'fileListPdf'
]
as
$value
){
array_push
(
$file_name
,
$value
[
'name'
]);
array_push
(
$fileUrl
,
$value
[
'url'
]);
}
$data
[
'fileListPdf'
]
=
implode
(
','
,
$fileUrl
);
$data
[
'file_name'
]
=
implode
(
','
,
$file_name
);
}
else
{
$data
[
'fileListPdf'
]
=
''
;
$data
[
'file_name'
]
=
''
;
}
$NormCollectsBus
=
new
\app\api\business\CommonBus
(
'NormCollectsBus'
);
// 通过公共业务初始化指标类
$res
=
$NormCollectsBus
->
getConditionalQuery
(
$arr
);
if
(
empty
(
$res
)){
...
...
@@ -235,6 +259,8 @@ class NormCollects extends AuthBase
'remark'
=>
$data
[
'remark'
],
'imgPath'
=>
$data
[
'imgPath'
],
'editorContent'
=>
$data
[
'editorContent'
],
'fileListPdf'
=>
$data
[
'fileListPdf'
],
'file_name'
=>
$data
[
'file_name'
],
];
$update
=
$NormCollectsBus
->
updateData
(
$updateData
,
$where
);
if
(
empty
(
$update
)){
...
...
app/api/controller/TaskPackage.php
View file @
5615cfc3
...
...
@@ -40,15 +40,20 @@ class TaskPackage extends AuthBase
// $normRes = $normBus->getConditionalQuery(['task_id'=>$value['id']]);
// // 领取进度
$NormBus
=
new
CommonBus
(
'NormBus'
);
// 通过公共业务初始化指标类
$NormInfo
=
$NormBus
->
getConditionalQuery
([
'task_id'
=>
$value
[
'id'
]]);
$NormInfo
=
$NormBus
->
getConditionalQuery
([
'task_id'
=>
$value
[
'id'
]
,
'type'
=>
0
]);
$NormListBus
=
new
CommonBus
(
'NormListBus'
);
// 通过公共业务初始化指标类
$totalDegree
=
$NormListBus
->
getConditionalQueryAll
([
'task_id'
=>
$value
[
'id'
]]);
$totalDegree
=
$NormListBus
->
getConditionalQueryAll
([
'task_id'
=>
$value
[
'id'
]
,
'type'
=>
0
]);
$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
)
*
$NormInfo
[
'num'
];
if
(
empty
(
$NormInfo
)){
$num
=
0
;
}
else
{
$num
=
$NormInfo
[
'num'
];
}
$totalNum
=
count
(
$totalDegree
)
*
$num
;
$result
[
'data'
][
$index
][
'receivedQuantity'
]
=
count
(
$receivedTimes
)
.
'/'
.
$totalNum
;
$result
[
'data'
][
$index
][
'collectsQuantity'
]
=
count
(
$collectsTimes
)
.
'/'
.
$totalNum
;
}
else
{
...
...
@@ -92,7 +97,7 @@ class TaskPackage extends AuthBase
}
/**
*
发布
任务
*
删除
任务
* @return \josn|void
*/
public
function
delete
()
...
...
app/api/controller/Upload.php
View file @
5615cfc3
...
...
@@ -69,6 +69,7 @@ class Upload
return
json
([
'errno'
=>
0
,
'data'
=>
[
'name'
=>
$file
->
getOriginalName
(),
'url'
=>
$url
,
'alt'
=>
$image_name
,
]
...
...
@@ -77,8 +78,9 @@ class Upload
// 文件上传失败
return
json
([
'errno'
=>
1
,
'name'
=>
''
,
'data'
=>
[],
'msg'
=>
$file
->
getError
()
'msg'
=>
'上传失败!'
]);
}
}
catch
(
\Exception
$e
){
...
...
app/api/route/api.php
View file @
5615cfc3
...
...
@@ -55,6 +55,7 @@ Route::rule("tasks/receive","TaksReceives/receive"); // 用户领取操作
/***************************任务包相关 */
Route
::
rule
(
"taskPackage/add"
,
"TaskPackage/add"
);
// 发布任务
Route
::
rule
(
"taskPackage/list"
,
"TaskPackage/list"
);
// 所有任务列表
Route
::
rule
(
"taskPackage/delete"
,
"TaskPackage/delete"
);
// 删除任务列表
/***************************指标相关 */
Route
::
rule
(
"norm/add"
,
"Norm/add"
);
// 新增指标
...
...
@@ -62,6 +63,7 @@ Route::rule("norm/list","Norm/list"); // 指标列表
Route
::
rule
(
"norm/detail"
,
"Norm/detail"
);
// 指标详情
Route
::
rule
(
"norm/edit"
,
"Norm/edit"
);
// 指标详情
Route
::
rule
(
"norm/finalData"
,
"Norm/finalData"
);
// 返回最后的ID
Route
::
rule
(
"norm/delete"
,
"Norm/delete"
);
// 删除详情
/***************************指标领取相关 */
Route
::
rule
(
"normList/list"
,
"NormList/list"
);
// 指标待领取
...
...
runtime/session/sess_75f1472990e8c7cb747f128032bfb5ca
0 → 100644
View file @
5615cfc3
a:1:{s:5:"users";a:10:{s:2:"id";i:1;s:4:"name";s:12:"开发人员";s:5:"phone";s:11:"18417180202";s:7:"account";s:5:"admin";s:8:"password";s:32:"e10adc3949ba59abbe56e057f20f883e";s:6:"status";i:1;s:4:"type";i:1;s:11:"create_time";s:1:"1";s:5:"email";s:18:"wesley_prc@163.com";s:13:"department_id";i:3;}}
\ No newline at end of file
runtime/session/sess_aed0a9a703105fef024f8acb001acb3b
0 → 100644
View file @
5615cfc3
a:1:{s:5:"users";a:10:{s:2:"id";i:3;s:4:"name";s:10:"管理员1";s:5:"phone";s:11:"18417180202";s:7:"account";s:8:"admin001";s:8:"password";s:32:"e10adc3949ba59abbe56e057f20f883e";s:6:"status";i:1;s:4:"type";i:1;s:11:"create_time";s:10:"1709196711";s:5:"email";s:0:"";s:13:"department_id";i:1;}}
\ No newline at end of file
runtime/session/sess_b2b45fb0b1ecabc88f659ca396a1b9b1
0 → 100644
View file @
5615cfc3
a:1:{s:5:"users";a:10:{s:2:"id";i:1;s:4:"name";s:12:"开发人员";s:5:"phone";s:11:"18417180202";s:7:"account";s:5:"admin";s:8:"password";s:32:"e10adc3949ba59abbe56e057f20f883e";s:6:"status";i:1;s:4:"type";i:1;s:11:"create_time";s:1:"1";s:5:"email";s:18:"wesley_prc@163.com";s:13:"department_id";i:3;}}
\ No newline at end of file
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