dbo.LN_Alta_Masiva_Informes

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

2
Name Data Type Length Description
@clienteproceso int 4
@freno int 4

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.LN_Alta_Masiva_Informes 

/*
EXEC LN_Alta_Masiva_Informes 861672084,0
*/


/*
select ln_gestiones.gestion,ln_gestiones.contraparte,ln_gestiones.cliente from ln_gestiones inner join ln_contrapartes on (ln_gestiones.contraparte=ln_contrapartes.contraparte and ln_contrapartes.activo=1 and ln_contrapartes.cliente = 861672084 and ln_contrapartes.contraparte not in (193603,194156))
and ln_contrapartes.contraparte not in (select contraparte  from ln_demo where contraparte in (select contraparte from ln_contrapartes where cliente = 861672084 and activo = 1 and contraparte not in (193603,194156)))
*/

/*

select informes.* from padrones inner join informes on (padrones.identificacion=informes.numero and padrones.identificador=informes.identificador)
where informes.informe_padre is null 
and id_padron in (select id_padron from ln_contrapartes where cliente = 861672084 and activo=1 and country_code!='AR')


select id_tipo_informe,* from informes where cliente = 861672084 and fecha_ingreso > getdate()-0.5 and informe_padre = 100682771

update informes set asignado =45460019,fecha_inicio = getdate(),fecha_aceptacion=getdate(),fecha_iniciado=getdate(),fecha_comprometida='2023-08-31 20:00:00',estado_informe='P'  where cliente = 861672084 and fecha_ingreso > '2023-08-09 18:34:00' and informe_padre is null

update informes set fecha_inicio = getdate(),fecha_aceptacion=getdate(),fecha_iniciado=getdate(),fecha_comprometida='2023-08-31 20:00:00',estado_informe='I'  where cliente = 861672084 and fecha_ingreso > getdate()-0.5 and informe_padre is not null
*/

/*
update informes set asignado =19160464,fecha_asignado=getdate(),estado_informe='A',fecha_inicio='2023-08-25 09:00',fecha_iniciado='2023-08-25 09:00'   where cliente = 861672084 and fecha_ingreso > getdate()-0.5 and informe_padre is not null and id_tipo_informe in (3988619,285465,1123336)
update informes set asignado =41904867,fecha_asignado=getdate(),estado_informe='A',fecha_inicio='2023-08-25 09:00',fecha_iniciado='2023-08-25 09:00'     where cliente = 861672084 and fecha_ingreso > getdate()-0.5 and informe_padre is not null and id_tipo_informe in (1054861)
update informes set asignado =58829932,fecha_asignado=getdate(),estado_informe='A',fecha_inicio='2023-08-25 09:00',fecha_iniciado='2023-08-25 09:00'     where cliente = 861672084 and fecha_ingreso > getdate()-0.5 and informe_padre is not null and id_tipo_informe in (6669922)
update informes set asignado =41904867,fecha_asignado=getdate(),estado_informe='A',fecha_inicio='2023-08-25 09:00',fecha_iniciado='2023-08-25 09:00'     where cliente = 861672084 and fecha_ingreso > getdate()-0.5 and informe_padre is not null and id_tipo_informe in (8996806)
update informes set asignado =436897241,fecha_asignado=getdate(),estado_informe='A',fecha_inicio='2023-08-25 09:00',fecha_iniciado='2023-08-25 09:00'     where cliente = 861672084 and fecha_ingreso > getdate()-0.5 and informe_padre is not null and id_tipo_informe in (6883670)


3988619,285465,1123336) --reyes 19160464
1054861 --celeste
6669922 --galeano
8996806 --produccion
6883670 --jorge 436897241

select * from users where username like '%jorge%'

*/



/*
select contraparte  from ln_demo where contraparte in (
select contraparte from ln_contrapartes where cliente = 861672084 and activo = 1 and contraparte not in (193603,194156))

select * from informes where informe in (select informe from ln_demo where contraparte in (select contraparte from ln_contrapartes where cliente = 861672084 and activo = 1 and contraparte not in (193603,194156)))
or informe_padre in (select informe from ln_demo where contraparte in (select contraparte from ln_contrapartes where cliente = 861672084 and activo = 1 and contraparte not in (193603,194156)))


*/


@clienteproceso int,
@freno int


AS
BEGIN
    SET NOCOUNT ON;


declare @FECHA_VIG_DESDE date = getdate()
declare @FECHA_VIG_HASTA date = getdate() + (365*3)
declare @idpadron int 
declare @cliente int 
declare @nombre varchar(150) 
declare @eMAIL varchar(150) 
declare @TE varchar(150) 
declare @clave varchar(10) = 'JHSYTRFS'
declare @Userid int = 15342812
declare @MODALIDAD varchar(10) 
declare @p_contraparte int = null
declare @idContra int = null
declare @familia int 
declare @gestion int = null 
declare @idAlta int 
declare @paisservicio varchar(2)
declare @contra int
declare @inf int
declare @solicitante int 
declare @idtipo int 
declare @datam int =5546717
declare @itemcontrato int = 382
declare @productoblue int = 4
declare @prioridad int = 5
declare @fechalimite varchar(10)='2023-01-31'
declare @productoleddemo int
declare @montoLCS decimal(15,2)
declare @TaxID varchar(50)
declare @servicio_contratado int = 47
declare @idImperium int
declare @tipo_contratista_imperium int
declare @estado_contratista_imperium  varchar(1)

