| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $nom_AA = 'Consultes'; |
| 6 | $versio = '0.1'; |
| 7 | |
| 8 | $args = trigger.data; |
| 9 | $_Portal = $args._Portal; |
| 10 | $refcons = $args.refcons; |
| 11 | $idgeto = $args.geto; |
| 12 | $dades_portal = var[ $_Portal ][ 'dades' ]; |
| 13 | $generics = $dades_portal.generics; |
| 14 | |
| 15 | |
| 16 | |
| 17 | $dades_accions = var[ $_Portal ][ 'dades' ]; |
| 18 | $validacions = var[ $_Portal ][ 'Validacions' ]; |
| 19 | $getons = var[ $_Portal ][ 'Getons' ]; |
| 20 | $geto = $getons[ $idgeto ]; |
| 21 | }", |
| 22 | "messages": [ |
| 23 | { |
| 24 | "app": "state", |
| 25 | "state": "{ |
| 26 | if ( $refcons == 'Portal' ) { |
| 27 | response[ 'Lapse' ] = $generics.Lapse; |
| 28 | |
| 29 | $__resp = $r => { |
| 30 | response[ $r ] = $generics[ $r ]; |
| 31 | }; |
| 32 | |
| 33 | $refs_generics = [ |
| 34 | '_Accions', '_Getons', '_Validacions', '_Validadores', |
| 35 | '_FRO', '_Estels', 'Interval', 'Lapse', |
| 36 | 'Import_Activacio', 'Import_Subscripcio', 'Import_Renovacio', |
| 37 | 'Taxa_Conversio', 'Factor_Conversio', 'Generacio_Minima', |
| 38 | 'Nombre_Delegades', 'Nombre_Aprovacions', 'Cicles_Diposit', |
| 39 | '_AUT_0', '_AUT_A', '_AUT_B', '_AUT_C' |
| 40 | ]; |
| 41 | |
| 42 | $respon = map( $refs_generics, 21, $__resp ); |
| 43 | } |
| 44 | if ( $refcons == 'Darrera_Proposta' ) { |
| 45 | $ordinals = $dades_portal.ordinals; |
| 46 | $ordinal = $ordinals[ $args.ref ]; |
| 47 | $propostes = $dades_portal.propostes; |
| 48 | $id_proposta = $args.ref || '_' || $ordinal; |
| 49 | $proposta = $propostes[ $id_proposta ]; |
| 50 | |
| 51 | if ( $proposta ) { |
| 52 | $data_confirmacio = $proposta.temps + $generics.Lapse; |
| 53 | |
| 54 | response[ 'ref darrera proposta per a' || $args.ref ] = $id_proposta; |
| 55 | response[ 'ref del param proposat' ] = $proposta.ref; |
| 56 | response[ 'valor del param proposat' ] = $proposta.val; |
| 57 | response[ 'proposant' ] = $proposta.proposant; |
| 58 | response[ 'data de la proposta' ] = |
| 59 | timestamp_to_string( $proposta.temps ); |
| 60 | response[ 'data inici confirmacio' ] = |
| 61 | timestamp_to_string( $data_confirmacio ); |
| 62 | |
| 63 | $valor_actual = $generics[ $proposta.ref ]; |
| 64 | $coincident = |
| 65 | $valor_actual AND $valor_actual == $proposta.val ? 'SÍ' : 'NO'; |
| 66 | response[ 'valor actual coincident amb el proposat' ] = $coincident; |
| 67 | response[ 'valor actual' ] = $valor_actual; |
| 68 | |
| 69 | $validacio = $validacions[ $id_proposta ]; |
| 70 | response[ 'proposta validada' ] = |
| 71 | $validacio ? timestamp_to_string( $validacio ) : 'NO'; |
| 72 | } else { |
| 73 | response[ 'No hi ha cap proposta per a aquest param genèric' ] = $id_proposta; |
| 74 | } |
| 75 | } |
| 76 | if ( $refcons == 'Validacio' ) { |
| 77 | $data_validacio = $validacions[ $args.id ]; |
| 78 | response[ 'Proposta' ] = $args.id; |
| 79 | response[ 'Validada' ] = |
| 80 | $data_validacio ? timestamp_to_string( $data_validacio ) : 'NO'; |
| 81 | } |
| 82 | if ( $refcons == 'Dades_Geto' ) { |
| 83 | $dades_geto = $getons[ $args.id ]; |
| 84 | response[ 'Id getó' ] = $args.id; |
| 85 | response[ 'Estat' ] = $dades_geto.estat; |
| 86 | response[ 'Proposant' ] = $dades_geto.proposant; |
| 87 | response[ 'Confirmant' ] = $dades_geto.confirmant; |
| 88 | response[ 'Data' ] = timestamp_to_string( $dades_geto.temps ); |
| 89 | $constants = $dades_geto.constants; |
| 90 | |
| 91 | $refs_constants = [ |
| 92 | '_FOG', '_AUT_A', 'factor_conversio', |
| 93 | 'valors_esmenables', 'llistats_editables', |
| 94 | 'bloqueig_possible', |
| 95 | ]; |
| 96 | $__resp_const = $r => { |
| 97 | response[ $r ] = $constants[ $r ]; |
| 98 | }; |
| 99 | |
| 100 | $resps_consts = map( $refs_constants, 6, $__resp_const ); |
| 101 | |
| 102 | $variables = $dades_geto.variables; |
| 103 | $refs_variables = [ |
| 104 | 'import_activacio', 'import_subscripcio', |
| 105 | 'import_renovacio', 'taxa_conversio', |
| 106 | 'cicles_diposit', 'derivacio', |
| 107 | '_AUT_0', '_AUT_0', '_AUT_0' |
| 108 | ]; |
| 109 | $__resp_var = $r => { |
| 110 | response[ $r ] = $variables[ $r ]; |
| 111 | }; |
| 112 | |
| 113 | $resps_vars = map( $refs_variables, 9, $__resp_var ); |
| 114 | |
| 115 | } |
| 116 | if ( $refcons == 'Dades_Node' ) { |
| 117 | $activacio = $dades_accions[ 'activacio_' || $args.adr || '_en_' || $idgeto ]; |
| 118 | $subscripcio = $dades_accions[ 'subscripcio_' || $args.adr || '_en_' || $idgeto ]; |
| 119 | $cicle_renovacio = $dades_accions[ 'renovacio_' || $args.adr__ || '_' || $idgeto ]; |
| 120 | $total_Derivacions = $dades_accions[ 'total_Derivacions_de_' || $args.adr || '_en_' || $idgeto ]; |
| 121 | |
| 122 | response[ 'Nom Activació' ] = $activacio.nom; |
| 123 | response[ 'Escala Activació' ] = $activacio.escala; |
| 124 | response[ 'Nom Subscripció' ] = $subscripcio.nom; |
| 125 | response[ '% Derivació a FOP' ] = $subscripcio.aFOP; |
| 126 | response[ 'Cicle Subscripció' ] = $subscripcio.cicle; |
| 127 | response[ 'Cicle Renovació' ] = $cicle_renovacio; |
| 128 | response[ 'Total Derivacions a FOP' ] = $total_Derivacions; |
| 129 | $avis = $geto.avisos[ $args.adr ]; |
| 130 | $avis_es_actual = $avis.temps + ( $generics.Lapse * 2 ) < timestamp; |
| 131 | if ( $avis_es_actual ) { response[ 'Avís' ] = $avis.text; } |
| 132 | } |
| 133 | if ( $refcons == 'Totals' ) { |
| 134 | $total_activacions = $dades_accions[ 'total_Activacions' || '_en_' || $idgeto ]; |
| 135 | $total_subscripcions = $dades_accions[ 'total_Subscripcions' || '_en_' || $idgeto ]; |
| 136 | $total_renovacions = $dades_accions[ 'total_Renovacions' || '_en_' || $idgeto ]; |
| 137 | $total_compensacions = $dades_accions[ 'total_Compensacions' || '_en_' || $idgeto ] ; |
| 138 | $total_derivacions = $dades_accions[ 'total_Derivacions' || '_en_' || $idgeto ]; |
| 139 | $total_diposits = $dades_accions[ 'total_Diposits' || '_en_' || $idgeto ]; |
| 140 | $total_liquidacions = $dades_accions[ 'total_Liquidacions' || '_en_' || $idgeto ]; |
| 141 | response[ 'Total Activacions' ] = $total_activacions; |
| 142 | response[ 'Total Subscripcions' ] = $total_subscripcions; |
| 143 | response[ 'Total Renovacions' ] = $total_renovacions; |
| 144 | response[ 'Total Compensacions' ] = $total_compensacions; |
| 145 | response[ 'Total Derivacions' ] = $total_derivacions; |
| 146 | response[ 'Total Diposits' ] = $total_diposits; |
| 147 | response[ 'Total Liquidacions' ] = $total_liquidacions; |
| 148 | } |
| 149 | if ( $refcons == 'Cicle_actual' ) { |
| 150 | $cicle_actual = $dades_accions[ 'cicle_actual']; |
| 151 | $data_cicle_actual = $dades_accions[ 'data_cicle_actual']; |
| 152 | $data_cicle_anterior = $dades_accions[ 'data_cicle_anterior']; |
| 153 | $interval = $dades_accions[ 'Interval']; |
| 154 | response[ 'Cicle Actual' ] = $cicle_actual; |
| 155 | response[ 'Data Cicle Actual' ] = timestamp_to_string( $data_cicle_actual ); |
| 156 | response[ 'Data Cicle Anterior' ] = timestamp_to_string( $data_cicle_anterior ); |
| 157 | response[ 'Data Cicle Actual milisegons' ] = $data_cicle_actual; |
| 158 | response[ 'Data Cicle Anterior milisegons' ] = $data_cicle_anterior; |
| 159 | response[ 'Interval' ] = $interval; |
| 160 | } |
| 161 | if ( $refcons == 'Avis' ) { |
| 162 | $avis = $geto.avisos[ $args.adr ]; |
| 163 | response[ 'Actuant' ] = $avis.actuant; |
| 164 | response[ 'Text' ] = $avis.text; |
| 165 | response[ 'Rebot' ] = $avis.rebot; |
| 166 | response[ 'Temps' ] = $avis.temps; |
| 167 | } |
| 168 | if ( $refcons == 'Capacitacio' ) { |
| 169 | $capacitacio = $geto.capacitacions[ $args.accio ][ $args.adr ]; |
| 170 | response[ 'Capacitacio' ] = $args.accio; |
| 171 | response[ 'Capacitadora' ] = $capacitacio.capacitadora; |
| 172 | response[ 'Estat' ] = $capacitacio.estat; |
| 173 | response[ 'Temps' ] = $capacitacio.temps; |
| 174 | } |
| 175 | }" |
| 176 | } |
| 177 | ] |
| 178 | } |
| 179 | ] |