Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE OR ALTER PROCEDURE dbo.Task_RegeneraImperiumx30Minutos
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
exec API_consumos
/* AGB 01/11/2023
exec completar_cuit_
*/
update informes set ingresado_por=IV_busquedas.creado_por from IV_busquedas inner join informes on informes.informe = IV_busquedas.informe where
informes.ingresado_por is null
and informes.estado_informe not in ('F','K','N')
/*
select LedC.user_id,LNC.email_contacto from led_contratistas LedC inner join ln_contrapartes LNC on LedC.contratista_1=LNC.id_imperium
where LedC.cliente in (2046807993,9936068,1226057645) and LedC.user_id=0
*/
update LedC set user_id=users.user_id from
led_contratistas LedC inner join ln_contrapartes LNC on LedC.contratista_1=LNC.id_imperium
inner join users on LNC.email_contacto=users.username
where LedC.cliente in (2046807993,9936068,1226057645) and LedC.user_id=0
/*
UPDATE INFORMES SET estado_informe='I',FILIAL=13136,datamanager=45460019,ASIGNADO=436897241 WHERE cliente = 632095719 AND informe_padre IS not NULL AND estado_informe='A' and fecha_asignado is null
UPDATE INFORMES SET estado_informe='E',FILIAL=13136,datamanager=45460019,ASIGNADO=436897241 WHERE cliente = 632095719 AND informe_padre IS NULL AND estado_informe='A'
*/
EXEC Imperium_Regeneracion_Documentacion30Min
EXEC IV_Arreglo_Identificador
exec LN_panel_reports 'PANEL_USUARIOS',28750576,null,null,null,null,47,null
insert into consultar_afip (cuit,procesado,proceso,fecha,prioridad)
select distinct cuit_empleador,0,'EMPLEADORES','2025-01-09',1 from mis_aportes left join padrones on mis_aportes.cuit_empleador = padrones.identificacion
left join consultar_afip on mis_aportes.cuit_empleador = consultar_afip.cuit
where mis_aportes.inserted > getdate()-3
and padrones.identificacion is null
and mis_aportes.cuit_empleador is not null
and consultar_afip.cuit is null
/* AGB 01/11/2023
update informes set ingresado_por=45460019 where ingresado_por=15342812
update LN_contrapartes set servicio_contratado=10 where contraparte in (
select distinct LNC.contraparte from LN_contraparte_familias LNF inner join ln_contrapartes LNC on LNF.contraparte=LNC.contraparte where LNF.familia in (select distinct familia from ln_familias where servicio_contratado=10)
and LNC.servicio_contratado=47)
delete led_docs where periodo > 202107 and tipo_doc=374 and cliente = 2046807993 and estado_doc = 'N'
delete led_docs where periodo > 202108 and tipo_doc=2 and cliente = 2046807993 and estado_doc = 'N'
delete led_docs where periodo < 202109 and tipo_doc IN (1032,1033,1034) and cliente = 2046807993 and estado_doc = 'N'
delete led_docs where tipo_doc=1032 and estado_doc='N' and periodo > 202201 and cliente = 2046807993
delete led_docs where tipo_doc=1032 and estado_doc='N' and cliente = 2046807993
delete led_docs where estado_doc = 'N' and tipo_doc in (1059,1060,1061)
delete led_docs where tipo_doc = 648 and cliente = 2046807993 and periodo > 202109 and estado_doc = 'N'
delete led_docs where doc_id in (select doc_id from led_docs where periodo>202112 and led_seccion='V' and contratista_1 in (select contratista from led_contratistas where tipo_contratista in (58) and cliente = 9936068) and estado_doc!='V')
*/
/*
exec PadronesBCRAUpdate
*/
/* AGB 01/11/2023
exec juicios_arreglar_datos_AGB
delete led_vehiculos_periodo where vehiculo in (select vehiculo from led_vehiculos where cliente = 2046807993)
delete led_vehiculos where cliente = 2046807993
delete led_docs where cliente = 2046807993 and led_seccion='V'
delete led_docs where tipo_doc=346 and periodo > 202304 and cliente = 9936068 and estado_doc !='V' and contratista in (select contratista from led_contratistas where tipo_contratista=59)
*/
/*
EXEC Imperium_sync_tipo_contratista
*/
/*INFORMES DE DATA CLEANING */
/*AGB 01/11/2023
update iv set estado_informe='K' from informes as IV inner join informes FIDE on (IV.id_tipo_informe in (118887) and iv.numero=fide.numero and iv.identificador=fide.identificador and fide.cliente = 632095719)
and fide.informe in (select informe from informes where id_tipo_informe in (9876021) and estado_informe='K')
and iv.estado_informe!=fide.estado_informe
*/
insert into led_empleado_locaciones (empleado, locacion, asignada, asignada_por, vigencia_desde, vigencia_hasta, activo, created, created_by, modified, modified_by)
select empleado,1013 as locacion,getdate() as asignada,null as asignada_por,getdate() as vigencia_desde,null as vigencia_hasta,
1 as activo,getdate() as created,null as created_by,null as modified,null as modified_by
from led_empleados where cliente = 9936068 and empleado not in (select distinct empleado from led_empleado_locaciones)
/*
DECLARE @vidreg int
DECLARE C_TerminosTask CURSOR FOR
select top 100000 idrow from PANEL_CONTROL_JSON where cliente = 515494256
OPEN C_TerminosTask
FETCH NEXT FROM C_TerminosTask INTO @vidreg
WHILE @@fetch_status = 0
BEGIN
delete PANEL_CONTROL_JSON where idrow =@vidreg
FETCH NEXT FROM C_TerminosTask INTO @vidreg
END
CLOSE C_TerminosTask
DEALLOCATE C_TerminosTask
*/
/*
update ln_contrapartes set limite_carga_inicial = getdate()-1 where contraparte in (
select contraparte from ln_contrapartes where cliente = 5546348 and activo=1 and servicio_contratado=47 and limite_carga_inicial > getdate()-2 and limite_carga_inicial < '2025-07-01')
*/
/* PADRONES COSTA RICA */
/*
DECLARE @vnumero varchar(20)
DECLARE @vtipo_persona varchar(1)
DECLARE @videntificador varchar(4)
DECLARE @videntificacion varchar(20)
DECLARE @vcuerpo_clave varchar(20)
DECLARE @vhabilitado bit
DECLARE @viscreated datetime
DECLARE @vafip_activo bit
DECLARE @vapellidos varchar(100)
DECLARE @vnombres varchar(100)
DECLARE @vnombre_persona varchar(200)
DECLARE @vidreg int
DECLARE C_TerminosTask CURSOR FOR
select top 15000 cedula as numero,'F' as tipo_persona,'CICR' as identificador,cedula as identificacion,cedula as cuerpo_clave,1 as habilitado,getdate() as iscreated,1 as afip_activo,
ltrim(rtrim(apellido1)) + ' ' + ltrim(rtrim(apellido2)) as apellidos,ltrim(rtrim(nombre)) as nombres, ltrim(rtrim(apellido1)) + ' ' + ltrim(rtrim(apellido2)) + ' ' + ltrim(rtrim(nombre)) as nombre_persona
,idreg
from padron_costa_rica where
procesado = 0
order by idreg asc
OPEN C_TerminosTask
FETCH NEXT FROM C_TerminosTask INTO @vnumero,@vtipo_persona,@videntificador,@videntificacion,@vcuerpo_clave,@vhabilitado,@viscreated,@vafip_activo,@vapellidos,@vnombres,@vnombre_persona,@vidreg
WHILE @@fetch_status = 0
BEGIN
insert into padrones (numero,tipo_persona,identificador,identificacion,cuerpo_clave,habilitado,iscreated,afip_activo,apellidos,nombres,nombre_persona)
values (@vnumero,@vtipo_persona,@videntificador,@videntificacion,@vcuerpo_clave,@vhabilitado,@viscreated,@vafip_activo,@vapellidos,@vnombres,@vnombre_persona)
update padron_costa_rica set procesado = 1 where idreg =@vidreg
FETCH NEXT FROM C_TerminosTask INTO @vnumero,@vtipo_persona,@videntificador,@videntificacion,@vcuerpo_clave,@vhabilitado,@viscreated,@vafip_activo,@vapellidos,@vnombres,@vnombre_persona,@vidreg
END
CLOSE C_TerminosTask
DEALLOCATE C_TerminosTask
*/
END
GO
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE OR ALTER PROCEDURE dbo.Task_RegeneraImperiumx30Minutos
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
exec API_consumos
/* AGB 01/11/2023
exec completar_cuit_
*/
update informes set ingresado_por=IV_busquedas.creado_por from IV_busquedas inner join informes on informes.informe = IV_busquedas.informe where
informes.ingresado_por is null
and informes.estado_informe not in ('F','K','N')
/*
select LedC.user_id,LNC.email_contacto from led_contratistas LedC inner join ln_contrapartes LNC on LedC.contratista_1=LNC.id_imperium
where LedC.cliente in (2046807993,9936068,1226057645) and LedC.user_id=0
*/
update LedC set user_id=users.user_id from
led_contratistas LedC inner join ln_contrapartes LNC on LedC.contratista_1=LNC.id_imperium
inner join users on LNC.email_contacto=users.username
where LedC.cliente in (2046807993,9936068,1226057645) and LedC.user_id=0
/*
UPDATE INFORMES SET estado_informe='I',FILIAL=13136,datamanager=45460019,ASIGNADO=436897241 WHERE cliente = 632095719 AND informe_padre IS not NULL AND estado_informe='A' and fecha_asignado is null
UPDATE INFORMES SET estado_informe='E',FILIAL=13136,datamanager=45460019,ASIGNADO=436897241 WHERE cliente = 632095719 AND informe_padre IS NULL AND estado_informe='A'
*/
EXEC Imperium_Regeneracion_Documentacion30Min
EXEC IV_Arreglo_Identificador
exec LN_panel_reports 'PANEL_USUARIOS',28750576,null,null,null,null,47,null
insert into consultar_afip (cuit,procesado,proceso,fecha,prioridad)
select distinct cuit_empleador,0,'EMPLEADORES','2025-01-09',1 from mis_aportes left join padrones on mis_aportes.cuit_empleador = padrones.identificacion
left join consultar_afip on mis_aportes.cuit_empleador = consultar_afip.cuit
where mis_aportes.inserted > getdate()-3
and padrones.identificacion is null
and mis_aportes.cuit_empleador is not null
and consultar_afip.cuit is null
/* AGB 01/11/2023
update informes set ingresado_por=45460019 where ingresado_por=15342812
update LN_contrapartes set servicio_contratado=10 where contraparte in (
select distinct LNC.contraparte from LN_contraparte_familias LNF inner join ln_contrapartes LNC on LNF.contraparte=LNC.contraparte where LNF.familia in (select distinct familia from ln_familias where servicio_contratado=10)
and LNC.servicio_contratado=47)
delete led_docs where periodo > 202107 and tipo_doc=374 and cliente = 2046807993 and estado_doc = 'N'
delete led_docs where periodo > 202108 and tipo_doc=2 and cliente = 2046807993 and estado_doc = 'N'
delete led_docs where periodo < 202109 and tipo_doc IN (1032,1033,1034) and cliente = 2046807993 and estado_doc = 'N'
delete led_docs where tipo_doc=1032 and estado_doc='N' and periodo > 202201 and cliente = 2046807993
delete led_docs where tipo_doc=1032 and estado_doc='N' and cliente = 2046807993
delete led_docs where estado_doc = 'N' and tipo_doc in (1059,1060,1061)
delete led_docs where tipo_doc = 648 and cliente = 2046807993 and periodo > 202109 and estado_doc = 'N'
delete led_docs where doc_id in (select doc_id from led_docs where periodo>202112 and led_seccion='V' and contratista_1 in (select contratista from led_contratistas where tipo_contratista in (58) and cliente = 9936068) and estado_doc!='V')
*/
/*
exec PadronesBCRAUpdate
*/
/* AGB 01/11/2023
exec juicios_arreglar_datos_AGB
delete led_vehiculos_periodo where vehiculo in (select vehiculo from led_vehiculos where cliente = 2046807993)
delete led_vehiculos where cliente = 2046807993
delete led_docs where cliente = 2046807993 and led_seccion='V'
delete led_docs where tipo_doc=346 and periodo > 202304 and cliente = 9936068 and estado_doc !='V' and contratista in (select contratista from led_contratistas where tipo_contratista=59)
*/
/*
EXEC Imperium_sync_tipo_contratista
*/
/*INFORMES DE DATA CLEANING */
/*AGB 01/11/2023
update iv set estado_informe='K' from informes as IV inner join informes FIDE on (IV.id_tipo_informe in (118887) and iv.numero=fide.numero and iv.identificador=fide.identificador and fide.cliente = 632095719)
and fide.informe in (select informe from informes where id_tipo_informe in (9876021) and estado_informe='K')
and iv.estado_informe!=fide.estado_informe
*/
insert into led_empleado_locaciones (empleado, locacion, asignada, asignada_por, vigencia_desde, vigencia_hasta, activo, created, created_by, modified, modified_by)
select empleado,1013 as locacion,getdate() as asignada,null as asignada_por,getdate() as vigencia_desde,null as vigencia_hasta,
1 as activo,getdate() as created,null as created_by,null as modified,null as modified_by
from led_empleados where cliente = 9936068 and empleado not in (select distinct empleado from led_empleado_locaciones)
/*
DECLARE @vidreg int
DECLARE C_TerminosTask CURSOR FOR
select top 100000 idrow from PANEL_CONTROL_JSON where cliente = 515494256
OPEN C_TerminosTask
FETCH NEXT FROM C_TerminosTask INTO @vidreg
WHILE @@fetch_status = 0
BEGIN
delete PANEL_CONTROL_JSON where idrow =@vidreg
FETCH NEXT FROM C_TerminosTask INTO @vidreg
END
CLOSE C_TerminosTask
DEALLOCATE C_TerminosTask
*/
/*
update ln_contrapartes set limite_carga_inicial = getdate()-1 where contraparte in (
select contraparte from ln_contrapartes where cliente = 5546348 and activo=1 and servicio_contratado=47 and limite_carga_inicial > getdate()-2 and limite_carga_inicial < '2025-07-01')
*/
/* PADRONES COSTA RICA */
/*
DECLARE @vnumero varchar(20)
DECLARE @vtipo_persona varchar(1)
DECLARE @videntificador varchar(4)
DECLARE @videntificacion varchar(20)
DECLARE @vcuerpo_clave varchar(20)
DECLARE @vhabilitado bit
DECLARE @viscreated datetime
DECLARE @vafip_activo bit
DECLARE @vapellidos varchar(100)
DECLARE @vnombres varchar(100)
DECLARE @vnombre_persona varchar(200)
DECLARE @vidreg int
DECLARE C_TerminosTask CURSOR FOR
select top 15000 cedula as numero,'F' as tipo_persona,'CICR' as identificador,cedula as identificacion,cedula as cuerpo_clave,1 as habilitado,getdate() as iscreated,1 as afip_activo,
ltrim(rtrim(apellido1)) + ' ' + ltrim(rtrim(apellido2)) as apellidos,ltrim(rtrim(nombre)) as nombres, ltrim(rtrim(apellido1)) + ' ' + ltrim(rtrim(apellido2)) + ' ' + ltrim(rtrim(nombre)) as nombre_persona
,idreg
from padron_costa_rica where
procesado = 0
order by idreg asc
OPEN C_TerminosTask
FETCH NEXT FROM C_TerminosTask INTO @vnumero,@vtipo_persona,@videntificador,@videntificacion,@vcuerpo_clave,@vhabilitado,@viscreated,@vafip_activo,@vapellidos,@vnombres,@vnombre_persona,@vidreg
WHILE @@fetch_status = 0
BEGIN
insert into padrones (numero,tipo_persona,identificador,identificacion,cuerpo_clave,habilitado,iscreated,afip_activo,apellidos,nombres,nombre_persona)
values (@vnumero,@vtipo_persona,@videntificador,@videntificacion,@vcuerpo_clave,@vhabilitado,@viscreated,@vafip_activo,@vapellidos,@vnombres,@vnombre_persona)
update padron_costa_rica set procesado = 1 where idreg =@vidreg
FETCH NEXT FROM C_TerminosTask INTO @vnumero,@vtipo_persona,@videntificador,@videntificacion,@vcuerpo_clave,@vhabilitado,@viscreated,@vafip_activo,@vapellidos,@vnombres,@vnombre_persona,@vidreg
END
CLOSE C_TerminosTask
DEALLOCATE C_TerminosTask
*/
END
GO
Depends On
14Used By
No items found