| 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 | $versions = []; |
| 14 | $versions.portal = var[ $_Portal ][ 'versions' ] otherwise $_Portal; |
| 15 | $versions.getons = var[ $_Portal ][ 'versions_getons' ] otherwise $_Portal; |
| 16 | $versions.accions = var[ $_Portal ][ 'versions_accions' ] otherwise $_Portal; |
| 17 | $versions.validacions = var[ $_Portal ][ 'versions_validacions' ] otherwise $_Portal; |
| 18 | $versions.validadores = var[ $_Portal ][ 'versions_validadores' ] otherwise $_Portal; |
| 19 | |
| 20 | $dades_accions = var[ $generics._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 | }", |
| 39 | "messages": [ |
| 40 | { |
| 41 | "app": "state", |
| 42 | "state": "{ |
| 43 | response[ 'consulta' ] = $refcons; |
| 44 | |
| 45 | if ( $refcons == 'Portal' ) { |
| 46 | |
| 47 | $__resp = $r => { |
| 48 | response[ $r ] = $generics[ $r ]; |
| 49 | }; |
| 50 | |
| 51 | $refs_generics = [ |
| 52 | '_Accions', '_Getons', '_Validacions', '_Validadores', |
| 53 | '_FRO', '_Estels', 'Interval', 'Lapse', |
| 54 | 'Import_Activacio', 'Import_Subscripcio', 'Import_Renovacio', |
| 55 | 'Taxa_Conversio', 'Factor_Conversio', 'Generacio_Minima', |
| 56 | 'Nombre_Delegades', 'Nombre_Aprovacions', 'Cicles_Diposit', |
| 57 | '_AUT_0', '_AUT_A', '_AUT_B', '_AUT_C' |
| 58 | ]; |
| 59 | |
| 60 | $respon = map( $refs_generics, 21, $__resp ); |
| 61 | |
| 62 | response[ 'Versions portal' ] = $versions.portal; |
| 63 | response[ 'Versions _Accions' ] = $versions.accions; |
| 64 | response[ 'Versions _Getons' ] = $versions.getons; |
| 65 | response[ 'Versions _Validacions' ] = $versions.validacions; |
| 66 | response[ 'Versions _Validadores' ] = $versions.validadores; |
| 67 | } |
| 68 | |
| 69 | |
| 70 | if ( $refcons == 'Valor_Generic' ) { |
| 71 | response[ 'valor ' || $args.ref ] = $generics[ $args.ref ]; |
| 72 | } |
| 73 | |
| 74 | |
| 75 | if ( $refcons == 'Valor_Dada' ) { |
| 76 | response[ 'valor ' || $args.ref ] = $__dada( $args.ref ); |
| 77 | } |
| 78 | |
| 79 | |
| 80 | if ( $refcons == 'Darrera_Proposta' ) { |
| 81 | $ordinals = var[ $_Portal ][ 'ordinals' ]; |
| 82 | $id_proposta = $args.ref || '_' || $ordinals[ $args.ref ]; |
| 83 | |
| 84 | if ( $__dada( $id_proposta ) ) { |
| 85 | $temps_prop = $__dada( $id_proposta ); |
| 86 | $data_confirmacio = $temps_prop + $generics.Lapse; |
| 87 | |
| 88 | response[ 'proposant' ] = $__dada( $id_proposta || '_proposant' ); |
| 89 | response[ 'data de la proposta' ] = |
| 90 | timestamp_to_string( $temps_prop ); |
| 91 | response[ 'data inici confirmacio' ] = |
| 92 | timestamp_to_string( $data_confirmacio ); |
| 93 | |
| 94 | $data_validacio = $__dada_AA( 'validacio_' || $id_proposta, $versions.validacions ); |
| 95 | response[ 'proposta validada' ] = |
| 96 | $data_validacio ? timestamp_to_string( $data_validacio ) : 'NO'; |
| 97 | } else { |
| 98 | response[ 'No hi ha cap proposta per a aquest param genèric' ] = $id_proposta; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | |
| 103 | if ( $refcons == 'Valor_Proposta' ) { |
| 104 | response[ 'ref proposta ' || $args.ref ] = $__dada( $args.ref || '_ref' ); |
| 105 | response[ 'val proposta ' || $args.ref ] = $__dada( $args.ref || '_val' ); |
| 106 | response[ 'proposant proposta ' || $args.ref ] = $__dada( $args.ref || '_proposant' ); |
| 107 | $temps_prop = $__dada( $args.ref ); |
| 108 | $data_confirmacio = $temps_prop + $generics.Lapse; |
| 109 | response[ 'data de la proposta' ] = |
| 110 | timestamp_to_string( $temps_prop ); |
| 111 | response[ 'data inici confirmacio' ] = |
| 112 | timestamp_to_string( $data_confirmacio ); |
| 113 | |
| 114 | $data_validacio = $__dada_AA( 'validacio_' || $args.ref, $versions.validacions ); |
| 115 | response[ 'proposta validada' ] = |
| 116 | $data_validacio ? timestamp_to_string( $data_validacio ) : 'NO'; |
| 117 | } |
| 118 | |
| 119 | |
| 120 | if ( $refcons == 'Validacio' ) { |
| 121 | $data_validacio = $__dada_AA( 'validacio_' || $args.idprop, $versions.validacions ); |
| 122 | response[ 'Proposta' ] = $args.idprop; |
| 123 | response[ 'Validada' ] = |
| 124 | $data_validacio ? timestamp_to_string( $data_validacio ) : 'NO'; |
| 125 | } |
| 126 | |
| 127 | |
| 128 | if ( $refcons == 'Dades_Geto' ) { |
| 129 | $refs_getons = var[ $_Portal ][ 'refs_getons' ]; |
| 130 | $ids_getons = var[ $_Portal ][ 'ids_getons' ]; |
| 131 | |
| 132 | response[ 'Id getó' ] = $ids_getons[ $refgeto ]; |
| 133 | |
| 134 | $refs = [ |
| 135 | '_FOG', '_AUT_A', 'factor_conversio', |
| 136 | 'valors_esmenables', 'llistats_editables', |
| 137 | 'bloqueig_possible', 'import_activacio', |
| 138 | 'import_subscripcio', 'import_renovacio', |
| 139 | 'taxa_conversio', 'cicles_diposit', 'derivacio', |
| 140 | '_AUT_B', '_AUT_C', '_AUT_0' |
| 141 | ]; |
| 142 | |
| 143 | $__resposta = $r => { |
| 144 | response[ $r ] = $__dada_getons( $refgeto || '_' || $r ); |
| 145 | }; |
| 146 | |
| 147 | $resps = map( $refs, 6, $__resposta ); |
| 148 | |
| 149 | response[ 'temps' ] = |
| 150 | timestamp_to_string( $__dada_getons( $refgeto ) ); |
| 151 | } |
| 152 | |
| 153 | |
| 154 | if ( $refcons == 'Dades_Node' ) { |
| 155 | $ref_activacio = 'activacio_' || $args.adr || '_en_' || $refgeto; |
| 156 | |
| 157 | $cicle_renovacio = $dades_accions[ 'renovacio_' || $args.adr || '_' || $refgeto ]; |
| 158 | |
| 159 | response[ 'Nom Activació' ] = $__dada_accions( $ref_activacio || '_nom' ); |
| 160 | response[ 'Qt Activació' ] = $__dada_accions( $ref_activacio || '_qt' ); |
| 161 | response[ 'Cicle Activació' ] = $__dada_accions( $ref_activacio || '_cicle' ); |
| 162 | response[ 'Escala Activació' ] = $__dada_accions( $ref_activacio || '_escala' ); |
| 163 | response[ 'Ordinal Activació' ] = $__dada_accions( $ref_activacio || '_ordinal' ); |
| 164 | |
| 165 | $ref_subscripcio = 'subscripcio_' || $args.adr || '_en_' || $refgeto; |
| 166 | $subscripcio = $__dada_accions( $ref_subscripcio || '_ordinal_' ); |
| 167 | |
| 168 | if ( $subscripcio ) { |
| 169 | response[ 'Nom Subscripció' ] = $__dada_accions( $ref_subscripcio || '_ordinal' ); |
| 170 | response[ '% Derivació a FOP' ] = $__dada_accions( $ref_subscripcio || '_derivacio' ); |
| 171 | response[ 'Cicle Subscripció' ] = $__dada_accions( $ref_subscripcio || '_cicle' ); |
| 172 | response[ 'Ordinal Subscripció' ] = $__dada_accions( $ref_subscripcio || '_ordinal' ); |
| 173 | response[ 'Total Derivacions a FOP' ] = |
| 174 | $__dada_accions( 'total_derivacions_' || $args.adr || '_en_' || $refgeto ); |
| 175 | response[ 'Cicle Renovació' ] = |
| 176 | $__dada_accions( 'renovacio_' || $args.adr || '_en_' || $refgeto ); |
| 177 | } |
| 178 | |
| 179 | $ref_avis = 'avis_' || $refgeto || '_' || $args.adr; |
| 180 | $temps_avis = $__dada_getons( $ref_avis ); |
| 181 | $avis_es_actual = $temps_avis + ( $generics.Lapse * 2 ) < timestamp; |
| 182 | if ( $avis_es_actual ) { |
| 183 | response[ 'Avís' ] = $__dada_getons( $ref_avis ); |
| 184 | response[ 'Temps' ] = timestamp_to_string( $temps_avis ); |
| 185 | response[ 'Rebot' ] = $__dada_getons( $ref_avis || '_rebot' ); |
| 186 | |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | |
| 191 | if ( $refcons == 'Totals' ) { |
| 192 | $total_unitat = $__dada_accions( 'total_' || $refgeto ); |
| 193 | $total_FOP = $__dada_accions( 'total_FOP_en_' || $refgeto ); |
| 194 | $total_derivacions = $__dada_accions( 'total_derivacions_' || '_en_' || $refgeto ); |
| 195 | $total_activacions = $__dada_accions( 'total_activacions_en_' || $refgeto ); |
| 196 | $total_subscripcions = $__dada_accions( 'total_subscripcions_en_' || $refgeto ); |
| 197 | $total_renovacions = $__dada_accions( 'total_renovacions_en_' || $refgeto ); |
| 198 | $total_diposits = $__dada_accions( 'total_diposits_en_' || $refgeto ); |
| 199 | $total_contribucions = $__dada_accions( 'total_contribucions_en_' || $refgeto ); |
| 200 | |
| 201 | response[ 'Total Activacions' ] = $total_activacions; |
| 202 | response[ 'Total Subscripcions' ] = $total_subscripcions; |
| 203 | response[ 'Total Renovacions' ] = $total_renovacions; |
| 204 | response[ 'Total Contribucions' ] = $total_contribucions; |
| 205 | response[ 'Total Derivacions' ] = $total_derivacions; |
| 206 | response[ 'Total Diposits' ] = $total_diposits; |
| 207 | } |
| 208 | |
| 209 | |
| 210 | if ( $refcons == 'Cicle_actual' ) { |
| 211 | $cicle_actual = $dades_accions[ 'cicle_actual']; |
| 212 | $data_cicle_actual = $dades_accions[ 'data_cicle_actual']; |
| 213 | $data_cicle_anterior = $dades_accions[ 'data_cicle_anterior']; |
| 214 | $interval = $dades_accions[ 'Interval']; |
| 215 | response[ 'Cicle Actual' ] = $cicle_actual; |
| 216 | response[ 'Data Cicle Actual' ] = timestamp_to_string( $data_cicle_actual ); |
| 217 | response[ 'Data Cicle Anterior' ] = timestamp_to_string( $data_cicle_anterior ); |
| 218 | response[ 'Data Cicle Actual milisegons' ] = $data_cicle_actual; |
| 219 | response[ 'Data Cicle Anterior milisegons' ] = $data_cicle_anterior; |
| 220 | response[ 'Interval' ] = $interval; |
| 221 | } |
| 222 | |
| 223 | |
| 224 | if ( $refcons == 'Avis' ) { |
| 225 | $ref_avis = 'avis_' || $refgeto || '_' || $args.adr; |
| 226 | $temps_avis = $__dada_getons( $ref_avis ); |
| 227 | $avis_es_actual = $temps_avis + ( $generics.Lapse * 2 ) < timestamp; |
| 228 | if ( $avis_es_actual ) { |
| 229 | response[ 'Avís' ] = $__dada_getons( $ref_avis ); |
| 230 | response[ 'Temps' ] = timestamp_to_string( $temps_avis ); |
| 231 | response[ 'Rebot' ] = $__dada_getons( $ref_avis || '_rebot' ); |
| 232 | } else { |
| 233 | response[ 'No hi ha cap avís per a' ] = $args.adr; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | |
| 238 | if ( $refcons == 'Capacitacio' ) { |
| 239 | $ref_capacitacio = 'capacitacio_' || $refgeto || '_' || $args.accio || '_' || $args.adr; |
| 240 | |
| 241 | response[ 'Capacitacio' ] = $__dada_getons( $ref_capacitacio ); |
| 242 | } |
| 243 | }" |
| 244 | } |
| 245 | ] |
| 246 | } |
| 247 | ] |