/*declare @clienteproceso int = 0 -- 3915936*/

DECLARE LEDALTAMASIVA Cursor
FOR
/*
select TOP 10 gestion,contraparte,cliente from ln_gestiones where contraparte in (select contraparte from ln_contrapartes where cliente = 861672084 and activo = 1 and contraparte not in (
--(193603,194156,194045)
select contraparte  from ln_demo where contraparte in (
select contraparte from ln_contrapartes where cliente = 861672084 and activo = 1 and contraparte not in (193603,194156))))
*/

/*
select distinct gestion,contraparte,cliente from ln_gestiones where cliente = 861672084 and contraparte not in (193603,194156) and contraparte not in (
select contraparte  from ln_demo where contraparte in (select contraparte from ln_contrapartes where cliente = 861672084 and activo = 1 and contraparte not in (193603,194156)))
and contraparte not in (193603,194156)
*/


select top 1000 ln_gestiones.gestion,ln_gestiones.contraparte,ln_gestiones.cliente from ln_gestiones inner join ln_contrapartes on (ln_gestiones.contraparte=ln_contrapartes.contraparte and ln_contrapartes.activo=1 and ln_contrapartes.cliente = 861672084 and ln_contrapartes.contraparte not in (193603,194156))
and ln_contrapartes.id_padron in (select id_padron from ln_contrapartes where cliente = 861672084 and activo=1 and country_code='AR')




/*
select * from padrones where id_padron in (
select id_padron from ln_contrapartes where contraparte in (193603,194090,194091,194094,194095,194103,194156) and contraparte not in (193603,194156))


select * from ln_gestiones where contraparte in (193603,194090,194091,194094,194095,194103,194156)
select * from ln_demo where contraparte in (193603,194090,194091,194094,194095,194103,194156)

select * from informes where cliente = 861672084 and  fecha_ingreso > '2023-01-15 12:16:06.080'
select contraparte  from ln_demo where contraparte in (select contraparte from ln_contrapartes where cliente = 861672084 and activo = 1 and contraparte not in (193603,194156))
delete ln_demo where contraparte in (select contraparte from ln_contrapartes where cliente = 861672084 and activo = 1 and contraparte not in (193603,194156))
delete informes where cliente = 861672084 and  fecha_ingreso > '2023-01-15 12:16:06.080'
delete consumo_contratos where informe in (select informe from informes where cliente = 861672084 and  fecha_ingreso > '2023-01-15 12:16:06.080')

*/







Open LEDALTAMASIVA

Fetch NEXT FROM LEDALTAMASIVA INTO @gestion,@p_contraparte,@cliente


While @@FETCH_STATUS = 0

BEGIN



BEGIN TRY

/* GENERAR INFORME EN BLUE Y EN LN_DEMO */
set @contra = @p_contraparte

if (@servicio_contratado !=73 )
begin
-- SELECT * FROM contratos_items WHERE item_contrato=1520
-- SELECT * FROM tipos_informe WHERE id_tipo_informe IN (SELECT DISTINCT id_tipo_informe  FROM INFORMES ) ORDER BY nombre_tipo_informe
 set @itemcontrato = 353  -- CONTRATOS ITEMS
 set @solicitante=224014006-- 295891824
 set @itemcontrato = 1520  -- CONTRATOS ITEMS
 declare @asignado int =45460019
 set @prioridad=5
 set @datam=45460019
 set @productoblue=64 -- CONTRATOS ITEMS
 set @productoleddemo = 2045--LEGAJO SIMPLE

 set @idtipo = 7772659 -- ENRIQUECIMIENTO
 --SELECT * FROM TIPOS_INFORME WHERE ID_TIPO_INFORME=7772659
-- SELECT * FROM USERS WHERE user_id IN (45460019,224014006,608083,102549745)

 exec LN_informes 'ingresar_informe', @contra, @inf output, @solicitante, @itemcontrato, @productoblue, @idtipo, @prioridad, 'A', @solicitante, @datam, @asignado, @cliente, @fechalimite, @productoleddemo, @fechalimite, 'Carga backend'
 --exec LN_informes 'activar_gestion_documentacion', @contra, @inf, @solicitante, @itemcontrato, @productoblue, @idtipo, @prioridad, 'P', @solicitante, @datam, @asignado, @cliente, @fechalimite, @productoleddemo,@fechalimite, 'Carga backend'
 /*
  insert into LN_demo (contraparte, gestion, producto, informe, created, visible) values (@contra, @gestion, @productoleddemo, @inf, GETDATE(), 0)
 
  select @contra, @gestion, @productoleddemo, @inf, GETDATE(), 0
  */

 --UPDATE LN_demo SET VISIBLE=0 where contraparte= @contra and gestion= @gestion and informe= @inf
 select 'DEMO Y BLUE GENERADO'
end


--update ln_altas_masivas2 set procesado = 1,contraparte = @idContra where id_padron=@idpadron and id_alta=@idAlta





END TRY
BEGIN CATCH

END CATCH




Fetch NEXT FROM LEDALTAMASIVA INTO  @gestion,@p_contraparte,@cliente

END 

CLOSE LEDALTAMASIVA
DEALLOCATE LEDALTAMASIVA


END

GO

Used By

No items found