Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sarun Mungthanya
SpnPatch-Laravel
Commits
592b70cf
Commit
592b70cf
authored
Dec 13, 2024
by
Sarun Mungthanya
Browse files
issue missing code
parent
c873e083
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/MasterFileController.php
View file @
592b70cf
...
@@ -8,6 +8,7 @@ use Illuminate\Http\Request;
...
@@ -8,6 +8,7 @@ use Illuminate\Http\Request;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Storage
;
use
Illuminate\Support\Facades\Storage
;
use
Illuminate\Support\Facades\Http
;
use
Illuminate\Support\Facades\Http
;
use
Illuminate\Support\Facades\Log
;
class
MasterFileController
extends
Controller
class
MasterFileController
extends
Controller
{
{
...
@@ -20,6 +21,7 @@ class MasterFileController extends Controller
...
@@ -20,6 +21,7 @@ class MasterFileController extends Controller
public
function
createPatch
(
Request
$request
)
public
function
createPatch
(
Request
$request
)
{
{
// $request->validate([
// $request->validate([
// 'format_file_id' => 'required|exists:conf_format_file,formatservice_ID',
// 'format_file_id' => 'required|exists:conf_format_file,formatservice_ID',
// 'file' => 'required|file|max:12209752',
// 'file' => 'required|file|max:12209752',
...
@@ -31,6 +33,7 @@ class MasterFileController extends Controller
...
@@ -31,6 +33,7 @@ class MasterFileController extends Controller
// ]);
// ]);
$file
=
$request
->
file
(
'file'
);
$file
=
$request
->
file
(
'file'
);
$filePath
=
$file
->
getRealPath
();
$filePath
=
$file
->
getRealPath
();
if
(
isset
(
$request
->
truncateGoods
)
&&
(
$request
->
format_file_id
==
196
))
{
if
(
isset
(
$request
->
truncateGoods
)
&&
(
$request
->
format_file_id
==
196
))
{
...
@@ -42,17 +45,17 @@ class MasterFileController extends Controller
...
@@ -42,17 +45,17 @@ class MasterFileController extends Controller
$fileFormat
=
ConfFormatFile
::
where
(
'formatservice_ID'
,
$request
->
format_file_id
)
->
first
();
$fileFormat
=
ConfFormatFile
::
where
(
'formatservice_ID'
,
$request
->
format_file_id
)
->
first
();
$jsonFilePath
=
storage_path
(
str_replace
(
".inc"
,
".json"
,
$fileFormat
->
file
));
$jsonFilePath
=
storage_path
(
str_replace
(
".inc"
,
".json"
,
$fileFormat
->
file
));
if
(
!
file_exists
(
$jsonFilePath
))
{
if
(
!
file_exists
(
$jsonFilePath
))
{
return
redirect
()
->
back
()
->
withErrors
([
'error'
=>
'Format JSON file not found.'
]);
return
redirect
()
->
back
()
->
withErrors
([
'error'
=>
'Format JSON file not found.'
]);
}
}
$formatData
=
json_decode
(
file_get_contents
(
$jsonFilePath
),
true
);
$formatData
=
json_decode
(
file_get_contents
(
$jsonFilePath
),
true
);
$message
=
''
;
$message
=
''
;
if
(
$request
->
createPatch
)
{
if
(
$request
->
createPatch
)
{
$sqlPackAll
=
$this
->
readTxt
(
$filePath
,
$formatData
,
$fileFormat
,
$request
->
limit
,
$request
->
noLimit
);
$sqlPackAll
=
$this
->
readTxt
(
$filePath
,
$formatData
,
$fileFormat
,
$request
->
limit
,
$request
->
noLimit
);
$this
->
processPatches
(
$sqlPackAll
,
$fileFormat
,
$request
->
genWithSmartUpdate
,
$request
->
noLimit
,
$truncateGoods
);
$this
->
processPatches
(
$sqlPackAll
,
$fileFormat
,
$request
->
genWithSmartUpdate
,
$request
->
noLimit
,
$truncateGoods
);
$message
.
=
'Patch master file created successfully. '
;
$message
.
=
'Patch master file created successfully. '
;
}
}
...
@@ -237,19 +240,20 @@ class MasterFileController extends Controller
...
@@ -237,19 +240,20 @@ class MasterFileController extends Controller
$sqlPack
=
[];
$sqlPack
=
[];
$count
=
0
;
$count
=
0
;
$fileHandle
=
fopen
(
$filePath
,
"r"
);
$fileHandle
=
fopen
(
$filePath
,
"r"
);
while
(
!
feof
(
$fileHandle
))
{
while
(
!
feof
(
$fileHandle
))
{
$text
=
fgets
(
$fileHandle
);
$text
=
fgets
(
$fileHandle
);
try
{
try
{
$text
=
iconv
(
'TIS-620'
,
'UTF-8'
,
$text
);
$text
=
iconv
(
'TIS-620'
,
'UTF-8'
,
$text
);
}
catch
(
\
Throwable
$th
)
{
}
catch
(
\
Throwable
$th
)
{
$encoding
=
mb_detect_encoding
(
$text
,
[
'UTF-8'
,
'ISO-8859-1'
,
'ASCII'
],
true
);
$encoding
=
mb_detect_encoding
(
$text
,
[
'UTF-8'
,
'ISO-8859-1'
,
'ASCII'
],
true
);
$text
=
iconv
(
'Windows-874'
,
'UTF-8'
,
$text
);
$text
=
iconv
(
'Windows-874'
,
'UTF-8'
,
$text
);
}
}
// Log::info($text);
$X
=
$Y
=
$Z
=
0
;
$X
=
$Y
=
$Z
=
0
;
$primaryKeyConditions
=
[];
$primaryKeyConditions
=
[];
...
@@ -284,7 +288,7 @@ class MasterFileController extends Controller
...
@@ -284,7 +288,7 @@ class MasterFileController extends Controller
$insertFields
=
[];
$insertFields
=
[];
$insertValues
=
[];
$insertValues
=
[];
foreach
(
$formatData
[
'format'
]
as
$fieldFormat
)
{
foreach
(
$formatData
[
'format'
]
as
$fieldFormat
)
{
$type
=
$fieldFormat
[
'TYPE'
];
$type
=
$fieldFormat
[
'TYPE'
];
...
@@ -321,7 +325,7 @@ class MasterFileController extends Controller
...
@@ -321,7 +325,7 @@ class MasterFileController extends Controller
'counter'
=>
$count
+=
1
'counter'
=>
$count
+=
1
];
];
if
(
$count
>=
$limit
&&
!
$noLimit
)
{
if
(
$count
>=
$limit
&&
!
$noLimit
)
{
$sqlPackAll
[]
=
$sqlPack
;
$sqlPackAll
[]
=
$sqlPack
;
$count
=
0
;
$count
=
0
;
...
...
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