Commit 592b70cf authored by Sarun Mungthanya's avatar Sarun Mungthanya
Browse files

issue missing code

parent c873e083
......@@ -8,6 +8,7 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class MasterFileController extends Controller
{
......@@ -20,6 +21,7 @@ class MasterFileController extends Controller
public function createPatch(Request $request)
{
// $request->validate([
// 'format_file_id' => 'required|exists:conf_format_file,formatservice_ID',
// 'file' => 'required|file|max:12209752',
......@@ -31,6 +33,7 @@ class MasterFileController extends Controller
// ]);
$file = $request->file('file');
$filePath = $file->getRealPath();
if(isset($request->truncateGoods) && ($request->format_file_id == 196)) {
......@@ -42,17 +45,17 @@ class MasterFileController extends Controller
$fileFormat = ConfFormatFile::where('formatservice_ID', $request->format_file_id)->first();
$jsonFilePath = storage_path(str_replace(".inc", ".json", $fileFormat->file));
if (!file_exists($jsonFilePath)) {
return redirect()->back()->withErrors(['error' => 'Format JSON file not found.']);
}
$formatData = json_decode(file_get_contents($jsonFilePath), true);
$message = '';
if ($request->createPatch) {
$sqlPackAll = $this->readTxt($filePath, $formatData, $fileFormat, $request->limit, $request->noLimit);
$this->processPatches($sqlPackAll, $fileFormat, $request->genWithSmartUpdate, $request->noLimit , $truncateGoods);
$message .= 'Patch master file created successfully. ';
}
......@@ -237,19 +240,20 @@ class MasterFileController extends Controller
$sqlPack = [];
$count = 0;
$fileHandle = fopen($filePath, "r");
while (!feof($fileHandle)) {
$text = fgets($fileHandle);
try {
$text = iconv('TIS-620', 'UTF-8', $text);
} catch (\Throwable $th) {
$encoding = mb_detect_encoding($text, ['UTF-8', 'ISO-8859-1', 'ASCII'], true);
$text = iconv('Windows-874', 'UTF-8', $text);
}
// Log::info($text);
$X = $Y = $Z = 0;
$primaryKeyConditions = [];
......@@ -284,7 +288,7 @@ class MasterFileController extends Controller
$insertFields = [];
$insertValues = [];
foreach ($formatData['format'] as $fieldFormat) {
$type = $fieldFormat['TYPE'];
......@@ -321,7 +325,7 @@ class MasterFileController extends Controller
'counter' => $count += 1
];
if ($count >= $limit && !$noLimit) {
$sqlPackAll[] = $sqlPack;
$count = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment