| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $nom_AA = 'Consultes'; |
| 6 | |
| 7 | $args = trigger.data; |
| 8 | $refcons = $args.refcons; |
| 9 | $geto = $args.geto; |
| 10 | |
| 11 | $__dada = $refval => |
| 12 | data_feed[[ oracles = $args._Registre, feed_name = $refval, ifnone = false ]]; |
| 13 | |
| 14 | $Lapse = $__dada( 'Lapse' ); |
| 15 | $Origen = $__dada( 'Origen' ); |
| 16 | $Estels = $__dada( 'Estels' ); |
| 17 | $cicle_actual = |
| 18 | 1 + floor( ( timestamp - $Origen ) / $__dada( 'Interval' ) ); |
| 19 | }", |
| 20 | "messages": [ |
| 21 | { |
| 22 | "app": "state", |
| 23 | "state": "{ |
| 24 | response[ 'consulta' ] = $refcons; |
| 25 | |
| 26 | |
| 27 | if ( $refcons == 'Portal' ) { |
| 28 | |
| 29 | $__resp = $r => { |
| 30 | response[ $r ] = $__dada( $r ); |
| 31 | }; |
| 32 | |
| 33 | $refs_definidors = [ |
| 34 | '_Accions', '_Getons', '_Validacions_TEST', |
| 35 | '_Convocatories', '_Pronunciaments', '_Vinculacions', |
| 36 | '_Getons', '_Emissions', '_Implementacions', |
| 37 | '_FRO', '_Calaix', 'Estels', 'Interval', 'Lapse', |
| 38 | 'Import_Activacio', 'Import_Subscripcio', 'Import_Renovacio', |
| 39 | 'Taxa_Conversio', 'Factor_Conversio', 'Compensacio_Interficie', |
| 40 | 'Compensacio_Promocio', 'Generacio_Minima', |
| 41 | 'Factor_Topall_Index_Baules', 'Nombre_Delegades', |
| 42 | 'Nombre_Aprovacions', 'Cicles_Diposit', |
| 43 | 'Diposit_Minim', 'Provisio', 'Romanent_Minim', 'Topall_Emissions', |
| 44 | '_AUT_0', '_AUT_A', '_AUT_B', '_AUT_C' |
| 45 | ]; |
| 46 | |
| 47 | $respon = map( $refs_definidors, 34, $__resp ); |
| 48 | } |
| 49 | |
| 50 | |
| 51 | if ( $refcons == 'Valor_Dada' ) { |
| 52 | response[ 'Valor ' || $args.ref ] = $__dada( $args.ref ); |
| 53 | } |
| 54 | |
| 55 | |
| 56 | if ( $refcons == 'Darrera_Proposta' ) { |
| 57 | $id_proposta = 'proposta_' || $args.ref || '_' || $__dada( 'ordinal_' || $args.ref ); |
| 58 | $temps_prop = $__dada( $id_proposta ); |
| 59 | |
| 60 | if ( !! $temps_prop ) { |
| 61 | $data_confirmacio = $temps_prop + $Lapse; |
| 62 | |
| 63 | response[ 'Ref proposta' ] = $__dada( $id_proposta || '_ref' ); |
| 64 | response[ 'Valor proposta' ] = $__dada( $id_proposta || '_val' ); |
| 65 | response[ 'Proposant' ] = $__dada( $id_proposta || '_proposant' ); |
| 66 | response[ 'Moment de la proposta' ] = |
| 67 | timestamp_to_string( $temps_prop, 'time' ); |
| 68 | response[ 'Moment confirmacio possible' ] = |
| 69 | timestamp_to_string( $data_confirmacio, 'time' ); |
| 70 | |
| 71 | $data_validacio = $__dada( 'validacio_' || $id_proposta ); |
| 72 | if ( !! $data_validacio ) { |
| 73 | response[ 'Hora validació' ] = |
| 74 | timestamp_to_string( $data_validacio, 'time' ); |
| 75 | response[ 'Data validació' ] = |
| 76 | timestamp_to_string( $data_validacio, 'date' ); |
| 77 | } |
| 78 | } else { |
| 79 | response[ 'No hi ha cap proposta per a aquest param definidor' ] = $id_proposta; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | |
| 84 | if ( $refcons == 'Dades_Calaix' ) { |
| 85 | $_Calaix = $__dada( '_Calaix' ); |
| 86 | |
| 87 | if ( !! $geto ) { |
| 88 | $idgeto = $__dada( $geto || '_id' ); |
| 89 | response[ "Id getó" ] = $idgeto; |
| 90 | response[ "Romanent en " || $geto ] = |
| 91 | balance[ $_Calaix ][ $idgeto ]; |
| 92 | response[ "Entrades en " || $geto ] = |
| 93 | $__dada( 'total_entrades_' || $geto ); |
| 94 | } |
| 95 | |
| 96 | response[ 'Total entrades en Bytes' ] = |
| 97 | $__dada( 'total_entrades_Bytes') otherwise 0; |
| 98 | response[ 'Total sortides en Bytes' ] = |
| 99 | $__dada( 'total_sortides_Bytes') otherwise 0; |
| 100 | response[ 'Total entrades en MBytes' ] = |
| 101 | round( $__dada( 'total_entrades_Bytes') / 1e6 ); |
| 102 | response[ 'Total sortides en MBytes' ] = |
| 103 | round( $__dada( 'total_sortides_MBytes') / 1e6 ); |
| 104 | response[ 'Total entrades en Estels' ] = |
| 105 | $__dada( 'total_entrades_Estels') otherwise 0; |
| 106 | response[ 'Total sortides en Estels' ] = |
| 107 | $__dada( 'total_sortides_Estels') otherwise 0; |
| 108 | response[ "Romanent en Bytes" ] = |
| 109 | balance[ $_Calaix ][ base ]; |
| 110 | response[ "Romanent en MBytes" ] = |
| 111 | round( balance[ $_Calaix ][ base ] / 1e6 ); |
| 112 | response[ "Romanent en Estels" ] = |
| 113 | balance[ $_Calaix ][ $Estels ]; |
| 114 | } |
| 115 | |
| 116 | |
| 117 | if ( $refcons == 'Dades_Proposta' ) { |
| 118 | response[ 'Ref proposta ' || $args.ref ] = |
| 119 | $__dada( $args.ref || '_ref' ); |
| 120 | response[ 'Valor proposta ' || $args.ref ] = |
| 121 | $__dada( $args.ref || '_val' ); |
| 122 | response[ 'Proposant proposta ' || $args.ref ] = |
| 123 | $__dada( $args.ref || '_proposant' ); |
| 124 | $temps_prop = $__dada( $args.ref ); |
| 125 | $data_confirmacio = $temps_prop + $Lapse; |
| 126 | |
| 127 | if ( ! $temps_prop ) |
| 128 | bounce( 'No hi ha cap proposta amb aquesta referència ' || $temps_prop ); |
| 129 | |
| 130 | response[ 'Data de la proposta' ] = |
| 131 | timestamp_to_string( $temps_prop, 'time' ); |
| 132 | response[ 'Data inici confirmacio' ] = |
| 133 | timestamp_to_string( $data_confirmacio, 'time' ); |
| 134 | |
| 135 | $data_aprovacio = $__dada( 'validacio_' || $args.ref ); |
| 136 | $data_refus = $__dada( 'refus_' || $args.ref ); |
| 137 | |
| 138 | if ( !! $data_aprovacio ) |
| 139 | response[ 'Proposta aprovada' ] = |
| 140 | timestamp_to_string( $data_aprovacio, 'date' ); |
| 141 | if ( !! $data_refus ) |
| 142 | response[ 'Proposta refusada' ] = |
| 143 | timestamp_to_string( $data_refus, 'date' ); |
| 144 | } |
| 145 | |
| 146 | |
| 147 | if ( $refcons == 'Dades_Isox' ) { |
| 148 | $ref_isox = 'isox_' || $args.adr; |
| 149 | $data_confirmacio = $__dada( $ref_isox || '_data' ); |
| 150 | |
| 151 | if ( !! $data_confirmacio ) { |
| 152 | response[ 'Ordinal' ] = $__dada( $ref_isox || '_ordinal' ); |
| 153 | response[ 'Proposant' ] = $__dada( $ref_isox || '_proposant' ); |
| 154 | response[ 'Confirmant' ] = $__dada( $ref_isox || '_confirmant' ); |
| 155 | response[ 'Data confirmació' ] = $data_confirmacio; |
| 156 | response[ 'Estat' ] = $__dada( $ref_isox || '_estat' ); |
| 157 | response[ 'Index baules' ] = $__dada( $ref_isox || '_index_baules' ); |
| 158 | } else { |
| 159 | response[ 'No consta cap isox amb aquesta adreça' ] = $args.adr; |
| 160 | $data_aspirant = $__dada( 'aspirant_' || $args.adr ) otherwise ''; |
| 161 | if ( $data_aspirant != '' ) |
| 162 | response[ 'Consta com a aspirant des de' ] = |
| 163 | timestamp_to_string( $data_aspirant, 'date' ); |
| 164 | } |
| 165 | response[ 'Mitjana index baules' ] = $__dada( 'mitjana_index_baules' ); |
| 166 | } |
| 167 | |
| 168 | |
| 169 | if ( $refcons == 'Dades_Vincle' ) { |
| 170 | $ref_vincle = $args.tipus || '_' || $args.nom; |
| 171 | $ord_vincle = $__dada( $ref_vincle ); |
| 172 | response[ 'Ref' ] = $ref_vincle; |
| 173 | response[ 'Ordinal' ] = $ord_vincle; |
| 174 | response[ 'Adreça' ] = $__dada( $ref_vincle || '_adr' ); |
| 175 | response[ 'Estat' ] = $__dada( $ref_vincle || '_estat' ); |
| 176 | if ( $args.tipus == 'entitat' ) { |
| 177 | response[ 'Delegada 1' ] = $__dada( $ref_vincle || '_delegada_1' ); |
| 178 | response[ 'Delegada 2' ] = $__dada( $ref_vincle || '_delegada_2' ); |
| 179 | response[ 'Delegada 3' ] = $__dada( $ref_vincle || '_delegada_3' ); |
| 180 | response[ 'Delegada 4' ] = $__dada( $ref_vincle || '_delegada_4' ); |
| 181 | response[ 'Delegada 5' ] = $__dada( $ref_vincle || '_delegada_5' ); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | if ( $refcons == 'Dades_Assignacio' ) { |
| 186 | $ord_assignacio = $__dada( $args.ref ); |
| 187 | $data_assignacio = $__dada( $ord_assignacio || '_data' ); |
| 188 | response[ 'Ref' ] = $args.ref; |
| 189 | response[ 'Ordinal' ] = $ord_assignacio; |
| 190 | response[ 'Quantitat' ] = $__dada( $ord_assignacio || '_qt' ); |
| 191 | response[ 'Unitat' ] = $__dada( $ord_assignacio || '_unitat' ); |
| 192 | response[ 'Rebedora' ] = $__dada( $ord_assignacio || '_rebedora' ); |
| 193 | response[ 'Requeriment' ] = $__dada( $ord_assignacio || '_unitat' ); |
| 194 | response[ 'Data' ] = timestamp_to_string( $data_assignacio, 'date' ); |
| 195 | } |
| 196 | |
| 197 | if ( $refcons == 'Saldo_AA' ) { |
| 198 | $agent = $args.agent; |
| 199 | $_AA = |
| 200 | $agent == 'Portal' ? $args._Portal : |
| 201 | $agent == 'Capsa' ? $__dada( $geto || '__Capsa' ) : |
| 202 | $__dada( '_' || $agent ); |
| 203 | |
| 204 | if( $args.idgeto != 'cap' ) |
| 205 | $idgeto = $args.idgeto; |
| 206 | else |
| 207 | $idgeto = |
| 208 | $geto == 'Estels' ? |
| 209 | $Estels : |
| 210 | $geto == 'Bytes' ? |
| 211 | 'base' : |
| 212 | $__dada( $geto || '_id' ); |
| 213 | |
| 214 | response[ "Id getó" ] = $idgeto; |
| 215 | response[ "_AA" ] = $_AA; |
| 216 | |
| 217 | $saldo = !! $idgeto ? balance[ $_AA ][ $idgeto ] : 'Getó desconegut'; |
| 218 | |
| 219 | if ( $geto != 'Estels' ) |
| 220 | response[ "Romanent de " || $agent || " en " || $geto ] = $saldo; |
| 221 | |
| 222 | response[ "Romanent de " || $agent || " en Bytes" ] = |
| 223 | balance[ $_AA ][ base ]; |
| 224 | |
| 225 | response[ "Romanent de " || $agent || " en MBytes" ] = |
| 226 | round( balance[ $_AA ][ base ] / 1e6 ); |
| 227 | |
| 228 | response[ "Romanent de " || $agent || " en Estels" ] = |
| 229 | balance[ $_AA ][ $Estels ]; |
| 230 | } |
| 231 | |
| 232 | if ( $refcons == 'Adr_AA' ) { |
| 233 | response[ "Adreça AA " || $args.nom ] = $__dada( '_' || $args.nom ); |
| 234 | } |
| 235 | |
| 236 | |
| 237 | if ( $refcons == 'Missatge' ) { |
| 238 | $_Missatges = $__dada( '_Missatges' ); |
| 239 | $missatge = var[ $_Missatges ][ $args.ref ]; |
| 240 | response[ "Ref" ] = $args.ref; |
| 241 | response[ "Missatge" ] = $missatge; |
| 242 | response[ "Adreça AA Missatges" ] = $_Missatges; |
| 243 | } |
| 244 | }" |
| 245 | } |
| 246 | ] |
| 247 | } |
| 248 | ] |