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
b3bc53fa
Commit
b3bc53fa
authored
Sep 30, 2024
by
wenyi.chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
线上
parent
35f9033a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
123 additions
and
1 deletions
+123
-1
app/api/controller/ProductAllocation - 副本.php
+0
-0
app/api/controller/ProductAllocation.php
+4
-1
app/api/controller/Test.php
+117
-0
app/api/route/api.php
+2
-0
No files found.
app/api/controller/ProductAllocation - 副本.php
0 → 100644
View file @
b3bc53fa
This diff is collapsed.
Click to expand it.
app/api/controller/ProductAllocation.php
View file @
b3bc53fa
...
...
@@ -56,7 +56,7 @@ class ProductAllocation extends AuthBase
->
alias
(
't1'
)
->
join
(
'product t2'
,
't1.product_id=t2.id'
)
->
join
(
'admin t3'
,
't1.user_id=t3.id'
)
->
field
(
't1.status as product_allocation_status,t1.*'
)
->
field
(
't1.status as product_allocation_status,t1.
id as allocation_id,t1.
*'
)
->
field
(
't2.status as product_status,t2.*'
)
->
field
(
't3.status as admin_status,t3.*'
)
->
where
(
$where
)
...
...
@@ -126,6 +126,9 @@ class ProductAllocation extends AuthBase
$EnterpriseInfoModel
=
new
EnterpriseInfoModel
();
$AdminModel
=
new
AdminModel
();
$productAllocationInfo
=
$ProductAllocationModel
->
where
(
'id'
,
$id
)
->
find
();
if
(
empty
(
$productAllocationInfo
)){
return
returnResult
(
config
(
"config.code.error"
),
'未找到相关信息!'
);
}
$productInfo
=
$ProductModel
->
where
(
'id'
,
$productAllocationInfo
[
'product_id'
])
->
find
();
$enterpriseInfo
=
$EnterpriseInfoModel
->
where
(
'id'
,
$productInfo
[
'enterprise_id'
])
->
find
();
$adminInfo
=
$AdminModel
->
where
(
'id'
,
$productAllocationInfo
[
'user_id'
])
->
find
();
...
...
app/api/controller/Test.php
View file @
b3bc53fa
...
...
@@ -162,5 +162,121 @@ class Test
$res
=
Db
::
name
(
'enterprise_info'
)
->
where
(
'enterprise_name'
,
'亿嘉和科技股份有限公司'
)
->
select
();
dump
(
$res
);
}
public
function
exportData
()
{
$result
=
Db
::
name
(
'product'
)
->
where
(
'status'
,
1
)
->
select
();
$spreadsheet
=
new
Spreadsheet
();
$writer
=
new
Xlsx
(
$spreadsheet
);
$spreadsheet
->
createSheet
();
$spreadsheet
->
setActiveSheetIndex
(
0
);
$spreadsheet
->
getActiveSheet
(
0
)
->
setTitle
(
'产品库'
);
$sheet
=
$spreadsheet
->
getActiveSheet
(
0
);
$num
=
0
;
$row
=
2
;
foreach
(
$result
as
$index
=>
$value
){
$info
=
Db
::
name
(
'enterprise_info'
)
->
where
(
'id'
,
$value
[
'enterprise_id'
])
->
find
();
$spreadsheet
->
getDefaultStyle
()
->
getAlignment
()
->
setVertical
(
\PhpOffice\PhpSpreadsheet\Style\Alignment
::
VERTICAL_CENTER
);
$spreadsheet
->
getDefaultStyle
()
->
getAlignment
()
->
setHorizontal
(
\PhpOffice\PhpSpreadsheet\Style\Alignment
::
HORIZONTAL_CENTER
);
$spreadsheet
->
getDefaultStyle
()
->
getAlignment
()
->
setWrapText
(
true
);
$sheet
->
getDefaultRowDimension
()
->
setRowHeight
(
50
);
// 默认行高
$sheet
->
getDefaultColumnDimension
()
->
setWidth
(
50
);
// 默认单元格宽度
$sheet
->
getStyle
(
'A1:J1'
)
->
getFill
()
->
setFillType
(
\PhpOffice\PhpSpreadsheet\Style\Fill
::
FILL_SOLID
)
->
getStartColor
()
->
setARGB
(
'C5D9F1'
);
// FF后面的六位数是颜色的RGB值
$title
=
[
'产品ID'
,
'企业名称'
,
'产品分类'
,
'产品名称'
,
'产品链接'
,
'产品型号'
,
'产品功能描述'
,
'产品规格参数'
,
'检查备注'
,
'检查状态'
,
];
$col
=
'A'
;
$column
=
[
'A'
];
for
(
$coli
=
0
;
$coli
<
count
(
$title
);
$coli
++
)
{
$col
=
\app\api\business\ExcelBus
::
excelColPlus
(
$col
);
array_push
(
$column
,
$col
);
}
// 遍历标题数组,设置每个单元格的值
foreach
(
$title
as
$columns
=>
$val
)
{
// 'A1', 'B1', 'C1', ...
$cell
=
$column
[
$columns
]
.
'1'
;
// 设置单元格的值
$sheet
->
setCellValue
(
$cell
,
$val
);
// 设置单元格A1的对齐方式为居中
}
$position
=
0
;
$sheet
=
$spreadsheet
->
getActiveSheet
();
// 名称
$sheet
->
setCellValue
(
$column
[
$num
+
$position
]
.
$row
,
$value
[
'product_id'
]);
$position
++
;
// 名称
$sheet
->
setCellValue
(
$column
[
$num
+
$position
]
.
$row
,
$info
[
'enterprise_name'
]);
$position
++
;
// 位置
$sheet
->
setCellValue
(
$column
[
$num
+
$position
]
.
$row
,
$value
[
'product_categ_name'
]);
$position
++
;
// 位置
$sheet
->
setCellValue
(
$column
[
$num
+
$position
]
.
$row
,
$value
[
'product_name'
]);
$position
++
;
// 位置
$sheet
->
setCellValue
(
$column
[
$num
+
$position
]
.
$row
,
$value
[
'page_url'
]);
$position
++
;
// 位置
$sheet
->
setCellValue
(
$column
[
$num
+
$position
]
.
$row
,
$value
[
'product_model'
]);
$position
++
;
// 位置
$sheet
->
setCellValue
(
$column
[
$num
+
$position
]
.
$row
,
$value
[
'describe'
]);
$position
++
;
// 位置
$sheet
->
setCellValue
(
$column
[
$num
+
$position
]
.
$row
,
$value
[
'parameter'
]);
$position
++
;
// 位置
$sheet
->
setCellValue
(
$column
[
$num
+
$position
]
.
$row
,
$value
[
'inspect_remarks'
]);
$position
++
;
$inspect_status
=
$value
[
'inspect_status'
];
if
(
$inspect_status
==
0
){
$inspect_status
=
'待检查'
;
}
if
(
$inspect_status
==
1
){
$inspect_status
=
'检查完成'
;
}
if
(
$inspect_status
==
2
){
$inspect_status
=
'检查中'
;
}
if
(
$inspect_status
==
3
){
$inspect_status
=
'数据异常'
;
}
if
(
$inspect_status
==
4
){
$inspect_status
=
'检查异常'
;
}
if
(
$inspect_status
==
5
){
$inspect_status
=
'数据废弃'
;
}
// 位置
$sheet
->
setCellValue
(
$column
[
$num
+
$position
]
.
$row
,
$inspect_status
);
$position
++
;
$row
++
;
}
$name
=
'./product_'
.
date
(
'Y-m-d H:i:s'
)
.
'.csv'
;
$writer
->
save
(
$name
);
}
}
\ No newline at end of file
app/api/route/api.php
View file @
b3bc53fa
...
...
@@ -112,3 +112,5 @@ Route::rule("service/enterpriseName","Service/enterpriseName");
Route
::
rule
(
"test"
,
"test/product"
);
Route
::
rule
(
"cee"
,
"test/cee"
);
Route
::
rule
(
"exportData"
,
"test/exportData"
);
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