| 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 | $generics = var[ $_Portal ][ 'generics' ]; |
| 13 | $portals = var[ $_Portal ][ 'portals' ]; |
| 14 | $dades_accions = var[ $generics._Accions ]; |
| 15 | |
| 16 | $__dada = $refval => { |
| 17 | data_feed[[ oracles = $portals, feed_name = $refval ]] |
| 18 | |
| 19 | }; |
| 20 | }", |
| 21 | "messages": [ |
| 22 | { |
| 23 | "app": "state", |
| 24 | "state": "{ |
| 25 | response[ 'consulta' ] = $refcons; |
| 26 | |
| 27 | if ( $refcons == 'Portal' ) { |
| 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 | response[ 'Portals ' ] = $portals; |
| 45 | } |
| 46 | |
| 47 | |
| 48 | if ( $refcons == 'Valor_Generic' ) { |
| 49 | response[ 'valor ' || $args.ref ] = $generics[ $args.ref ]; |
| 50 | } |
| 51 | |
| 52 | |
| 53 | if ( $refcons == 'Valor_Dada' ) { |
| 54 | response[ 'valor ' || $args.ref ] = $__dada( $args.ref ); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | if ( $refcons == 'Valor_Proposta' ) { |
| 59 | $prop = data_feed[[ oracles = $portals, feed_name = $args.ref ]]; |
| 60 | response[ 'ref proposta ' || $args.ref ] = $__dada( $args.ref || '_ref' ); |
| 61 | response[ 'val proposta ' || $args.ref ] = $__dada( $args.ref || '_val' ); |
| 62 | response[ 'proposant proposta ' || $args.ref ] = $__dada( $args.ref || '_proposant' ); |
| 63 | response[ 'temps proposta ' || $args.ref ] = $__dada( $args.ref || '_temps' ); |
| 64 | } |
| 65 | |
| 66 | |
| 67 | if ( $refcons == 'Validacio' ) { |
| 68 | $data_validacio = $__dada( 'validacio_' || $args.idprop ); |
| 69 | response[ 'Proposta' ] = $args.idprop; |
| 70 | response[ 'Validada' ] = |
| 71 | $data_validacio ? timestamp_to_string( $data_validacio ) : 'NO'; |
| 72 | } |
| 73 | |
| 74 | |
| 75 | if ( $refcons == 'Dades_Geto' ) { |
| 76 | $refs_getons = var[ $_Portal ][ 'refs_getons' ]; |
| 77 | $ids_getons = var[ $_Portal ][ 'ids_getons' ]; |
| 78 | |
| 79 | response[ 'Id getó' ] = $ids_getons[ $refgeto ]; |
| 80 | |
| 81 | $refs = [ |
| 82 | '_FOG', '_AUT_A', 'factor_conversio', |
| 83 | 'valors_esmenables', 'llistats_editables', |
| 84 | 'bloqueig_possible', 'import_activacio', |
| 85 | 'import_subscripcio', 'import_renovacio', |
| 86 | 'taxa_conversio', 'cicles_diposit', 'derivacio', |
| 87 | '_AUT_B', '_AUT_C', '_AUT_0' |
| 88 | ]; |
| 89 | |
| 90 | $__resposta = $r => { |
| 91 | response[ $r ] = $__dada( $refgeto || '_' || $r ); |
| 92 | }; |
| 93 | |
| 94 | $resps = map( $refs, 6, $__resposta ); |
| 95 | |
| 96 | response[ 'temps' ] = timestamp_to_string( $__dada( $refgeto || '_temps' ) ); |
| 97 | } |
| 98 | |
| 99 | |
| 100 | if ( $refcons == 'Dades_Node' ) { |
| 101 | $ref_activacio = 'activacio_' || $args.adr || '_en_' || $refgeto; |
| 102 | |
| 103 | $cicle_renovacio = $dades_accions[ 'renovacio_' || $args.adr || '_' || $refgeto ]; |
| 104 | |
| 105 | response[ 'Nom Activació' ] = $__dada( $ref_activacio || '_nom' ); |
| 106 | response[ 'Qt Activació' ] = $__dada( $ref_activacio || '_qt' ); |
| 107 | response[ 'Cicle Activació' ] = $__dada( $ref_activacio || '_cicle' ); |
| 108 | response[ 'Escala Activació' ] = $__dada( $ref_activacio || '_escala' ); |
| 109 | response[ 'Ordinal Activació' ] = $__dada( $ref_activacio || '_ordinal' ); |
| 110 | |
| 111 | $ref_subscripcio = 'subscripcio_' || $args.adr || '_en_' || $refgeto; |
| 112 | $subscripcio = $__dada( $ref_subscripcio || '_ordinal_' ); |
| 113 | |
| 114 | if ( $subscripcio ) { |
| 115 | response[ 'Nom Subscripció' ] = $__dada( $ref_subscripcio || '_ordinal' ); |
| 116 | response[ '% Derivació a FOP' ] = $__dada( $ref_subscripcio || '_derivacio' ); |
| 117 | response[ 'Cicle Subscripció' ] = $__dada( $ref_subscripcio || '_cicle' ); |
| 118 | response[ 'Ordinal Subscripció' ] = $__dada( $ref_subscripcio || '_ordinal' ); |
| 119 | response[ 'Total Derivacions a FOP' ] = |
| 120 | $__dada( 'total_derivacions_' || $args.adr || '_en_' || $refgeto ); |
| 121 | response[ 'Cicle Renovació' ] = |
| 122 | $__dada( 'renovacio_' || $args.adr || '_en_' || $refgeto ); |
| 123 | } |
| 124 | |
| 125 | $ref_avis = 'avis_' || $refgeto || '_' || $args.adr; |
| 126 | $temps_avis = $__dada( $ref_avis || '_temps' ); |
| 127 | $avis_es_actual = $temps_avis + ( $generics.Lapse * 2 ) < timestamp; |
| 128 | if ( $avis_es_actual ) { |
| 129 | response[ 'Avís' ] = $__dada( $ref_avis ); |
| 130 | response[ 'Temps' ] = timestamp_to_string( $temps_avis ); |
| 131 | response[ 'Rebot' ] = $__dada( $ref_avis || '_rebot' ); |
| 132 | |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | |
| 137 | if ( $refcons == 'Totals' ) { |
| 138 | $total_unitat = $__dada( 'total_' || $refgeto ); |
| 139 | $total_FOP = $__dada( 'total_FOP_en_' || $refgeto ); |
| 140 | $total_derivacions = $__dada( 'total_derivacions_' || '_en_' || $refgeto ); |
| 141 | $total_activacions = $__dada( 'total_activacions_en_' || $refgeto ); |
| 142 | $total_subscripcions = $__dada( 'total_subscripcions_en_' || $refgeto ); |
| 143 | $total_renovacions = $__dada( 'total_renovacions_en_' || $refgeto ); |
| 144 | $total_diposits = $__dada( 'total_diposits_en_' || $refgeto ); |
| 145 | $total_contribucions = $__dada( 'total_contribucions_en_' || $refgeto ); |
| 146 | |
| 147 | response[ 'Total Activacions' ] = $total_activacions; |
| 148 | response[ 'Total Subscripcions' ] = $total_subscripcions; |
| 149 | response[ 'Total Renovacions' ] = $total_renovacions; |
| 150 | response[ 'Total Contribucions' ] = $total_contribucions; |
| 151 | response[ 'Total Derivacions' ] = $total_derivacions; |
| 152 | response[ 'Total Diposits' ] = $total_diposits; |
| 153 | } |
| 154 | |
| 155 | |
| 156 | if ( $refcons == 'Cicle_actual' ) { |
| 157 | $cicle_actual = $dades_accions[ 'cicle_actual']; |
| 158 | $data_cicle_actual = $dades_accions[ 'data_cicle_actual']; |
| 159 | $data_cicle_anterior = $dades_accions[ 'data_cicle_anterior']; |
| 160 | $interval = $dades_accions[ 'Interval']; |
| 161 | response[ 'Cicle Actual' ] = $cicle_actual; |
| 162 | response[ 'Data Cicle Actual' ] = timestamp_to_string( $data_cicle_actual ); |
| 163 | response[ 'Data Cicle Anterior' ] = timestamp_to_string( $data_cicle_anterior ); |
| 164 | response[ 'Data Cicle Actual milisegons' ] = $data_cicle_actual; |
| 165 | response[ 'Data Cicle Anterior milisegons' ] = $data_cicle_anterior; |
| 166 | response[ 'Interval' ] = $interval; |
| 167 | } |
| 168 | |
| 169 | |
| 170 | if ( $refcons == 'Avis' ) { |
| 171 | $ref_avis = 'avis_' || $refgeto || '_' || $args.adr; |
| 172 | $temps_avis = $__dada( $ref_avis || '_temps' ); |
| 173 | $avis_es_actual = $temps_avis + ( $generics.Lapse * 2 ) < timestamp; |
| 174 | if ( $avis_es_actual ) { |
| 175 | response[ 'Avís' ] = $__dada( $ref_avis ); |
| 176 | response[ 'Temps' ] = timestamp_to_string( $temps_avis ); |
| 177 | response[ 'Rebot' ] = $__dada( $ref_avis || '_rebot' ); |
| 178 | } else { |
| 179 | response[ 'No hi ha cap avís per a' ] = $args.adr; |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | |
| 184 | if ( $refcons == 'Capacitacio' ) { |
| 185 | $ref_capacitacio = 'capacitacio_' || $refgeto || '_' || $args.accio || '_' || $args.adr; |
| 186 | |
| 187 | response[ 'Capacitacio' ] = $__dada( $ref_capacitacio ); |
| 188 | } |
| 189 | }" |
| 190 | } |
| 191 | ] |
| 192 | } |
| 193 | ] |