def get_conteineres(self, ovr): conteineres = set() rvfs = lista_rvfovr(self.session, ovr.id) for rvf in rvfs: if rvf.numerolote: conteineres.add(rvf.numerolote) return conteineres
def test_0_FiltrosOVR(self): setor = Setor() setor.id = 9991 setor.nome = 'Setor 1' session.add(setor) setor2 = Setor() setor2.id = 9992 setor2.nome = 'Setor 2' session.add(setor2) session.commit() ovr1 = self.create_OVR_campos('R1', 'U1', 'C1', '2020-05-01', 'teste1', setor) session.refresh(ovr1) ovr2 = self.create_OVR_campos('R2', 'U2', 'C2', '2020-05-02', 'teste2', setor2) ovr3 = self.create_OVR_campos('R3', 'U3', 'C3', '2020-05-03', 'teste3', setor) ovr4 = self.create_OVR_campos('R4', 'U4', 'C4', '2020-05-01', 'teste4', setor, '20') ovrs = get_ovr_filtro(session, {}) assert isinstance(ovrs, list) assert len(ovrs) == 4 ovrs = get_ovr_filtro(session, {'numero': 'teste1'}) assert len(ovrs) == 1 ovrs = get_ovr_filtro(session, {'numeroCEmercante': 'C2'}, 'U2') assert len(ovrs) == 1 ovrs = get_ovr_filtro(session, {'numeroCEmercante': 'C2'}, 'U1') assert len(ovrs) == 0 ovrs = get_ovr_filtro(session, {'numeroCEmercante': 'Non ecsiste'}) assert len(ovrs) == 0 ovrs = get_ovr_filtro(session, {'numero': 'teste4'}) assert len(ovrs) == 1 ovrs = get_ovr_filtro(session, {'numero': 'teste'}) assert len(ovrs) == 4 ovrs = get_ovr_filtro(session, {'numerodeclaracao': '10'}) assert len(ovrs) == 0 ovrs = get_ovr_filtro(session, {'numerodeclaracao': '20'}) assert len(ovrs) == 1 # Teste de pesquisa por numero processo ovrs = get_ovr_filtro(session, {'numeroprocesso': '12345'}) assert len(ovrs) == 0 processo = ProcessoOVR() processo.ovr_id = ovr1.id processo.numero = '12345' session.add(processo) ovrs = get_ovr_filtro(session, {'numeroprocesso': '12345'}) assert len(ovrs) == 1 # Teste de pesquisa por numeroCEmercante de RVF rvf = RVF() rvf.ovr_id = ovr1.id rvf.numeroCEmercante = 'C2' session.add(rvf) session.commit() ovrs = get_ovr_filtro(session, {'numeroCEmercante': 'C2'}) rvfs = lista_rvfovr(session, ovr1.id) print(rvfs) print(ovr1.numeroCEmercante, ovr1.id) print(ovr2.numeroCEmercante) print(rvf.numeroCEmercante, rvf.ovr_id) assert len(ovrs) == 2
def listarvfovr(): session = app.config.get('dbsession') ovr_id = request.args.get('ovr_id') lista = lista_rvfovr(session, ovr_id) title_page = 'Verificações Físicas' return render_template('lista_rvfovr.html', listarvfovr=lista, ovr_id=ovr_id, title_page=title_page)
def get_peso_apreensoes(self, ovr): peso = 0. rvfs = lista_rvfovr(self.session, ovr.id) for rvf in rvfs: for apreensao in rvf.apreensoes: try: peso += float(apreensao.peso) except TypeError: pass return peso
def get_infracoes_e_marcas(self, ovr): infracoes = set() marcas = set() rvfs = lista_rvfovr(self.session, ovr.id) for rvf in rvfs: for infracao in rvf.infracoesencontradas: infracoes.add(infracao.nome) for marca in rvf.marcasencontradas: marcas.add(marca.nome) return infracoes, marcas
def consulta_due_objects(due: str, session, mongodb): if due is None or due == '' or len(due) < 14: raise ValueError('get_imagens: Informe o número da DUE' ' com 14 dígitos (AABR9999999999)!') logger.info('Consultando due %s' % due) logger.info('get_ovrs_filtro') ovrs = get_ovr_filtro(session, {'numerodeclaracao': due}) rvfs = [] for ovr in ovrs: rvfs_ovr = lista_rvfovr(session, ovr.id) rvfs.extend(rvfs_ovr) logger.info('get detalhes DUE') infoce = get_due(mongodb, due) return rvfs, ovrs, infoce
def autos_contrafacao(): session = app.config['dbsession'] # db = app.config['mongo_risco'] listafichasresumo = [] ovr = None rvfs = [] marcas_dict = {} supervisor = False exibicao_ovr = ExibicaoOVR(session, TipoExibicao.Descritivo, current_user.name) titulos = exibicao_ovr.get_titulos() evento_form = HistoricoOVRForm() title_page = 'Assistente de Contrafação' try: usuario = get_usuario(session, current_user.name) if usuario is None: raise Exception('Erro: Usuário não encontrado!') flags = get_ids_flags_contrafacao(session) supervisor = usuario_tem_perfil_nome(session, current_user.name, 'Supervisor') listafichas = get_ovrs_abertas_flags(session, current_user.name, flags) print('*************************', len(listafichas)) for ovr_linha in listafichas: resumo = exibicao_ovr.get_linha(ovr_linha) listafichasresumo.append(resumo) ovr_id = request.args.get('ovr_id') if ovr_id: ovr = get_ovr(session, ovr_id) tiposevento = get_tiposevento_assistente_choice(session, Assistente.Marcas) evento_form = HistoricoOVRForm(ovr_id=ovr_id, tiposeventos=tiposevento, responsaveis=[usuario.cpf]) rvfs = lista_rvfovr(session, ovr_id) marca_manager = MarcaManager(session) for rvf in rvfs: marca_dict = marca_manager.get_marcas_rvf_por_representante(rvf.id) marcas_dict.update(marca_dict) except Exception as err: logger.error(err, exc_info=True) flash('Erro! Detalhes no log da aplicação.') flash(str(type(err))) flash(str(err)) return render_template('autos_contrafeitos.html', titulos=titulos, listaovrs=listafichasresumo, marcas_dict=marcas_dict, ovr=ovr, rvfs=rvfs, supervisor=supervisor, evento_form=evento_form, title_page=title_page)