dmencu 0.1.37 → 0.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/install/actualizar_inconvar.sql +30 -0
- package/install/agregados_tem.sql +5 -0
- package/install/control_cargado_tareas_tem_trg.sql +30 -0
- package/install/control_disform_cerrado_trg.sql +51 -0
- package/install/desintegrarpk.sql +24 -0
- package/install/esquema_comun.sql +60 -0
- package/install/metadatos/permisos.tab +12 -0
- package/install/metadatos/roles.tab +11 -0
- package/install/metadatos/roles_permisos.tab +95 -0
- package/install/metadatos/tipoc.tab +13 -0
- package/install/metadatos/tipoc_tipoc.tab +23 -0
- package/install/metadatos/tipovar.tab +10 -0
- package/install/roles_permisos_ini.sql +4 -0
- package/install/sincro_tareas_areas_tareas_tem_trg.sql +28 -0
- package/install/sincronizacion_tareas_tem.sql +18 -0
- package/install/sincronizacion_tem.sql +49 -0
- package/package.json +3 -2
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
set search_path= base;
|
|
2
|
+
set role preju2022_owner;
|
|
3
|
+
|
|
4
|
+
CREATE OR REPLACE FUNCTION actualizar_inconvar_trg()
|
|
5
|
+
RETURNS trigger AS
|
|
6
|
+
$BODY$
|
|
7
|
+
begin
|
|
8
|
+
if tg_op = 'INSERT' or tg_op = 'UPDATE' then
|
|
9
|
+
delete from in_con_var where operativo=new.operativo and pk_integrada=new.pk_integrada and consistencia=new.consistencia;
|
|
10
|
+
insert into in_con_var(operativo, consistencia, pk_integrada, variable, tabla_datos, valor)
|
|
11
|
+
select new.operativo, new.consistencia, new.pk_integrada, split_part(key, '.', 2 ) as variable, split_part(key, '.', 1) as tabla_datos, value as valor
|
|
12
|
+
from jsonb_each_text(new.incon_valores) ;
|
|
13
|
+
return new;
|
|
14
|
+
end if;
|
|
15
|
+
if tg_op = 'DELETE' then
|
|
16
|
+
delete from in_con_var where operativo=old.operativo and pk_integrada=old.pk_integrada and consistencia=old.consistencia;
|
|
17
|
+
return old;
|
|
18
|
+
else
|
|
19
|
+
return new;
|
|
20
|
+
end if;
|
|
21
|
+
end;
|
|
22
|
+
$BODY$
|
|
23
|
+
LANGUAGE plpgsql VOLATILE SECURITY DEFINER;
|
|
24
|
+
|
|
25
|
+
--DROP TRIGGER actualizar_inconvar_trg ON inconsistencias;
|
|
26
|
+
CREATE TRIGGER actualizar_inconvar_trg
|
|
27
|
+
BEFORE INSERT OR DELETE OR UPDATE OF incon_valores
|
|
28
|
+
ON inconsistencias
|
|
29
|
+
FOR EACH ROW
|
|
30
|
+
EXECUTE PROCEDURE actualizar_inconvar_trg();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
--set search_path = base;
|
|
2
|
+
--set role dmencu_owner;
|
|
3
|
+
|
|
4
|
+
CREATE OR REPLACE FUNCTION control_cargado_tareas_tem_trg()
|
|
5
|
+
RETURNS trigger
|
|
6
|
+
LANGUAGE 'plpgsql'
|
|
7
|
+
AS $BODY$
|
|
8
|
+
declare
|
|
9
|
+
cant_cargados integer;
|
|
10
|
+
tarea_cargada text;
|
|
11
|
+
begin
|
|
12
|
+
if new.operacion='cargar' then
|
|
13
|
+
select count(*), min(tarea)
|
|
14
|
+
into cant_cargados, tarea_cargada
|
|
15
|
+
from tareas_tem tt join parametros using(operativo)
|
|
16
|
+
where tt.enc=old.enc and tt.cargado_dm is not null and tt.tarea is distinct from new.tarea
|
|
17
|
+
and unico_registro;
|
|
18
|
+
if cant_cargados >0 then
|
|
19
|
+
raise exception 'Error: la encuesta % ya esta cargada para la tarea %', old.enc, tarea_cargada;
|
|
20
|
+
end if;
|
|
21
|
+
end if;
|
|
22
|
+
return new;
|
|
23
|
+
end;
|
|
24
|
+
$BODY$;
|
|
25
|
+
|
|
26
|
+
CREATE TRIGGER control_cargado_tareas_tem_trg
|
|
27
|
+
BEFORE UPDATE OF operacion
|
|
28
|
+
ON tareas_tem
|
|
29
|
+
FOR EACH ROW
|
|
30
|
+
EXECUTE PROCEDURE control_cargado_tareas_tem_trg();
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
--set search_path=base;
|
|
2
|
+
--set role dmencu_owner;
|
|
3
|
+
|
|
4
|
+
CREATE OR REPLACE FUNCTION control_disform_cerrado_trg()
|
|
5
|
+
RETURNS trigger AS
|
|
6
|
+
$BODY$
|
|
7
|
+
DECLARE
|
|
8
|
+
v_operativo TEXT;
|
|
9
|
+
v_disform_cerrado boolean;
|
|
10
|
+
v_registro_salida RECORD;
|
|
11
|
+
v_ref_op RECORD;
|
|
12
|
+
|
|
13
|
+
BEGIN
|
|
14
|
+
v_ref_op=NEW;
|
|
15
|
+
v_registro_salida=NEW;
|
|
16
|
+
|
|
17
|
+
IF TG_OP IN ('UPDATE','DELETE') THEN
|
|
18
|
+
v_ref_op=OLD;
|
|
19
|
+
END IF;
|
|
20
|
+
IF TG_OP ='DELETE' THEN
|
|
21
|
+
v_registro_salida=OLD;
|
|
22
|
+
END IF;
|
|
23
|
+
|
|
24
|
+
IF TG_TABLE_NAME IN ('casilleros','unidad_analisis') THEN
|
|
25
|
+
v_operativo=v_ref_op.operativo;
|
|
26
|
+
SELECT disform_cerrado
|
|
27
|
+
INTO v_disform_cerrado
|
|
28
|
+
FROM operativos
|
|
29
|
+
WHERE operativo= v_operativo;
|
|
30
|
+
IF v_disform_cerrado THEN
|
|
31
|
+
RAISE EXCEPTION 'ERROR diseño de formularios cerrado. No es posible modificar la tabla % del operativo %.', tg_table_name, v_operativo;
|
|
32
|
+
END IF;
|
|
33
|
+
END IF;
|
|
34
|
+
|
|
35
|
+
RETURN v_registro_salida;
|
|
36
|
+
END;
|
|
37
|
+
$BODY$
|
|
38
|
+
LANGUAGE plpgsql ;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
CREATE TRIGGER unidad_analisis_disform_cerrado_trg
|
|
42
|
+
BEFORE UPDATE OR INSERT OR DELETE
|
|
43
|
+
ON unidad_analisis
|
|
44
|
+
FOR EACH ROW
|
|
45
|
+
EXECUTE PROCEDURE control_disform_cerrado_trg();
|
|
46
|
+
|
|
47
|
+
CREATE TRIGGER casilleros_disform_cerrado_trg
|
|
48
|
+
BEFORE UPDATE OR INSERT OR DELETE
|
|
49
|
+
ON casilleros
|
|
50
|
+
FOR EACH ROW
|
|
51
|
+
EXECUTE PROCEDURE control_disform_cerrado_trg();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
set search_path= base;
|
|
2
|
+
set role preju2022_owner;
|
|
3
|
+
|
|
4
|
+
create or replace function desintegrarpk_trg() returns trigger
|
|
5
|
+
language plpgsql SECURITY DEFINER as
|
|
6
|
+
$body$
|
|
7
|
+
begin
|
|
8
|
+
new.vivienda := new.pk_integrada->>'vivienda';
|
|
9
|
+
new.hogar := new.pk_integrada->>'hogar';
|
|
10
|
+
new.persona := new.pk_integrada->>'persona';
|
|
11
|
+
new.visita := new.pk_integrada->>'visita';
|
|
12
|
+
return new;
|
|
13
|
+
end;
|
|
14
|
+
$body$;
|
|
15
|
+
|
|
16
|
+
create trigger desintegrarpk_trg
|
|
17
|
+
before insert or update
|
|
18
|
+
of pk_integrada
|
|
19
|
+
on inconsistencias
|
|
20
|
+
for each row
|
|
21
|
+
execute procedure desintegrarpk_trg();
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
-- set role preju_test2022_owner;
|
|
2
|
+
-- set role preju_capa2022_owner;
|
|
3
|
+
set role preju2022_owner;
|
|
4
|
+
|
|
5
|
+
drop schema if exists "comun" cascade;
|
|
6
|
+
create schema "comun";
|
|
7
|
+
grant usage on schema "comun" to "preju2022_admin";
|
|
8
|
+
grant create on schema "comun" to "preju2022_admin";
|
|
9
|
+
|
|
10
|
+
CREATE OR REPLACE FUNCTION comun.informado("P_valor" anyelement)
|
|
11
|
+
RETURNS boolean AS
|
|
12
|
+
'SELECT $1 IS NOT NULL'
|
|
13
|
+
LANGUAGE sql IMMUTABLE;
|
|
14
|
+
|
|
15
|
+
CREATE OR REPLACE FUNCTION comun.informado("P_valor" text)
|
|
16
|
+
RETURNS boolean AS
|
|
17
|
+
$BODY$SELECT $1 !~ '^\s*$' AND $1 IS NOT NULL$BODY$
|
|
18
|
+
LANGUAGE sql IMMUTABLE;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
--NSNC
|
|
23
|
+
CREATE OR REPLACE FUNCTION comun.nsnc("P_valor" anyelement)
|
|
24
|
+
RETURNS boolean AS
|
|
25
|
+
'SELECT $1 IS NOT DISTINCT FROM -9'
|
|
26
|
+
LANGUAGE sql IMMUTABLE;
|
|
27
|
+
|
|
28
|
+
CREATE OR REPLACE FUNCTION comun.nsnc("P_valor" text)
|
|
29
|
+
RETURNS boolean AS
|
|
30
|
+
$BODY$SELECT $1 IS NOT DISTINCT FROM '-9'$BODY$
|
|
31
|
+
LANGUAGE sql IMMUTABLE;
|
|
32
|
+
|
|
33
|
+
CREATE OR REPLACE FUNCTION comun.nsnc("P_valor" date)
|
|
34
|
+
RETURNS boolean AS
|
|
35
|
+
$$SELECT $1 IS NOT DISTINCT FROM '0999-09-09'$$
|
|
36
|
+
LANGUAGE sql IMMUTABLE;
|
|
37
|
+
|
|
38
|
+
--CON_DATO
|
|
39
|
+
CREATE OR REPLACE FUNCTION comun.con_dato("P_valor" anyelement)
|
|
40
|
+
RETURNS boolean AS
|
|
41
|
+
'SELECT comun.informado($1) AND NOT comun.nsnc($1)'
|
|
42
|
+
LANGUAGE sql IMMUTABLE;
|
|
43
|
+
|
|
44
|
+
--blanco
|
|
45
|
+
CREATE OR REPLACE FUNCTION comun.blanco("P_valor" anyelement)
|
|
46
|
+
RETURNS boolean AS
|
|
47
|
+
'SELECT $1 IS NULL'
|
|
48
|
+
LANGUAGE sql IMMUTABLE;
|
|
49
|
+
|
|
50
|
+
CREATE OR REPLACE FUNCTION comun.blanco("P_valor" text)
|
|
51
|
+
RETURNS boolean AS
|
|
52
|
+
$BODY$SELECT $1 IS NULL$BODY$
|
|
53
|
+
LANGUAGE sql IMMUTABLE;
|
|
54
|
+
|
|
55
|
+
--es_par
|
|
56
|
+
CREATE OR REPLACE FUNCTION comun.es_par(p_valor anyelement)
|
|
57
|
+
RETURNS boolean
|
|
58
|
+
AS $BODY$select case when mod(p_valor,2)=0 then TRUE else FALSE end$BODY$
|
|
59
|
+
LANGUAGE 'sql'
|
|
60
|
+
IMMUTABLE ;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
permiso |accion |predeterminado
|
|
2
|
+
campo |editar |false
|
|
3
|
+
campo |ver |false
|
|
4
|
+
campo |administrar|false
|
|
5
|
+
configurar |editar |false
|
|
6
|
+
configurar |ver |false
|
|
7
|
+
encuestas |ingresar |false
|
|
8
|
+
encuestas |procesar |false
|
|
9
|
+
encuestas |justificar|false
|
|
10
|
+
encuestas |relevar |false
|
|
11
|
+
consistencias |editar |false
|
|
12
|
+
casilleros_texto|editar |false
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
rol |superuser|nombre
|
|
2
|
+
admin |true |Administrador
|
|
3
|
+
direccion |false |Dirección
|
|
4
|
+
coor_campo |false |Coordinador de Campo
|
|
5
|
+
encuestador |false |Encuestador
|
|
6
|
+
dis_conceptual|false |Diseño Conceptual
|
|
7
|
+
recepcionista |false |Recepcionista
|
|
8
|
+
procesamiento |false |Procesamiento
|
|
9
|
+
auxiliar |false |Auxiliar de campo
|
|
10
|
+
recuperador |false |recuperador
|
|
11
|
+
supervisor |false |Supervisor
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
rol|permiso|accion|habilitado
|
|
2
|
+
admin|campo|editar|true
|
|
3
|
+
admin|campo|ver|true
|
|
4
|
+
admin|casilleros_texto|editar|true
|
|
5
|
+
admin|configurar|editar|true
|
|
6
|
+
admin|configurar|ver|true
|
|
7
|
+
admin|consistencias|editar|true
|
|
8
|
+
admin|encuestas|ingresar|true
|
|
9
|
+
admin|encuestas|justificar|true
|
|
10
|
+
admin|encuestas|procesar|true
|
|
11
|
+
auxiliar|campo|editar|false
|
|
12
|
+
auxiliar|campo|ver|false
|
|
13
|
+
auxiliar|casilleros_texto|editar|false
|
|
14
|
+
auxiliar|configurar|editar|false
|
|
15
|
+
auxiliar|configurar|ver|false
|
|
16
|
+
auxiliar|consistencias|editar|false
|
|
17
|
+
auxiliar|encuestas|ingresar|false
|
|
18
|
+
auxiliar|encuestas|justificar|false
|
|
19
|
+
auxiliar|encuestas|procesar|false
|
|
20
|
+
coor_campo|campo|administrar|true
|
|
21
|
+
coor_campo|campo|editar|true
|
|
22
|
+
coor_campo|campo|ver|true
|
|
23
|
+
coor_campo|casilleros_texto|editar|false
|
|
24
|
+
coor_campo|configurar|editar|true
|
|
25
|
+
coor_campo|configurar|ver|true
|
|
26
|
+
coor_campo|consistencias|editar|true
|
|
27
|
+
coor_campo|encuestas|ingresar|true
|
|
28
|
+
coor_campo|encuestas|justificar|true
|
|
29
|
+
coor_campo|encuestas|procesar|true
|
|
30
|
+
direccion|campo|editar|true
|
|
31
|
+
direccion|campo|ver|true
|
|
32
|
+
direccion|casilleros_texto|editar|false
|
|
33
|
+
direccion|configurar|editar|true
|
|
34
|
+
direccion|configurar|ver|true
|
|
35
|
+
direccion|consistencias|editar|true
|
|
36
|
+
direccion|encuestas|ingresar|true
|
|
37
|
+
direccion|encuestas|justificar|true
|
|
38
|
+
direccion|encuestas|procesar|true
|
|
39
|
+
dis_conceptual|campo|editar|false
|
|
40
|
+
dis_conceptual|campo|ver|true
|
|
41
|
+
dis_conceptual|casilleros_texto|editar|true
|
|
42
|
+
dis_conceptual|configurar|editar|false
|
|
43
|
+
dis_conceptual|configurar|ver|true
|
|
44
|
+
dis_conceptual|consistencias|editar|false
|
|
45
|
+
dis_conceptual|encuestas|ingresar|false
|
|
46
|
+
dis_conceptual|encuestas|justificar|false
|
|
47
|
+
dis_conceptual|encuestas|procesar|false
|
|
48
|
+
procesamiento|campo|editar|false
|
|
49
|
+
procesamiento|campo|ver|false
|
|
50
|
+
procesamiento|casilleros_texto|editar|false
|
|
51
|
+
procesamiento|configurar|editar|false
|
|
52
|
+
procesamiento|configurar|ver|false
|
|
53
|
+
procesamiento|consistencias|editar|true
|
|
54
|
+
procesamiento|encuestas|ingresar|true
|
|
55
|
+
procesamiento|encuestas|justificar|true
|
|
56
|
+
procesamiento|encuestas|procesar|true
|
|
57
|
+
recepcionista|campo|editar|true
|
|
58
|
+
recepcionista|campo|ver|true
|
|
59
|
+
recepcionista|casilleros_texto|editar|false
|
|
60
|
+
recepcionista|configurar|editar|true
|
|
61
|
+
recepcionista|configurar|ver|true
|
|
62
|
+
recepcionista|consistencias|editar|false
|
|
63
|
+
recepcionista|encuestas|ingresar|true
|
|
64
|
+
recepcionista|encuestas|justificar|true
|
|
65
|
+
recepcionista|encuestas|procesar|false
|
|
66
|
+
encuestador|campo|editar|false
|
|
67
|
+
encuestador|campo|ver|false
|
|
68
|
+
encuestador|casilleros_texto|editar|false
|
|
69
|
+
encuestador|configurar|editar|false
|
|
70
|
+
encuestador|configurar|ver|false
|
|
71
|
+
encuestador|consistencias|editar|false
|
|
72
|
+
encuestador|encuestas|ingresar|true
|
|
73
|
+
encuestador|encuestas|justificar|true
|
|
74
|
+
encuestador|encuestas|procesar|false
|
|
75
|
+
encuestador|encuestas|relevar|true
|
|
76
|
+
recuperador|campo|editar|false
|
|
77
|
+
recuperador|campo|ver|false
|
|
78
|
+
recuperador|casilleros_texto|editar|false
|
|
79
|
+
recuperador|configurar|editar|false
|
|
80
|
+
recuperador|configurar|ver|false
|
|
81
|
+
recuperador|consistencias|editar|false
|
|
82
|
+
recuperador|encuestas|ingresar|true
|
|
83
|
+
recuperador|encuestas|justificar|true
|
|
84
|
+
recuperador|encuestas|procesar|false
|
|
85
|
+
recuperador|encuestas|relevar|true
|
|
86
|
+
supervisor|campo|editar|false
|
|
87
|
+
supervisor|campo|ver|false
|
|
88
|
+
supervisor|casilleros_texto|editar|false
|
|
89
|
+
supervisor|configurar|editar|false
|
|
90
|
+
supervisor|configurar|ver|false
|
|
91
|
+
supervisor|consistencias|editar|false
|
|
92
|
+
supervisor|encuestas|ingresar|true
|
|
93
|
+
supervisor|encuestas|justificar|true
|
|
94
|
+
supervisor|encuestas|procesar|false
|
|
95
|
+
supervisor|encuestas|relevar|true
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
tipoc|denominacion|irrepetible|desp_casillero|desp_hijos|puede_ser_var
|
|
2
|
+
B|bloque|true|||false
|
|
3
|
+
BF|Botón para formulario|true|||
|
|
4
|
+
CONS|consistencia|true|||false
|
|
5
|
+
CP|conjunto de preguntas|true|||false
|
|
6
|
+
F|formulario||||false
|
|
7
|
+
FILTRO|filtro|true|||false
|
|
8
|
+
MATRIZ|matriz (de varias preguntas)|true|||false
|
|
9
|
+
O|opción|||nueva_fila|false
|
|
10
|
+
OM|opción múltiple|||misma_fila|
|
|
11
|
+
P|pregunta|true||tabla|
|
|
12
|
+
PMATRIZ|pregunta en forma de matriz|true||tabla_matriz|false
|
|
13
|
+
TEXTO|texto aclaratorio sin pregunta||||false
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
tipovar|html_type|type_name|validar|radio
|
|
2
|
+
boolean|text|boolean|boolean|false
|
|
3
|
+
decimal|number|decimal|numerico|false
|
|
4
|
+
fecha|text|date|texto|false
|
|
5
|
+
hora|text|interval|texto|false
|
|
6
|
+
numero|number|bigint|numerico|false
|
|
7
|
+
opciones|number|bigint|opciones|true
|
|
8
|
+
si_no|number|bigint|opciones|true
|
|
9
|
+
si_no_nn|number|bigint|opciones|true
|
|
10
|
+
texto|text|text|texto|false
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
--set role dmencu_owner;
|
|
2
|
+
--set search_path=base;
|
|
3
|
+
|
|
4
|
+
DROP FUNCTION if exists sincro_tareas_areas_tareas_tem_trg();
|
|
5
|
+
CREATE OR REPLACE FUNCTION sincro_tareas_areas_tareas_tem_trg()
|
|
6
|
+
RETURNS trigger
|
|
7
|
+
LANGUAGE 'plpgsql'
|
|
8
|
+
AS $BODY$
|
|
9
|
+
begin
|
|
10
|
+
update tareas_tem tt
|
|
11
|
+
set operacion = case when new.operacion is not null and new.operacion is distinct from old.operacion then new.operacion else operacion end,
|
|
12
|
+
asignado = case when new.asignado is not null and new.asignado is distinct from old.asignado then new.asignado else asignado end,
|
|
13
|
+
fecha_asignacion = case when new.fecha_asignacion is not null and new.fecha_asignacion is distinct from old.fecha_asignacion then new.fecha_asignacion else fecha_asignacion end
|
|
14
|
+
from tem t
|
|
15
|
+
where t.operativo=tt.operativo and t.enc=tt.enc
|
|
16
|
+
and area=t.area and tt.habilitada
|
|
17
|
+
and tt.tarea=new.tarea
|
|
18
|
+
and area=new.area;
|
|
19
|
+
return new;
|
|
20
|
+
end;
|
|
21
|
+
$BODY$;
|
|
22
|
+
|
|
23
|
+
DROP TRIGGER IF EXISTS sincro_tareas_areas_tareas_tem_trg ON tareas_areas;
|
|
24
|
+
CREATE TRIGGER sincro_tareas_areas_tareas_tem_trg
|
|
25
|
+
AFTER INSERT OR UPDATE OF operacion, asignado,fecha_asignacion,asignante
|
|
26
|
+
ON tareas_areas
|
|
27
|
+
FOR EACH ROW
|
|
28
|
+
EXECUTE PROCEDURE sincro_tareas_areas_tareas_tem_trg();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
--set role dmencu_owner;
|
|
2
|
+
--set search_path=base;
|
|
3
|
+
|
|
4
|
+
CREATE OR REPLACE FUNCTION sincronizacion_tareas_tem_trg()
|
|
5
|
+
RETURNS trigger
|
|
6
|
+
LANGUAGE 'plpgsql'
|
|
7
|
+
AS $BODY$
|
|
8
|
+
begin
|
|
9
|
+
new.cargado = new.cargado_dm is not null;
|
|
10
|
+
return new;
|
|
11
|
+
end;
|
|
12
|
+
$BODY$;
|
|
13
|
+
|
|
14
|
+
CREATE TRIGGER sincronizacion_tareas_tem_trg
|
|
15
|
+
BEFORE INSERT OR UPDATE OF cargado_dm
|
|
16
|
+
ON tareas_tem
|
|
17
|
+
FOR EACH ROW
|
|
18
|
+
EXECUTE PROCEDURE sincronizacion_tareas_tem_trg();
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
--set role to preju2022_owner;
|
|
2
|
+
--set search_path = base;
|
|
3
|
+
|
|
4
|
+
CREATE OR REPLACE FUNCTION sincronizacion_tem_trg()
|
|
5
|
+
RETURNS trigger
|
|
6
|
+
LANGUAGE 'plpgsql'
|
|
7
|
+
AS $BODY$
|
|
8
|
+
declare
|
|
9
|
+
datos jsonb=new.json_encuesta;
|
|
10
|
+
v_cant_p integer;
|
|
11
|
+
v_seleccionado text;
|
|
12
|
+
begin
|
|
13
|
+
|
|
14
|
+
select sum (total_m) as cant_p--sum(jsonb_array_length(personas))
|
|
15
|
+
,case when sum(jsonb_array_length(datos->'hogares'))>1 then string_agg('h'||ordinality||':'||coalesce(cr_num_miembro::text,'')||'-'||coalesce(msnombre),',')
|
|
16
|
+
else min(cr_num_miembro)||'-'||min(msnombre)
|
|
17
|
+
end as seleccionado
|
|
18
|
+
into v_cant_p, v_seleccionado
|
|
19
|
+
from rows from (jsonb_to_recordset(datos->'hogares') as (total_m integer, cr_num_miembro integer, msnombre text, personas jsonb)
|
|
20
|
+
) with ordinality as hogares (total_m, cr_num_miembro,msnombre, personas);
|
|
21
|
+
|
|
22
|
+
new.cant_h = (datos ->>'total_h') ::integer ;
|
|
23
|
+
--new.cant_h = jsonb_array_length(datos ->'hogares');
|
|
24
|
+
|
|
25
|
+
new.cant_p = v_cant_p ;
|
|
26
|
+
new.seleccionado = v_seleccionado;
|
|
27
|
+
if old.json_encuesta is distinct from datos then
|
|
28
|
+
new.modificado= current_timestamp;
|
|
29
|
+
end if;
|
|
30
|
+
|
|
31
|
+
return new;
|
|
32
|
+
end;
|
|
33
|
+
$BODY$;
|
|
34
|
+
|
|
35
|
+
-- /*
|
|
36
|
+
CREATE TRIGGER sincronizacion_tem_trg
|
|
37
|
+
BEFORE INSERT OR UPDATE OF json_encuesta, obs
|
|
38
|
+
ON tem
|
|
39
|
+
FOR EACH ROW
|
|
40
|
+
EXECUTE PROCEDURE sincronizacion_tem_trg();
|
|
41
|
+
|
|
42
|
+
-- */
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
--para forzar sincro
|
|
46
|
+
update tem
|
|
47
|
+
set obs=obs
|
|
48
|
+
where json_encuesta is not null;
|
|
49
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dmencu",
|
|
3
3
|
"description": "DM Encu - Encuestas en dispositivo móvil",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.38",
|
|
5
5
|
"author": "Codenautas <codenautas@googlegroups.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/server/server/app-dmencu.js",
|
|
8
8
|
"types": "dist/server/server/app-dmencu.d.ts",
|
|
9
9
|
"files": [
|
|
10
|
-
"dist"
|
|
10
|
+
"dist",
|
|
11
|
+
"install"
|
|
11
12
|
],
|
|
12
13
|
"dependencies": {
|
|
13
14
|
"@material-ui/core": "~4.12.3",
|