Beispiel #1
0
 public function getUserPrintedDigital(\Core_Dto_Search $search)
 {
     $result = array('user' => false, 'date' => null);
     $eLoteEtiqueta = $this->_getRepository()->find($search->getSqLoteEtiqueta());
     if ($eLoteEtiqueta->getSqUsuario()) {
         $result['user'] = $eLoteEtiqueta->getSqUsuario()->getSqPessoa()->getNoPessoa();
         $result['date'] = $eLoteEtiqueta->getDtImpressao()->get('dd/MM/yyyy');
     }
     return $result;
 }
Beispiel #2
0
 public function listSeries(\Core_Dto_Search $search)
 {
     $sql = "WITH etiquetas_lote AS(\n                        SELECT et.sq_lote_etiqueta\n                               ,et.nu_ano\n                               ,cast(LPAD(CAST(et.nu_ano as VARCHAR)||LPAD(CAST(et.nu_etiqueta as VARCHAR),7,'0'),11,'0') as BIGINT) AS nu_etiqueta\n\n                               ,CASE WHEN et.seq_nup_siorg IS NOT NULL THEN\n                                    et.sq_unidade_siorg || LPAD(CAST(et.seq_nup_siorg as VARCHAR),8,'0') || et.nu_ano\n                                ELSE\n                                    NULL\n                                END AS nu_nup_siorg_sem_dv\n                        FROM (\n                            SELECT l.sq_lote_etiqueta\n                                   ,l.nu_ano\n                                   ,generate_series(nu_inicial, nu_final) nu_etiqueta\n                                   ,CASE WHEN l.in_lote_com_nup_siorg THEN\n                                        generate_series(nu_inicial_nup_siorg, nu_final_nup_siorg)\n                                    ELSE\n                                        NULL\n                                    END AS seq_nup_siorg\n                                   ,LPAD(:coSiorg,7,'0') AS sq_unidade_siorg\n\n                            FROM sgdoce.lote_etiqueta l\n                           WHERE l.sq_lote_etiqueta = :sqLoteEtiqueta\n                   ) AS et\n                )\n                SELECT *\n                  FROM etiquetas_lote l\n                 ORDER BY nu_etiqueta";
     $rsm = new \Doctrine\ORM\Query\ResultSetMapping();
     $rsm->addScalarResult('sq_lote_etiqueta', 'sqLoteEtiqueta');
     $rsm->addScalarResult('nu_ano', 'nuAno');
     $rsm->addScalarResult('nu_etiqueta', 'nuEtiqueta');
     $rsm->addScalarResult('nu_nup_siorg_sem_dv', 'nuNupSiorgSemDv');
     $query = $this->_em->createNativeQuery($sql, $rsm);
     $query->setParameter('sqLoteEtiqueta', $search->getSqLoteEtiqueta());
     $query->setParameter('coSiorg', $search->getCoSiorg());
     return $query->getScalarResult();
 }
Beispiel #3
0
 /**
  * Metódo que realiza o save do Artefato
  * @param Object $dtoSearch
  * @return \Sgdoce\Model\Entity\Artefato
  */
 public function saveArtefato(\Core_Dto_Search $dtoSearch)
 {
     $date = new \Zend_Date();
     $this->getEntityManager()->getConnection()->beginTransaction();
     try {
         $sqPessoaSgdoce = $this->_getRepository('app:PessoaSgdoce')->findBySqPessoaCorporativo(\Core_Integration_Sica_User::getPersonId());
         if (empty($sqPessoaSgdoce)) {
             $filter = new \Zend_Filter_Digits();
             $sqPessoaCorporativo = \Core_Integration_Sica_User::getPersonId();
             $data['sqPessoaCorporativo'] = $this->_getRepository('app:VwPessoa')->find($sqPessoaCorporativo);
             $dtoPessoaSearch = \Core_Dto::factoryFromData($data, 'search');
             $cpfCnpjPassaportUnfiltered = $this->getServiceLocator()->getService('VwPessoa')->returnCpfCnpjPassaporte($dtoPessoaSearch);
             $cpfCnpjPassaport = $filter->filter($cpfCnpjPassaportUnfiltered);
             $noPessoaCorporativo = $data['sqPessoaCorporativo']->getNoPessoa();
             $this->addPessoaSgdoce($sqPessoaCorporativo, $noPessoaCorporativo, $cpfCnpjPassaport);
             $sqPessoaSgdoce = $this->_getRepository('app:PessoaSgdoce')->findBySqPessoaCorporativo(\Core_Integration_Sica_User::getPersonId());
         }
         /** @var \Sgdoce\Model\Entity\Artefato $entityArtefato */
         $entityArtefato = $this->_newEntity('app:Artefato');
         //só seta o numero da digital se for documento tipo físico
         if (!$dtoSearch->getInEletronico()) {
             $entityLoteEtiqueta = $this->getEntityManager()->getPartialReference('app:LoteEtiqueta', $dtoSearch->getSqLoteEtiqueta());
             /** @var \Sgdoce\Model\Entity\EtiquetasUso $entityEtiquetasUso */
             $entityEtiquetasUso = $this->_newEntity('app:EtiquetasUso');
             $entityEtiquetasUso->setNuEtiqueta($dtoSearch->getNuDigital());
             $entityEtiquetasUso->setSqLoteEtiqueta($entityLoteEtiqueta);
             //persist Etiquetas Uso
             $this->getEntityManager()->persist($entityEtiquetasUso);
             $this->getEntityManager()->flush($entityEtiquetasUso);
             $entityArtefato->setNuDigital($entityEtiquetasUso);
             $entityArtefato->setSqLoteEtiqueta($entityEtiquetasUso);
         }
         $entityArtefato->setDtPrazo(NULL);
         $entityArtefato->setDtArtefato($date);
         $entityArtefato->setInEletronico($dtoSearch->getInEletronico());
         //persist artefato
         $this->getEntityManager()->persist($entityArtefato);
         $this->getEntityManager()->flush($entityArtefato);
         $sqPessoaFuncao = $this->getEntityManager()->getPartialReference('app:PessoaFuncao', \Core_Configuration::getSgdocePessoaFuncaoAutor());
         /** @var \Sgdoce\Model\Entity\PessoaArtefato $entityPessoaArtefato */
         $entityPessoaArtefato = $this->_newEntity('app:PessoaArtefato');
         $entityPessoaArtefato->setSqArtefato($entityArtefato);
         $entityPessoaArtefato->setSqPessoaSgdoce($sqPessoaSgdoce[0]);
         $entityPessoaArtefato->setSqPessoaFuncao($sqPessoaFuncao);
         $this->getEntityManager()->persist($entityPessoaArtefato);
         $this->getEntityManager()->flush($entityPessoaArtefato);
         // salva o historico do artefato
         $arrDto = array('sqPessoa' => \Core_Integration_Sica_User::getPersonId(), 'sqUnidade' => \Core_Integration_Sica_User::getUserUnit());
         // #HistoricoArtefato::save();
         $strMessage = $this->getServiceLocator()->getService('HistoricoArtefato')->getMessage('MH005');
         $this->getServiceLocator()->getService('HistoricoArtefato')->registrar($entityArtefato->getSqArtefato(), \Core_COnfiguration::getSgdoceSqOcorrenciaCadastrar(), $strMessage);
         $this->getEntityManager()->getConnection()->commit();
     } catch (\Exception $e) {
         $this->getEntityManager()->getConnection()->rollback();
         throw $e;
     }
     return $entityArtefato;
 }