Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Satini_pvduc
/
ocrpdf
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
tien_nemo
2025-08-13 15:59:03 +0700
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
406ace5f44687f0a547791011623f0e538e80c9f
406ace5f
1 parent
04184f3e
test load data
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
app/Http/Controllers/OcrController.php
resources/views/ocr/index.blade.php
app/Http/Controllers/OcrController.php
View file @
406ace5
...
...
@@ -17,13 +17,11 @@ class OcrController extends Controller
public
function
store
(
Request
$request
)
{
// dd($request->all());
$request
->
validate
([
'customer_name_text'
=>
'required|string'
,
'customer_name_xy'
=>
'required|string'
,
'template_name'
=>
'required|string|unique:mst_template,tpl_name'
,
'fields'
=>
'required|array'
,
'fields.*.name'
=>
'required|string'
,
'fields.*.xy'
=>
'required|string'
,
]);
try
{
...
...
@@ -35,11 +33,11 @@ class OcrController extends Controller
]);
// Lưu các field khác vào dt_template
foreach
(
$request
->
fields
as
$field
)
{
foreach
(
$request
->
fields
as
$field
=>
$value
)
{
DtTemplate
::
create
([
'tpl_id'
=>
$mst
->
id
,
'field_name'
=>
$field
[
'name'
]
,
'field_xy'
=>
$field
[
'xy
'
],
'field_name'
=>
$field
,
'field_xy'
=>
is_array
(
$value
[
'coords'
])
?
implode
(
','
,
$value
[
'coords'
])
:
$value
[
'coords
'
],
]);
}
...
...
@@ -61,7 +59,7 @@ class OcrController extends Controller
{
try
{
// Lấy template name từ request hoặc mặc định
$templateName
=
$request
->
get
(
'template_name'
,
'
nemo
'
);
$templateName
=
$request
->
get
(
'template_name'
,
'
A
'
);
// Giả sử file OCR JSON & ảnh nằm trong storage/app/public/image/
$jsonPath
=
public_path
(
"image/data_picking_detail_1754967679.json"
);
...
...
@@ -77,6 +75,7 @@ class OcrController extends Controller
}
$formData
=
[];
$dataMapping
=
[];
if
(
$templateName
)
{
$mst
=
MstTemplate
::
where
(
'tpl_name'
,
$templateName
)
->
first
();
...
...
@@ -94,6 +93,11 @@ class OcrController extends Controller
// field_name => text
$formData
[
$detail
->
field_name
]
=
$text
;
$dataMapping
[
$detail
->
field_name
]
=
[
'text'
=>
$text
,
'coords'
=>
$coords
];
}
}
else
{
$formData
=
[
...
...
@@ -112,6 +116,7 @@ class OcrController extends Controller
'ocrData'
=>
$ocrData
,
'pdfImageUrl'
=>
$imgPath
,
'formData'
=>
$formData
,
'dataMapping'
=>
$dataMapping
,
'fieldOptions'
=>
[
[
'value'
=>
'template_name'
,
'label'
=>
'Tên Mẫu PDF'
],
[
'value'
=>
'customer_name'
,
'label'
=>
'Tên khách hàng'
],
...
...
resources/views/ocr/index.blade.php
View file @
406ace5
This diff is collapsed.
Click to expand it.
Please
register
or
sign in
to post a comment