protected function execute(InputInterface $input, OutputInterface $output) { $tt1 = microtime(true); $output->writeln('Recuperar y cargar datos de los empleados en base de metadatos de Archivos de Sifinca 2.0 '); $name = $input->getArgument('Document'); if ($name) { $text = 'Aqui debe instanciar clase empleados '; ## conectar a sifinca $output->writeln('<info>1.Conectando a base de datos</info>'); ## conectar a base de zeus $conn = new data(array('server' => '10.102.1.3', 'user' => 'sa', 'pass' => 'i3kygbb2', 'database' => 'mca', 'engine' => 'mssql')); $contable = new contable($conn); $cliente = new cliente($conn); $year = $input->getOption('year'); $month = $input->getOption('month'); $periodo = $year . str_pad($month, 2, "0", STR_PAD_LEFT); $param = array('ANODCTO' => $periodo); // cargar resto de documentos $output->writeln('<info>3.Trayendo comprobantes contables </info>'); $datos = $contable->getDocument($param); $output->writeln('<info>4.Haciendo el llamado a la url </info>'); $api = $this->setupApi(); $count = 0; foreach ($datos as $key => $t) { $transactions = $contable->getTransac(array('ANOTRA' => $periodo, 'NUMDOCTRA' => $t['NUMEDCTO'], 'IDFUENTE' => $t['FNTEDCTO'])); $tercero = $cliente->getClientes(array('IDTERCERO' => $t['IDTERCERO'])); $t['TERCERO'] = $tercero[0]; foreach ($transactions as $key => $tra) { $account = $contable->getAccount(array('CODICTA' => $tra['CODICTA'])); $ter = $cliente->getClientes(array('IDTERCERO' => $tra['NITTRA'])); $transactions[$key]['TERCERO'] = $ter[0]; $transactions[$key]['INFOCTA'] = $account[0]; } $t['movements'] = $transactions; print_r($api->post($t)); echo $count . "\n"; $count++; } return null; $total = count($datos); $output->writeln('<info>Total registros = ' . $total . ' </info>'); if ($input->getOption('tasks')) { ### Agregar tareas a Job ### Client de Jobs $client = new GearmanClient(); $this->addTasks($datos, $client); } else { ## obtener $api $api = $this->setupApi(); $this->postTasks($datos, $api); } $tt2 = microtime(true); $r = $tt2 - $tt1; $output->writeln('<info>Tiempo de ' . $r . ' para ' . $total . ' </info>'); } else { $text = 'NO GETDOCUMENT'; $output->writeln('<info>' . $text . '</info>'); } }
protected function execute(InputInterface $input, OutputInterface $output) { $tt1 = microtime(true); $output->writeln('Recuperar y cargar datos de los empleados en base de metadatos de Archivos de Sifinca 2.0 '); $name = $input->getArgument('Document'); if ($name) { $text = 'Aqui debe instanciar clase empleados '; ## conectar a sifinca $output->writeln('<info>1.Conectando a base de datos</info>'); ## conectar a base de zeus $conn = new data(array('server' => '10.102.1.3', 'user' => 'sa', 'pass' => 'i3kygbb2', 'database' => 'mca', 'engine' => 'mssql')); $output->writeln('<info>2.Trayendo Egresos</info>'); $contable = new contable($conn); $year = $input->getOption('year'); $month = $input->getOption('month'); $periodo = $year . str_pad($month, 2, "0", STR_PAD_LEFT); $param = array('ANODCTO' => $periodo); $datos1 = $contable->getEgresos($param); // print_r($datos1); // return null; // cargar resto de documentos $output->writeln('<info>3.Trayendo comprobantes contables </info>'); $datos2 = $contable->getDocument($param); $datos = array_merge($datos2, $datos1); $total = count($datos); $output->writeln('<info>Total registros = ' . $total . ' </info>'); if ($input->getOption('tasks')) { ### Agregar tareas a Job ### Client de Jobs $client = new GearmanClient(); $this->addTasks($datos, $client); } else { ## obtener $api $api = $this->setupApi(); $this->postTasks($datos, $api); } $tt2 = microtime(true); $r = $tt2 - $tt1; $output->writeln('<info>Tiempo de ' . $r . ' para ' . $total . ' </info>'); } else { $text = 'NO GETDOCUMENT'; $output->writeln('<info>' . $text . '</info>'); } }
<?php $json_document_type = '{ "code": "002", "description": "PRUEBA 1", }'; $type = json_decode($json_document_type, true); require_once '../vendor/autoload.php'; use upload\model\contable; use upload\lib\data; use upload\lib\api; $db = new data(array('server' => '10.102.1.3', 'user' => 'sa', 'pass' => 'i3kygbb2', 'database' => 'mca', 'engine' => 'mssql')); $contable = new contable($db); $data = $contable->getFuentes(); $user = "******"; $pass = "******"; // $url = "http://www.sifinca.net/sifinca/web/app.php/admin/sifinca/mapper"; $url = "http://10.102.1.22/sifinca/web/app.php/admin/sifinca/mapper"; $apimapper = SetupApi($url, $user, $pass); $url = "http://10.102.1.22/sifinca/web/app.php/admin/accounting/documenttype"; $apidocumenttype = SetupApi($url, $user, $pass); ## recorrer tipos foreach ($data as $row) { ## postear en documentype $documenttype = $type; $documenttype['code'] = $row['IDFUENTE']; $documenttype['description'] = $row['DESFUENTE']; echo "fuente\n"; print_r($documenttype); $result = json_decode($apidocumenttype->post($documenttype), true); print_r($result);