| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $nom_AA = 'Consultes'; |
| 6 | |
| 7 | $args = trigger.data; |
| 8 | $_Portal = $args._Portal; |
| 9 | $refcons = $args.refcons; |
| 10 | $refgeto = $args.geto; |
| 11 | |
| 12 | $__dada = $refval => |
| 13 | data_feed[[ oracles = $args._Registre, feed_name = $refval, ifnone = false ]]; |
| 14 | |
| 15 | $Lapse = $__dada( 'Lapse' ); |
| 16 | $Origen = $__dada( 'Origen' ); |
| 17 | $cicle_actual = |
| 18 | 1 + floor( ( timestamp - $Origen ) / $__dada( 'Interval' ) ); |
| 19 | }", |
| 20 | "messages": [ |
| 21 | { |
| 22 | "app": "state", |
| 23 | "state": "{ |
| 24 | response[ 'consulta' ] = $refcons; |
| 25 | $dada_args_ref = !! $args.ref ? $__dada( $args.ref ) : false; |
| 26 | |
| 27 | if ( $refcons == 'Portal' ) { |
| 28 | |
| 29 | $__resp = $r => { |
| 30 | response[ $r ] = $__dada( $r ); |
| 31 | }; |
| 32 | |
| 33 | $refs_definidors = [ |
| 34 | '_Accions', '_Getons', '_Validacions', '_Validadores', |
| 35 | '_FRO', '_Estels', 'Interval', 'Lapse', |
| 36 | 'Import_Activacio', 'Import_Subscripcio', 'Import_Renovacio', |
| 37 | 'Taxa_Conversio', 'Factor_Conversio', 'Compensacio_Interficie', |
| 38 | 'Compensacio_Promocio', 'Generacio_Minima', |
| 39 | 'Nombre_Delegades', 'Nombre_Aprovacions', 'Cicles_Diposit', |
| 40 | 'Diposit_Minim', '_AUT_0', '_AUT_A', '_AUT_B', '_AUT_C' |
| 41 | ]; |
| 42 | |
| 43 | $respon = map( $refs_definidors, 24, $__resp ); |
| 44 | } |
| 45 | |
| 46 | |
| 47 | if ( $refcons == 'Valor_Dada' ) { |
| 48 | response[ 'Valor ' || $args.ref ] = $dada_args_ref; |
| 49 | } |
| 50 | |
| 51 | |
| 52 | if ( $refcons == 'Darrera_Proposta' ) { |
| 53 | $id_proposta = 'proposta_' || $args.ref || '_' || $__dada( 'ordinal_' || $args.ref ); |
| 54 | $temps_prop = $__dada( $id_proposta ); |
| 55 | |
| 56 | if ( !! $temps_prop ) { |
| 57 | $data_confirmacio = $temps_prop + $Lapse; |
| 58 | |
| 59 | response[ 'Ref proposta' ] = $__dada( $id_proposta || '_ref' ); |
| 60 | response[ 'Valor proposta' ] = $__dada( $id_proposta || '_val' ); |
| 61 | response[ 'Proposant' ] = $__dada( $id_proposta || '_proposant' ); |
| 62 | response[ 'Data de la proposta' ] = timestamp_to_string( $temps_prop, 'date' ); |
| 63 | response[ 'Data inici confirmacio' ] = timestamp_to_string( $data_confirmacio, 'date' ); |
| 64 | |
| 65 | $data_validacio = $__dada( 'validacio_' || $id_proposta ); |
| 66 | if ( !! $data_validacio ) { |
| 67 | response[ 'Hora validació' ] = timestamp_to_string( $data_validacio, 'time' ); |
| 68 | response[ 'Data validació' ] = timestamp_to_string( $data_validacio, 'date' ); |
| 69 | } |
| 70 | } else { |
| 71 | response[ 'No hi ha cap proposta per a aquest param definidor' ] = $id_proposta; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | |
| 76 | if ( $refcons == 'Valor_Proposta' ) { |
| 77 | response[ 'Ref proposta ' || $args.ref ] = $__dada( $args.ref || '_ref' ); |
| 78 | response[ 'Valor proposta ' || $args.ref ] = $__dada( $args.ref || '_val' ); |
| 79 | response[ 'Proposant proposta ' || $args.ref ] = $__dada( $args.ref || '_proposant' ); |
| 80 | $temps_prop = $dada_args_ref; |
| 81 | $data_confirmacio = $temps_prop + $Lapse; |
| 82 | response[ 'Data de la proposta' ] = timestamp_to_string( $temps_prop, 'date' ); |
| 83 | response[ 'Data inici confirmacio' ] = timestamp_to_string( $data_confirmacio, 'date' ); |
| 84 | |
| 85 | $data_validacio = $__dada( 'validacio_' || $args.ref ); |
| 86 | if ( !! $data_validacio ) { |
| 87 | response[ 'Hora validació' ] = timestamp_to_string( $data_validacio, 'time' ); |
| 88 | response[ 'Data validació' ] = timestamp_to_string( $data_validacio, 'date' ); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | |
| 93 | if ( $refcons == 'Validacio' ) { |
| 94 | $data_validacio = $__dada( 'validacio_' || $args.idprop ); |
| 95 | if ( !! $data_validacio ) { |
| 96 | response[ 'Proposta' ] = $args.idprop; |
| 97 | response[ 'Hora validació' ] = timestamp_to_string( $data_validacio, 'time' ); |
| 98 | response[ 'Data validació' ] = timestamp_to_string( $data_validacio, 'date' ); |
| 99 | } else |
| 100 | response[ 'La proposta ' || $args.idprop ] = 'no consta com a validada'; |
| 101 | } |
| 102 | |
| 103 | |
| 104 | if ( $refcons == 'Dades_Node' ) { |
| 105 | $ref_activacio = 'activacio_' || $args.adr || '_en_' || $refgeto; |
| 106 | $data_activacio = $__dada( $ref_activacio ); |
| 107 | |
| 108 | if ( !! $data_activacio ) { |
| 109 | response[ 'Node ' || $args.adr || ' activat per a' ] = $refgeto; |
| 110 | response[ 'Nom node' ] = $__dada( $ref_activacio || '_nom' ); |
| 111 | response[ 'Aportació per activació' ] = $__dada( $ref_activacio || '_qt' ); |
| 112 | response[ 'Cicle activació' ] = $__dada( $ref_activacio || '_cicle' ); |
| 113 | response[ 'Escala activació' ] = $__dada( $ref_activacio || '_escala' ); |
| 114 | response[ 'Interval activació' ] = $__dada( $ref_activacio || '_interval' ); |
| 115 | response[ 'Data activació' ] = timestamp_to_string( $data_activacio, 'date' ); |
| 116 | |
| 117 | $ref_subscripcio = 'subscripcio_' || $args.adr || '_en_' || $refgeto; |
| 118 | $data_subscripcio = $__dada( $ref_subscripcio ); |
| 119 | |
| 120 | if ( !! $data_subscripcio ) { |
| 121 | response[ 'Subscripció per a ' || $refgeto || ' de' ] = $args.adr; |
| 122 | response[ 'Nom subscripció' ] = $__dada( $ref_subscripcio || '_nom' ); |
| 123 | response[ '% derivació' ] = $__dada( $ref_subscripcio || '_derivacio' ); |
| 124 | response[ 'Cicle subscripció' ] = $__dada( $ref_subscripcio || '_cicle' ); |
| 125 | response[ 'Data subscripció' ] = timestamp_to_string( $data_subscripcio, 'date' ); |
| 126 | response[ 'Total derivacions' ] = |
| 127 | $__dada( 'total_derivacions_' || $args.adr || '_en_' || $refgeto ); |
| 128 | response[ 'Darrer cicle renovat' ] = |
| 129 | $__dada( 'renovacio_' || $args.adr || '_en_' || $refgeto || '_cicle' ); |
| 130 | } |
| 131 | |
| 132 | $ref_avis = 'avis_' || $refgeto || '_' || $args.adr; |
| 133 | $temps_avis = $__dada( $ref_avis ); |
| 134 | if ( $temps_avis ) { |
| 135 | $avis_es_actual = $temps_avis + ( $Lapse * 2 ) < timestamp; |
| 136 | if ( $avis_es_actual ) { |
| 137 | response[ 'Avís' ] = $__dada( $ref_avis || '_text' ); |
| 138 | response[ 'Data' ] = timestamp_to_string( $temps_avis, 'date' ); |
| 139 | response[ 'Rebot' ] = $__dada( $ref_avis || '_rebot' ); |
| 140 | } |
| 141 | } |
| 142 | } else { |
| 143 | response[ 'adr ' || $args.adr ] = 'NO activada per a ' || $refgeto; |
| 144 | } |
| 145 | response[ 'Cicle actual' ] = $cicle_actual; |
| 146 | } |
| 147 | |
| 148 | if ( $refcons == 'Dades_Isox' ) { |
| 149 | $ref_isox = 'isox_' || $args.adr; |
| 150 | $data_confirmacio = $__dada( $ref_isox || '_data' ); |
| 151 | |
| 152 | if ( !! $data_confirmacio ) { |
| 153 | response[ 'Ordinal' ] = $__dada( $ref_isox || '_ordinal' ); |
| 154 | response[ 'Proposant' ] = $__dada( $ref_isox || '_proposant' ); |
| 155 | response[ 'Confirmant' ] = $__dada( $ref_isox || '_confirmant' ); |
| 156 | response[ 'Data confirmació' ] = $data_confirmacio; |
| 157 | response[ 'Estat' ] = $__dada( $ref_isox || '_estat' ); |
| 158 | response[ 'Mitjana baules' ] = $__dada( $ref_isox || '_mitjana_baules' ); |
| 159 | } else { |
| 160 | response[ 'No consta cap isox amb aquesta adreça' ] = $args.adr; |
| 161 | $data_aspirant = $__dada( 'aspirant_' || $args.adr ) otherwise ''; |
| 162 | if ( $data_aspirant != '' ) |
| 163 | response[ 'Consta com a aspirant des de' ] = |
| 164 | timestamp_to_string( $data_aspirant, 'date' ); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | if ( $refcons == 'Dades_Diposit' ) { |
| 169 | response[ 'Ref' ] = $args.ref; |
| 170 | response[ 'Quantitat dipositada' ] = $dada_args_ref; |
| 171 | response[ 'Dipositant' ] = $__dada( $args.ref || '_dipositant' ); |
| 172 | response[ 'Cicle dipòsit' ] = $__dada( $args.ref || '_cicle' ); |
| 173 | response[ 'Getó dipòsit' ] = $__dada( $args.ref || '_geto_diposit' ); |
| 174 | response[ 'Data dipòsit' ] = $__dada( $args.ref || '_data'); |
| 175 | |
| 176 | response[ 'Taxa' ] = $__dada( $args.ref || '_taxa' ); |
| 177 | response[ 'Qt conversió' ] = $__dada( $args.ref || '_qt_conversio' ); |
| 178 | response[ 'Cicle conversió' ] = $__dada( $args.ref || '_cicle_conversio' ); |
| 179 | response[ 'Cicle actual' ] = $cicle_actual; |
| 180 | } |
| 181 | |
| 182 | |
| 183 | if ( $refcons == 'Dades_Contribucio' ) { |
| 184 | response[ 'Ref' ] = $args.ref; |
| 185 | response[ 'Quantitat' ] = $dada_args_ref; |
| 186 | response[ 'Contribuidora' ] = $__dada( $args.ref || '_contribuidora' ); |
| 187 | response[ 'Cicle contribució' ] = $__dada( $args.ref || '_cicle' ); |
| 188 | response[ 'Escala contribució' ] = $__dada( $args.ref || '_escala' ); |
| 189 | response[ 'Interval contribució' ] = $__dada( $args.ref || '_interval' ); |
| 190 | response[ 'Data contribució' ] = $__dada( $args.ref || '_data'); |
| 191 | $data_escala = $__dada( 'data_escala_actual' ); |
| 192 | response[ "Segons transcorreguts des del darrer salt d'escala" ] = |
| 193 | timestamp - $data_escala; |
| 194 | response[ 'Total Contribucions' ] = $__dada( 'total_contribucions_en_estels' ); |
| 195 | } |
| 196 | |
| 197 | |
| 198 | if ( $refcons == 'Dades_Conversio' OR $refcons == 'Dades_Retribucio' ) { |
| 199 | response[ 'Ref' ] = $args.ref; |
| 200 | response[ 'Destinatària' ] = $__dada( $args.ref || '_destinataria' ); |
| 201 | response[ 'Quantitat' ] = $__dada( $args.ref || '_qt' ); |
| 202 | response[ 'Data' ] = timestamp_to_string( $__dada( $args.ref || '_data' ), 'date' ); |
| 203 | if ( $refcons == 'Dades_Conversio' ) |
| 204 | response[ 'Unitat' ] = $__dada( $args.ref || '_unitat' ); |
| 205 | } |
| 206 | |
| 207 | |
| 208 | if ( $refcons == 'Totals' ) { |
| 209 | $total_geto = $__dada( 'total_en_' || $refgeto ); |
| 210 | $total_FOP = $__dada( 'total_FOP_en_' || $refgeto ); |
| 211 | $total_derivacions = $__dada( 'total_derivacions_en_' || $refgeto ); |
| 212 | $total_activacions = $__dada( 'total_activacions_en_' || $refgeto ); |
| 213 | $total_subscripcions = $__dada( 'total_subscripcions_en_' || $refgeto ); |
| 214 | $total_renovacions = $__dada( 'total_renovacions_en_' || $refgeto ); |
| 215 | $total_diposits = $__dada( 'total_diposits_en_' || $refgeto ); |
| 216 | $total_contribucions = $__dada( 'total_contribucions_en_' || $refgeto ); |
| 217 | $total_conversions = $__dada( 'total_conversions_de_' || $refgeto ); |
| 218 | $total_taxes = $__dada( 'total_taxes_de_' || $refgeto ); |
| 219 | $total_retribucions = $__dada( 'total_retribucions' ); |
| 220 | $total_assignacions = $__dada( 'total_assignacions' ); |
| 221 | |
| 222 | response[ 'Total Getó' ] = $total_geto; |
| 223 | response[ 'Total FOP' ] = $total_FOP; |
| 224 | response[ 'Total Activacions' ] = $total_activacions; |
| 225 | response[ 'Total Subscripcions' ] = $total_subscripcions; |
| 226 | response[ 'Total Renovacions' ] = $total_renovacions; |
| 227 | response[ 'Total Derivacions' ] = $total_derivacions; |
| 228 | response[ 'Total Diposits' ] = $total_diposits; |
| 229 | response[ 'Total Contribucions' ] = $total_contribucions; |
| 230 | response[ 'Total Conversions' ] = $total_conversions; |
| 231 | response[ 'Total Taxes' ] = $total_taxes; |
| 232 | response[ 'Total Retribucions' ] = $total_retribucions; |
| 233 | response[ 'Total Assignacions' ] = $total_assignacions; |
| 234 | } |
| 235 | |
| 236 | |
| 237 | if ( $refcons == 'Cicle_Actual' ) { |
| 238 | $interval = $__dada( 'Interval' ); |
| 239 | $segons_cicle_actual = ( $Origen + ( $cicle_actual * $interval ) ) - timestamp; |
| 240 | $percent_cicle_actual = $segons_cicle_actual / $interval * 100; |
| 241 | response[ 'Cicle actual' ] = $cicle_actual; |
| 242 | response[ 'Data actual' ] = timestamp; |
| 243 | response[ 'Data origen' ] = $Origen; |
| 244 | response[ 'Durada cicles' ] = $interval; |
| 245 | response[ 'Segons restants cicle actual' ] = $segons_cicle_actual; |
| 246 | response[ '% restant del cicle actual' ] = |
| 247 | round( $percent_cicle_actual, 0 ) || ' %'; |
| 248 | } |
| 249 | |
| 250 | |
| 251 | if ( $refcons == 'Escala_Actual' ) { |
| 252 | $escala_actual = $__dada( 'escala_actual' ); |
| 253 | $data_escala = $__dada( 'data_escala_actual' ); |
| 254 | response[ 'Escala Actual' ] = $escala_actual; |
| 255 | response[ "Data del salt d'escala" ] = timestamp_to_string( $data_escala, 'date' ); |
| 256 | response[ 'Data en segons' ] = $data_escala; |
| 257 | response[ 'Segons transcorreguts des de salt escala' ] = timestamp - $data_escala; |
| 258 | response[ 'Total Aportacions a FOP' ] = $__dada( 'total_FOP_en_estels' ); |
| 259 | } |
| 260 | |
| 261 | |
| 262 | if ( $refcons == 'Romanents' ) { |
| 263 | response[ 'Romanent en bytes' ] = balance[ $_Portal ][ base ]; |
| 264 | response[ "Romanent en estels" ] = balance[ $_Portal ][ $__dada( '_Estels' ) ]; |
| 265 | } |
| 266 | }" |
| 267 | } |
| 268 | ] |
| 269 | } |
| 270 | ] |