v.1.7 update

This commit is contained in:
miroman-afk
2021-11-01 14:35:53 +03:00
parent 3b61b27200
commit 87cf29a443
26 changed files with 1342 additions and 42 deletions

View File

@@ -11,7 +11,7 @@ class ClientFile extends HRCCommand implements HRCCommandInterface {
protected $signature = 'getclientfile';
public function command($input, $output = null) {
$terminal = Terminal::where('soft', '=', 1)->where('is_active', '=', 1)->where('work_code', '=', 1)->first();
$terminal = Terminal::where('soft', '=', 1)->where('is_active', '=', 1)->first();
$tmp_dirname = __DIR__ . "\\..\\..\\..\\Exchange\\" . $terminal['key'] . "\\tmp\\" . $terminal['key'] . "\\";
$dirname = __DIR__ . "\\..\\..\\..\\Exchange\\" . $terminal['key'] . "\\";
$code = '';
@@ -57,24 +57,25 @@ class ClientFile extends HRCCommand implements HRCCommandInterface {
'filedate' => $file,
];
}
$clientsCount = Client::count();
$urlThread = $input['th'];
$mainThreads = 4;
$countPerThread = ceil($clientsCount / $mainThreads);
$offset = ($urlThread - 1) * $countPerThread;
$clients = Client::with('clientPhone:client_guid,phone')->skip($offset)->take($countPerThread)->get();
$clientsCount = Client::count();
$urlThread = $input['th'];
$mainThreads = 4;
$countPerThread = ceil($clientsCount / $mainThreads);
$offset = ($urlThread - 1) * $countPerThread;
$clients = Client::with('clientPhone:client_guid')->skip($offset)->take($countPerThread)->get();
if (!is_dir($tmp_dirname)) {
mkdir($tmp_dirname, 0755, 'w+');
}
$filename = str_replace(' ', '_', date("d.m.Y H.i.s")) . '_' . $urlThread . '.tmp';
$handle = fopen($tmp_dirname . $filename, 'w+');
fputs($handle, chr(0xEF) . chr(0xBB) . chr(0xBF)); // BOM
$filename = str_replace('_', ' ', $filename);
foreach ($clients as $row) {
if (($row['clientPhone']->phone !== '') && ($row['clientPhone']->phone !== '+375 ( ) - -')) {
$row = array($row['name'], $row['clientPhone']->phone);
fputcsv($handle, $row, ';');
if (!is_dir($tmp_dirname)) {
mkdir($tmp_dirname, 0755, 'w+');
}
$filename = str_replace(' ', '_', date("d.m.Y H.i.s")) . '_' . $urlThread . '.tmp';
$handle = fopen($tmp_dirname . $filename, 'w+');
$filename = str_replace('_', ' ', $filename);
foreach ($clients as $row) {
if (($row['clientPhone']->phone !== '') && ($row['clientPhone']->phone !== '+375 ( ) - -')) {
$row = array($row['name'], $row['clientPhone']->phone);
fputcsv($handle, $row, ';');
}
}
}
fclose($handle);