| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $nom_AA = 'Consultes_Getons'; |
| 6 | |
| 7 | $args = trigger.data; |
| 8 | $_Portal = $args._Portal; |
| 9 | $refcons = $args.refcons; |
| 10 | |
| 11 | $__dada = $refval => { |
| 12 | data_feed[[ oracles = $args._Registre, feed_name = $refval, ifnone = false ]] |
| 13 | }; |
| 14 | }", |
| 15 | "messages": [ |
| 16 | { |
| 17 | "app": "state", |
| 18 | "state": "{ |
| 19 | response[ 'consulta' ] = $refcons; |
| 20 | $geto = |
| 21 | $args.geto otherwise |
| 22 | $__dada( 'geto_' || $args.idgeto ); |
| 23 | |
| 24 | if ( $refcons == 'Dades_Geto' ) { |
| 25 | |
| 26 | if( ! $__dada( $geto || '_estat' ) ) bounce( 'Getó desconegut' ); |
| 27 | |
| 28 | $resp = $geto ? 'getó amb nom ' || $geto : 'getó amb id ' || $args.idgeto; |
| 29 | response[ 'Dades' ] = $resp; |
| 30 | |
| 31 | $ord_geto = $__dada( $geto ); |
| 32 | response[ 'Ordinal' ] = $ord_geto; |
| 33 | |
| 34 | if ( ! $ord_geto ) |
| 35 | response[ "No hi consta cap" ] = $resp; |
| 36 | |
| 37 | $data_implementacio = $__dada( $geto || '_data' ); |
| 38 | response[ 'Data implementació' ] = |
| 39 | timestamp_to_string( $data_implementacio, 'date' ); |
| 40 | |
| 41 | response[ 'Total emissions' ] = |
| 42 | $__dada( 'total_emesos_' || $geto ) otherwise 0; |
| 43 | |
| 44 | response[ 'Total Estels convertits' ] = |
| 45 | $__dada( 'total_estels_convertits_' || $geto ) otherwise 0; |
| 46 | |
| 47 | $refs = [ |
| 48 | 'id', 'estat', '_FOP', 'topall', 'factor_conversio', |
| 49 | 'taxa_conversio', 'derivacio', 'import_activacio', |
| 50 | 'import_subscripcio', 'import_renovacio','cicles_diposit', |
| 51 | 'activacions_restringides', 'subscripcions_restringides', |
| 52 | 'recepcions_restringides', 'conversions_restringides', |
| 53 | 'redefinible', 'llistats_editables', 'bloqueig_possible', |
| 54 | '_AUT_A', '_AUT_B', '_AUT_C' |
| 55 | ]; |
| 56 | |
| 57 | $__resposta = $r => { |
| 58 | response[ $r ] = $__dada( $geto || '_' || $r ); |
| 59 | }; |
| 60 | |
| 61 | $resps = map( $refs, 23, $__resposta ); |
| 62 | } |
| 63 | |
| 64 | if ( $refcons == 'Avis' ) { |
| 65 | $refavis = 'avis_' || $geto || '_' || $args.adr; |
| 66 | $ord_avis = $__dada( $refavis ); |
| 67 | $temps_avis = $__dada( $ord_avis || '_data' ); |
| 68 | |
| 69 | $avis_es_actual = true; |
| 70 | if ( $avis_es_actual ) { |
| 71 | response[ 'Avís' ] = $__dada( $ord_avis || '_text' ); |
| 72 | response[ 'Hora' ] = timestamp_to_string( $temps_avis, 'time' ); |
| 73 | response[ 'Data' ] = timestamp_to_string( $temps_avis, 'date' ); |
| 74 | response[ 'Rebot' ] = $__dada( $ord_avis || '_rebot' ); |
| 75 | } else { |
| 76 | response[ 'No hi ha cap avís per a' ] = $args.adr; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | if ( $refcons == 'Capacitacio' ) { |
| 81 | $ref_capacitacio = $geto || '_' || $args.accio || '_' || $args.adr; |
| 82 | $capacitada = $__dada( $ref_capacitacio ) otherwise ''; |
| 83 | $secc = $capacitada == 'capacitada' ? ' ' : ' NO '; |
| 84 | response[ 'Ref' ] = $ref_capacitacio; |
| 85 | response[ 'Capacitacio' ] = 'Adreça' || $secc || 'capacitada per a ' || $args.accio || 'ns'; |
| 86 | } |
| 87 | |
| 88 | if ( $refcons == 'Geto_Pendent' ) { |
| 89 | $getons_pendents = var[ $_Portal ][ 'getons_pendents' ]; |
| 90 | response[ "Getó pendent d'inscripció" ] = $getons_pendents[ $geto ]; |
| 91 | } |
| 92 | |
| 93 | if ( $refcons == 'Emissions_Geto' ) { |
| 94 | $total_emissions = $__dada( 'total_estels_convertits_' || $geto ) otherwise 0; |
| 95 | response[ 'Emissions de ' || $geto ] = $total_emissions; |
| 96 | } |
| 97 | |
| 98 | if ( $refcons == 'Romanent_Geto' ) { |
| 99 | $idgeto = $__dada( $geto || '_id' ); |
| 100 | response[ 'Id ' || $geto ] = $idgeto; |
| 101 | response[ 'Romanent en ' || $geto ] = balance[ $args._Portal ][ $idgeto ]; |
| 102 | } |
| 103 | }" |
| 104 | } |
| 105 | ] |
| 106 | } |
| 107 | ] |