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-18 14:31:08 +0700
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
03917d9a4f3256d25245483785d93b7d4158aac9
03917d9a
1 parent
e50d3344
update data tpl
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
19 deletions
app/Http/Controllers/OcrController.php
app/Models/DtTemplate.php
app/Http/Controllers/OcrController.php
View file @
03917d9
...
...
@@ -17,34 +17,42 @@ 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'
,
]);
$dataDetail
=
$request
->
fields
??
[];
try
{
// Lưu vào bảng mst_template
$mst
=
MstTemplate
::
create
([
'tpl_name'
=>
$request
->
template_name
,
'tpl_text'
=>
$request
->
customer_name_text
,
'tpl_xy'
=>
$request
->
customer_name_xy
,
]);
$masterTemplate
=
MstTemplate
::
updateOrCreate
(
[
'tpl_name'
=>
$request
->
template_name
],
[
'tpl_text'
=>
$request
->
customer_name_text
,
'tpl_xy'
=>
$request
->
customer_name_xy
,
]
);
foreach
(
$dataDetail
as
$field
=>
$value
)
{
if
(
empty
(
$value
[
'coords'
]))
{
continue
;
}
// Lưu các field khác vào dt_template
foreach
(
$request
->
fields
as
$field
=>
$value
)
{
DtTemplate
::
create
([
'tpl_id'
=>
$mst
->
id
,
'field_name'
=>
$field
,
'field_xy'
=>
is_array
(
$value
[
'coords'
])
?
implode
(
','
,
$value
[
'coords'
])
:
$value
[
'coords'
],
]);
}
DtTemplate
::
updateOrInsert
(
[
'tpl_id'
=>
$masterTemplate
->
id
,
'field_name'
=>
$field
,
],
[
'field_xy'
=>
is_array
(
$value
[
'coords'
])
?
implode
(
','
,
$value
[
'coords'
])
:
$value
[
'coords'
],
]
);
}
return
response
()
->
json
([
'success'
=>
true
,
'message'
=>
'Lưu template thành công'
,
'template_id'
=>
$m
st
->
id
'template_id'
=>
$m
asterTemplate
->
id
]);
}
catch
(
\Exception
$e
)
{
return
response
()
->
json
([
...
...
@@ -59,7 +67,7 @@ class OcrController extends Controller
{
try
{
// Lấy template name từ request hoặc mặc định
$templateName
=
$request
->
get
(
'template_name'
,
''
);
$templateName
=
$request
->
get
(
'template_name'
,
'
nemo12
'
);
// Giả sử file OCR JSON & ảnh nằm trong storage/app/public/image/
$jsonPath
=
public_path
(
"image/data_picking_detail_1754967679.json"
);
...
...
app/Models/DtTemplate.php
View file @
03917d9
...
...
@@ -10,6 +10,7 @@ class DtTemplate extends Model
public
$timestamps
=
false
;
protected
$table
=
'dt_template'
;
protected
$primaryKey
=
'tpl_detail_id'
;
protected
$guarded
=
[];
...
...
Please
register
or
sign in
to post a comment