| 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 | $refgeto = $args.geto; |
| 12 | $definidors = var[ $_Portal ][ 'definidors' ]; |
| 13 | $versions = var[ $_Portal ][ 'versions' ] otherwise {}; |
| 14 | $versions.Portal = $versions.Portal otherwise $_Portal; |
| 15 | $versions.Accions = $versions.Accions otherwise $definidors._Accions; |
| 16 | $versions.Getons = $versions.Getons otherwise $definidors._Getons; |
| 17 | $versions.Validacions = $versions.Validacions otherwise $definidors._Validacions; |
| 18 | $versions.Validadores = $versions.Validadores otherwise $definidors.Validadores; |
| 19 | |
| 20 | $dades_accions = var[ $definidors._Accions ]; |
| 21 | |
| 22 | $__dada = $refval => { |
| 23 | data_feed[[ oracles = $versions.Portal, feed_name = $refval, ifnone = false ]] |
| 24 | }; |
| 25 | |
| 26 | $__dada_accions = $refval => { |
| 27 | data_feed[[ oracles = $versions.Accions, feed_name = $refval, ifnone = false ]] |
| 28 | }; |
| 29 | |
| 30 | $__dada_getons = $refval => { |
| 31 | data_feed[[ oracles = $versions.Getons, feed_name = $refval, ifnone = false ]] |
| 32 | }; |
| 33 | |
| 34 | $__dada_AA = $refval, $vers => { |
| 35 | data_feed[[ oracles = $vers, feed_name = $refval, ifnone = false ]] |
| 36 | }; |
| 37 | }", |
| 38 | "messages": [ |
| 39 | { |
| 40 | "app": "state", |
| 41 | "state": "{ |
| 42 | response[ 'consulta' ] = $refcons; |
| 43 | |
| 44 | if ( $refcons == 'Portal' ) { |
| 45 | |
| 46 | $__resp = $r => { |
| 47 | response[ $r ] = $definidors[ $r ]; |
| 48 | }; |
| 49 | |
| 50 | $refs_definidors = [ |
| 51 | '_Accions', '_Getons', '_Validacions', '_Validadores', |
| 52 | '_FRO', '_Estels', 'Interval', 'Lapse', |
| 53 | 'Import_Activacio', 'Import_Subscripcio', 'Import_Renovacio', |
| 54 | 'Taxa_Conversio', 'Factor_Conversio', 'Generacio_Minima', |
| 55 | 'Nombre_Delegades', 'Nombre_Aprovacions', 'Cicles_Diposit', |
| 56 | 'Diposit_Minim', '_AUT_0', '_AUT_A', '_AUT_B', '_AUT_C' |
| 57 | ]; |
| 58 | |
| 59 | $respon = map( $refs_definidors, 22, $__resp ); |
| 60 | |
| 61 | response[ 'Versions portal' ] = $versions.Portal; |
| 62 | response[ 'Versions Accions' ] = $versions.Accions; |
| 63 | response[ 'Versions Getons' ] = $versions.Getons; |
| 64 | response[ 'Versions Validacions' ] = $versions.Validacions; |
| 65 | response[ 'Versions Validadores' ] = $versions.Validadores; |
| 66 | } |
| 67 | |
| 68 | |
| 69 | if ( $refcons == 'Valor_Definidor' ) { |
| 70 | response[ 'Valor ' || $args.ref ] = $definidors[ $args.ref ]; |
| 71 | } |
| 72 | |
| 73 | |
| 74 | if ( $refcons == 'Valor_Dada' ) { |
| 75 | response[ 'Valor ' || $args.ref ] = $__dada( $args.ref ); |
| 76 | } |
| 77 | |
| 78 | |
| 79 | if ( $refcons == 'Darrera_Proposta' ) { |
| 80 | $ordinals = var[ $_Portal ][ 'ordinals' ]; |
| 81 | $id_proposta = $args.ref || '_' || $ordinals[ $args.ref ]; |
| 82 | |
| 83 | if ( $__dada( $id_proposta ) ) { |
| 84 | $temps_prop = $__dada( $id_proposta ); |
| 85 | $data_confirmacio = $temps_prop + $definidors.Lapse; |
| 86 | |
| 87 | response[ 'Proposant' ] = $__dada( $id_proposta || '_proposant' ); |
| 88 | response[ 'Data de la proposta' ] = timestamp_to_string( $temps_prop, 'date' ); |
| 89 | response[ 'Data inici confirmacio' ] = timestamp_to_string( $data_confirmacio, 'date' ); |
| 90 | |
| 91 | $data_validacio = $__dada_AA( 'validacio_' || $id_proposta, $versions.Validacions ); |
| 92 | if ( is_integer( $data_validacio ) ) { |
| 93 | response[ 'Hora validació' ] = timestamp_to_string( $data_validacio, 'time' ); |
| 94 | response[ 'Data validació' ] = timestamp_to_string( $data_validacio, 'date' ); |
| 95 | } |
| 96 | } else { |
| 97 | response[ 'No hi ha cap proposta per a aquest param definidor' ] = $id_proposta; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | |
| 102 | if ( $refcons == 'Valor_Proposta' ) { |
| 103 | response[ 'Ref proposta ' || $args.ref ] = $__dada( $args.ref || '_ref' ); |
| 104 | response[ 'Valor proposta ' || $args.ref ] = $__dada( $args.ref || '_val' ); |
| 105 | response[ 'Proposant proposta ' || $args.ref ] = $__dada( $args.ref || '_proposant' ); |
| 106 | $temps_prop = $__dada( $args.ref ); |
| 107 | $data_confirmacio = $temps_prop + $definidors.Lapse; |
| 108 | response[ 'Data de la proposta' ] = timestamp_to_string( $temps_prop, 'date' ); |
| 109 | response[ 'Data inici confirmacio' ] = timestamp_to_string( $data_confirmacio, 'date' ); |
| 110 | |
| 111 | $data_validacio = $__dada_AA( 'validacio_' || $args.ref, $versions.Validacions ); |
| 112 | if ( is_integer( $data_validacio ) ) { |
| 113 | response[ 'Hora validació' ] = timestamp_to_string( $data_validacio, 'time' ); |
| 114 | response[ 'Data validació' ] = timestamp_to_string( $data_validacio, 'date' ); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | |
| 119 | if ( $refcons == 'Validacio' ) { |
| 120 | $data_validacio = $__dada_AA( 'validacio_' || $args.idprop, $versions.Validacions ); |
| 121 | response[ 'Proposta' ] = $args.idprop; |
| 122 | if ( is_integer( $data_validacio ) ) { |
| 123 | response[ 'Hora validació' ] = timestamp_to_string( $data_validacio, 'time' ); |
| 124 | response[ 'Data validació' ] = timestamp_to_string( $data_validacio, 'date' ); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | |
| 129 | if ( $refcons == 'Dades_Geto' ) { |
| 130 | $refs_getons = var[ $_Portal ][ 'refs_getons' ]; |
| 131 | $ids_getons = var[ $_Portal ][ 'ids_getons' ]; |
| 132 | |
| 133 | response[ 'Id getó' ] = $ids_getons[ $refgeto ]; |
| 134 | |
| 135 | $refs = [ |
| 136 | '_FOG', '_AUT_A', 'factor_conversio', |
| 137 | 'valors_esmenables', 'llistats_editables', |
| 138 | 'bloqueig_possible', 'import_activacio', |
| 139 | 'import_subscripcio', 'import_renovacio', |
| 140 | 'taxa_conversio', 'cicles_diposit', 'derivacio', |
| 141 | '_AUT_B', '_AUT_C', '_AUT_0' |
| 142 | ]; |
| 143 | |
| 144 | $__resposta = $r => { |
| 145 | response[ $r ] = $__dada_getons( $refgeto || '_' || $r ); |
| 146 | }; |
| 147 | |
| 148 | $resps = map( $refs, 6, $__resposta ); |
| 149 | |
| 150 | response[ 'Data implementació' ] = timestamp_to_string( $__dada_getons( $refgeto ), 'date' ); |
| 151 | response[ 'Hora implementació' ] = timestamp_to_string( $__dada_getons( $refgeto ), 'time' ); |
| 152 | } |
| 153 | |
| 154 | |
| 155 | if ( $refcons == 'Dades_Node' ) { |
| 156 | $ref_activacio = 'activacio_' || $args.adr || '_en_' || $refgeto; |
| 157 | |
| 158 | $activacio = $__dada_accions( $ref_activacio ); |
| 159 | |
| 160 | if ( $activacio ) { |
| 161 | |
| 162 | $cicle_renovacio = $dades_accions[ 'renovacio_' || $args.adr || '_' || $refgeto ]; |
| 163 | |
| 164 | response[ 'Node ' || $args.adr || ' activat per a' ] = $refgeto; |
| 165 | response[ 'Nom node' ] = $__dada_accions( $ref_activacio || '_nom' ); |
| 166 | response[ 'Aportació per activació' ] = $__dada_accions( $ref_activacio || '_qt' ); |
| 167 | response[ 'Cicle activació' ] = $__dada_accions( $ref_activacio || '_cicle' ); |
| 168 | response[ 'Escala activació' ] = $__dada_accions( $ref_activacio || '_escala' ); |
| 169 | response[ 'Data activació' ] = timestamp_to_string( $__dada_accions( $ref_activacio), 'date' ); |
| 170 | |
| 171 | $ref_subscripcio = 'subscripcio_' || $args.adr || '_en_' || $refgeto; |
| 172 | $subscripcio = $__dada_accions( $ref_subscripcio ); |
| 173 | |
| 174 | if ( $subscripcio ) { |
| 175 | response[ 'Subscripció per a ' || $refgeto || ' de' ] = $args.adr; |
| 176 | response[ 'Nom subscripció' ] = $__dada_accions( $ref_subscripcio || '_nom' ); |
| 177 | response[ '% derivació' ] = $__dada_accions( $ref_subscripcio || '_derivacio' ); |
| 178 | response[ 'Cicle subscripció' ] = $__dada_accions( $ref_subscripcio || '_cicle' ); |
| 179 | response[ 'Data subscripció' ] = timestamp_to_string( $__dada_accions( $ref_subscripcio ), 'date' ); |
| 180 | response[ 'Hora subscripció' ] = timestamp_to_string( $__dada_accions( $ref_subscripcio ), 'time' ); |
| 181 | response[ 'Total derivacions' ] = |
| 182 | $__dada( 'total_derivacions_' || $args.adr || '_en_' || $refgeto ); |
| 183 | response[ 'Darrer cicle renovat' ] = |
| 184 | $__dada_accions( 'renovacio_' || $args.adr || '_en_' || $refgeto || '_cicle' ); |
| 185 | } |
| 186 | |
| 187 | $ref_avis = 'avis_' || $refgeto || '_' || $args.adr; |
| 188 | $temps_avis = $__dada_getons( $ref_avis ); |
| 189 | if ( $temps_avis ) { |
| 190 | $avis_es_actual = $temps_avis + ( $definidors.Lapse * 2 ) < timestamp; |
| 191 | if ( $avis_es_actual ) { |
| 192 | response[ 'Avís' ] = $__dada_getons( $ref_avis ); |
| 193 | response[ 'Hora' ] = timestamp_to_string( $temps_avis, 'time' ); |
| 194 | response[ 'Data' ] = timestamp_to_string( $temps_avis, 'date' ); |
| 195 | response[ 'Rebot' ] = $__dada_getons( $ref_avis || '_rebot' ); |
| 196 | |
| 197 | } |
| 198 | } |
| 199 | } else { |
| 200 | response[ 'adr ' || $args.adr ] = 'NO activada per a ' || $refgeto; |
| 201 | } |
| 202 | response[ 'Cicle actual' ] = $__dada_accions( 'cicle_actual' ); |
| 203 | } |
| 204 | |
| 205 | |
| 206 | if ( $refcons == 'Dades_Diposit' ) { |
| 207 | response[ 'Quantitat dipositada' ] = $__dada_accions( $args.ref ); |
| 208 | response[ 'Dipositant' ] = $__dada_accions( $args.ref || '_dipositant' ); |
| 209 | response[ 'Cicle dipòsit' ] = $__dada_accions( $args.ref || '_cicle' ); |
| 210 | response[ 'Getó dipòsit' ] = $__dada_accions( $args.ref || '_geto_diposit' ); |
| 211 | response[ 'Data dipòsit' ] = $__dada_accions( $args.ref || '_data'); |
| 212 | |
| 213 | response[ 'Taxa' ] = $__dada_accions( $args.ref || '_taxa' ); |
| 214 | response[ 'Qt conversió' ] = $__dada_accions( $args.ref || '_qt_conversio' ); |
| 215 | response[ 'Cicle conversió' ] = $__dada_accions( $args.ref || '_cicle_conversio' ); |
| 216 | } |
| 217 | |
| 218 | |
| 219 | if ( $refcons == 'Dades_Contribucio' ) { |
| 220 | response[ 'Quantitat' ] = $__dada_accions( $args.ref ); |
| 221 | response[ 'Contribuidora' ] = $__dada_accions( $args.ref || '_contribuidora' ); |
| 222 | response[ 'Cicle contribució' ] = $__dada_accions( $args.ref || '_cicle' ); |
| 223 | response[ 'Escala contribució' ] = $__dada_accions( $args.ref || '_escala' ); |
| 224 | response[ 'Data contribució' ] = $__dada_accions( $args.ref || '_data'); |
| 225 | |
| 226 | } |
| 227 | |
| 228 | |
| 229 | if ( $refcons == 'Totals' ) { |
| 230 | $total_geto = $__dada( 'total_en_' || $refgeto ); |
| 231 | $total_FOP = $__dada( 'total_FOP_en_' || $refgeto ); |
| 232 | $total_derivacions = $__dada( 'total_derivacions_' || '_en_' || $refgeto ); |
| 233 | $total_activacions = $__dada_accions( 'total_activacions_en_' || $refgeto ); |
| 234 | $total_subscripcions = $__dada_accions( 'total_subscripcions_en_' || $refgeto ); |
| 235 | $total_renovacions = $__dada_accions( 'total_renovacions_en_' || $refgeto ); |
| 236 | $total_diposits = $__dada_accions( 'total_diposits_en_' || $refgeto ); |
| 237 | $total_contribucions = $__dada_accions( 'total_contribucions_en_' || $refgeto ); |
| 238 | |
| 239 | response[ 'Total Getó' ] = $total_geto; |
| 240 | response[ 'Total FOP' ] = $total_FOP; |
| 241 | response[ 'Total Activacions' ] = $total_activacions; |
| 242 | response[ 'Total Subscripcions' ] = $total_subscripcions; |
| 243 | response[ 'Total Renovacions' ] = $total_renovacions; |
| 244 | response[ 'Total Contribucions' ] = $total_contribucions; |
| 245 | response[ 'Total Derivacions' ] = $total_derivacions; |
| 246 | response[ 'Total Diposits' ] = $total_diposits; |
| 247 | } |
| 248 | |
| 249 | |
| 250 | if ( $refcons == 'Cicle_Actual' ) { |
| 251 | $cicle_actual = $__dada_accions( 'cicle_actual' ); |
| 252 | $data_cicle = $__dada_accions( 'data_cicle_' || $cicle_actual ); |
| 253 | response[ 'Cicle Actual' ] = $cicle_actual; |
| 254 | response[ 'Escala del cicle' ] = $__dada_accions( 'escala_cicle_' || $cicle_actual ); |
| 255 | response[ 'Data en segons' ] = $data_cicle; |
| 256 | response[ 'Data del cicle' ] = timestamp_to_string( $data_cicle, 'date' ); |
| 257 | } |
| 258 | |
| 259 | |
| 260 | if ( $refcons == 'Escala_Actual' ) { |
| 261 | $escala_actual = $__dada_accions( 'escala_actual' ); |
| 262 | $data_escala = $__dada_accions( 'data_escala_' || $escala_actual ); |
| 263 | response[ 'Escala Actual' ] = $escala_actual; |
| 264 | response[ "Cicle del salt d'escala" ] = $__dada_accions( 'cicle_escala_' || $escala_actual ); |
| 265 | response[ "Data del salt d'escala" ] = timestamp_to_string( $data_escala, 'date' ); |
| 266 | response[ 'Data en segons' ] = $data_escala; |
| 267 | response[ 'Total Aportacions a FOP' ] = $__dada( 'total_FOP_en_estels' ); |
| 268 | } |
| 269 | |
| 270 | |
| 271 | if ( $refcons == 'Avis' ) { |
| 272 | $ref_avis = 'avis_' || $refgeto || '_' || $args.adr; |
| 273 | $temps_avis = $__dada_getons( $ref_avis ); |
| 274 | $avis_es_actual = $temps_avis + ( $definidors.Lapse * 2 ) < timestamp; |
| 275 | if ( $avis_es_actual ) { |
| 276 | response[ 'Avís' ] = $__dada_getons( $ref_avis ); |
| 277 | response[ 'Hora' ] = timestamp_to_string( $temps_avis, 'time' ); |
| 278 | response[ 'Data' ] = timestamp_to_string( $temps_avis, 'date' ); |
| 279 | response[ 'Rebot' ] = $__dada_getons( $ref_avis || '_rebot' ); |
| 280 | } else { |
| 281 | response[ 'No hi ha cap avís per a' ] = $args.adr; |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | |
| 286 | if ( $refcons == 'Capacitacio' ) { |
| 287 | $ref_capacitacio = 'capacitacio_' || $refgeto || '_' || $args.accio || '_' || $args.adr; |
| 288 | |
| 289 | response[ 'Capacitacio' ] = $__dada_getons( $ref_capacitacio ); |
| 290 | } |
| 291 | }" |
| 292 | } |
| 293 | ] |
| 294 | } |
| 295 | ] |