Subir archivos a "/"
This commit is contained in:
66
ventas.awk
Normal file
66
ventas.awk
Normal file
@ -0,0 +1,66 @@
|
||||
#!/usr/bin/nawk -f
|
||||
BEGIN {
|
||||
file="/export/oracle/scripts/oper_ult_min.txt"
|
||||
if (ARGC == 2) {hoy=ARGV[1]}
|
||||
else {"date +%Y%m%d" | getline hoy; }
|
||||
while ((getline < file) > 0)
|
||||
{
|
||||
if ($0 ~ "^"hoy) {
|
||||
split($0,cad,";");
|
||||
|
||||
sum_vpm+=cad[2];
|
||||
sum_tventa+=cad[3];
|
||||
sum_tsia+=cad[4];
|
||||
|
||||
hora=substr(cad[1],9,2);
|
||||
min=substr(cad[1],11,2);
|
||||
hhmm=hora":"min;
|
||||
|
||||
a_vpm[hora]+=cad[2];
|
||||
a_tventa[hora]+=cad[3];
|
||||
a_tsia[hora]+=cad[4];
|
||||
a_tsermepa[hora]=a_tventa[hora]-a_tsia[hora];
|
||||
|
||||
a_count[hora]+=1;
|
||||
count+=1;
|
||||
|
||||
if (mayor_vpm[hora]<cad[2]){mayor_vpm[hora]=cad[2]; hora_mayor_vpm[hora]=hhmm}
|
||||
if (mayor_tventa[hora]<cad[3]){mayor_tventa[hora]=cad[3]; hora_mayor_tventa[hora]=hhmm}
|
||||
if (mayor_tsia[hora]<cad[4]){mayor_tsia[hora]=cad[4]; hora_mayor_tsia[hora]=hhmm}
|
||||
if (mayor_tsermepa[hora]<cad[3]-cad[4]){mayor_tsermepa[hora]=cad[3]-cad[4]; hora_mayor_tsermepa[hora]=hhmm}
|
||||
}
|
||||
}
|
||||
close file
|
||||
{
|
||||
print "\n[Resumen Ventas -",hoy"]\n"
|
||||
print (" --------------------------------------------------------------------------------------------------------------------------- ");
|
||||
print (" | V E N T A S | T. C O M P L E T O | T. S I A | T. S E R M E P A |");
|
||||
print (" -----------------------------------------------------------------------------------------------------------------------------------|");
|
||||
print ("| Tramo | Total Med | Max Hora | Med | Peor Hora | Med | Peor Hora | Med | Peor Hora |");
|
||||
print ("| ----- | ------ ---- | ----- ----- | --------- | --------- ----- | --------- | --------- ----- | --------- | --------- ----- |");
|
||||
|
||||
for (i=0;i<=23;i++ ) {
|
||||
if (i<10) { i="0"i }
|
||||
if (a_count[i]<1) {
|
||||
a_count[i]=1;
|
||||
a_vpm[i]=0; a_tventa[i]=0; a_tsia[i]=0;
|
||||
mayor_tventa[i]=0; mayor_vpm[i]=0; mayor_tsia[i]=0; mayor_tsermepa[i]=0;
|
||||
hora_mayor_tventa[i]="--:--"; hora_mayor_vpm[i]="--:--"; hora_mayor_tsermepa[i]="--:--"; hora_mayor_tsia[i]="--:--";
|
||||
}
|
||||
|
||||
printf ("| %2s-%02d | %6s %3d | %5d %5s | %6d ms | %6d ms %5s | %6d ms | %6d ms %5s | %6d ms | %6d ms %5s |\n",
|
||||
i,i+1,a_vpm[i],a_vpm[i]/a_count[i],mayor_vpm[i],hora_mayor_vpm[i],
|
||||
a_tventa[i]/a_count[i],mayor_tventa[i], hora_mayor_tventa[i],
|
||||
a_tsia[i]/a_count[i],mayor_tsia[i], hora_mayor_tsia[i],
|
||||
a_tsermepa[i]/a_count[i],mayor_tsermepa[i], hora_mayor_tsermepa[i])
|
||||
|
||||
}
|
||||
|
||||
print (" ----------------------------------------------------------------------------------------------------------------------------------- ");
|
||||
printf "\n"
|
||||
printf " Total: %4s ventas procesadas en %d segundos (%d minutos)\n",
|
||||
sum_vpm,sum_tventa/1000,sum_tventa/1000/60
|
||||
printf " Media: %4d ventas por minuto, %d ms aprox. por venta\n\n",
|
||||
sum_vpm/count,sum_tventa/count
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user