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
20a05623
Commit
20a05623
authored
Apr 01, 2024
by
wenyi.chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
线上
parent
173e63d1
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
114 additions
and
21 deletions
+114
-21
app/api/controller/ExcelFile.php
+80
-6
app/api/controller/Norm.php
+4
-9
app/api/controller/NormReceives.php
+3
-0
app/api/controller/Test.php
+2
-2
app/api/route/api.php
+6
-2
app/common/model/mysql/NormReceives.php
+1
-2
runtime/session/sess_1ce1969e23af14a3c33b94a5a4ac36bc
+2
-0
runtime/session/sess_2af0a735c3ba6aa7da2b3a08b0e9d393
+2
-0
runtime/session/sess_2be01c0c815c8f0fa18313e2dcbe5321
+2
-0
runtime/session/sess_4d5d280b0ad6c6c8a4da1272f74d52af
+2
-0
runtime/session/sess_5b81eff6e77c6e0831d5157a735daa55
+2
-0
runtime/session/sess_5fb10d26d97d29774ebf901ce4f163f2
+2
-0
runtime/session/sess_7d6bf69b3c1a63dbd59f179797db18e6
+2
-0
runtime/session/sess_aa33c33c11ef7e01a0d67a51ca8422a8
+2
-0
runtime/session/sess_dc60b8fc7f95811a898a1084e4d11609
+2
-0
No files found.
app/api/controller/Excel
Test
.php
→
app/api/controller/Excel
File
.php
View file @
20a05623
...
...
@@ -16,12 +16,13 @@ use think\facade\Filesystem;
use
PhpOffice\PhpSpreadsheet\Spreadsheet
;
use
PhpOffice\PhpSpreadsheet\Writer\Xlsx
;
use
think\facade\Env
;
class
ExcelTest
extends
BaseController
use
think\facade\Db
;
class
ExcelFile
extends
BaseController
{
public
function
importFile
()
{
try
{
$spreadsheet
=
IOFactory
::
load
(
'
excel_with_image
.xlsx'
);
$spreadsheet
=
IOFactory
::
load
(
'
import
.xlsx'
);
// $allSheets = $spreadsheet->getAllSheets();
$objWorksheet
=
$spreadsheet
->
getSheet
(
0
);
$drawings
=
$objWorksheet
->
getDrawingCollection
();
...
...
@@ -81,8 +82,8 @@ class ExcelTest extends BaseController
// 创建一个新的 Spreadsheet 对象
$spreadsheet
=
new
Spreadsheet
();
$list
=
[];
for
(
$i
=
0
;
$i
<
10
;
$i
++
){
if
(
$i
%
2
00
==
0
){
for
(
$i
=
0
;
$i
<
10
0
;
$i
++
){
if
(
$i
%
2
==
0
){
array_push
(
$list
,
$data
[
1
]);
}
else
{
array_push
(
$list
,
$data
[
0
]);
...
...
@@ -124,9 +125,82 @@ class ExcelTest extends BaseController
$drawing
->
setWidth
(
80
);
// 图片宽度,单位为磅
}
}
// 保存 Excel
Test
文件
// 保存 Excel
File
文件
$writer
=
new
Xlsx
(
$spreadsheet
);
$writer
->
save
(
'excel_with_image.xlsx'
);
$writer
->
save
(
'import.xlsx'
);
}
catch
(
\Exception
$e
){
var_dump
(
$e
->
getMessage
());
}
}
public
function
taskExportFile
()
{
try
{
$task
=
Db
::
table
(
'task_package'
)
->
where
(
'id'
,
22
)
->
find
();
$norm
=
Db
::
table
(
'norm'
)
->
where
(
'task_id'
,
22
)
->
select
();
$list
=
[];
foreach
(
$norm
as
$value
){
$sheet
=
[
'total'
=>
0
,
'data'
=>
[]];
$normList
=
Db
::
table
(
'norm_list'
)
->
where
(
'norm_id'
,
$value
[
'id'
])
->
select
();
foreach
(
$normList
as
$index
=>
$val
){
$total
=
0
;
$normCollects
=
Db
::
table
(
'norm_collects'
)
->
where
(
'norm_list_id'
,
$val
[
'id'
])
->
find
();
$referType
=
'无'
;
// 信源类型
$imgPath
=
'无'
;
// 图片
$remark
=
'无'
;
$normCollectsId
=
''
;
if
(
$normCollects
){
if
(
$normCollects
[
'refer_type'
]
==
1
){
$referType
=
'官网/政府'
;
}
else
if
(
$normCollects
[
'refer_type'
]
==
2
){
$referType
=
'权威媒体'
;
}
else
{
$referType
=
'其他可信信源'
;
}
if
(
$normCollects
[
'imgPath'
]){
$imgPath
=
$normCollects
[
'imgPath'
];
}
if
(
$normCollects
[
'remark'
]){
$remark
=
$normCollects
[
'remark'
];
}
$normCollectsId
=
$normCollects
[
'id'
];
}
$data
=
[
$index
,
$val
[
'name'
],
$val
[
'level'
],
$val
[
'refer'
],
$val
[
'price'
],
$value
[
'guide'
],
$value
[
'sort'
],
$remark
,
$referType
,
];
$normListExtend
=
Db
::
table
(
'norm_list_extend'
)
->
where
(
'norm_list_id'
,
$val
[
'id'
])
->
select
();
// 添加展示端
foreach
(
$normListExtend
as
$extendValue
){
$total
+=
1
;
array_push
(
$data
,
$extendValue
[
'extend_name'
]);
array_push
(
$data
,
$extendValue
[
'extend_value'
]);
}
// 添加用户端
if
(
$normCollectsId
){
$collectsInfo
=
Db
::
table
(
'norm_collects_extend'
)
->
where
(
'norm_collects_id'
,
$normCollectsId
)
->
select
();
foreach
(
$collectsInfo
as
$collectsValue
){
$total
+=
1
;
array_push
(
$data
,
$collectsValue
[
'extend_name'
]);
array_push
(
$data
,
$collectsValue
[
'extend_value'
]);
}
}
// 添加图片信息
array_push
(
$data
,
$imgPath
);
// 添加第一条指标信息
$sheet
[
'total'
]
=
$total
;
array_push
(
$sheet
[
'data'
],
$data
);
}
array_push
(
$list
,
$sheet
);
}
dump
(
$list
);
}
catch
(
\Exception
$e
){
var_dump
(
$e
->
getMessage
());
}
...
...
app/api/controller/Norm.php
View file @
20a05623
...
...
@@ -13,7 +13,7 @@ use app\api\business\CommonBus as CommonBus; // 指标待领取扩展业务
use
think\facade\Db
;
class
Norm
{
public
$num
=
1
;
public
$num
=
2
;
/**
* 任务列表
* @return \josn|void
...
...
@@ -420,14 +420,10 @@ class Norm
array_push
(
$extend
,[
'name'
=>
$value
[
'name'
],
'value'
=>
$value
[
'value'
]]);
}
}
$keyName
=
[];
//每个值对应的名称
$ordering
=
[];
// 需要排列组合的数据
foreach
(
$extend
as
$value
){
$exp
=
explode
(
','
,
$value
[
'value'
]);
array_push
(
$ordering
,
$exp
);
foreach
(
$exp
as
$value1
){
array_push
(
$keyName
,[
$value
[
'name'
]
=>
$value1
]);
}
}
// 格式化数据
...
...
@@ -436,12 +432,11 @@ class Norm
// 格式化每个数据表需要的数据格式
foreach
(
$processedData
as
$value
){
$exp
=
explode
(
','
,
$value
);
foreach
(
$exp
as
$value1
){
foreach
(
$exp
as
$
index
=>
$
value1
){
$normList
=
[];
// 指标待领取数据
$normListExtend
=
[];
// 指标待领取数据扩展
$key
=
\app\common\lib\Arr
::
deepGetKey
(
$value1
,
$keyName
);
// 添加到用户待领取数据表
if
(
$
key
==
'名称'
){
if
(
$
index
==
0
){
$normList
[
'task_id'
]
=
$data
[
'task_id'
];
$normList
[
'norm_id'
]
=
$normId
;
$normList
[
'name'
]
=
$value1
;
...
...
@@ -461,7 +456,7 @@ class Norm
}
else
{
$normListExtend
[
'norm_id'
]
=
$normId
;
$normListExtend
[
'norm_list_id'
]
=
$normListId
;
$normListExtend
[
'extend_name'
]
=
$
key
;
$normListExtend
[
'extend_name'
]
=
$
extend
[
$index
][
'name'
]
;
$normListExtend
[
'extend_value'
]
=
$value1
;
$normListExtend
[
'extend_type'
]
=
1
;
$normListExtendBus
=
new
CommonBus
(
'NormListExtendBus'
);
// 通过公共业务初始化用户待领取指标扩展类
...
...
app/api/controller/NormReceives.php
View file @
20a05623
...
...
@@ -11,6 +11,7 @@ use think\facade\Db;
class
NormReceives
extends
AuthBase
{
public
$num
=
2
;
/**
* 当前可领取的指标列表
* @return \josn|void
...
...
@@ -176,9 +177,11 @@ class NormReceives extends AuthBase
$NormListBus
=
new
\app\api\business\CommonBus
(
'NormListBus'
);
$info
=
$NormListBus
->
getConditionalQuery
([
'id'
=>
$data
[
'norm_list_id'
]]);
if
(
$info
){
if
(
$info
[
'num'
]
>
0
){
$NormListBus
->
decrementing
(
$data
[
'norm_list_id'
],
1
);
//添加数据
$result
=
$NormReceivesBus
->
addData
(
$data
);
}
}
else
{
return
returnResult
(
config
(
"config.code.error"
),
'待领取指标ID错误!'
,
''
);
}
...
...
app/api/controller/Test.php
View file @
20a05623
...
...
@@ -26,7 +26,7 @@ class Test extends BaseController
$sheet
=
$spreadsheet
->
getActiveSheet
();
// 设置一些数据到单元格中
$sheet
->
setCellValue
(
'A1'
,
'带有图片的 Excel
Test
表格'
);
$sheet
->
setCellValue
(
'A1'
,
'带有图片的 Excel
File
表格'
);
// 创建一个 Drawing 对象,并设置图片的路径
$drawing
=
new
Drawing
();
...
...
@@ -40,7 +40,7 @@ class Test extends BaseController
$drawing
->
setHeight
(
36
);
// 图片高度,单位为磅
$drawing
->
setWidth
(
32
);
// 图片宽度,单位为磅
// 保存 Excel
Test
文件
// 保存 Excel
File
文件
$writer
=
new
Xlsx
(
$spreadsheet
);
$writer
->
save
(
'excel_with_image.xlsx'
);
}
catch
(
\Exception
$e
){
...
...
app/api/route/api.php
View file @
20a05623
...
...
@@ -93,6 +93,9 @@ Route::rule("normOrders/list","NormOrders/list"); //结算指标列表
Route
::
rule
(
"normOrders/detail"
,
"NormOrders/detail"
);
//结算指标列表
Route
::
rule
(
"test"
,
"ExcelTest/importFile"
);
//结算指标列表
Route
::
rule
(
"test1"
,
"ExcelTest/exportFile"
);
//结算指标列表
Route
::
rule
(
"importFile"
,
"ExcelFile/importFile"
);
//结算指标列表
Route
::
rule
(
"exportFile"
,
"ExcelFile/exportFile"
);
//结算指标列表
Route
::
rule
(
"taskExportFile"
,
"ExcelFile/taskExportFile"
);
//结算指标列表
//
Route
::
rule
(
"import"
,
"ImportFile/import"
);
\ No newline at end of file
app/common/model/mysql/NormReceives.php
View file @
20a05623
...
...
@@ -115,8 +115,7 @@ class NormReceives extends Model
try
{
return
$this
->
with
([
'userInfo'
=>
function
(
$query
){
$query
->
field
(
"id,name"
);
},
$query
->
field
(
"id,name"
);},
])
->
where
(
$where
)
->
find
();
}
catch
(
\Exception
$e
){
exception
(
$e
,
'mysql.NormReceives.getFindModel'
);
...
...
runtime/session/sess_1ce1969e23af14a3c33b94a5a4ac36bc
0 → 100644
View file @
20a05623
a:1:{s:5:"users";a:10:{s:2:"id";i:4;s:4:"name";s:13:"测试人员2";s:5:"phone";s:4:"2131";s:7:"account";s:7:"test002";s:8:"password";s:32:"e10adc3949ba59abbe56e057f20f883e";s:6:"status";i:1;s:4:"type";i:1;s:11:"create_time";s:10:"1708836112";s:5:"email";s:3:"123";s:13:"department_id";i:2;}}
\ No newline at end of file
runtime/session/sess_2af0a735c3ba6aa7da2b3a08b0e9d393
0 → 100644
View file @
20a05623
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_2be01c0c815c8f0fa18313e2dcbe5321
0 → 100644
View file @
20a05623
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:1;}}
\ No newline at end of file
runtime/session/sess_4d5d280b0ad6c6c8a4da1272f74d52af
0 → 100644
View file @
20a05623
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_5b81eff6e77c6e0831d5157a735daa55
0 → 100644
View file @
20a05623
a:1:{s:5:"users";a:10:{s:2:"id";i:2;s:4:"name";s:13:"测试人员1";s:5:"phone";s:4:"2131";s:7:"account";s:7:"test001";s:8:"password";s:32:"e10adc3949ba59abbe56e057f20f883e";s:6:"status";i:1;s:4:"type";i:1;s:11:"create_time";s:10:"1708836112";s:5:"email";s:3:"123";s:13:"department_id";i:2;}}
\ No newline at end of file
runtime/session/sess_5fb10d26d97d29774ebf901ce4f163f2
0 → 100644
View file @
20a05623
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:1;}}
\ No newline at end of file
runtime/session/sess_7d6bf69b3c1a63dbd59f179797db18e6
0 → 100644
View file @
20a05623
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:1;}}
\ No newline at end of file
runtime/session/sess_aa33c33c11ef7e01a0d67a51ca8422a8
0 → 100644
View file @
20a05623
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:1;}}
\ No newline at end of file
runtime/session/sess_dc60b8fc7f95811a898a1084e4d11609
0 → 100644
View file @
20a05623
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:1;}}
\ 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