Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
13| Name | Data Type | Length | Description |
|---|---|---|---|
| @accion | varchar | 50 | |
| @p_cliente | int | 4 | |
| @p_user_id | int | 4 | |
| @p_id_tipo_informe | int | 4 | |
| @p_identificacion | varchar | 20 | |
| @p_identificador | varchar | 5 | |
| @p_idTareaExterna | int | 4 | |
| @p_team_id | int | 4 | |
| @p_fecha_desde | datetime | 8 | |
| @p_fecha_hasta | datetime | 8 | |
| @p_plataforma | varchar | 10 | |
| @p_id_padron | int | 4 | |
| @fecha_comprometida | datetime | 8 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/* sp Blue Terceros */
CREATE OR ALTER PROCEDURE dbo.LN_blue_terceros
@accion varchar(50), /*CONTRAPARTE_DATACLEAN / PANEL_TAREAS_TERCEROS / REPORTE_DCL */
@p_cliente int,
@p_user_id int,
@p_id_tipo_informe int,
@p_identificacion varchar(20),
@p_identificador varchar(5),
@p_idTareaExterna int,
@p_team_id int,
@p_fecha_desde datetime = null,
@p_fecha_hasta datetime = null,
@p_plataforma varchar(10)=null,
@p_id_padron int = null,
@fecha_comprometida datetime = null
/*
APIKEY
IDENTIFICACION
IDENTIFICADOR
TareaExterna
CLIENTE
USER_ID
ID TIPO DE INFORME
*/
/*
EXEC LN_blue_terceros 'ALTA_INFORME_TERCEROS',2254875,15342812,9876052,'20955578350','CUIL',23541,15
EXEC LN_blue_terceros 'PANEL_TAREAS_TERCEROS',738156811,null,9876052,null,null,null,null
SELECT * FROM INFORMES WHERE ID_TIPO_INFORME = 9876052 OR INFORME_PADRE = 100710579
*/
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
DECLARE @ahora datetime = GETDATE()
DECLARE @usuario varchar(100) = NULL
DECLARE @preffix varchar(200) = ''
declare @nombre_candidato varchar(100) = null
declare @identificador varchar(30) = null
declare @numero varchar(100) = null
declare @sexo varchar(1) = null
declare @country varchar(2) = null
declare @informe int
declare @informeClean int
declare @cliente int = @p_cliente
declare @p_datamanager int = 0
if (upper(@accion)='CONTRAPARTE_DATACLEAN')
BEGIN
declare @iv_busqueda int = 0
declare @contrap int = 0
declare @gestion int = 0
declare @producto_led int = @p_plataforma
declare @p_id_producto int = 2039
declare @p_familia int = 0
DECLARE @item_contrato INT = 0
declare @consumo int = 0
set @p_familia = (select top 1 familia from ln_familias where cliente = @p_cliente and visible=1)
/** datos del padrón **/
select @nombre_candidato = left(padrones.nombre_persona,100),
@identificador = padrones.identificador,
@numero = padrones.numero,
@sexo = padrones.sexo,
@country = identificadores.country_code
from padrones inner join identificadores on padrones.identificador = identificadores.identificador
where padrones.id_padron = @p_id_padron
EXEC @informeClean = LN_blue_terceros 'ALTA_INFORME_TERCEROS', @p_cliente, @p_user_id, @p_id_tipo_informe, @numero,
@identificador, @p_idTareaExterna, 15, null, null, null, null, @fecha_comprometida
/** INGRESO DE LA BUSQUEDA **/
insert into IV_busquedas
(cliente, informe, item_contrato, consumo,
creado, creado_por, id_padron, verif_padron, identificador, numero, nombre_candidato,sexo_candidato)
values
(@p_cliente, @informeClean, iif(@item_contrato > 0, @item_contrato, 0), iif(@consumo > 0, @consumo, 0),
getdate(), @p_user_id, @p_id_padron, 1,
@identificador, @numero, @nombre_candidato, @sexo)
set @iv_busqueda = SCOPE_IDENTITY()
if (@iv_busqueda is not null)
begin
/* Ingresar la contraparte y gestión */
insert into LN_contrapartes (cliente, id_padron, country_code, activo, nombre_contacto,
created, created_by, modified, modified_by,
vigencia_desde, vigencia_hasta, subcontratista, codigo_idioma,
clave, clave_temporal, clave_expira, servicio_contratado)
values (@p_cliente, @p_id_padron, @country, 1, @nombre_candidato,
GETDATE(), @p_user_id, NULL, NULL, GETDATE(), GETDATE()+700, 0, 'spa', 'DATACLEAN', 0, GETDATE()+700,@p_plataforma)
set @contrap = SCOPE_IDENTITY()
INSERT INTO LN_gestiones (contraparte, cliente, desde, hasta, vigente, created, created_by, modified, modified_by, iv_busqueda)
values (@contrap, @p_cliente, GETDATE(), GETDATE()+700, 1, GETDATE(), @p_user_id, NULL, NULL, @iv_busqueda)
set @gestion = SCOPE_IDENTITY()
if (@producto_led is not null)
begin
insert into LN_demo (contraparte, gestion, producto, informe, visible,idTeam) values (@contrap, @gestion, @p_id_producto, @informeClean, 0,@p_team_id)
end
insert into LN_contraparte_familias (contraparte, familia, activo, created, created_by) values (@contrap, @p_familia, 1, GETDATE(), @p_user_id)
/*
select @producto_led = producto from LN_productos where producto_consumos = @p_id_producto
*/
-- Asentar consumo de usuario
insert into usuarios_consumos (user_id, cuit_consultado, id_producto, created)
values (@p_user_id, @numero, @p_id_producto, GETDATE())
/* Actualizar el legajo */
EXEC LN_actualizar_legajo @contrap, @gestion, @p_user_id
-- Devolución de los datos generados
/*SELECT @iv_busqueda AS iv_busqueda, @informe AS informe, @contrap AS contraparte, @gestion AS gestion*/
select @informeClean as infGenerado
return
end
END
IF ( UPPER(@accion)='REPORTE_DCL' )
BEGIN
-- Panel de Reportes de data cleaning
SELECT
-- datos de cliente
Tareas.cliente,
clientes.nombre_cliente,
-- datos de la tarea
Tareas.informe,
Tareas.id_tipo_informe,
LN_tareas.nombre_tarea,
Tareas.estado_informe as cod_estado_tarea,
Tareas.fecha_ingreso,
Tareas.fecha_inicio as inicio_tarea,
Tareas.fecha_comprometida as fecha_comprometida_tarea,
Tareas.ready_to_start,
Tareas.ready_to_start_date,
Tareas.asignado,
(users.first_name+' '+users.last_name) as usuario_tarea,
Tareas.pausa,
-- datos de la persona
padrones.nombre_persona,
padrones.identificador,
padrones.identificacion,
identificadores.country_code,
-- datos el informe
Tareas.informe_padre,
informes.estado_informe as cod_estado_informe,
LN_tipo_informes.nombre_tipo_informe AS nombre_informe,
informes.fecha_inicio as inicio_informe,
informes.fecha_comprometida as fecha_comprometida_informe,
15 as idTeam, -- forzado por ahora
'TEAM 15' AS nombreTeam -- forzado por ahora
FROM informes as Tareas
INNER JOIN informes ON informes.informe=Tareas.informe_padre
INNER JOIN LN_tipo_informes ON LN_tipo_informes.idTipoInforme = informes.id_tipo_informe
--
INNER JOIN clientes ON clientes.cliente=informes.cliente
--
INNER JOIN LN_tareas ON LN_tareas.idTarea=Tareas.idTarea
--
INNER JOIN users ON users.user_id=Tareas.asignado
--
INNER JOIN padrones ON padrones.numero = informes.numero AND padrones.identificador=informes.identificador
INNER JOIN identificadores ON identificadores.identificador=padrones.identificador
WHERE
informes.id_tipo_informe IN ('632095719','9876052','9876050') -- tipo de informe de data cleaning (forzados por ahora)
AND informes.estado_informe NOT IN ('K','N','C','F')
AND Tareas.informe_padre IS NOT NULL
AND Tareas.estado_informe NOT IN ('K','N','C','F')
RETURN;
END
if (upper(@accion)='PANEL_TAREAS_TERCEROS')
BEGIN
select distinct informes.informe, subinformes.informe as tarea,
clientes.nombre_cliente,
tipos_informe_padre.nombre_tipo_informe as tipo_informe_padre,
users.first_name, users.last_name,
ISNULL(users.first_name,'') + ' ' + ISNULL(users.last_name,'') as usuario,
/*tipos_informe_tarea.nombre_tarea as tipo_informe_tarea,*/
tipos_informe_tarea.nombre_tarea as tipo_informe_tarea,
subinformes.fecha_iniciado as fecha_iniciado,
subinformes.fecha_inicio as fecha_inicio,
subinformes.fecha_entregado, identificadores.abreviatura,
identificadores.country_code, padrones.numero, padrones.nombre_persona, country.country_name,
/*datediff(minute,subinformes.fecha_inicio,subinformes.fecha_entregado) as minutos_tardo,/* lo que tardo en total en minutos */ */
LN_informe_design.duracion as minutos_std, /* duracion standard de la tarea en minutos */
format(LN_informe_design.duracion/60*100 +LN_informe_design.duracion%60*1 ,'00:00') as duracion, /* duracion standard de la tarea en hh:mm */
subinformes.TAT_Task as tiempo_acumulado
,CAST((subinformes.TAT_Task - LN_informe_design.duracion) AS DECIMAL(10,2)) AS diferencia /* diferencia entre la duracion standard de la tarea y lo que tardo en total */
from informes
INNER JOIN informes AS subinformes ON informes.informe = subinformes.informe_padre
/*
INNER JOIN ln_demo ON (ln_demo.informe=informes.informe)
INNER JOIN ln_contrapartes ON (ln_demo.contraparte=ln_contrapartes.contraparte AND LN_contrapartes.servicio_contratado = 10)
*/
INNER JOIN LN_tipo_informes AS tipos_informe_padre ON informes.id_tipo_informe=tipos_informe_padre.idTipoInforme
/*inner join tipos_informe as tipos_informe_tarea on subinformes.id_tipo_informe = tipos_informe_tarea.id_tipo_informe*/
INNER JOIN ln_tareas AS tipos_informe_tarea ON subinformes.idtarea = tipos_informe_tarea.idTarea
INNER JOIN LN_informe_design ON (LN_informe_design.idElem = tipos_informe_tarea.idTarea and informes.id_tipo_informe = LN_informe_design.idTipoInforme)
INNER JOIN clientes ON informes.cliente = clientes.cliente
INNER JOIN users ON subinformes.asignado = users.user_id
INNER JOIN padrones ON (informes.identificador = padrones.identificador AND informes.numero = padrones.IDENTIFICACION)
INNER JOIN identificadores ON padrones.identificador = identificadores.identificador
INNER JOIN country ON identificadores.country_code = country.country_code
WHERE /*(subinformes.fecha_entregado BETWEEN @p_fecha_desde and (@p_fecha_hasta+1) OR subinformes.fecha_aprobacion BETWEEN @p_fecha_desde and (@p_fecha_hasta+1) )
AND */subinformes.estado_informe not IN ('F', 'K', 'N')
and informes.id_tipo_informe = @p_id_tipo_informe
/* and (clientes.cliente = @V_cliente or @V_cliente = 0)
and (subinformes.id_tipo_informe = @V_id_tipo_informe or @V_id_tipo_informe = 0)
and (users.user_id = @V_user_id or @V_user_id = 0)
*/
/*and informes.informe = 100702586*/
ORDER BY subinformes.fecha_entregado ASC
END
if (upper(@accion) = 'ALTA_INFORME_TERCEROS')
begin
if (@p_identificacion is not null and @p_id_tipo_informe is not null)
begin
/** datos del padrón **/
select @nombre_candidato = left(padrones.nombre_persona,100),
@identificador = padrones.identificador,
@numero = padrones.numero,
@sexo = padrones.sexo,
@country = identificadores.country_code
from padrones inner join identificadores on padrones.identificador = identificadores.identificador
where padrones.identificacion = @p_identificacion and habilitado = 1 and padrones.identificador in (select identificador from identificadores where country_code='AR' and se_usa=1)
/* Ingresar el informe */
/* 23-10-2023 se elimna esta linea a pedido de Rami */
--exec @informe = Genera_ID_Informe_2022 @cliente,null
/* Ingresar el informe en el sistema de terceros */
declare @informeIVterceros int = @p_id_tipo_informe
declare @cliIVTerceros int=@p_cliente
declare @dependency_tree varchar(200)=null
exec @informeIVterceros = Genera_ID_Informe_2022 @cliIVTerceros,null
if (@informeIVterceros IS NOT NULL)
begin
declare @tipoinformeTerceros int = @p_id_tipo_informe
set @ahora = getdate()
declare @superv int = null
declare @idTarea int = null
declare @duracionDesign int = 0
declare @prioridad int = 5
declare @fecha_limite datetime
select top 1 @superv = LN_Team_Members.user_id
/* select LN_Team_Members. */
from LN_informe_design inner join ln_tareas on (ln_tareas.idTarea = LN_informe_design.idElem and LN_informe_design.tipo_elem='T')
left join LN_Roles on ln_tareas.perfil_usr_default=ln_roles.id_rol
left join LN_Team_Members on LN_Team_Members.id_rol=LN_Roles.id_rol
where LN_informe_design.idTipoInforme = @tipoinformeTerceros --9876052
and LN_Team_Members.id_team= @p_team_id --15
and LN_Team_Members.activo=1
and LN_Team_Members.isdefault=1
and LN_informe_design.activo=1
and LN_Roles.id_rol=1
/* Ingresar el informe en Fidelitas */
update informes set informe= @informeIVterceros, cliente=@cliIVTerceros, identificador=@identificador, numero=@numero, fecha_ingreso=@ahora, id_tipo_informe=@tipoinformeTerceros,
objeto_informe='SOLICITUD DE DATA CLEANING TERCEROS', ingresado_por=@p_user_id, prioridad=@prioridad, datamanager=@p_datamanager,
idioma=29523,
informeid_terceros = @p_idTareaExterna,
asignado = @superv,
estado_informe= 'A',
fecha_asignado=getdate(),
fecha_aceptacion=getdate(),
fecha_comprometida=@fecha_comprometida,
fecha_inicio=@ahora
where informe = @informeIVterceros and idreg= @informeIVterceros
declare @tarea int = 0
declare @tipo_subinforme int = 0
declare @USID int = 0
declare @orden int = 0
declare @prioridad_tarea int = 0
declare @activa_gestion bit = 0
declare @isinicial bit = 0
/* Generación de las subtareas */
/*TAREAS DEL INFORME DE TERCEROS DATA CLEANING*/
DECLARE TipoTerceros CURSOR FOR
select ln_tareas.id_tipo_informe_blue, LN_informe_design.orden, isnull(LN_informe_design.prioridad,0) as prioridad_default,0 as genera_solicitud_doc,/* tipos_informe.genera_solicitud_doc,*/
/*ln_tareas.*,LN_Roles.*,*/LN_Team_Members.user_id as USID,ln_tareas.isinicial,LN_tareas.idTarea,LN_informe_design.duracion,LN_informe_design.dependency_tree
from LN_informe_design inner join ln_tareas on (ln_tareas.idTarea = LN_informe_design.idElem and LN_informe_design.tipo_elem='T')
left join LN_Roles on ln_tareas.perfil_usr_default=ln_roles.id_rol
left join LN_Team_Members on LN_Team_Members.id_rol=LN_Roles.id_rol
where LN_informe_design.idTipoInforme = @tipoinformeTerceros--@p_id_tipo_informe
and LN_Team_Members.id_team=@p_team_id
and LN_Team_Members.activo=1
and LN_Team_Members.isdefault=1
and LN_informe_design.activo=1
order by LN_informe_design.orden
--informeid_terceros = @informe, @idTarea
OPEN TipoTerceros
FETCH NEXT FROM TipoTerceros INTO @tipo_subinforme, @orden, @prioridad_tarea, @activa_gestion,@USID,@isinicial,@idTarea,@duracionDesign,@dependency_tree
WHILE @@FETCH_STATUS = 0 BEGIN
exec @tarea = Genera_ID_Informe_2022 @cliIVTerceros,@informeIVterceros
/*select @tarea as miTarea*/
if (@tarea > 0) begin
/* La prioridad de cada tarea depende del tipo de informe. Si está en 0 o nula toma la del informe padre */
update informes set informe =@tarea , cliente=@cliIVTerceros, identificador=@identificador, numero=@numero, fecha_ingreso=getdate(), id_tipo_informe=@tipo_subinforme,
objeto_informe=null, historial_informe=@preffix + 'Creación de tarea.', ingresado_por=@p_user_id, asignado=@USID,
fecha_comprometida=DATEADD(minute,@duracionDesign,getdate()) ,
idioma=29523,
prioridad=iif(@prioridad_tarea > 0, @prioridad_tarea, @prioridad), datamanager=@p_datamanager, estado_informe='A', orden=@orden, informe_padre=@informeIVterceros,
ready_to_start = iif(@dependency_tree is null,1,0),
informeid_terceros=@p_idTareaExterna,idTarea=@idTarea,
fecha_inicio=@ahora
where informe = @tarea and idreg= @tarea
end
FETCH NEXT FROM TipoTerceros INTO @tipo_subinforme, @orden, @prioridad_tarea, @activa_gestion,@USID,@isinicial,@idTarea,@duracionDesign,@dependency_tree
END
CLOSE TipoTerceros
DEALLOCATE TipoTerceros
/* FIN DE TERCEROS*/
end
/** fin de informe **/
--select @informe as infGenerado
/* 23-10-2023: A pedido de Rami: cambia el ultimo select del store para que sea ese */
--select @informeIVterceros as infGenerado
return @informeIVterceros
end
end
END
GO
GO
/* sp Blue Terceros */
CREATE OR ALTER PROCEDURE dbo.LN_blue_terceros
@accion varchar(50), /*CONTRAPARTE_DATACLEAN / PANEL_TAREAS_TERCEROS / REPORTE_DCL */
@p_cliente int,
@p_user_id int,
@p_id_tipo_informe int,
@p_identificacion varchar(20),
@p_identificador varchar(5),
@p_idTareaExterna int,
@p_team_id int,
@p_fecha_desde datetime = null,
@p_fecha_hasta datetime = null,
@p_plataforma varchar(10)=null,
@p_id_padron int = null,
@fecha_comprometida datetime = null
/*
APIKEY
IDENTIFICACION
IDENTIFICADOR
TareaExterna
CLIENTE
USER_ID
ID TIPO DE INFORME
*/
/*
EXEC LN_blue_terceros 'ALTA_INFORME_TERCEROS',2254875,15342812,9876052,'20955578350','CUIL',23541,15
EXEC LN_blue_terceros 'PANEL_TAREAS_TERCEROS',738156811,null,9876052,null,null,null,null
SELECT * FROM INFORMES WHERE ID_TIPO_INFORME = 9876052 OR INFORME_PADRE = 100710579
*/
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
DECLARE @ahora datetime = GETDATE()
DECLARE @usuario varchar(100) = NULL
DECLARE @preffix varchar(200) = ''
declare @nombre_candidato varchar(100) = null
declare @identificador varchar(30) = null
declare @numero varchar(100) = null
declare @sexo varchar(1) = null
declare @country varchar(2) = null
declare @informe int
declare @informeClean int
declare @cliente int = @p_cliente
declare @p_datamanager int = 0
if (upper(@accion)='CONTRAPARTE_DATACLEAN')
BEGIN
declare @iv_busqueda int = 0
declare @contrap int = 0
declare @gestion int = 0
declare @producto_led int = @p_plataforma
declare @p_id_producto int = 2039
declare @p_familia int = 0
DECLARE @item_contrato INT = 0
declare @consumo int = 0
set @p_familia = (select top 1 familia from ln_familias where cliente = @p_cliente and visible=1)
/** datos del padrón **/
select @nombre_candidato = left(padrones.nombre_persona,100),
@identificador = padrones.identificador,
@numero = padrones.numero,
@sexo = padrones.sexo,
@country = identificadores.country_code
from padrones inner join identificadores on padrones.identificador = identificadores.identificador
where padrones.id_padron = @p_id_padron
EXEC @informeClean = LN_blue_terceros 'ALTA_INFORME_TERCEROS', @p_cliente, @p_user_id, @p_id_tipo_informe, @numero,
@identificador, @p_idTareaExterna, 15, null, null, null, null, @fecha_comprometida
/** INGRESO DE LA BUSQUEDA **/
insert into IV_busquedas
(cliente, informe, item_contrato, consumo,
creado, creado_por, id_padron, verif_padron, identificador, numero, nombre_candidato,sexo_candidato)
values
(@p_cliente, @informeClean, iif(@item_contrato > 0, @item_contrato, 0), iif(@consumo > 0, @consumo, 0),
getdate(), @p_user_id, @p_id_padron, 1,
@identificador, @numero, @nombre_candidato, @sexo)
set @iv_busqueda = SCOPE_IDENTITY()
if (@iv_busqueda is not null)
begin
/* Ingresar la contraparte y gestión */
insert into LN_contrapartes (cliente, id_padron, country_code, activo, nombre_contacto,
created, created_by, modified, modified_by,
vigencia_desde, vigencia_hasta, subcontratista, codigo_idioma,
clave, clave_temporal, clave_expira, servicio_contratado)
values (@p_cliente, @p_id_padron, @country, 1, @nombre_candidato,
GETDATE(), @p_user_id, NULL, NULL, GETDATE(), GETDATE()+700, 0, 'spa', 'DATACLEAN', 0, GETDATE()+700,@p_plataforma)
set @contrap = SCOPE_IDENTITY()
INSERT INTO LN_gestiones (contraparte, cliente, desde, hasta, vigente, created, created_by, modified, modified_by, iv_busqueda)
values (@contrap, @p_cliente, GETDATE(), GETDATE()+700, 1, GETDATE(), @p_user_id, NULL, NULL, @iv_busqueda)
set @gestion = SCOPE_IDENTITY()
if (@producto_led is not null)
begin
insert into LN_demo (contraparte, gestion, producto, informe, visible,idTeam) values (@contrap, @gestion, @p_id_producto, @informeClean, 0,@p_team_id)
end
insert into LN_contraparte_familias (contraparte, familia, activo, created, created_by) values (@contrap, @p_familia, 1, GETDATE(), @p_user_id)
/*
select @producto_led = producto from LN_productos where producto_consumos = @p_id_producto
*/
-- Asentar consumo de usuario
insert into usuarios_consumos (user_id, cuit_consultado, id_producto, created)
values (@p_user_id, @numero, @p_id_producto, GETDATE())
/* Actualizar el legajo */
EXEC LN_actualizar_legajo @contrap, @gestion, @p_user_id
-- Devolución de los datos generados
/*SELECT @iv_busqueda AS iv_busqueda, @informe AS informe, @contrap AS contraparte, @gestion AS gestion*/
select @informeClean as infGenerado
return
end
END
IF ( UPPER(@accion)='REPORTE_DCL' )
BEGIN
-- Panel de Reportes de data cleaning
SELECT
-- datos de cliente
Tareas.cliente,
clientes.nombre_cliente,
-- datos de la tarea
Tareas.informe,
Tareas.id_tipo_informe,
LN_tareas.nombre_tarea,
Tareas.estado_informe as cod_estado_tarea,
Tareas.fecha_ingreso,
Tareas.fecha_inicio as inicio_tarea,
Tareas.fecha_comprometida as fecha_comprometida_tarea,
Tareas.ready_to_start,
Tareas.ready_to_start_date,
Tareas.asignado,
(users.first_name+' '+users.last_name) as usuario_tarea,
Tareas.pausa,
-- datos de la persona
padrones.nombre_persona,
padrones.identificador,
padrones.identificacion,
identificadores.country_code,
-- datos el informe
Tareas.informe_padre,
informes.estado_informe as cod_estado_informe,
LN_tipo_informes.nombre_tipo_informe AS nombre_informe,
informes.fecha_inicio as inicio_informe,
informes.fecha_comprometida as fecha_comprometida_informe,
15 as idTeam, -- forzado por ahora
'TEAM 15' AS nombreTeam -- forzado por ahora
FROM informes as Tareas
INNER JOIN informes ON informes.informe=Tareas.informe_padre
INNER JOIN LN_tipo_informes ON LN_tipo_informes.idTipoInforme = informes.id_tipo_informe
--
INNER JOIN clientes ON clientes.cliente=informes.cliente
--
INNER JOIN LN_tareas ON LN_tareas.idTarea=Tareas.idTarea
--
INNER JOIN users ON users.user_id=Tareas.asignado
--
INNER JOIN padrones ON padrones.numero = informes.numero AND padrones.identificador=informes.identificador
INNER JOIN identificadores ON identificadores.identificador=padrones.identificador
WHERE
informes.id_tipo_informe IN ('632095719','9876052','9876050') -- tipo de informe de data cleaning (forzados por ahora)
AND informes.estado_informe NOT IN ('K','N','C','F')
AND Tareas.informe_padre IS NOT NULL
AND Tareas.estado_informe NOT IN ('K','N','C','F')
RETURN;
END
if (upper(@accion)='PANEL_TAREAS_TERCEROS')
BEGIN
select distinct informes.informe, subinformes.informe as tarea,
clientes.nombre_cliente,
tipos_informe_padre.nombre_tipo_informe as tipo_informe_padre,
users.first_name, users.last_name,
ISNULL(users.first_name,'') + ' ' + ISNULL(users.last_name,'') as usuario,
/*tipos_informe_tarea.nombre_tarea as tipo_informe_tarea,*/
tipos_informe_tarea.nombre_tarea as tipo_informe_tarea,
subinformes.fecha_iniciado as fecha_iniciado,
subinformes.fecha_inicio as fecha_inicio,
subinformes.fecha_entregado, identificadores.abreviatura,
identificadores.country_code, padrones.numero, padrones.nombre_persona, country.country_name,
/*datediff(minute,subinformes.fecha_inicio,subinformes.fecha_entregado) as minutos_tardo,/* lo que tardo en total en minutos */ */
LN_informe_design.duracion as minutos_std, /* duracion standard de la tarea en minutos */
format(LN_informe_design.duracion/60*100 +LN_informe_design.duracion%60*1 ,'00:00') as duracion, /* duracion standard de la tarea en hh:mm */
subinformes.TAT_Task as tiempo_acumulado
,CAST((subinformes.TAT_Task - LN_informe_design.duracion) AS DECIMAL(10,2)) AS diferencia /* diferencia entre la duracion standard de la tarea y lo que tardo en total */
from informes
INNER JOIN informes AS subinformes ON informes.informe = subinformes.informe_padre
/*
INNER JOIN ln_demo ON (ln_demo.informe=informes.informe)
INNER JOIN ln_contrapartes ON (ln_demo.contraparte=ln_contrapartes.contraparte AND LN_contrapartes.servicio_contratado = 10)
*/
INNER JOIN LN_tipo_informes AS tipos_informe_padre ON informes.id_tipo_informe=tipos_informe_padre.idTipoInforme
/*inner join tipos_informe as tipos_informe_tarea on subinformes.id_tipo_informe = tipos_informe_tarea.id_tipo_informe*/
INNER JOIN ln_tareas AS tipos_informe_tarea ON subinformes.idtarea = tipos_informe_tarea.idTarea
INNER JOIN LN_informe_design ON (LN_informe_design.idElem = tipos_informe_tarea.idTarea and informes.id_tipo_informe = LN_informe_design.idTipoInforme)
INNER JOIN clientes ON informes.cliente = clientes.cliente
INNER JOIN users ON subinformes.asignado = users.user_id
INNER JOIN padrones ON (informes.identificador = padrones.identificador AND informes.numero = padrones.IDENTIFICACION)
INNER JOIN identificadores ON padrones.identificador = identificadores.identificador
INNER JOIN country ON identificadores.country_code = country.country_code
WHERE /*(subinformes.fecha_entregado BETWEEN @p_fecha_desde and (@p_fecha_hasta+1) OR subinformes.fecha_aprobacion BETWEEN @p_fecha_desde and (@p_fecha_hasta+1) )
AND */subinformes.estado_informe not IN ('F', 'K', 'N')
and informes.id_tipo_informe = @p_id_tipo_informe
/* and (clientes.cliente = @V_cliente or @V_cliente = 0)
and (subinformes.id_tipo_informe = @V_id_tipo_informe or @V_id_tipo_informe = 0)
and (users.user_id = @V_user_id or @V_user_id = 0)
*/
/*and informes.informe = 100702586*/
ORDER BY subinformes.fecha_entregado ASC
END
if (upper(@accion) = 'ALTA_INFORME_TERCEROS')
begin
if (@p_identificacion is not null and @p_id_tipo_informe is not null)
begin
/** datos del padrón **/
select @nombre_candidato = left(padrones.nombre_persona,100),
@identificador = padrones.identificador,
@numero = padrones.numero,
@sexo = padrones.sexo,
@country = identificadores.country_code
from padrones inner join identificadores on padrones.identificador = identificadores.identificador
where padrones.identificacion = @p_identificacion and habilitado = 1 and padrones.identificador in (select identificador from identificadores where country_code='AR' and se_usa=1)
/* Ingresar el informe */
/* 23-10-2023 se elimna esta linea a pedido de Rami */
--exec @informe = Genera_ID_Informe_2022 @cliente,null
/* Ingresar el informe en el sistema de terceros */
declare @informeIVterceros int = @p_id_tipo_informe
declare @cliIVTerceros int=@p_cliente
declare @dependency_tree varchar(200)=null
exec @informeIVterceros = Genera_ID_Informe_2022 @cliIVTerceros,null
if (@informeIVterceros IS NOT NULL)
begin
declare @tipoinformeTerceros int = @p_id_tipo_informe
set @ahora = getdate()
declare @superv int = null
declare @idTarea int = null
declare @duracionDesign int = 0
declare @prioridad int = 5
declare @fecha_limite datetime
select top 1 @superv = LN_Team_Members.user_id
/* select LN_Team_Members. */
from LN_informe_design inner join ln_tareas on (ln_tareas.idTarea = LN_informe_design.idElem and LN_informe_design.tipo_elem='T')
left join LN_Roles on ln_tareas.perfil_usr_default=ln_roles.id_rol
left join LN_Team_Members on LN_Team_Members.id_rol=LN_Roles.id_rol
where LN_informe_design.idTipoInforme = @tipoinformeTerceros --9876052
and LN_Team_Members.id_team= @p_team_id --15
and LN_Team_Members.activo=1
and LN_Team_Members.isdefault=1
and LN_informe_design.activo=1
and LN_Roles.id_rol=1
/* Ingresar el informe en Fidelitas */
update informes set informe= @informeIVterceros, cliente=@cliIVTerceros, identificador=@identificador, numero=@numero, fecha_ingreso=@ahora, id_tipo_informe=@tipoinformeTerceros,
objeto_informe='SOLICITUD DE DATA CLEANING TERCEROS', ingresado_por=@p_user_id, prioridad=@prioridad, datamanager=@p_datamanager,
idioma=29523,
informeid_terceros = @p_idTareaExterna,
asignado = @superv,
estado_informe= 'A',
fecha_asignado=getdate(),
fecha_aceptacion=getdate(),
fecha_comprometida=@fecha_comprometida,
fecha_inicio=@ahora
where informe = @informeIVterceros and idreg= @informeIVterceros
declare @tarea int = 0
declare @tipo_subinforme int = 0
declare @USID int = 0
declare @orden int = 0
declare @prioridad_tarea int = 0
declare @activa_gestion bit = 0
declare @isinicial bit = 0
/* Generación de las subtareas */
/*TAREAS DEL INFORME DE TERCEROS DATA CLEANING*/
DECLARE TipoTerceros CURSOR FOR
select ln_tareas.id_tipo_informe_blue, LN_informe_design.orden, isnull(LN_informe_design.prioridad,0) as prioridad_default,0 as genera_solicitud_doc,/* tipos_informe.genera_solicitud_doc,*/
/*ln_tareas.*,LN_Roles.*,*/LN_Team_Members.user_id as USID,ln_tareas.isinicial,LN_tareas.idTarea,LN_informe_design.duracion,LN_informe_design.dependency_tree
from LN_informe_design inner join ln_tareas on (ln_tareas.idTarea = LN_informe_design.idElem and LN_informe_design.tipo_elem='T')
left join LN_Roles on ln_tareas.perfil_usr_default=ln_roles.id_rol
left join LN_Team_Members on LN_Team_Members.id_rol=LN_Roles.id_rol
where LN_informe_design.idTipoInforme = @tipoinformeTerceros--@p_id_tipo_informe
and LN_Team_Members.id_team=@p_team_id
and LN_Team_Members.activo=1
and LN_Team_Members.isdefault=1
and LN_informe_design.activo=1
order by LN_informe_design.orden
--informeid_terceros = @informe, @idTarea
OPEN TipoTerceros
FETCH NEXT FROM TipoTerceros INTO @tipo_subinforme, @orden, @prioridad_tarea, @activa_gestion,@USID,@isinicial,@idTarea,@duracionDesign,@dependency_tree
WHILE @@FETCH_STATUS = 0 BEGIN
exec @tarea = Genera_ID_Informe_2022 @cliIVTerceros,@informeIVterceros
/*select @tarea as miTarea*/
if (@tarea > 0) begin
/* La prioridad de cada tarea depende del tipo de informe. Si está en 0 o nula toma la del informe padre */
update informes set informe =@tarea , cliente=@cliIVTerceros, identificador=@identificador, numero=@numero, fecha_ingreso=getdate(), id_tipo_informe=@tipo_subinforme,
objeto_informe=null, historial_informe=@preffix + 'Creación de tarea.', ingresado_por=@p_user_id, asignado=@USID,
fecha_comprometida=DATEADD(minute,@duracionDesign,getdate()) ,
idioma=29523,
prioridad=iif(@prioridad_tarea > 0, @prioridad_tarea, @prioridad), datamanager=@p_datamanager, estado_informe='A', orden=@orden, informe_padre=@informeIVterceros,
ready_to_start = iif(@dependency_tree is null,1,0),
informeid_terceros=@p_idTareaExterna,idTarea=@idTarea,
fecha_inicio=@ahora
where informe = @tarea and idreg= @tarea
end
FETCH NEXT FROM TipoTerceros INTO @tipo_subinforme, @orden, @prioridad_tarea, @activa_gestion,@USID,@isinicial,@idTarea,@duracionDesign,@dependency_tree
END
CLOSE TipoTerceros
DEALLOCATE TipoTerceros
/* FIN DE TERCEROS*/
end
/** fin de informe **/
--select @informe as infGenerado
/* 23-10-2023: A pedido de Rami: cambia el ultimo select del store para que sea ese */
--select @informeIVterceros as infGenerado
return @informeIVterceros
end
end
END
GO
Depends On
14Used By
No items found